861dc14ccdc1cc98269ae35d28730f887c54a32e
[sip-router] / cfg.y
1 /*
2  * $Id$
3  *
4  *  cfg grammar
5  *
6  * Copyright (C) 2001-2003 FhG Fokus
7  *
8  * This file is part of ser, a free SIP server.
9  *
10  * ser is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version
14  *
15  * For a license to use the ser software under conditions
16  * other than those described here, or to purchase support for this
17  * software, please contact iptel.org by e-mail at the following addresses:
18  *    info@iptel.org
19  *
20  * ser is distributed in the hope that it will be useful,
21  * but WITHOUT ANY WARRANTY; without even the implied warranty of
22  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
23  * GNU General Public License for more details.
24  *
25  * You should have received a copy of the GNU General Public License
26  * along with this program; if not, write to the Free Software
27  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
28  */
29  /*
30  * History:
31  * ---------
32  * 2003-01-29  src_port added (jiri)
33  * 2003-01-23  mhomed added (jiri)
34  * 2003-03-19  replaced all mallocs/frees with pkg_malloc/pkg_free (andrei)
35  * 2003-03-19  Added support for route type in find_export (janakj)
36  * 2003-03-20  Regex support in modparam (janakj)
37  * 2003-04-01  added dst_port, proto , af (andrei)
38  * 2003-04-05  s/reply_route/failure_route, onreply_route introduced (jiri)
39  * 2003-04-12  added force_rport, chroot and wdir (andrei)
40  * 2003-04-15  added tcp_children, disable_tcp (andrei)
41  * 2003-04-22  strip_tail added (jiri)
42  * 2003-07-03  tls* (disable, certificate, private_key, ca_list, verify,
43  *              require_certificate added (andrei)
44  * 2003-07-06  more tls config. vars added: tls_method, tls_port_no (andrei)
45  * 2003-10-02  added {,set_}advertised_{address,port} (andrei)
46  * 2003-10-10  added <,>,<=,>=, != operators support
47  *             added msg:len (andrei)
48  * 2003-10-11  if(){} doesn't require a ';' after it anymore (andrei)
49  * 2003-10-13  added FIFO_DIR & proto:host:port listen/alias support (andrei)
50  * 2003-10-24  converted to the new socket_info lists (andrei)
51  * 2003-10-28  added tcp_accept_aliases (andrei)
52  * 2003-11-20  added {tcp_connect, tcp_send, tls_*}_timeout (andrei)
53  * 2004-03-30  added DISABLE_CORE and OPEN_FD_LIMIT (andrei)
54  * 2004-04-29  added SOCK_MODE, SOCK_USER & SOCK_GROUP (andrei)
55  * 2004-05-03  applied multicast support patch (MCAST_LOOPBACK) from janakj
56  *             added MCAST_TTL (andrei)
57  * 2004-07-05  src_ip & dst_ip will detect ip addresses between quotes
58  *              (andrei)
59  * 2004-10-19  added FROM_URI, TO_URI (andrei)
60  * 2004-11-30  added force_send_socket (andrei)
61  * 2005-07-08  added TCP_CON_LIFETIME, TCP_POLL_METHOD, TCP_MAX_CONNECTIONS
62  *              (andrei)
63  * 2005-07-11 added DNS_RETR_TIME, DNS_RETR_NO, DNS_SERVERS_NO, DNS_USE_SEARCH,
64  *             DNS_TRY_IPV6 (andrei)
65  * 2005-07-12  default onreply route added (andrei)
66  * 2005-11-16  fixed if (cond) cmd; (andrei)
67  * 2005-12-11  added onsend_route support, fcmd (filtered cmd),
68  *             snd_{ip,port,proto,af}, to_{ip,proto} (andrei)
69  * 2005-12-19  select framework (mma)
70  * 2006-01-06  AVP index support (mma)
71  * 2005-01-07  optional semicolon in statement, PARAM_STR&PARAM_STRING
72  * 2006-02-02  named flags support (andrei)
73  * 2006-02-06  named routes support (andrei)
74  * 2006-05-30  avp flags (tma)
75  * 2006-09-11  added dns cache (use, flags, ttls, mem ,gc) & dst blacklist
76  *              options (andrei)
77  * 2006-10-13  added STUN_ALLOW_STUN, STUN_ALLOW_FP, STUN_REFRESH_INTERVAL
78  *              (vlada)
79  * 2007-02-09  separated command needed for tls-in-core and for tls in general
80  *              (andrei)
81  * 2007-06-07  added SHM_FORCE_ALLOC, MLOCK_PAGES, REAL_TIME, RT_PRIO,
82  *              RT_POLICY, RT_TIMER1_PRIO, RT_TIMER1_POLICY, RT_TIMER2_PRIO,
83  *              RT_TIMER2_POLICY (andrei)
84  * 2007-06-16  added DDNS_SRV_LB, DNS_TRY_NAPTR (andrei)
85  * 2007-09-10  introduced phone2tel option which allows NOT to consider
86  *             user=phone URIs as TEL URIs (jiri)
87  * 2007-10-10  added DNS_SEARCH_FMATCH (mma)
88  * 2007-11-28  added TCP_OPT_{FD_CACHE, DEFER_ACCEPT, DELAYED_ACK, SYNCNT,
89  *              LINGER2, KEEPALIVE, KEEPIDLE, KEEPINTVL, KEEPCNT} (andrei)
90  * 2008-01-24  added cfg_var definition (Miklos)
91 */
92
93 %{
94
95 #include <stdlib.h>
96 #include <stdio.h>
97 #include <sys/types.h>
98 #include <sys/socket.h>
99 #include <netinet/in.h>
100 #include <arpa/inet.h>
101 #include <string.h>
102 #include <errno.h>
103 #include "route_struct.h"
104 #include "globals.h"
105 #include "route.h"
106 #include "dprint.h"
107 #include "sr_module.h"
108 #include "modparam.h"
109 #include "ip_addr.h"
110 #include "resolve.h"
111 #include "socket_info.h"
112 #include "name_alias.h"
113 #include "ut.h"
114 #include "dset.h"
115 #include "select.h"
116 #include "flags.h"
117 #include "tcp_init.h"
118 #include "tcp_options.h"
119 #include "sctp_options.h"
120 #include "msg_translator.h"
121
122 #include "config.h"
123 #include "cfg_core.h"
124 #include "cfg/cfg.h"
125 #ifdef CORE_TLS
126 #include "tls/tls_config.h"
127 #endif
128 #include "timer_ticks.h"
129
130 #ifdef DEBUG_DMALLOC
131 #include <dmalloc.h>
132 #endif
133
134 /* hack to avoid alloca usage in the generated C file (needed for compiler
135  with no built in alloca, like icc*/
136 #undef _ALLOCA_H
137
138 #define onsend_check(s) \
139         do{\
140                 if (rt!=ONSEND_ROUTE) yyerror( s " allowed only in onsend_routes");\
141         }while(0)
142
143
144 #ifdef USE_DNS_CACHE
145         #define IF_DNS_CACHE(x) x
146 #else
147         #define IF_DNS_CACHE(x) warn("dns cache support not compiled in")
148 #endif
149
150 #ifdef USE_DNS_FAILOVER
151         #define IF_DNS_FAILOVER(x) x
152 #else
153         #define IF_DNS_FAILOVER(x) warn("dns failover support not compiled in")
154 #endif
155
156 #ifdef USE_NAPTR
157         #define IF_NAPTR(x) x
158 #else
159         #define IF_NAPTR(x) warn("dns naptr support not compiled in")
160 #endif
161
162 #ifdef USE_DST_BLACKLIST
163         #define IF_DST_BLACKLIST(x) x
164 #else
165         #define IF_DST_BLACKLIST(x) warn("dst blacklist support not compiled in")
166 #endif
167
168 #ifdef USE_STUN
169         #define IF_STUN(x) x
170 #else 
171         #define IF_STUN(x) warn("stun support not compiled in")
172 #endif
173
174
175 extern int yylex();
176 static void yyerror(char* s);
177 static char* tmp;
178 static int i_tmp;
179 static struct socket_id* lst_tmp;
180 static struct name_lst*  nl_tmp;
181 static int rt;  /* Type of route block for find_export */
182 static str* str_tmp;
183 static str s_tmp;
184 static struct ip_addr* ip_tmp;
185 static struct avp_spec* s_attr;
186 static select_t sel;
187 static select_t* sel_ptr;
188 static struct action *mod_func_action;
189
190 static void warn(char* s);
191 static struct socket_id* mk_listen_id(char*, int, int);
192 static struct name_lst* mk_name_lst(char* name, int flags);
193 static struct socket_id* mk_listen_id2(struct name_lst*, int, int);
194 static void free_name_lst(struct name_lst* lst);
195 static void free_socket_id_lst(struct socket_id* i);
196
197 %}
198
199 %union {
200         long intval;
201         unsigned long uval;
202         char* strval;
203         struct expr* expr;
204         struct action* action;
205         struct net* ipnet;
206         struct ip_addr* ipaddr;
207         struct socket_id* sockid;
208         struct name_lst* name_l;
209         struct avp_spec* attr;
210         select_t* select;
211 }
212
213 /* terminals */
214
215
216 /* keywords */
217 %token FORWARD
218 %token FORWARD_TCP
219 %token FORWARD_TLS
220 %token FORWARD_SCTP
221 %token FORWARD_UDP
222 %token SEND
223 %token SEND_TCP
224 %token DROP
225 %token RETURN
226 %token BREAK
227 %token LOG_TOK
228 %token ERROR
229 %token ROUTE
230 %token ROUTE_FAILURE
231 %token ROUTE_ONREPLY
232 %token ROUTE_BRANCH
233 %token ROUTE_SEND
234 %token EXEC
235 %token SET_HOST
236 %token SET_HOSTPORT
237 %token SET_HOSTPORTTRANS
238 %token PREFIX
239 %token STRIP
240 %token STRIP_TAIL
241 %token APPEND_BRANCH
242 %token SET_USER
243 %token SET_USERPASS
244 %token SET_PORT
245 %token SET_URI
246 %token REVERT_URI
247 %token FORCE_RPORT
248 %token FORCE_TCP_ALIAS
249 %token UDP_MTU
250 %token UDP_MTU_TRY_PROTO
251 %token IF
252 %token ELSE
253 %token SET_ADV_ADDRESS
254 %token SET_ADV_PORT
255 %token FORCE_SEND_SOCKET
256 %token URIHOST
257 %token URIPORT
258 %token MAX_LEN
259 %token SETFLAG
260 %token RESETFLAG
261 %token ISFLAGSET
262 %token SETAVPFLAG
263 %token RESETAVPFLAG
264 %token ISAVPFLAGSET
265 %token METHOD
266 %token URI
267 %token FROM_URI
268 %token TO_URI
269 %token SRCIP
270 %token SRCPORT
271 %token DSTIP
272 %token DSTPORT
273 %token TOIP
274 %token TOPORT
275 %token SNDIP
276 %token SNDPORT
277 %token SNDPROTO
278 %token SNDAF
279 %token PROTO
280 %token AF
281 %token MYSELF
282 %token MSGLEN
283 %token RETCODE
284 %token UDP
285 %token TCP
286 %token TLS
287 %token SCTP
288
289 /* config vars. */
290 %token DEBUG_V
291 %token FORK
292 %token LOGSTDERROR
293 %token LOGFACILITY
294 %token LISTEN
295 %token ALIAS
296 %token DNS
297 %token REV_DNS
298 %token DNS_TRY_IPV6
299 %token DNS_TRY_NAPTR
300 %token DNS_SRV_LB
301 %token DNS_UDP_PREF
302 %token DNS_TCP_PREF
303 %token DNS_TLS_PREF
304 %token DNS_SCTP_PREF
305 %token DNS_RETR_TIME
306 %token DNS_RETR_NO
307 %token DNS_SERVERS_NO
308 %token DNS_USE_SEARCH
309 %token DNS_SEARCH_FMATCH
310 %token DNS_CACHE_INIT
311 %token DNS_USE_CACHE
312 %token DNS_USE_FAILOVER
313 %token DNS_CACHE_FLAGS
314 %token DNS_CACHE_NEG_TTL
315 %token DNS_CACHE_MIN_TTL
316 %token DNS_CACHE_MAX_TTL
317 %token DNS_CACHE_MEM
318 %token DNS_CACHE_GC_INT
319 %token DNS_CACHE_DEL_NONEXP
320 /*blacklist*/
321 %token DST_BLST_INIT
322 %token USE_DST_BLST
323 %token DST_BLST_MEM
324 %token DST_BLST_TTL
325 %token DST_BLST_GC_INT
326
327 %token PORT
328 %token STAT
329 %token CHILDREN
330 %token CHECK_VIA
331 %token PHONE2TEL
332 %token SYN_BRANCH
333 %token MEMLOG
334 %token MEMDBG
335 %token SIP_WARNING
336 %token SERVER_SIGNATURE
337 %token REPLY_TO_VIA
338 %token LOADMODULE
339 %token LOADPATH
340 %token MODPARAM
341 %token MAXBUFFER
342 %token USER
343 %token GROUP
344 %token CHROOT
345 %token WDIR
346 %token MHOMED
347 %token DISABLE_TCP
348 %token TCP_ACCEPT_ALIASES
349 %token TCP_CHILDREN
350 %token TCP_CONNECT_TIMEOUT
351 %token TCP_SEND_TIMEOUT
352 %token TCP_CON_LIFETIME
353 %token TCP_POLL_METHOD
354 %token TCP_MAX_CONNECTIONS
355 %token TCP_NO_CONNECT
356 %token TCP_SOURCE_IPV4
357 %token TCP_SOURCE_IPV6
358 %token TCP_OPT_FD_CACHE
359 %token TCP_OPT_BUF_WRITE
360 %token TCP_OPT_CONN_WQ_MAX
361 %token TCP_OPT_WQ_MAX
362 %token TCP_OPT_DEFER_ACCEPT
363 %token TCP_OPT_DELAYED_ACK
364 %token TCP_OPT_SYNCNT
365 %token TCP_OPT_LINGER2
366 %token TCP_OPT_KEEPALIVE
367 %token TCP_OPT_KEEPIDLE
368 %token TCP_OPT_KEEPINTVL
369 %token TCP_OPT_KEEPCNT
370 %token TCP_OPT_CRLF_PING
371 %token DISABLE_TLS
372 %token ENABLE_TLS
373 %token TLSLOG
374 %token TLS_PORT_NO
375 %token TLS_METHOD
376 %token TLS_HANDSHAKE_TIMEOUT
377 %token TLS_SEND_TIMEOUT
378 %token SSLv23
379 %token SSLv2
380 %token SSLv3
381 %token TLSv1
382 %token TLS_VERIFY
383 %token TLS_REQUIRE_CERTIFICATE
384 %token TLS_CERTIFICATE
385 %token TLS_PRIVATE_KEY
386 %token TLS_CA_LIST
387 %token DISABLE_SCTP
388 %token ENABLE_SCTP
389 %token SCTP_CHILDREN
390 %token SCTP_SOCKET_RCVBUF
391 %token SCTP_SOCKET_SNDBUF
392 %token SCTP_AUTOCLOSE
393 %token SCTP_SEND_TTL
394 %token SCTP_SEND_RETRIES
395 %token ADVERTISED_ADDRESS
396 %token ADVERTISED_PORT
397 %token DISABLE_CORE
398 %token OPEN_FD_LIMIT
399 %token SHM_FORCE_ALLOC
400 %token MLOCK_PAGES
401 %token REAL_TIME
402 %token RT_PRIO
403 %token RT_POLICY
404 %token RT_TIMER1_PRIO
405 %token RT_TIMER1_POLICY
406 %token RT_TIMER2_PRIO
407 %token RT_TIMER2_POLICY
408 %token MCAST_LOOPBACK
409 %token MCAST_TTL
410 %token TOS
411 %token PMTU_DISCOVERY
412 %token KILL_TIMEOUT
413 %token CFG_DESCRIPTION
414 %token SERVER_ID
415
416 %token FLAGS_DECL
417 %token AVPFLAGS_DECL
418
419 %token ATTR_MARK
420 %token SELECT_MARK
421 %token ATTR_FROM
422 %token ATTR_TO
423 %token ATTR_FROMURI
424 %token ATTR_TOURI
425 %token ATTR_FROMUSER
426 %token ATTR_TOUSER
427 %token ATTR_FROMDOMAIN
428 %token ATTR_TODOMAIN
429 %token ATTR_GLOBAL
430 %token ADDEQ
431
432 %token STUN_REFRESH_INTERVAL
433 %token STUN_ALLOW_STUN
434 %token STUN_ALLOW_FP
435
436
437 /* operators */
438 %nonassoc EQUAL
439 %nonassoc EQUAL_T
440 %nonassoc GT
441 %nonassoc LT
442 %nonassoc GTE
443 %nonassoc LTE
444 %nonassoc DIFF
445 %nonassoc MATCH
446 %left LOG_OR
447 %left LOG_AND
448 %left BIN_OR
449 %left BIN_AND
450 %left PLUS MINUS
451 %right NOT
452
453 /* values */
454 %token <intval> NUMBER
455 %token <strval> ID
456 %token <strval> STRING
457 %token <strval> IPV6ADDR
458
459 /* other */
460 %token COMMA
461 %token SEMICOLON
462 %token RPAREN
463 %token LPAREN
464 %token LBRACE
465 %token RBRACE
466 %token LBRACK
467 %token RBRACK
468 %token SLASH
469 %token DOT
470 %token CR
471 %token COLON
472 %token STAR
473
474
475 /*non-terminals */
476 %type <expr> exp exp_elem /*, condition*/
477 %type <action> action actions cmd fcmd if_cmd stm exp_stm assign_action
478 %type <ipaddr> ipv4 ipv6 ipv6addr ip
479 %type <ipnet> ipnet
480 %type <strval> host
481 %type <strval> listen_id
482 %type <name_l> listen_id_lst
483 %type <name_l> listen_id2
484 %type <sockid>  id_lst
485 %type <sockid>  phostport
486 %type <sockid>  listen_phostport
487 %type <intval> proto port
488 %type <intval> equalop strop intop binop
489 %type <strval> host_sep
490 %type <intval> uri_type
491 %type <attr> attr_id
492 %type <attr> attr_id_num_idx
493 %type <attr> attr_id_no_idx
494 %type <attr> attr_id_ass
495 %type <attr> attr_id_val
496 %type <attr> attr_id_any
497 %type <attr> attr_id_any_str
498 /* %type <intval> class_id */
499 %type <intval> assign_op
500 %type <select> select_id
501 %type <strval>  flag_name;
502 %type <strval>  route_name;
503 %type <intval> avpflag_oper
504
505 /*%type <route_el> rules;
506   %type <route_el> rule;
507 */
508
509 %%
510
511
512 cfg:
513         statements
514         ;
515 statements:
516         statements statement {}
517         | statement {}
518         | statements error { yyerror(""); YYABORT;}
519         ;
520 statement:
521         assign_stm
522         | flags_decl
523         | avpflags_decl
524         | module_stm
525         | {rt=REQUEST_ROUTE;} route_stm
526         | {rt=FAILURE_ROUTE;} failure_route_stm
527         | {rt=ONREPLY_ROUTE;} onreply_route_stm
528         | {rt=BRANCH_ROUTE;} branch_route_stm
529         | {rt=ONSEND_ROUTE;}   send_route_stm
530         | SEMICOLON     /* null statement */
531         | CR    /* null statement*/
532         ;
533 listen_id:
534         ip {
535                 tmp=ip_addr2a($1);
536                 if (tmp==0) {
537                         LOG(L_CRIT, "ERROR: cfg. parser: bad ip "
538                                         "address.\n");
539                         $$=0;
540                 } else {
541                         $$=pkg_malloc(strlen(tmp)+1);
542                         if ($$==0) {
543                                 LOG(L_CRIT, "ERROR: cfg. parser: out of "
544                                                 "memory.\n");
545                         } else {
546                                 strncpy($$, tmp, strlen(tmp)+1);
547                         }
548                 }
549         }
550         | STRING {
551                 $$=pkg_malloc(strlen($1)+1);
552                 if ($$==0) {
553                                 LOG(L_CRIT, "ERROR: cfg. parser: out of "
554                                                 "memory.\n");
555                 } else {
556                                 strncpy($$, $1, strlen($1)+1);
557                 }
558         }
559         | host {
560                 $$=pkg_malloc(strlen($1)+1);
561                 if ($$==0) {
562                                 LOG(L_CRIT, "ERROR: cfg. parser: out of "
563                                                 "memory.\n");
564                 } else {
565                                 strncpy($$, $1, strlen($1)+1);
566                 }
567         }
568         ;
569
570
571 listen_id_lst:
572         listen_id       { $$=mk_name_lst($1, SI_IS_MHOMED); }
573         | listen_id COMMA listen_id_lst { $$=mk_name_lst($1, SI_IS_MHOMED); 
574                                                                                 if ($$) $$->next=$3;
575                                                                         }
576         ;
577
578 listen_id2:
579         LPAREN listen_id_lst RPAREN { $$=$2; }
580         | listen_id     { $$=mk_name_lst($1, 0); }
581         ;
582
583 proto:
584         UDP     { $$=PROTO_UDP; }
585         | TCP   { $$=PROTO_TCP; }
586         | TLS   { $$=PROTO_TLS; }
587         | SCTP  { $$=PROTO_SCTP; }
588         | STAR  { $$=0; }
589         ;
590 port:
591         NUMBER  { $$=$1; }
592         | STAR  { $$=0; }
593 ;
594 phostport:
595         listen_id               { $$=mk_listen_id($1, 0, 0); }
596         | listen_id COLON port  { $$=mk_listen_id($1, 0, $3); }
597         | proto COLON listen_id { $$=mk_listen_id($3, $1, 0); }
598         | proto COLON listen_id COLON port      { $$=mk_listen_id($3, $1, $5);}
599         | listen_id COLON error { $$=0; yyerror(" port number expected"); }
600         ;
601
602 listen_phostport:
603         listen_id2              { $$=mk_listen_id2($1, 0, 0); }
604         | listen_id2 COLON port { $$=mk_listen_id2($1, 0, $3); }
605         | proto COLON listen_id2        { $$=mk_listen_id2($3, $1, 0); }
606         | proto COLON listen_id2 COLON port     { $$=mk_listen_id2($3, $1, $5);}
607         | listen_id2 COLON error { $$=0; yyerror(" port number expected"); }
608         ;
609
610 id_lst:
611         listen_phostport                {  $$=$1 ; }
612         | listen_phostport id_lst       { $$=$1; $$->next=$2; }
613         ;
614
615 flags_decl:             FLAGS_DECL      flag_list
616                         |       FLAGS_DECL error { yyerror("flag list expected\n"); }
617 ;
618 flag_list:              flag_spec
619                         |       flag_spec COMMA flag_list
620 ;
621
622 flag_spec:              flag_name       { if (register_flag($1,-1)<0)
623                                                                 yyerror("register flag failed");
624                                                 }
625                         |       flag_name COLON NUMBER {
626                                                 if (register_flag($1, $3)<0)
627                                                                 yyerror("register flag failed");
628                                                                                 }
629 ;
630
631 flag_name:              STRING  { $$=$1; }
632                         |       ID              { $$=$1; }
633 ;
634
635 avpflags_decl:
636         AVPFLAGS_DECL avpflag_list
637         | AVPFLAGS_DECL error { yyerror("avpflag list expected\n"); }
638         ;
639 avpflag_list:
640         avpflag_spec
641         | avpflag_spec COMMA avpflag_list
642         ;
643 avpflag_spec:
644         flag_name {
645                 if (register_avpflag($1)==0)
646                         yyerror("cannot declare avpflag");
647         }
648         ;
649 assign_stm:
650         DEBUG_V EQUAL NUMBER { default_core_cfg.debug=$3; }
651         | DEBUG_V EQUAL error  { yyerror("number  expected"); }
652         | FORK  EQUAL NUMBER { dont_fork= ! $3; }
653         | FORK  EQUAL error  { yyerror("boolean value expected"); }
654         | LOGSTDERROR EQUAL NUMBER { if (!config_check) log_stderr=$3; }
655         | LOGSTDERROR EQUAL error { yyerror("boolean value expected"); }
656         | LOGFACILITY EQUAL ID {
657                 if ( (i_tmp=str2facility($3))==-1)
658                         yyerror("bad facility (see syslog(3) man page)");
659                 if (!config_check)
660                         default_core_cfg.log_facility=i_tmp;
661         }
662         | LOGFACILITY EQUAL error { yyerror("ID expected"); }
663         | DNS EQUAL NUMBER   { received_dns|= ($3)?DO_DNS:0; }
664         | DNS EQUAL error { yyerror("boolean value expected"); }
665         | REV_DNS EQUAL NUMBER { received_dns|= ($3)?DO_REV_DNS:0; }
666         | REV_DNS EQUAL error { yyerror("boolean value expected"); }
667         | DNS_TRY_IPV6 EQUAL NUMBER   { default_core_cfg.dns_try_ipv6=$3; }
668         | DNS_TRY_IPV6 error { yyerror("boolean value expected"); }
669         | DNS_TRY_NAPTR EQUAL NUMBER   { IF_NAPTR(default_core_cfg.dns_try_naptr=$3); }
670         | DNS_TRY_NAPTR error { yyerror("boolean value expected"); }
671         | DNS_SRV_LB EQUAL NUMBER   { IF_DNS_FAILOVER(default_core_cfg.dns_srv_lb=$3); }
672         | DNS_SRV_LB error { yyerror("boolean value expected"); }
673         | DNS_UDP_PREF EQUAL NUMBER { IF_NAPTR(default_core_cfg.dns_udp_pref=$3);}
674         | DNS_UDP_PREF error { yyerror("number expected"); }
675         | DNS_TCP_PREF EQUAL NUMBER { IF_NAPTR(default_core_cfg.dns_tcp_pref=$3);}
676         | DNS_TCP_PREF error { yyerror("number expected"); }
677         | DNS_TLS_PREF EQUAL NUMBER { IF_NAPTR(default_core_cfg.dns_tls_pref=$3);}
678         | DNS_TLS_PREF error { yyerror("number expected"); }
679         | DNS_SCTP_PREF EQUAL NUMBER { 
680                                                                 IF_NAPTR(default_core_cfg.dns_sctp_pref=$3); }
681         | DNS_SCTP_PREF error { yyerror("number expected"); }
682         | DNS_RETR_TIME EQUAL NUMBER   { default_core_cfg.dns_retr_time=$3; }
683         | DNS_RETR_TIME error { yyerror("number expected"); }
684         | DNS_RETR_NO EQUAL NUMBER   { default_core_cfg.dns_retr_no=$3; }
685         | DNS_RETR_NO error { yyerror("number expected"); }
686         | DNS_SERVERS_NO EQUAL NUMBER   { default_core_cfg.dns_servers_no=$3; }
687         | DNS_SERVERS_NO error { yyerror("number expected"); }
688         | DNS_USE_SEARCH EQUAL NUMBER   { default_core_cfg.dns_search_list=$3; }
689         | DNS_USE_SEARCH error { yyerror("boolean value expected"); }
690         | DNS_SEARCH_FMATCH EQUAL NUMBER   { default_core_cfg.dns_search_fmatch=$3; }
691         | DNS_SEARCH_FMATCH error { yyerror("boolean value expected"); }
692         | DNS_CACHE_INIT EQUAL NUMBER   { IF_DNS_CACHE(dns_cache_init=$3); }
693         | DNS_CACHE_INIT error { yyerror("boolean value expected"); }
694         | DNS_USE_CACHE EQUAL NUMBER   { IF_DNS_CACHE(default_core_cfg.use_dns_cache=$3); }
695         | DNS_USE_CACHE error { yyerror("boolean value expected"); }
696         | DNS_USE_FAILOVER EQUAL NUMBER   { IF_DNS_FAILOVER(default_core_cfg.use_dns_failover=$3);}
697         | DNS_USE_FAILOVER error { yyerror("boolean value expected"); }
698         | DNS_CACHE_FLAGS EQUAL NUMBER   { IF_DNS_CACHE(default_core_cfg.dns_cache_flags=$3); }
699         | DNS_CACHE_FLAGS error { yyerror("boolean value expected"); }
700         | DNS_CACHE_NEG_TTL EQUAL NUMBER   { IF_DNS_CACHE(default_core_cfg.dns_neg_cache_ttl=$3); }
701         | DNS_CACHE_NEG_TTL error { yyerror("boolean value expected"); }
702         | DNS_CACHE_MAX_TTL EQUAL NUMBER   { IF_DNS_CACHE(default_core_cfg.dns_cache_max_ttl=$3); }
703         | DNS_CACHE_MAX_TTL error { yyerror("boolean value expected"); }
704         | DNS_CACHE_MIN_TTL EQUAL NUMBER   { IF_DNS_CACHE(default_core_cfg.dns_cache_min_ttl=$3); }
705         | DNS_CACHE_MIN_TTL error { yyerror("boolean value expected"); }
706         | DNS_CACHE_MEM EQUAL NUMBER   { IF_DNS_CACHE(default_core_cfg.dns_cache_max_mem=$3); }
707         | DNS_CACHE_MEM error { yyerror("boolean value expected"); }
708         | DNS_CACHE_GC_INT EQUAL NUMBER   { IF_DNS_CACHE(dns_timer_interval=$3); }
709         | DNS_CACHE_GC_INT error { yyerror("boolean value expected"); }
710         | DNS_CACHE_DEL_NONEXP EQUAL NUMBER   { IF_DNS_CACHE(default_core_cfg.dns_cache_del_nonexp=$3); }
711         | DNS_CACHE_DEL_NONEXP error { yyerror("boolean value expected"); }
712         | DST_BLST_INIT EQUAL NUMBER   { IF_DST_BLACKLIST(dst_blacklist_init=$3); }
713         | DST_BLST_INIT error { yyerror("boolean value expected"); }
714         | USE_DST_BLST EQUAL NUMBER   { IF_DST_BLACKLIST(default_core_cfg.use_dst_blacklist=$3); }
715         | USE_DST_BLST error { yyerror("boolean value expected"); }
716         | DST_BLST_MEM EQUAL NUMBER   { IF_DST_BLACKLIST(default_core_cfg.blst_max_mem=$3); }
717         | DST_BLST_MEM error { yyerror("boolean value expected"); }
718         | DST_BLST_TTL EQUAL NUMBER   { IF_DST_BLACKLIST(default_core_cfg.blst_timeout=$3); }
719         | DST_BLST_TTL error { yyerror("boolean value expected"); }
720         | DST_BLST_GC_INT EQUAL NUMBER { IF_DST_BLACKLIST(blst_timer_interval=$3);}
721         | DST_BLST_GC_INT error { yyerror("boolean value expected"); }
722         | PORT EQUAL NUMBER   { port_no=$3; }
723         | STAT EQUAL STRING {
724                 #ifdef STATS
725                                 stat_file=$3;
726                 #endif
727         }
728         | MAXBUFFER EQUAL NUMBER { maxbuffer=$3; }
729         | MAXBUFFER EQUAL error { yyerror("number expected"); }
730         | PORT EQUAL error    { yyerror("number expected"); }
731         | CHILDREN EQUAL NUMBER { children_no=$3; }
732         | CHILDREN EQUAL error { yyerror("number expected"); }
733         | CHECK_VIA EQUAL NUMBER { check_via=$3; }
734         | CHECK_VIA EQUAL error { yyerror("boolean value expected"); }
735         | PHONE2TEL EQUAL NUMBER { phone2tel=$3; }
736         | PHONE2TEL EQUAL error { yyerror("boolean value expected"); }
737         | SYN_BRANCH EQUAL NUMBER { syn_branch=$3; }
738         | SYN_BRANCH EQUAL error { yyerror("boolean value expected"); }
739         | MEMLOG EQUAL NUMBER { memlog=$3; }
740         | MEMLOG EQUAL error { yyerror("int value expected"); }
741         | MEMDBG EQUAL NUMBER { memdbg=$3; }
742         | MEMDBG EQUAL error { yyerror("int value expected"); }
743         | SIP_WARNING EQUAL NUMBER { sip_warning=$3; }
744         | SIP_WARNING EQUAL error { yyerror("boolean value expected"); }
745         | USER EQUAL STRING     { user=$3; }
746         | USER EQUAL ID         { user=$3; }
747         | USER EQUAL error      { yyerror("string value expected"); }
748         | GROUP EQUAL STRING     { group=$3; }
749         | GROUP EQUAL ID         { group=$3; }
750         | GROUP EQUAL error      { yyerror("string value expected"); }
751         | CHROOT EQUAL STRING     { chroot_dir=$3; }
752         | CHROOT EQUAL ID         { chroot_dir=$3; }
753         | CHROOT EQUAL error      { yyerror("string value expected"); }
754         | WDIR EQUAL STRING     { working_dir=$3; }
755         | WDIR EQUAL ID         { working_dir=$3; }
756         | WDIR EQUAL error      { yyerror("string value expected"); }
757         | MHOMED EQUAL NUMBER { mhomed=$3; }
758         | MHOMED EQUAL error { yyerror("boolean value expected"); }
759         | DISABLE_TCP EQUAL NUMBER {
760                 #ifdef USE_TCP
761                         tcp_disable=$3;
762                 #else
763                         warn("tcp support not compiled in");
764                 #endif
765         }
766         | DISABLE_TCP EQUAL error { yyerror("boolean value expected"); }
767         | TCP_ACCEPT_ALIASES EQUAL NUMBER {
768                 #ifdef USE_TCP
769                         tcp_default_cfg.accept_aliases=$3;
770                 #else
771                         warn("tcp support not compiled in");
772                 #endif
773         }
774         | TCP_ACCEPT_ALIASES EQUAL error { yyerror("boolean value expected"); }
775         | TCP_CHILDREN EQUAL NUMBER {
776                 #ifdef USE_TCP
777                         tcp_children_no=$3;
778                 #else
779                         warn("tcp support not compiled in");
780                 #endif
781         }
782         | TCP_CHILDREN EQUAL error { yyerror("number expected"); }
783         | TCP_CONNECT_TIMEOUT EQUAL NUMBER {
784                 #ifdef USE_TCP
785                         tcp_default_cfg.connect_timeout_s=$3;
786                 #else
787                         warn("tcp support not compiled in");
788                 #endif
789         }
790         | TCP_CONNECT_TIMEOUT EQUAL error { yyerror("number expected"); }
791         | TCP_SEND_TIMEOUT EQUAL NUMBER {
792                 #ifdef USE_TCP
793                         tcp_default_cfg.send_timeout_s=$3;
794                 #else
795                         warn("tcp support not compiled in");
796                 #endif
797         }
798         | TCP_SEND_TIMEOUT EQUAL error { yyerror("number expected"); }
799         | TCP_CON_LIFETIME EQUAL NUMBER {
800                 #ifdef USE_TCP
801                         if ($3<0)
802                                 tcp_default_cfg.con_lifetime=-1;
803                         else
804                                 tcp_default_cfg.con_lifetime=S_TO_TICKS($3);
805                 #else
806                         warn("tcp support not compiled in");
807                 #endif
808         }
809         | TCP_CON_LIFETIME EQUAL error { yyerror("number expected"); }
810         | TCP_POLL_METHOD EQUAL ID {
811                 #ifdef USE_TCP
812                         tcp_poll_method=get_poll_type($3);
813                         if (tcp_poll_method==POLL_NONE) {
814                                 LOG(L_CRIT, "bad poll method name:"
815                                                 " %s\n, try one of %s.\n",
816                                                 $3, poll_support);
817                                 yyerror("bad tcp_poll_method "
818                                                 "value");
819                         }
820                 #else
821                         warn("tcp support not compiled in");
822                 #endif
823         }
824         | TCP_POLL_METHOD EQUAL STRING {
825                 #ifdef USE_TCP
826                         tcp_poll_method=get_poll_type($3);
827                         if (tcp_poll_method==POLL_NONE) {
828                                 LOG(L_CRIT, "bad poll method name:"
829                                                 " %s\n, try one of %s.\n",
830                                                 $3, poll_support);
831                                 yyerror("bad tcp_poll_method "
832                                                 "value");
833                         }
834                 #else
835                         warn("tcp support not compiled in");
836                 #endif
837         }
838         | TCP_POLL_METHOD EQUAL error { yyerror("poll method name expected"); }
839         | TCP_MAX_CONNECTIONS EQUAL NUMBER {
840                 #ifdef USE_TCP
841                         tcp_max_connections=$3;
842                 #else
843                         warn("tcp support not compiled in");
844                 #endif
845         }
846         | TCP_MAX_CONNECTIONS EQUAL error { yyerror("number expected"); }
847         | TCP_NO_CONNECT EQUAL NUMBER {
848                 #ifdef USE_TCP
849                         tcp_default_cfg.no_connect=$3;
850                 #else
851                         warn("tcp support not compiled in");
852                 #endif
853         }
854         | TCP_NO_CONNECT EQUAL error { yyerror("boolean value expected"); }
855         | TCP_SOURCE_IPV4 EQUAL ipv4 {
856                 #ifdef USE_TCP
857                         if (tcp_set_src_addr($3)<0)
858                                 warn("tcp_source_ipv4 failed");
859                 #else
860                         warn("tcp support not compiled in");
861                 #endif
862                 pkg_free($3);
863         }
864         | TCP_SOURCE_IPV4 EQUAL error { yyerror("IPv4 address expected"); }
865         | TCP_SOURCE_IPV6 EQUAL ipv6 {
866                 #ifdef USE_TCP
867                         #ifdef USE_IPV6
868                                 if (tcp_set_src_addr($3)<0)
869                                         warn("tcp_source_ipv6 failed");
870                         #else
871                                 warn("IPv6 support not compiled in");
872                         #endif
873                 #else
874                         warn("tcp support not compiled in");
875                 #endif
876                 pkg_free($3);
877         }
878         | TCP_SOURCE_IPV6 EQUAL error { yyerror("IPv6 address expected"); }
879         | TCP_OPT_FD_CACHE EQUAL NUMBER {
880                 #ifdef USE_TCP
881                         tcp_default_cfg.fd_cache=$3;
882                 #else
883                         warn("tcp support not compiled in");
884                 #endif
885         }
886         | TCP_OPT_FD_CACHE EQUAL error { yyerror("boolean value expected"); }
887         | TCP_OPT_BUF_WRITE EQUAL NUMBER {
888                 #ifdef USE_TCP
889                         tcp_default_cfg.async=$3;
890                 #else
891                         warn("tcp support not compiled in");
892                 #endif
893         }
894         | TCP_OPT_BUF_WRITE EQUAL error { yyerror("boolean value expected"); }
895         | TCP_OPT_CONN_WQ_MAX EQUAL NUMBER {
896                 #ifdef USE_TCP
897                         tcp_default_cfg.tcpconn_wq_max=$3;
898                 #else
899                         warn("tcp support not compiled in");
900                 #endif
901         }
902         | TCP_OPT_CONN_WQ_MAX error { yyerror("boolean value expected"); }
903         | TCP_OPT_WQ_MAX EQUAL NUMBER {
904                 #ifdef USE_TCP
905                         tcp_default_cfg.tcp_wq_max=$3;
906                 #else
907                         warn("tcp support not compiled in");
908                 #endif
909         }
910         | TCP_OPT_WQ_MAX error { yyerror("boolean value expected"); }
911         | TCP_OPT_DEFER_ACCEPT EQUAL NUMBER {
912                 #ifdef USE_TCP
913                         tcp_default_cfg.defer_accept=$3;
914                 #else
915                         warn("tcp support not compiled in");
916                 #endif
917         }
918         | TCP_OPT_DEFER_ACCEPT EQUAL error { yyerror("boolean value expected"); }
919         | TCP_OPT_DELAYED_ACK EQUAL NUMBER {
920                 #ifdef USE_TCP
921                         tcp_default_cfg.delayed_ack=$3;
922                 #else
923                         warn("tcp support not compiled in");
924                 #endif
925         }
926         | TCP_OPT_DELAYED_ACK EQUAL error { yyerror("boolean value expected"); }
927         | TCP_OPT_SYNCNT EQUAL NUMBER {
928                 #ifdef USE_TCP
929                         tcp_default_cfg.syncnt=$3;
930                 #else
931                         warn("tcp support not compiled in");
932                 #endif
933         }
934         | TCP_OPT_SYNCNT EQUAL error { yyerror("number expected"); }
935         | TCP_OPT_LINGER2 EQUAL NUMBER {
936                 #ifdef USE_TCP
937                         tcp_default_cfg.linger2=$3;
938                 #else
939                         warn("tcp support not compiled in");
940                 #endif
941         }
942         | TCP_OPT_LINGER2 EQUAL error { yyerror("number expected"); }
943         | TCP_OPT_KEEPALIVE EQUAL NUMBER {
944                 #ifdef USE_TCP
945                         tcp_default_cfg.keepalive=$3;
946                 #else
947                         warn("tcp support not compiled in");
948                 #endif
949         }
950         | TCP_OPT_KEEPALIVE EQUAL error { yyerror("boolean value expected");}
951         | TCP_OPT_KEEPIDLE EQUAL NUMBER {
952                 #ifdef USE_TCP
953                         tcp_default_cfg.keepidle=$3;
954                 #else
955                         warn("tcp support not compiled in");
956                 #endif
957         }
958         | TCP_OPT_KEEPIDLE EQUAL error { yyerror("number expected"); }
959         | TCP_OPT_KEEPINTVL EQUAL NUMBER {
960                 #ifdef USE_TCP
961                         tcp_default_cfg.keepintvl=$3;
962                 #else
963                         warn("tcp support not compiled in");
964                 #endif
965         }
966         | TCP_OPT_KEEPINTVL EQUAL error { yyerror("number expected"); }
967         | TCP_OPT_KEEPCNT EQUAL NUMBER {
968                 #ifdef USE_TCP
969                         tcp_default_cfg.keepcnt=$3;
970                 #else
971                         warn("tcp support not compiled in");
972                 #endif
973         }
974         | TCP_OPT_KEEPCNT EQUAL error { yyerror("number expected"); }
975         | TCP_OPT_CRLF_PING EQUAL NUMBER {
976                 #ifdef USE_TCP
977                         tcp_default_cfg.crlf_ping=$3;
978                 #else
979                         warn("tcp support not compiled in");
980                 #endif
981         }
982         | TCP_OPT_CRLF_PING EQUAL error { yyerror("boolean value expected"); }
983         | DISABLE_TLS EQUAL NUMBER {
984                 #ifdef USE_TLS
985                         tls_disable=$3;
986                 #else
987                         warn("tls support not compiled in");
988                 #endif
989         }
990         | DISABLE_TLS EQUAL error { yyerror("boolean value expected"); }
991         | ENABLE_TLS EQUAL NUMBER {
992                 #ifdef USE_TLS
993                         tls_disable=!($3);
994                 #else
995                         warn("tls support not compiled in");
996                 #endif
997         }
998         | ENABLE_TLS EQUAL error { yyerror("boolean value expected"); }
999         | TLSLOG EQUAL NUMBER {
1000                 #ifdef CORE_TLS
1001                         tls_log=$3;
1002                 #else
1003                         warn("tls-in-core support not compiled in");
1004                 #endif
1005         }
1006         | TLSLOG EQUAL error { yyerror("int value expected"); }
1007         | TLS_PORT_NO EQUAL NUMBER {
1008                 #ifdef USE_TLS
1009                         tls_port_no=$3;
1010                 #else
1011                         warn("tls support not compiled in");
1012                 #endif
1013         }
1014         | TLS_PORT_NO EQUAL error { yyerror("number expected"); }
1015         | TLS_METHOD EQUAL SSLv23 {
1016                 #ifdef CORE_TLS
1017                         tls_method=TLS_USE_SSLv23;
1018                 #else
1019                         warn("tls-in-core support not compiled in");
1020                 #endif
1021         }
1022         | TLS_METHOD EQUAL SSLv2 {
1023                 #ifdef CORE_TLS
1024                         tls_method=TLS_USE_SSLv2;
1025                 #else
1026                         warn("tls-in-core support not compiled in");
1027                 #endif
1028         }
1029         | TLS_METHOD EQUAL SSLv3 {
1030                 #ifdef CORE_TLS
1031                         tls_method=TLS_USE_SSLv3;
1032                 #else
1033                         warn("tls-in-core support not compiled in");
1034                 #endif
1035         }
1036         | TLS_METHOD EQUAL TLSv1 {
1037                 #ifdef CORE_TLS
1038                         tls_method=TLS_USE_TLSv1;
1039                 #else
1040                         warn("tls-in-core support not compiled in");
1041                 #endif
1042         }
1043         | TLS_METHOD EQUAL error {
1044                 #ifdef CORE_TLS
1045                         yyerror("SSLv23, SSLv2, SSLv3 or TLSv1 expected");
1046                 #else
1047                         warn("tls-in-core support not compiled in");
1048                 #endif
1049         }
1050         | TLS_VERIFY EQUAL NUMBER {
1051                 #ifdef CORE_TLS
1052                         tls_verify_cert=$3;
1053                 #else
1054                         warn("tls-in-core support not compiled in");
1055                 #endif
1056         }
1057         | TLS_VERIFY EQUAL error { yyerror("boolean value expected"); }
1058         | TLS_REQUIRE_CERTIFICATE EQUAL NUMBER {
1059                 #ifdef CORE_TLS
1060                         tls_require_cert=$3;
1061                 #else
1062                         warn( "tls-in-core support not compiled in");
1063                 #endif
1064         }
1065         | TLS_REQUIRE_CERTIFICATE EQUAL error { yyerror("boolean value expected"); }
1066         | TLS_CERTIFICATE EQUAL STRING {
1067                 #ifdef CORE_TLS
1068                         tls_cert_file=$3;
1069                 #else
1070                         warn("tls-in-core support not compiled in");
1071                 #endif
1072         }
1073         | TLS_CERTIFICATE EQUAL error { yyerror("string value expected"); }
1074         | TLS_PRIVATE_KEY EQUAL STRING {
1075                 #ifdef CORE_TLS
1076                         tls_pkey_file=$3;
1077                 #else
1078                         warn("tls-in-core support not compiled in");
1079                 #endif
1080         }
1081         | TLS_PRIVATE_KEY EQUAL error { yyerror("string value expected"); }
1082         | TLS_CA_LIST EQUAL STRING {
1083                 #ifdef CORE_TLS
1084                         tls_ca_file=$3;
1085                 #else
1086                         warn("tls-in-core support not compiled in");
1087                 #endif
1088         }
1089         | TLS_CA_LIST EQUAL error { yyerror("string value expected"); }
1090         | TLS_HANDSHAKE_TIMEOUT EQUAL NUMBER {
1091                 #ifdef CORE_TLS
1092                         tls_handshake_timeout=$3;
1093                 #else
1094                         warn("tls-in-core support not compiled in");
1095                 #endif
1096         }
1097         | TLS_HANDSHAKE_TIMEOUT EQUAL error { yyerror("number expected"); }
1098         | TLS_SEND_TIMEOUT EQUAL NUMBER {
1099                 #ifdef CORE_TLS
1100                         tls_send_timeout=$3;
1101                 #else
1102                         warn("tls-in-core support not compiled in");
1103                 #endif
1104         }
1105         | TLS_SEND_TIMEOUT EQUAL error { yyerror("number expected"); }
1106         | DISABLE_SCTP EQUAL NUMBER {
1107                 #ifdef USE_SCTP
1108                         sctp_disable=$3;
1109                 #else
1110                         warn("sctp support not compiled in");
1111                 #endif
1112         }
1113         | DISABLE_SCTP EQUAL error { yyerror("boolean value expected"); }
1114         | ENABLE_SCTP EQUAL NUMBER {
1115                 #ifdef USE_SCTP
1116                         sctp_disable=($3<=1)?!$3:$3;
1117                 #else
1118                         warn("sctp support not compiled in");
1119                 #endif
1120         }
1121         | ENABLE_SCTP EQUAL error { yyerror("boolean or number expected"); }
1122         | SCTP_CHILDREN EQUAL NUMBER {
1123                 #ifdef USE_SCTP
1124                         sctp_children_no=$3;
1125                 #else
1126                         warn("sctp support not compiled in");
1127                 #endif
1128         }
1129         | SCTP_CHILDREN EQUAL error { yyerror("number expected"); }
1130         | SCTP_SOCKET_RCVBUF EQUAL NUMBER {
1131                 #ifdef USE_SCTP
1132                         sctp_options.sctp_so_rcvbuf=$3;
1133                 #else
1134                         warn("sctp support not compiled in");
1135                 #endif
1136         }
1137         | SCTP_SOCKET_RCVBUF EQUAL error { yyerror("number expected"); }
1138         | SCTP_SOCKET_SNDBUF EQUAL NUMBER {
1139                 #ifdef USE_SCTP
1140                         sctp_options.sctp_so_sndbuf=$3;
1141                 #else
1142                         warn("sctp support not compiled in");
1143                 #endif
1144         }
1145         | SCTP_SOCKET_SNDBUF EQUAL error { yyerror("number expected"); }
1146         | SCTP_AUTOCLOSE EQUAL NUMBER {
1147                 #ifdef USE_SCTP
1148                         sctp_options.sctp_autoclose=$3;
1149                 #else
1150                         warn("sctp support not compiled in");
1151                 #endif
1152         }
1153         | SCTP_AUTOCLOSE EQUAL error { yyerror("number expected"); }
1154         | SCTP_SEND_TTL EQUAL NUMBER {
1155                 #ifdef USE_SCTP
1156                         sctp_options.sctp_send_ttl=$3;
1157                 #else
1158                         warn("sctp support not compiled in");
1159                 #endif
1160         }
1161         | SCTP_SEND_TTL EQUAL error { yyerror("number expected"); }
1162         | SCTP_SEND_RETRIES EQUAL NUMBER {
1163                 #ifdef USE_SCTP
1164                         sctp_options.sctp_send_retries=$3;
1165                 #else
1166                         warn("sctp support not compiled in");
1167                 #endif
1168         }
1169         | SCTP_SEND_RETRIES EQUAL error { yyerror("number expected"); }
1170         | SERVER_SIGNATURE EQUAL NUMBER { server_signature=$3; }
1171         | SERVER_SIGNATURE EQUAL error { yyerror("boolean value expected"); }
1172         | REPLY_TO_VIA EQUAL NUMBER { reply_to_via=$3; }
1173         | REPLY_TO_VIA EQUAL error { yyerror("boolean value expected"); }
1174         | LISTEN EQUAL id_lst {
1175                 for(lst_tmp=$3; lst_tmp; lst_tmp=lst_tmp->next) {
1176                         if (add_listen_iface(   lst_tmp->addr_lst->name,
1177                                                                         lst_tmp->addr_lst->next,
1178                                                                         lst_tmp->port, lst_tmp->proto,
1179                                                                         lst_tmp->flags)!=0) {
1180                                 LOG(L_CRIT,  "ERROR: cfg. parser: failed to add listen"
1181                                                                 " address\n");
1182                                 break;
1183                         }
1184                 }
1185                 free_socket_id_lst($3);
1186         }
1187         | LISTEN EQUAL  error { yyerror("ip address or hostname expected"); }
1188         | ALIAS EQUAL  id_lst {
1189                 for(lst_tmp=$3; lst_tmp; lst_tmp=lst_tmp->next){
1190                         add_alias(      lst_tmp->addr_lst->name,
1191                                                 strlen(lst_tmp->addr_lst->name),
1192                                                 lst_tmp->port, lst_tmp->proto);
1193                         for (nl_tmp=lst_tmp->addr_lst->next; nl_tmp; nl_tmp=nl_tmp->next)
1194                                 add_alias(nl_tmp->name, strlen(nl_tmp->name),
1195                                                         lst_tmp->port, lst_tmp->proto);
1196                 }
1197                 free_socket_id_lst($3);
1198         }
1199         | ALIAS  EQUAL error  { yyerror(" hostname expected"); }
1200         | ADVERTISED_ADDRESS EQUAL listen_id {
1201                 default_global_address.s=$3;
1202                 default_global_address.len=strlen($3);
1203         }
1204         | ADVERTISED_ADDRESS EQUAL error {yyerror("ip address or hostname expected"); }
1205         | ADVERTISED_PORT EQUAL NUMBER {
1206                 tmp=int2str($3, &i_tmp);
1207                 if ((default_global_port.s=pkg_malloc(i_tmp))==0) {
1208                         LOG(L_CRIT, "ERROR: cfg. parser: out of memory.\n");
1209                         default_global_port.len=0;
1210                 } else {
1211                         default_global_port.len=i_tmp;
1212                         memcpy(default_global_port.s, tmp, default_global_port.len);
1213                 };
1214         }
1215         |ADVERTISED_PORT EQUAL error {yyerror("ip address or hostname expected"); }
1216         | DISABLE_CORE EQUAL NUMBER { disable_core_dump=$3; }
1217         | DISABLE_CORE EQUAL error { yyerror("boolean value expected"); }
1218         | OPEN_FD_LIMIT EQUAL NUMBER { open_files_limit=$3; }
1219         | OPEN_FD_LIMIT EQUAL error { yyerror("number expected"); }
1220         | SHM_FORCE_ALLOC EQUAL NUMBER { shm_force_alloc=$3; }
1221         | SHM_FORCE_ALLOC EQUAL error { yyerror("boolean value expected"); }
1222         | MLOCK_PAGES EQUAL NUMBER { mlock_pages=$3; }
1223         | MLOCK_PAGES EQUAL error { yyerror("boolean value expected"); }
1224         | REAL_TIME EQUAL NUMBER { real_time=$3; }
1225         | REAL_TIME EQUAL error { yyerror("boolean value expected"); }
1226         | RT_PRIO EQUAL NUMBER { rt_prio=$3; }
1227         | RT_PRIO EQUAL error { yyerror("boolean value expected"); }
1228         | RT_POLICY EQUAL NUMBER { rt_policy=$3; }
1229         | RT_POLICY EQUAL error { yyerror("boolean value expected"); }
1230         | RT_TIMER1_PRIO EQUAL NUMBER { rt_timer1_prio=$3; }
1231         | RT_TIMER1_PRIO EQUAL error { yyerror("boolean value expected"); }
1232         | RT_TIMER1_POLICY EQUAL NUMBER { rt_timer1_policy=$3; }
1233         | RT_TIMER1_POLICY EQUAL error { yyerror("boolean value expected"); }
1234         | RT_TIMER2_PRIO EQUAL NUMBER { rt_timer2_prio=$3; }
1235         | RT_TIMER2_PRIO EQUAL error { yyerror("boolean value expected"); }
1236         | RT_TIMER2_POLICY EQUAL NUMBER { rt_timer2_policy=$3; }
1237         | RT_TIMER2_POLICY EQUAL error { yyerror("boolean value expected"); }
1238         | MCAST_LOOPBACK EQUAL NUMBER {
1239                 #ifdef USE_MCAST
1240                         mcast_loopback=$3;
1241                 #else
1242                         warn("no multicast support compiled in");
1243                 #endif
1244         }
1245         | MCAST_LOOPBACK EQUAL error { yyerror("boolean value expected"); }
1246         | MCAST_TTL EQUAL NUMBER {
1247                 #ifdef USE_MCAST
1248                         mcast_ttl=$3;
1249                 #else
1250                         warn("no multicast support compiled in");
1251                 #endif
1252         }
1253         | MCAST_TTL EQUAL error { yyerror("number expected"); }
1254         | TOS EQUAL NUMBER { tos=$3; }
1255         | TOS EQUAL error { yyerror("number expected"); }
1256         | PMTU_DISCOVERY EQUAL NUMBER { pmtu_discovery=$3; }
1257         | PMTU_DISCOVERY error { yyerror("number expected"); }
1258         | KILL_TIMEOUT EQUAL NUMBER { ser_kill_timeout=$3; }
1259         | KILL_TIMEOUT EQUAL error { yyerror("number expected"); }
1260         | STUN_REFRESH_INTERVAL EQUAL NUMBER { IF_STUN(stun_refresh_interval=$3); }
1261         | STUN_REFRESH_INTERVAL EQUAL error{ yyerror("number expected"); }
1262         | STUN_ALLOW_STUN EQUAL NUMBER { IF_STUN(stun_allow_stun=$3); }
1263         | STUN_ALLOW_STUN EQUAL error{ yyerror("number expected"); }
1264         | STUN_ALLOW_FP EQUAL NUMBER { IF_STUN(stun_allow_fp=$3) ; }
1265         | STUN_ALLOW_FP EQUAL error{ yyerror("number expected"); }
1266     | SERVER_ID EQUAL NUMBER { server_id=$3; }
1267         | UDP_MTU EQUAL NUMBER { default_core_cfg.udp_mtu=$3; }
1268         | UDP_MTU EQUAL error { yyerror("number expected"); }
1269         | FORCE_RPORT EQUAL NUMBER 
1270                 { default_core_cfg.force_rport=$3; fix_global_req_flags(0); }
1271         | FORCE_RPORT EQUAL error { yyerror("boolean value expected"); }
1272         | UDP_MTU_TRY_PROTO EQUAL proto
1273                 { default_core_cfg.udp_mtu_try_proto=$3; fix_global_req_flags(0); }
1274         | UDP_MTU_TRY_PROTO EQUAL error
1275                 { yyerror("TCP, TLS, SCTP or UDP expected"); }
1276         | cfg_var
1277         | error EQUAL { yyerror("unknown config variable"); }
1278         ;
1279 cfg_var:
1280         ID DOT ID EQUAL NUMBER {
1281                 if (cfg_declare_int($1, $3, $5, 0, 0, NULL)) {
1282                         yyerror("variable cannot be declared");
1283                 }
1284         }
1285         | ID DOT ID EQUAL STRING {
1286                 if (cfg_declare_str($1, $3, $5, NULL)) {
1287                         yyerror("variable cannot be declared");
1288                 }
1289         }
1290         | ID DOT ID EQUAL NUMBER CFG_DESCRIPTION STRING {
1291                 if (cfg_declare_int($1, $3, $5, 0, 0, $7)) {
1292                         yyerror("variable cannot be declared");
1293                 }
1294         }
1295         | ID DOT ID EQUAL STRING CFG_DESCRIPTION STRING {
1296                 if (cfg_declare_str($1, $3, $5, $7)) {
1297                         yyerror("variable cannot be declared");
1298                 }
1299         }
1300         | ID DOT ID EQUAL error { yyerror("number or string expected"); }
1301         ;
1302 module_stm:
1303         LOADMODULE STRING {
1304                 DBG("loading module %s\n", $2);
1305                         if (load_module($2)!=0) {
1306                                 yyerror("failed to load module");
1307                         }
1308         }
1309         | LOADMODULE error      { yyerror("string expected"); }
1310         | LOADPATH STRING {
1311                 DBG("loading modules under %s\n", $2);
1312                 printf("loading modules under %s\n", $2);
1313                 mods_dir = $2;
1314         }
1315         | LOADPATH error        { yyerror("string expected"); }
1316         | MODPARAM LPAREN STRING COMMA STRING COMMA STRING RPAREN {
1317                 if (set_mod_param_regex($3, $5, PARAM_STRING, $7) != 0) {
1318                          yyerror("Can't set module parameter");
1319                 }
1320         }
1321         | MODPARAM LPAREN STRING COMMA STRING COMMA NUMBER RPAREN {
1322                 if (set_mod_param_regex($3, $5, PARAM_INT, (void*)$7) != 0) {
1323                          yyerror("Can't set module parameter");
1324                 }
1325         }
1326         | MODPARAM error { yyerror("Invalid arguments"); }
1327         ;
1328 ip:
1329         ipv4  { $$=$1; }
1330         | ipv6  { $$=$1; }
1331         ;
1332 ipv4:
1333         NUMBER DOT NUMBER DOT NUMBER DOT NUMBER {
1334                 $$=pkg_malloc(sizeof(struct ip_addr));
1335                 if ($$==0) {
1336                         LOG(L_CRIT, "ERROR: cfg. parser: out of memory.\n");
1337                 } else {
1338                         memset($$, 0, sizeof(struct ip_addr));
1339                         $$->af=AF_INET;
1340                         $$->len=4;
1341                         if (($1>255) || ($1<0) ||
1342                                 ($3>255) || ($3<0) ||
1343                                 ($5>255) || ($5<0) ||
1344                                 ($7>255) || ($7<0)) {
1345                                 yyerror("invalid ipv4 address");
1346                                 $$->u.addr32[0]=0;
1347                                 /* $$=0; */
1348                         } else {
1349                                 $$->u.addr[0]=$1;
1350                                 $$->u.addr[1]=$3;
1351                                 $$->u.addr[2]=$5;
1352                                 $$->u.addr[3]=$7;
1353                                 /*
1354                                 $$=htonl( ($1<<24)|
1355                                 ($3<<16)| ($5<<8)|$7 );
1356                                 */
1357                         }
1358                 }
1359         }
1360         ;
1361 ipv6addr:
1362         IPV6ADDR {
1363                 $$=pkg_malloc(sizeof(struct ip_addr));
1364                 if ($$==0) {
1365                         LOG(L_CRIT, "ERROR: cfg. parser: out of memory.\n");
1366                 } else {
1367                 #ifdef USE_IPV6
1368                         memset($$, 0, sizeof(struct ip_addr));
1369                         $$->af=AF_INET6;
1370                         $$->len=16;
1371                         if (inet_pton(AF_INET6, $1, $$->u.addr)<=0) {
1372                                 yyerror("bad ipv6 address");
1373                         }
1374                 #else
1375                         yyerror("ipv6 address & no ipv6 support compiled in");
1376                         YYABORT;
1377                 #endif
1378                 }
1379         }
1380         ;
1381 ipv6:
1382         ipv6addr { $$=$1; }
1383         | LBRACK ipv6addr RBRACK {$$=$2; }
1384 ;
1385
1386
1387 route_name:             NUMBER  {
1388                                         tmp=int2str($1, &i_tmp);
1389                                         if (($$=pkg_malloc(i_tmp+1))==0) {
1390                                                 yyerror("out of  memory");
1391                                                 YYABORT;
1392                                         } else {
1393                                                 memcpy($$, tmp, i_tmp);
1394                                                 $$[i_tmp]=0;
1395                                         }
1396                                                 }
1397                         |       ID              { $$=$1; }
1398                         |       STRING  { $$=$1; }
1399 ;
1400
1401 route_stm:
1402         ROUTE LBRACE actions RBRACE { push($3, &main_rt.rlist[DEFAULT_RT]); }
1403         | ROUTE LBRACK route_name RBRACK LBRACE actions RBRACE {
1404                 i_tmp=route_get(&main_rt, $3);
1405                 if (i_tmp==-1){
1406                         yyerror("internal error");
1407                         YYABORT;
1408                 }
1409                 if (main_rt.rlist[i_tmp]){
1410                         yyerror("duplicate route");
1411                         YYABORT;
1412                 }
1413                 push($6, &main_rt.rlist[i_tmp]);
1414         }
1415         | ROUTE error { yyerror("invalid  route  statement"); }
1416         ;
1417 failure_route_stm:
1418         ROUTE_FAILURE LBRACE actions RBRACE {
1419                                                                         push($3, &failure_rt.rlist[DEFAULT_RT]);
1420                                                                                 }
1421         | ROUTE_FAILURE LBRACK route_name RBRACK LBRACE actions RBRACE {
1422                 i_tmp=route_get(&failure_rt, $3);
1423                 if (i_tmp==-1){
1424                         yyerror("internal error");
1425                         YYABORT;
1426                 }
1427                 if (failure_rt.rlist[i_tmp]){
1428                         yyerror("duplicate route");
1429                         YYABORT;
1430                 }
1431                 push($6, &failure_rt.rlist[i_tmp]);
1432         }
1433         | ROUTE_FAILURE error { yyerror("invalid failure_route statement"); }
1434         ;
1435 onreply_route_stm:
1436         ROUTE_ONREPLY LBRACE actions RBRACE {
1437                                                                         push($3, &onreply_rt.rlist[DEFAULT_RT]);
1438                                                                                 }
1439         | ROUTE_ONREPLY LBRACK route_name RBRACK LBRACE actions RBRACE {
1440                 i_tmp=route_get(&onreply_rt, $3);
1441                 if (i_tmp==-1){
1442                         yyerror("internal error");
1443                         YYABORT;
1444                 }
1445                 if (onreply_rt.rlist[i_tmp]){
1446                         yyerror("duplicate route");
1447                         YYABORT;
1448                 }
1449                 push($6, &onreply_rt.rlist[i_tmp]);
1450         }
1451         | ROUTE_ONREPLY error { yyerror("invalid onreply_route statement"); }
1452         ;
1453 branch_route_stm:
1454         ROUTE_BRANCH LBRACE actions RBRACE {
1455                                                                         push($3, &branch_rt.rlist[DEFAULT_RT]);
1456                                                                                 }
1457         | ROUTE_BRANCH LBRACK route_name RBRACK LBRACE actions RBRACE {
1458                 i_tmp=route_get(&branch_rt, $3);
1459                 if (i_tmp==-1){
1460                         yyerror("internal error");
1461                         YYABORT;
1462                 }
1463                 if (branch_rt.rlist[i_tmp]){
1464                         yyerror("duplicate route");
1465                         YYABORT;
1466                 }
1467                 push($6, &branch_rt.rlist[i_tmp]);
1468         }
1469         | ROUTE_BRANCH error { yyerror("invalid branch_route statement"); }
1470         ;
1471 send_route_stm: ROUTE_SEND LBRACE actions RBRACE {
1472                                                                         push($3, &onsend_rt.rlist[DEFAULT_RT]);
1473                                                                                                 }
1474         | ROUTE_SEND LBRACK route_name RBRACK LBRACE actions RBRACE {
1475                 i_tmp=route_get(&onsend_rt, $3);
1476                 if (i_tmp==-1){
1477                         yyerror("internal error");
1478                         YYABORT;
1479                 }
1480                 if (onsend_rt.rlist[i_tmp]){
1481                         yyerror("duplicate route");
1482                         YYABORT;
1483                 }
1484                 push($6, &onsend_rt.rlist[i_tmp]);
1485         }
1486         | ROUTE_SEND error { yyerror("invalid onsend_route statement"); }
1487         ;
1488 /*
1489 rules:
1490         rules rule { push($2, &$1); $$=$1; }
1491         | rule {$$=$1; }
1492         | rules error { $$=0; yyerror("invalid rule"); }
1493         ;
1494 rule:
1495         condition actions CR {
1496                 $$=0;
1497                 if (add_rule($1, $2, &$$)<0) {
1498                         yyerror("error calling add_rule");
1499                         YYABORT;
1500                 }
1501         }
1502         | CR    { $$=0;}
1503         | condition error { $$=0; yyerror("bad actions in rule"); }
1504         ;
1505 condition:
1506         exp {$$=$1;}
1507 */
1508 exp:    exp LOG_AND exp         { $$=mk_exp(LOGAND_OP, $1, $3); }
1509         | exp LOG_OR exp        { $$=mk_exp(LOGOR_OP, $1, $3);  }
1510         | NOT exp               { $$=mk_exp(NOT_OP, $2, 0);  }
1511         | LPAREN exp RPAREN     { $$=$2; }
1512         | exp_elem              { $$=$1; }
1513         ;
1514 equalop:
1515         EQUAL_T {$$=EQUAL_OP; }
1516         | DIFF  {$$=DIFF_OP; }
1517         ;
1518 intop:  equalop {$$=$1; }
1519         | GT    {$$=GT_OP; }
1520         | LT    {$$=LT_OP; }
1521         | GTE   {$$=GTE_OP; }
1522         | LTE   {$$=LTE_OP; }
1523         ;
1524 binop :
1525         BIN_OR { $$= BINOR_OP; }
1526         | BIN_AND { $$ = BINAND_OP; }
1527         ;
1528 strop:
1529         equalop {$$=$1; }
1530         | MATCH {$$=MATCH_OP; }
1531         ;
1532 uri_type:
1533         URI             {$$=URI_O;}
1534         | FROM_URI      {$$=FROM_URI_O;}
1535         | TO_URI        {$$=TO_URI_O;}
1536         ;
1537
1538 exp_elem:
1539         METHOD strop STRING     {$$= mk_elem($2, METHOD_O, 0, STRING_ST, $3);}
1540         | METHOD strop attr_id_val  {$$ = mk_elem($2, METHOD_O, 0, AVP_ST, $3); }
1541         | METHOD strop select_id {$$ = mk_elem($2, METHOD_O, 0, SELECT_ST, $3); }
1542         | METHOD strop  ID      {$$ = mk_elem($2, METHOD_O, 0, STRING_ST,$3); }
1543         | METHOD strop error { $$=0; yyerror("string expected"); }
1544         | METHOD error  { $$=0; yyerror("invalid operator,== , !=, or =~ expected"); }
1545         | uri_type strop STRING {$$ = mk_elem($2, $1, 0, STRING_ST, $3); }
1546         | uri_type strop host   {$$ = mk_elem($2, $1, 0, STRING_ST, $3); }
1547         | uri_type strop attr_id_val {$$ = mk_elem($2, $1, 0, AVP_ST, $3); }
1548         | uri_type strop select_id {$$ = mk_elem($2, $1, 0, SELECT_ST, $3); }
1549         | uri_type equalop MYSELF {$$=mk_elem($2, $1, 0, MYSELF_ST, 0); }
1550         | uri_type strop error { $$=0; yyerror("string or MYSELF expected"); }
1551         | uri_type error        { $$=0; yyerror("invalid operator, == , != or =~ expected"); }
1552
1553         | SRCPORT intop NUMBER { $$=mk_elem($2, SRCPORT_O, 0, NUMBER_ST, (void*)$3 ); }
1554         | SRCPORT intop attr_id_val { $$=mk_elem($2, SRCPORT_O, 0, AVP_ST, (void*)$3 ); }
1555         | SRCPORT intop error { $$=0; yyerror("number expected"); }
1556         | SRCPORT error { $$=0; yyerror("==, !=, <,>, >= or <=  expected"); }
1557
1558         | DSTPORT intop NUMBER  { $$=mk_elem($2, DSTPORT_O, 0, NUMBER_ST, (void*)$3 ); }
1559         | DSTPORT intop attr_id_val     { $$=mk_elem($2, DSTPORT_O, 0, AVP_ST, (void*)$3 ); }
1560         | DSTPORT intop error { $$=0; yyerror("number expected"); }
1561         | DSTPORT error { $$=0; yyerror("==, !=, <,>, >= or <=  expected"); }
1562
1563         | SNDPORT intop NUMBER {
1564                 onsend_check("snd_port");
1565                 $$=mk_elem($2, SNDPORT_O, 0, NUMBER_ST, (void*)$3 );
1566         }
1567         | SNDPORT intop attr_id_val {
1568                 onsend_check("snd_port");
1569                 $$=mk_elem($2, SNDPORT_O, 0, AVP_ST, (void*)$3 );
1570         }
1571         | SNDPORT intop error { $$=0; yyerror("number expected"); }
1572         | SNDPORT error { $$=0; yyerror("==, !=, <,>, >= or <=  expected"); }
1573
1574         | TOPORT intop NUMBER {
1575                 onsend_check("to_port");
1576                 $$=mk_elem($2, TOPORT_O, 0, NUMBER_ST, (void*)$3 );
1577         }
1578         | TOPORT intop attr_id_val {
1579                 onsend_check("to_port");
1580                 $$=mk_elem($2, TOPORT_O, 0, AVP_ST, (void*)$3 );
1581         }
1582         | TOPORT intop error { $$=0; yyerror("number expected"); }
1583         | TOPORT error { $$=0; yyerror("==, !=, <,>, >= or <=  expected"); }
1584
1585         | PROTO intop proto     { $$=mk_elem($2, PROTO_O, 0, NUMBER_ST, (void*)$3 ); }
1586         | PROTO intop attr_id_val       { $$=mk_elem($2, PROTO_O, 0, AVP_ST, (void*)$3 ); }
1587         | PROTO intop error { $$=0; yyerror("protocol expected (udp, tcp or tls)"); }
1588
1589         | PROTO error { $$=0; yyerror("equal/!= operator expected"); }
1590
1591         | SNDPROTO intop proto  {
1592                 onsend_check("snd_proto");
1593                 $$=mk_elem($2, SNDPROTO_O, 0, NUMBER_ST, (void*)$3 );
1594         }
1595         | SNDPROTO intop attr_id_val {
1596                 onsend_check("snd_proto");
1597                 $$=mk_elem($2, SNDPROTO_O, 0, AVP_ST, (void*)$3 );
1598         }
1599         | SNDPROTO intop error { $$=0; yyerror("protocol expected (udp, tcp or tls)"); }
1600         | SNDPROTO error { $$=0; yyerror("equal/!= operator expected"); }
1601
1602         | AF intop NUMBER       { $$=mk_elem($2, AF_O, 0, NUMBER_ST,(void *) $3 ); }
1603         | AF intop attr_id_val  { $$=mk_elem($2, AF_O, 0, AVP_ST,(void *) $3 ); }
1604         | AF intop error { $$=0; yyerror("number expected"); }
1605         | AF error { $$=0; yyerror("equal/!= operator expected"); }
1606
1607         | SNDAF intop NUMBER {
1608                 onsend_check("snd_af");
1609                 $$=mk_elem($2, SNDAF_O, 0, NUMBER_ST, (void *) $3 ); }
1610         | SNDAF intop attr_id_val {
1611                 onsend_check("snd_af");
1612                 $$=mk_elem($2, SNDAF_O, 0, AVP_ST, (void *) $3 );
1613         }
1614         | SNDAF intop error { $$=0; yyerror("number expected"); }
1615         | SNDAF error { $$=0; yyerror("equal/!= operator expected"); }
1616
1617         | MSGLEN intop NUMBER           { $$=mk_elem($2, MSGLEN_O, 0, NUMBER_ST, (void *) $3 ); }
1618         | MSGLEN intop attr_id_val      { $$=mk_elem($2, MSGLEN_O, 0, AVP_ST, (void *) $3 ); }
1619         | MSGLEN intop MAX_LEN          { $$=mk_elem($2, MSGLEN_O, 0, NUMBER_ST, (void *) BUF_SIZE); }
1620         | MSGLEN intop error { $$=0; yyerror("number expected"); }
1621         | MSGLEN error { $$=0; yyerror("equal/!= operator expected"); }
1622
1623         | RETCODE intop NUMBER  { $$=mk_elem($2, RETCODE_O, 0, NUMBER_ST, (void *) $3 ); }
1624         | RETCODE intop attr_id_val     { $$=mk_elem($2, RETCODE_O, 0, AVP_ST, (void *) $3 ); }
1625         | RETCODE intop error { $$=0; yyerror("number expected"); }
1626         | RETCODE error { $$=0; yyerror("equal/!= operator expected"); }
1627
1628         | SRCIP equalop ipnet   { $$=mk_elem($2, SRCIP_O, 0, NET_ST, $3); }
1629         | SRCIP strop STRING {
1630                 s_tmp.s=$3;
1631                 s_tmp.len=strlen($3);
1632                 ip_tmp=str2ip(&s_tmp);
1633         #ifdef USE_IPV6
1634                 if (ip_tmp==0)
1635                         ip_tmp=str2ip6(&s_tmp);
1636         #endif
1637                 if (ip_tmp) {
1638                         $$=mk_elem($2, SRCIP_O, 0, NET_ST, mk_net_bitlen(ip_tmp, ip_tmp->len*8) );
1639                 } else {
1640                         $$=mk_elem($2, SRCIP_O, 0, STRING_ST, $3);
1641                 }
1642         }
1643         | SRCIP strop host      { $$=mk_elem($2, SRCIP_O, 0, STRING_ST, $3); }
1644         | SRCIP equalop MYSELF  { $$=mk_elem($2, SRCIP_O, 0, MYSELF_ST, 0);
1645                                                         }
1646         | SRCIP strop error { $$=0; yyerror( "ip address or hostname expected" ); }
1647         | SRCIP error  { $$=0; yyerror("invalid operator, ==, != or =~ expected");}
1648         | DSTIP equalop ipnet   { $$=mk_elem(   $2, DSTIP_O, 0, NET_ST, (void*)$3); }
1649         | DSTIP strop STRING    {
1650                 s_tmp.s=$3;
1651                 s_tmp.len=strlen($3);
1652                 ip_tmp=str2ip(&s_tmp);
1653         #ifdef USE_IPV6
1654                 if (ip_tmp==0)
1655                         ip_tmp=str2ip6(&s_tmp);
1656         #endif /* USE_IPV6 */
1657                 if (ip_tmp) {
1658                         $$=mk_elem($2, DSTIP_O, 0, NET_ST, mk_net_bitlen(ip_tmp, ip_tmp->len*8) );
1659                 } else {
1660                         $$=mk_elem($2, DSTIP_O, 0, STRING_ST, $3);
1661                 }
1662         }
1663         | DSTIP strop host      { $$=mk_elem(   $2, DSTIP_O, 0, STRING_ST, $3); }
1664         | DSTIP equalop MYSELF  { $$=mk_elem(   $2, DSTIP_O, 0, MYSELF_ST, 0); }
1665         | DSTIP strop error { $$=0; yyerror( "ip address or hostname expected" ); }
1666         | DSTIP error { $$=0; yyerror("invalid operator, ==, != or =~ expected"); }
1667         | SNDIP equalop ipnet {
1668                 onsend_check("snd_ip");
1669                 $$=mk_elem($2, SNDIP_O, 0, NET_ST, $3);
1670         }
1671         | SNDIP strop STRING    {
1672                 onsend_check("snd_ip");
1673                 s_tmp.s=$3;
1674                 s_tmp.len=strlen($3);
1675                 ip_tmp=str2ip(&s_tmp);
1676         #ifdef USE_IPV6
1677                 if (ip_tmp==0)
1678                         ip_tmp=str2ip6(&s_tmp);
1679         #endif /* USE_IPV6 */
1680                 if (ip_tmp) {
1681                         $$=mk_elem($2, SNDIP_O, 0, NET_ST, mk_net_bitlen(ip_tmp, ip_tmp->len*8) );
1682                 } else {
1683                         $$=mk_elem($2, SNDIP_O, 0, STRING_ST, $3);
1684                 }
1685         }
1686         | SNDIP strop host      {
1687                 onsend_check("snd_ip");
1688                 $$=mk_elem($2, SNDIP_O, 0, STRING_ST, $3);
1689         }
1690         | SNDIP equalop attr_id_val     {
1691                 onsend_check("snd_ip");
1692             $$=mk_elem($2, SNDIP_O, 0, AVP_ST, (void*)$3 ); 
1693         }
1694         | SNDIP equalop MYSELF  {
1695                 onsend_check("snd_ip");
1696                 $$=mk_elem($2, SNDIP_O, 0, MYSELF_ST, 0);
1697         }
1698         | SNDIP strop error { $$=0; yyerror( "ip address or hostname expected" ); }
1699         | SNDIP error  { $$=0; yyerror("invalid operator, ==, != or =~ expected"); }
1700         | TOIP equalop ipnet    {
1701                 onsend_check("to_ip");
1702                 $$=mk_elem($2, TOIP_O, 0, NET_ST, $3);
1703         }
1704         | TOIP strop STRING     {
1705                 onsend_check("to_ip");
1706                 s_tmp.s=$3;
1707                 s_tmp.len=strlen($3);
1708                 ip_tmp=str2ip(&s_tmp);
1709         #ifdef USE_IPV6
1710                 if (ip_tmp==0)
1711                         ip_tmp=str2ip6(&s_tmp);
1712         #endif /* USE_IPV6 */
1713                 if (ip_tmp) {
1714                         $$=mk_elem($2, TOIP_O, 0, NET_ST, mk_net_bitlen(ip_tmp, ip_tmp->len*8) );
1715                 } else {
1716                         $$=mk_elem($2, TOIP_O, 0, STRING_ST, $3);
1717                 }
1718         }
1719         | TOIP strop host       {
1720                 onsend_check("to_ip");
1721                 $$=mk_elem($2, TOIP_O, 0, STRING_ST, $3);
1722         }
1723         | TOIP equalop attr_id_val      {
1724                 onsend_check("to_ip");
1725             $$=mk_elem($2, TOIP_O, 0, AVP_ST, (void*)$3 ); 
1726         }
1727         | TOIP equalop MYSELF  {
1728                 onsend_check("to_ip");
1729                 $$=mk_elem($2, TOIP_O, 0, MYSELF_ST, 0);
1730         }
1731         | TOIP strop error { $$=0; yyerror( "ip address or hostname expected" ); }
1732         | TOIP error  { $$=0; yyerror("invalid operator, ==, != or =~ expected"); }
1733
1734         | MYSELF equalop uri_type       { $$=mk_elem($2, $3, 0, MYSELF_ST, 0); }
1735         | MYSELF equalop SRCIP  { $$=mk_elem($2, SRCIP_O, 0, MYSELF_ST, 0); }
1736         | MYSELF equalop DSTIP  { $$=mk_elem($2, DSTIP_O, 0, MYSELF_ST, 0); }
1737         | MYSELF equalop SNDIP  {
1738                 onsend_check("snd_ip");
1739                 $$=mk_elem($2, SNDIP_O, 0, MYSELF_ST, 0);
1740         }
1741         | MYSELF equalop TOIP  {
1742                 onsend_check("to_ip");
1743                 $$=mk_elem($2, TOIP_O, 0, MYSELF_ST, 0);
1744         }
1745         | MYSELF equalop error { $$=0; yyerror(" URI, SRCIP or DSTIP expected"); }
1746         | MYSELF error  { $$=0; yyerror ("invalid operator, == or != expected"); }
1747         | exp_stm       { $$=mk_elem( NO_OP, ACTION_O, 0, ACTIONS_ST, $1);  }
1748         | NUMBER        { $$=mk_elem( NO_OP, NUMBER_O, 0, NUMBER_ST, (void*)$1 ); }
1749
1750         | attr_id_any                           {$$=mk_elem( NO_OP, AVP_O, (void*)$1, 0, 0); }
1751         | attr_id_val strop STRING      {$$=mk_elem( $2, AVP_O, (void*)$1, STRING_ST, $3); }
1752         | attr_id_val strop select_id   {$$=mk_elem( $2, AVP_O, (void*)$1, SELECT_ST, $3); }
1753         | attr_id_val intop NUMBER      {$$=mk_elem( $2, AVP_O, (void*)$1, NUMBER_ST, (void*)$3); }
1754         | attr_id_val binop NUMBER      {$$=mk_elem( $2, AVP_O, (void*)$1, NUMBER_ST, (void*)$3); }
1755         | attr_id_val strop attr_id_val {$$=mk_elem( $2, AVP_O, (void*)$1, AVP_ST, (void*)$3); }
1756         | attr_id_val intop attr_id_val {$$=mk_elem( $2, AVP_O, (void*)$1, AVP_ST, (void*)$3); }
1757
1758         | select_id                 { $$=mk_elem( NO_OP, SELECT_O, $1, 0, 0); }
1759         | select_id strop STRING    { $$=mk_elem( $2, SELECT_O, $1, STRING_ST, $3); }
1760         | select_id strop attr_id_val   { $$=mk_elem( $2, SELECT_O, $1, AVP_ST, (void*)$3); }
1761         | select_id strop select_id { $$=mk_elem( $2, SELECT_O, $1, SELECT_ST, $3); }
1762 ;
1763 ipnet:
1764         ip SLASH ip     { $$=mk_net($1, $3); }
1765         | ip SLASH NUMBER {
1766                 if (($3<0) || ($3>$1->len*8)) {
1767                         yyerror("invalid bit number in netmask");
1768                         $$=0;
1769                 } else {
1770                         $$=mk_net_bitlen($1, $3);
1771                 /*
1772                         $$=mk_net($1, htonl( ($3)?~( (1<<(32-$3))-1 ):0 ) );
1773                 */
1774                 }
1775         }
1776         | ip    { $$=mk_net_bitlen($1, $1->len*8); }
1777         | ip SLASH error { $$=0; yyerror("netmask (eg:255.0.0.0 or 8) expected"); }
1778         ;
1779 host_sep:
1780         DOT {$$=".";}
1781         | MINUS {$$="-"; }
1782         ;
1783
1784 host:
1785         ID { $$=$1; }
1786         | host host_sep ID {
1787                 $$=(char*)pkg_malloc(strlen($1)+1+strlen($3)+1);
1788                 if ($$==0) {
1789                         LOG(L_CRIT, "ERROR: cfg. parser: memory allocation failure while parsing host\n");
1790                 } else {
1791                         memcpy($$, $1, strlen($1));
1792                         $$[strlen($1)]=*$2;
1793                         memcpy($$+strlen($1)+1, $3, strlen($3));
1794                         $$[strlen($1)+1+strlen($3)]=0;
1795                 }
1796                 pkg_free($1);
1797                 pkg_free($3);
1798         }
1799         | host DOT error { $$=0; pkg_free($1); yyerror("invalid hostname"); }
1800         ;
1801 /* filtered cmd */
1802 fcmd:
1803         cmd {
1804                 /* check if allowed */
1805                 if ($1 && rt==ONSEND_ROUTE) {
1806                         switch($1->type) {
1807                                 case DROP_T:
1808                                 case SEND_T:
1809                                 case SEND_TCP_T:
1810                                 case LOG_T:
1811                                 case SETFLAG_T:
1812                                 case RESETFLAG_T:
1813                                 case ISFLAGSET_T:
1814                                 case IF_T:
1815                                 case MODULE_T:
1816                                         $$=$1;
1817                                         break;
1818                                 default:
1819                                         $$=0;
1820                                         yyerror("command not allowed in onsend_route\n");
1821                         }
1822                 } else {
1823                         $$=$1;
1824                 }
1825         }
1826         ;
1827 exp_stm:
1828         fcmd    { $$=$1; }
1829         | if_cmd        { $$=$1; }
1830         | assign_action { $$ = $1; }
1831         | LBRACE actions RBRACE { $$=$2; }
1832         ;
1833 stm:
1834         action  { $$=$1; }
1835         | LBRACE actions RBRACE { $$=$2; }
1836         ;
1837 actions:
1838         actions action  {$$=append_action($1, $2); }
1839         | action        {$$=$1;}
1840         | actions error { $$=0; yyerror("bad command"); }
1841         ;
1842 action:
1843         fcmd SEMICOLON {$$=$1;}
1844         | if_cmd {$$=$1;}
1845         | assign_action SEMICOLON {$$=$1;}
1846         | SEMICOLON /* null action */ {$$=0;}
1847         | fcmd error { $$=0; yyerror("bad command: missing ';'?"); }
1848         ;
1849 if_cmd:
1850         IF exp stm              { $$=mk_action( IF_T, 3, EXPR_ST, $2, ACTIONS_ST, $3, NOSUBTYPE, 0); }
1851         | IF exp stm ELSE stm   { $$=mk_action( IF_T, 3, EXPR_ST, $2, ACTIONS_ST, $3, ACTIONS_ST, $5); }
1852         ;
1853 /* class_id:
1854         LBRACK ATTR_USER RBRACK { $$ = AVP_CLASS_USER; }
1855         | LBRACK ATTR_DOMAIN RBRACK { $$ = AVP_CLASS_DOMAIN; }
1856         | LBRACK ATTR_GLOBAL RBRACK { $$ = AVP_CLASS_GLOBAL; }
1857         ;
1858 */
1859 select_param:
1860         ID {
1861                 if (sel.n >= MAX_SELECT_PARAMS-1) {
1862                         yyerror("Select identifier too long\n");
1863                 }
1864                 sel.params[sel.n].type = SEL_PARAM_STR;
1865                 sel.params[sel.n].v.s.s = $1;
1866                 sel.params[sel.n].v.s.len = strlen($1);
1867                 sel.n++;
1868         }
1869         | ID LBRACK NUMBER RBRACK {
1870                 if (sel.n >= MAX_SELECT_PARAMS-2) {
1871                         yyerror("Select identifier too long\n");
1872                 }
1873                 sel.params[sel.n].type = SEL_PARAM_STR;
1874                 sel.params[sel.n].v.s.s = $1;
1875                 sel.params[sel.n].v.s.len = strlen($1);
1876                 sel.n++;
1877                 sel.params[sel.n].type = SEL_PARAM_INT;
1878                 sel.params[sel.n].v.i = $3;
1879                 sel.n++;
1880         }
1881         | ID LBRACK STRING RBRACK {
1882                 if (sel.n >= MAX_SELECT_PARAMS-2) {
1883                         yyerror("Select identifier too long\n");
1884                 }
1885                 sel.params[sel.n].type = SEL_PARAM_STR;
1886                 sel.params[sel.n].v.s.s = $1;
1887                 sel.params[sel.n].v.s.len = strlen($1);
1888                 sel.n++;
1889                 sel.params[sel.n].type = SEL_PARAM_STR;
1890                 sel.params[sel.n].v.s.s = $3;
1891                 sel.params[sel.n].v.s.len = strlen($3);
1892                 sel.n++;
1893         }
1894         ;
1895 select_params:
1896         select_params DOT select_param
1897         | select_param
1898         ;
1899 select_id:
1900         SELECT_MARK { sel.n = 0; sel.f[0] = 0; } select_params {
1901                 sel_ptr = (select_t*)pkg_malloc(sizeof(select_t));
1902                 if (!sel_ptr) {
1903                         yyerror("No memory left to allocate select structure\n");
1904                 }
1905                 memcpy(sel_ptr, &sel, sizeof(select_t));
1906                 $$ = sel_ptr;
1907         }
1908         ;
1909 attr_class_spec:
1910         ATTR_FROM { s_attr->type |= AVP_TRACK_FROM; }
1911         | ATTR_TO { s_attr->type |= AVP_TRACK_TO; }
1912         | ATTR_FROMURI { s_attr->type |= AVP_TRACK_FROM | AVP_CLASS_URI; }
1913         | ATTR_TOURI { s_attr->type |= AVP_TRACK_TO | AVP_CLASS_URI; }
1914         | ATTR_FROMUSER { s_attr->type |= AVP_TRACK_FROM | AVP_CLASS_USER; }
1915         | ATTR_TOUSER { s_attr->type |= AVP_TRACK_TO | AVP_CLASS_USER; }
1916         | ATTR_FROMDOMAIN { s_attr->type |= AVP_TRACK_FROM | AVP_CLASS_DOMAIN; }
1917         | ATTR_TODOMAIN { s_attr->type |= AVP_TRACK_TO | AVP_CLASS_DOMAIN; }
1918         | ATTR_GLOBAL { s_attr->type |= AVP_TRACK_ALL | AVP_CLASS_GLOBAL; }
1919         ;
1920 attr_name_spec:
1921         ID { s_attr->type |= AVP_NAME_STR; s_attr->name.s.s = $1; s_attr->name.s.len = strlen ($1); }
1922         ;
1923 attr_spec:
1924         attr_name_spec
1925         | attr_class_spec DOT attr_name_spec
1926         ;
1927 attr_mark:
1928         ATTR_MARK {
1929                 s_attr = (struct avp_spec*)pkg_malloc(sizeof(struct avp_spec));
1930                 if (!s_attr) { yyerror("No memory left"); }
1931                 s_attr->type = 0;
1932         }
1933         ;
1934 attr_id:
1935         attr_mark attr_spec { $$ = s_attr; }
1936         ;
1937 attr_id_num_idx:
1938         attr_mark attr_spec LBRACK NUMBER RBRACK {
1939                 s_attr->type|= (AVP_NAME_STR | ($4<0?AVP_INDEX_BACKWARD:AVP_INDEX_FORWARD));
1940                 s_attr->index = ($4<0?-$4:$4);
1941                 $$ = s_attr;
1942         }
1943         ;
1944 attr_id_no_idx:
1945         attr_mark attr_spec LBRACK RBRACK {
1946                 s_attr->type|= AVP_INDEX_ALL;
1947                 $$ = s_attr;
1948         }
1949         ;
1950 attr_id_ass:
1951         attr_id
1952         | attr_id_no_idx
1953         ;
1954 attr_id_val:
1955         attr_id
1956         | attr_id_num_idx
1957         ;
1958 attr_id_any:
1959         attr_id
1960         | attr_id_no_idx
1961         | attr_id_num_idx
1962 ;
1963 attr_id_any_str:
1964         attr_id
1965         | STRING {
1966                 avp_spec_t *avp_spec;
1967                 str s;
1968                 int type, idx;
1969                 avp_spec = pkg_malloc(sizeof(*avp_spec));
1970                 if (!avp_spec) {
1971                         yyerror("Not enough memory");
1972                         YYABORT;
1973                 }
1974                 s.s = $1;
1975                 if (s.s[0] == '$')
1976                         s.s++;
1977                 s.len = strlen(s.s);
1978                 if (parse_avp_name(&s, &type, &avp_spec->name, &idx)) {
1979                         yyerror("error when parsing AVP");
1980                         pkg_free(avp_spec);
1981                         YYABORT;
1982                 }
1983                 avp_spec->type = type;
1984                 avp_spec->index = idx;
1985                 $$ = avp_spec;
1986         }
1987         ;
1988 /*
1989 assign_op:
1990         ADDEQ { $$ = ADD_T; }
1991         | EQUAL { $$ = ASSIGN_T; }
1992         ;
1993 */
1994 assign_op:
1995         EQUAL { $$ = ASSIGN_T; }
1996         ;
1997 assign_action:
1998         attr_id_ass assign_op STRING  { $$=mk_action($2, 2, AVP_ST, $1, STRING_ST, $3); }
1999         | attr_id_ass assign_op NUMBER  { $$=mk_action($2, 2, AVP_ST, $1, NUMBER_ST, (void*)$3); }
2000         | attr_id_ass assign_op fcmd    { $$=mk_action($2, 2, AVP_ST, $1, ACTION_ST, $3); }
2001         | attr_id_ass assign_op attr_id_any { $$=mk_action($2, 2, AVP_ST, $1, AVP_ST, $3); }
2002         | attr_id_ass assign_op select_id { $$=mk_action($2, 2, AVP_ST, (void*)$1, SELECT_ST, (void*)$3); }
2003         | attr_id_ass assign_op LPAREN exp RPAREN { $$ = mk_action($2, 2, AVP_ST, $1, EXPR_ST, $4); }
2004         ;
2005 avpflag_oper:
2006         SETAVPFLAG { $$ = 1; }
2007         | RESETAVPFLAG { $$ = 0; }
2008         | ISAVPFLAGSET { $$ = -1; }
2009         ;
2010 cmd:
2011         FORWARD LPAREN host RPAREN      { $$=mk_action( FORWARD_T, 2, STRING_ST, $3, NUMBER_ST, 0); }
2012         | FORWARD LPAREN STRING RPAREN  { $$=mk_action( FORWARD_T, 2, STRING_ST, $3, NUMBER_ST, 0); }
2013         | FORWARD LPAREN ip RPAREN      { $$=mk_action( FORWARD_T, 2, IP_ST, (void*)$3, NUMBER_ST, 0); }
2014         | FORWARD LPAREN host COMMA NUMBER RPAREN { $$=mk_action(FORWARD_T, 2, STRING_ST, $3, NUMBER_ST, (void*)$5); }
2015         | FORWARD LPAREN STRING COMMA NUMBER RPAREN {$$=mk_action(FORWARD_T, 2, STRING_ST, $3, NUMBER_ST, (void*)$5); }
2016         | FORWARD LPAREN ip COMMA NUMBER RPAREN { $$=mk_action(FORWARD_T, 2, IP_ST, (void*)$3, NUMBER_ST, (void*)$5); }
2017         | FORWARD LPAREN URIHOST COMMA URIPORT RPAREN { $$=mk_action(FORWARD_T, 2, URIHOST_ST, 0, URIPORT_ST, 0); }
2018         | FORWARD LPAREN URIHOST COMMA NUMBER RPAREN {$$=mk_action(FORWARD_T, 2, URIHOST_ST, 0, NUMBER_ST, (void*)$5); }
2019         | FORWARD LPAREN URIHOST RPAREN { $$=mk_action(FORWARD_T, 2, URIHOST_ST, 0, NUMBER_ST, 0); }
2020         | FORWARD error { $$=0; yyerror("missing '(' or ')' ?"); }
2021         | FORWARD LPAREN error RPAREN { $$=0; yyerror("bad forward argument"); }
2022         | FORWARD_UDP LPAREN host RPAREN        { $$=mk_action(FORWARD_UDP_T, 2, STRING_ST, $3, NUMBER_ST, 0); }
2023         | FORWARD_UDP LPAREN STRING RPAREN      { $$=mk_action(FORWARD_UDP_T, 2, STRING_ST, $3, NUMBER_ST, 0); }
2024         | FORWARD_UDP LPAREN ip RPAREN  { $$=mk_action(FORWARD_UDP_T, 2, IP_ST, (void*)$3, NUMBER_ST, 0); }
2025         | FORWARD_UDP LPAREN host COMMA NUMBER RPAREN { $$=mk_action(FORWARD_UDP_T, 2, STRING_ST, $3, NUMBER_ST, (void*)$5); }
2026         | FORWARD_UDP LPAREN STRING COMMA NUMBER RPAREN {$$=mk_action(FORWARD_UDP_T, 2, STRING_ST, $3, NUMBER_ST, (void*)$5); }
2027         | FORWARD_UDP LPAREN ip COMMA NUMBER RPAREN { $$=mk_action(FORWARD_UDP_T, 2, IP_ST, (void*)$3, NUMBER_ST, (void*)$5); }
2028         | FORWARD_UDP LPAREN URIHOST COMMA URIPORT RPAREN {$$=mk_action(FORWARD_UDP_T, 2, URIHOST_ST, 0, URIPORT_ST, 0); }
2029         | FORWARD_UDP LPAREN URIHOST COMMA NUMBER RPAREN { $$=mk_action(FORWARD_UDP_T, 2, URIHOST_ST, 0, NUMBER_ST, (void*)$5); }
2030         | FORWARD_UDP LPAREN URIHOST RPAREN { $$=mk_action(FORWARD_UDP_T, 2, URIHOST_ST, 0, NUMBER_ST, 0); }
2031         | FORWARD_UDP error { $$=0; yyerror("missing '(' or ')' ?"); }
2032         | FORWARD_UDP LPAREN error RPAREN { $$=0; yyerror("bad forward_udp argument"); }
2033         | FORWARD_TCP LPAREN host RPAREN        { $$=mk_action(FORWARD_TCP_T, 2, STRING_ST, $3, NUMBER_ST, 0); }
2034         | FORWARD_TCP LPAREN STRING RPAREN      { $$=mk_action(FORWARD_TCP_T, 2, STRING_ST, $3, NUMBER_ST, 0); }
2035         | FORWARD_TCP LPAREN ip RPAREN  { $$=mk_action(FORWARD_TCP_T, 2, IP_ST, (void*)$3, NUMBER_ST, 0); }
2036         | FORWARD_TCP LPAREN host COMMA NUMBER RPAREN { $$=mk_action(FORWARD_TCP_T, 2, STRING_ST, $3, NUMBER_ST, (void*)$5); }
2037         | FORWARD_TCP LPAREN STRING COMMA NUMBER RPAREN {$$=mk_action(FORWARD_TCP_T, 2, STRING_ST, $3, NUMBER_ST, (void*)$5); }
2038         | FORWARD_TCP LPAREN ip COMMA NUMBER RPAREN { $$=mk_action(FORWARD_TCP_T, 2, IP_ST, (void*)$3, NUMBER_ST, (void*)$5); }
2039         | FORWARD_TCP LPAREN URIHOST COMMA URIPORT RPAREN {$$=mk_action(FORWARD_TCP_T, 2, URIHOST_ST, 0, URIPORT_ST, 0); }
2040         | FORWARD_TCP LPAREN URIHOST COMMA NUMBER RPAREN { $$=mk_action(FORWARD_TCP_T, 2, URIHOST_ST, 0, NUMBER_ST, (void*)$5); }
2041         | FORWARD_TCP LPAREN URIHOST RPAREN { $$=mk_action(FORWARD_TCP_T, 2, URIHOST_ST, 0, NUMBER_ST, 0); }
2042         | FORWARD_TCP error { $$=0; yyerror("missing '(' or ')' ?"); }
2043         | FORWARD_TCP LPAREN error RPAREN { $$=0; yyerror("bad forward_tcp argument"); }
2044         | FORWARD_TLS LPAREN host RPAREN {
2045                 #ifdef USE_TLS
2046                         $$=mk_action(FORWARD_TLS_T, 2, STRING_ST, $3, NUMBER_ST, 0);
2047                 #else
2048                         $$=0;
2049                         yyerror("tls support not compiled in");
2050                 #endif
2051         }
2052         | FORWARD_TLS LPAREN STRING RPAREN {
2053                 #ifdef USE_TLS
2054                         $$=mk_action(FORWARD_TLS_T, 2, STRING_ST, $3, NUMBER_ST, 0);
2055                 #else
2056                         $$=0;
2057                         yyerror("tls support not compiled in");
2058                 #endif
2059         }
2060         | FORWARD_TLS LPAREN ip RPAREN  {
2061                 #ifdef USE_TLS
2062                         $$=mk_action(FORWARD_TLS_T, 2, IP_ST, (void*)$3, NUMBER_ST, 0);
2063                 #else
2064                         $$=0;
2065                         yyerror("tls support not compiled in");
2066                 #endif
2067         }
2068         | FORWARD_TLS LPAREN host COMMA NUMBER RPAREN {
2069                 #ifdef USE_TLS
2070                         $$=mk_action(FORWARD_TLS_T, 2, STRING_ST, $3, NUMBER_ST, (void*)$5);
2071                 #else
2072                         $$=0;
2073                         yyerror("tls support not compiled in");
2074                 #endif
2075         }
2076         | FORWARD_TLS LPAREN STRING COMMA NUMBER RPAREN {
2077                 #ifdef USE_TLS
2078                         $$=mk_action(FORWARD_TLS_T, 2, STRING_ST, $3, NUMBER_ST, (void*)$5);
2079                 #else
2080                         $$=0;
2081                         yyerror("tls support not compiled in");
2082                 #endif
2083         }
2084         | FORWARD_TLS LPAREN ip COMMA NUMBER RPAREN {
2085                 #ifdef USE_TLS
2086                         $$=mk_action(FORWARD_TLS_T, 2, IP_ST, (void*)$3, NUMBER_ST, (void*)$5);
2087                 #else
2088                         $$=0;
2089                         yyerror("tls support not compiled in");
2090                 #endif
2091                                         }
2092         | FORWARD_TLS LPAREN URIHOST COMMA URIPORT RPAREN {
2093                 #ifdef USE_TLS
2094                         $$=mk_action(FORWARD_TLS_T, 2, URIHOST_ST, 0, URIPORT_ST, 0);
2095                 #else
2096                         $$=0;
2097                         yyerror("tls support not compiled in");
2098                 #endif
2099         }
2100         | FORWARD_TLS LPAREN URIHOST COMMA NUMBER RPAREN {
2101                 #ifdef USE_TLS
2102                         $$=mk_action(FORWARD_TLS_T, 2, URIHOST_ST, 0, NUMBER_ST, (void*)$5);
2103                 #else
2104                         $$=0;
2105                         yyerror("tls support not compiled in");
2106                 #endif
2107         }
2108         | FORWARD_TLS LPAREN URIHOST RPAREN {
2109                 #ifdef USE_TLS
2110                         $$=mk_action(FORWARD_TLS_T, 2, URIHOST_ST, 0, NUMBER_ST, 0);
2111                 #else
2112                         $$=0;
2113                         yyerror("tls support not compiled in");
2114                 #endif
2115         }
2116         | FORWARD_TLS error { $$=0; yyerror("missing '(' or ')' ?"); }
2117         | FORWARD_TLS LPAREN error RPAREN { $$=0; 
2118                                                                         yyerror("bad forward_tls argument"); }
2119         | FORWARD_SCTP LPAREN host RPAREN {
2120                 #ifdef USE_SCTP
2121                         $$=mk_action(FORWARD_SCTP_T, 2, STRING_ST, $3, NUMBER_ST, 0);
2122                 #else
2123                         $$=0;
2124                         yyerror("sctp support not compiled in");
2125                 #endif
2126         }
2127         | FORWARD_SCTP LPAREN STRING RPAREN {
2128                 #ifdef USE_SCTP
2129                         $$=mk_action(FORWARD_SCTP_T, 2, STRING_ST, $3, NUMBER_ST, 0);
2130                 #else
2131                         $$=0;
2132                         yyerror("sctp support not compiled in");
2133                 #endif
2134         }
2135         | FORWARD_SCTP LPAREN ip RPAREN {
2136                 #ifdef USE_SCTP
2137                         $$=mk_action(FORWARD_SCTP_T, 2, IP_ST, (void*)$3, NUMBER_ST, 0);
2138                 #else
2139                         $$=0;
2140                         yyerror("sctp support not compiled in");
2141                 #endif
2142         }
2143         | FORWARD_SCTP LPAREN host COMMA NUMBER RPAREN {
2144                 #ifdef USE_SCTP
2145                         $$=mk_action(FORWARD_SCTP_T, 2, STRING_ST, $3, NUMBER_ST,
2146                                                         (void*)$5);
2147                 #else
2148                         $$=0;
2149                         yyerror("sctp support not compiled in");
2150                 #endif
2151         }
2152         | FORWARD_SCTP LPAREN STRING COMMA NUMBER RPAREN {
2153                 #ifdef USE_SCTP
2154                         $$=mk_action(FORWARD_SCTP_T, 2, STRING_ST, $3, NUMBER_ST,
2155                                                         (void*)$5);
2156                 #else
2157                         $$=0;
2158                         yyerror("sctp support not compiled in");
2159                 #endif
2160         }
2161         | FORWARD_SCTP LPAREN ip COMMA NUMBER RPAREN {
2162                 #ifdef USE_SCTP
2163                         $$=mk_action(FORWARD_SCTP_T, 2, IP_ST, (void*)$3, NUMBER_ST, 
2164                                                         (void*)$5);
2165                 #else
2166                         $$=0;
2167                         yyerror("sctp support not compiled in");
2168                 #endif
2169                                         }
2170         | FORWARD_SCTP LPAREN URIHOST COMMA URIPORT RPAREN {
2171                 #ifdef USE_SCTP
2172                         $$=mk_action(FORWARD_SCTP_T, 2, URIHOST_ST, 0, URIPORT_ST, 0);
2173                 #else
2174                         $$=0;
2175                         yyerror("sctp support not compiled in");
2176                 #endif
2177         }
2178         | FORWARD_SCTP LPAREN URIHOST COMMA NUMBER RPAREN {
2179                 #ifdef USE_SCTP
2180                         $$=mk_action(FORWARD_SCTP_T, 2, URIHOST_ST, 0, NUMBER_ST,
2181                                                         (void*)$5);
2182                 #else
2183                         $$=0;
2184                         yyerror("sctp support not compiled in");
2185                 #endif
2186         }
2187         | FORWARD_SCTP LPAREN URIHOST RPAREN {
2188                 #ifdef USE_SCTP
2189                         $$=mk_action(FORWARD_SCTP_T, 2, URIHOST_ST, 0, NUMBER_ST, 0);
2190                 #else
2191                         $$=0;
2192                         yyerror("tls support not compiled in");
2193                 #endif
2194         }
2195         | FORWARD_SCTP error { $$=0; yyerror("missing '(' or ')' ?"); }
2196         | FORWARD_SCTP LPAREN error RPAREN { $$=0; 
2197                                                                         yyerror("bad forward_tls argument"); }
2198         | SEND LPAREN host RPAREN       { $$=mk_action(SEND_T, 2, STRING_ST, $3, NUMBER_ST, 0); }
2199         | SEND LPAREN STRING RPAREN { $$=mk_action(SEND_T, 2, STRING_ST, $3, NUMBER_ST, 0); }
2200         | SEND LPAREN ip RPAREN         { $$=mk_action(SEND_T, 2, IP_ST, (void*)$3, NUMBER_ST, 0); }
2201         | SEND LPAREN host COMMA NUMBER RPAREN  { $$=mk_action(SEND_T, 2, STRING_ST, $3, NUMBER_ST, (void*)$5); }
2202         | SEND LPAREN STRING COMMA NUMBER RPAREN {$$=mk_action(SEND_T, 2, STRING_ST, $3, NUMBER_ST, (void*)$5); }
2203         | SEND LPAREN ip COMMA NUMBER RPAREN { $$=mk_action(SEND_T, 2, IP_ST, (void*)$3, NUMBER_ST, (void*)$5); }
2204         | SEND error { $$=0; yyerror("missing '(' or ')' ?"); }
2205         | SEND LPAREN error RPAREN { $$=0; yyerror("bad send argument"); }
2206         | SEND_TCP LPAREN host RPAREN   { $$=mk_action(SEND_TCP_T, 2, STRING_ST, $3, NUMBER_ST, 0); }
2207         | SEND_TCP LPAREN STRING RPAREN { $$=mk_action(SEND_TCP_T, 2, STRING_ST, $3, NUMBER_ST, 0); }
2208         | SEND_TCP LPAREN ip RPAREN     { $$=mk_action(SEND_TCP_T, 2, IP_ST, (void*)$3, NUMBER_ST, 0); }
2209         | SEND_TCP LPAREN host COMMA NUMBER RPAREN      { $$=mk_action( SEND_TCP_T, 2, STRING_ST, $3, NUMBER_ST, (void*)$5);}
2210         | SEND_TCP LPAREN STRING COMMA NUMBER RPAREN {$$=mk_action(SEND_TCP_T, 2, STRING_ST, $3, NUMBER_ST, (void*)$5); }
2211         | SEND_TCP LPAREN ip COMMA NUMBER RPAREN { $$=mk_action(SEND_TCP_T, 2, IP_ST, (void*)$3, NUMBER_ST, (void*)$5); }
2212         | SEND_TCP error { $$=0; yyerror("missing '(' or ')' ?"); }
2213         | SEND_TCP LPAREN error RPAREN { $$=0; yyerror("bad send_tcp argument"); }
2214         | DROP LPAREN RPAREN            {$$=mk_action(DROP_T, 2, NUMBER_ST, 0, NUMBER_ST, (void*)EXIT_R_F); }
2215         | DROP LPAREN NUMBER RPAREN     {$$=mk_action(DROP_T, 2, NUMBER_ST, (void*)$3, NUMBER_ST, (void*)EXIT_R_F); }
2216         | DROP NUMBER                   {$$=mk_action(DROP_T, 2, NUMBER_ST, (void*)$2, NUMBER_ST, (void*)EXIT_R_F); }
2217         | DROP RETCODE                  {$$=mk_action(DROP_T, 2, RETCODE_ST, 0, NUMBER_ST, (void*)EXIT_R_F); }
2218         | DROP                          {$$=mk_action(DROP_T, 2, NUMBER_ST, 0, NUMBER_ST, (void*)EXIT_R_F); }
2219         | RETURN                        {$$=mk_action(DROP_T, 2, NUMBER_ST, (void*)1, NUMBER_ST, (void*)RETURN_R_F); }
2220         | RETURN NUMBER                 {$$=mk_action(DROP_T, 2, NUMBER_ST, (void*)$2, NUMBER_ST, (void*)RETURN_R_F);}
2221         | RETURN RETCODE                {$$=mk_action(DROP_T, 2, RETCODE_ST, 0, NUMBER_ST, (void*)RETURN_R_F);}
2222         | BREAK                         {$$=mk_action(DROP_T, 2, NUMBER_ST, 0, NUMBER_ST, (void*)RETURN_R_F); }
2223         | LOG_TOK LPAREN STRING RPAREN  {$$=mk_action(LOG_T, 2, NUMBER_ST,
2224                                                                                 (void*)(L_DBG+1), STRING_ST, $3); }
2225         | LOG_TOK LPAREN NUMBER COMMA STRING RPAREN     {$$=mk_action(LOG_T, 2, NUMBER_ST, (void*)$3, STRING_ST, $5); }
2226         | LOG_TOK error                 { $$=0; yyerror("missing '(' or ')' ?"); }
2227         | LOG_TOK LPAREN error RPAREN   { $$=0; yyerror("bad log argument"); }
2228         | SETFLAG LPAREN NUMBER RPAREN  {
2229                                                         if (check_flag($3)==-1)
2230                                                                 yyerror("bad flag value");
2231                                                         $$=mk_action(SETFLAG_T, 1, NUMBER_ST,
2232                                                                                                         (void*)$3);
2233                                                                         }
2234         | SETFLAG LPAREN flag_name RPAREN       {
2235                                                         i_tmp=get_flag_no($3, strlen($3));
2236                                                         if (i_tmp<0) yyerror("flag not declared");
2237                                                         $$=mk_action(SETFLAG_T, 1, NUMBER_ST,
2238                                                                                 (void*)(long)i_tmp);
2239                                                                         }
2240         | SETFLAG error                 { $$=0; yyerror("missing '(' or ')'?"); }
2241         | RESETFLAG LPAREN NUMBER RPAREN {
2242                                                         if (check_flag($3)==-1)
2243                                                                 yyerror("bad flag value");
2244                                                         $$=mk_action(RESETFLAG_T, 1, NUMBER_ST, (void*)$3);
2245                                                                         }
2246         | RESETFLAG LPAREN flag_name RPAREN     {
2247                                                         i_tmp=get_flag_no($3, strlen($3));
2248                                                         if (i_tmp<0) yyerror("flag not declared");
2249                                                         $$=mk_action(RESETFLAG_T, 1, NUMBER_ST,
2250                                                                                 (void*)(long)i_tmp);
2251                                                                         }
2252         | RESETFLAG error               { $$=0; yyerror("missing '(' or ')'?"); }
2253         | ISFLAGSET LPAREN NUMBER RPAREN {
2254                                                         if (check_flag($3)==-1)
2255                                                                 yyerror("bad flag value");
2256                                                         $$=mk_action(ISFLAGSET_T, 1, NUMBER_ST, (void*)$3);
2257                                                                         }
2258         | ISFLAGSET LPAREN flag_name RPAREN     {
2259                                                         i_tmp=get_flag_no($3, strlen($3));
2260                                                         if (i_tmp<0) yyerror("flag not declared");
2261                                                         $$=mk_action(ISFLAGSET_T, 1, NUMBER_ST,
2262                                                                                 (void*)(long)i_tmp);
2263                                                                         }
2264         | ISFLAGSET error { $$=0; yyerror("missing '(' or ')'?"); }
2265         | avpflag_oper LPAREN attr_id_any_str COMMA flag_name RPAREN {
2266                 i_tmp=get_avpflag_no($5);
2267                 if (i_tmp==0) yyerror("avpflag not declared");
2268                 $$=mk_action(AVPFLAG_OPER_T, 3, AVP_ST, $3, NUMBER_ST, (void*)(long)i_tmp, NUMBER_ST, (void*)$1);
2269         }
2270         | avpflag_oper error { $$=0; yyerror("missing '(' or ')'?"); }
2271         | ERROR LPAREN STRING COMMA STRING RPAREN {$$=mk_action(ERROR_T, 2, STRING_ST, $3, STRING_ST, $5); }
2272         | ERROR error { $$=0; yyerror("missing '(' or ')' ?"); }
2273         | ERROR LPAREN error RPAREN { $$=0; yyerror("bad error argument"); }
2274         | ROUTE LPAREN route_name RPAREN        {
2275                                                 i_tmp=route_get(&main_rt, $3);
2276                                                 if (i_tmp==-1){
2277                                                         yyerror("internal error");
2278                                                         YYABORT;
2279                                                 }
2280                                                 $$=mk_action(ROUTE_T, 1, NUMBER_ST,(void*)(long)i_tmp);
2281                                                                                 }
2282         | ROUTE error { $$=0; yyerror("missing '(' or ')' ?"); }
2283         | ROUTE LPAREN error RPAREN { $$=0; yyerror("bad route argument"); }
2284         | EXEC LPAREN STRING RPAREN     { $$=mk_action(EXEC_T, 1, STRING_ST, $3); }
2285         | SET_HOST LPAREN STRING RPAREN { $$=mk_action(SET_HOST_T, 1, STRING_ST, $3); }
2286         | SET_HOST error { $$=0; yyerror("missing '(' or ')' ?"); }
2287         | SET_HOST LPAREN error RPAREN { $$=0; yyerror("bad argument, string expected"); }
2288         | PREFIX LPAREN STRING RPAREN { $$=mk_action(PREFIX_T, 1, STRING_ST,  $3); }
2289         | PREFIX error { $$=0; yyerror("missing '(' or ')' ?"); }
2290         | PREFIX LPAREN error RPAREN { $$=0; yyerror("bad argument, string expected"); }
2291         | STRIP_TAIL LPAREN NUMBER RPAREN { $$=mk_action(STRIP_TAIL_T, 1, NUMBER_ST, (void*)$3); }
2292         | STRIP_TAIL error { $$=0; yyerror("missing '(' or ')' ?"); }
2293         | STRIP_TAIL LPAREN error RPAREN { $$=0; yyerror("bad argument, number expected"); }
2294         | STRIP LPAREN NUMBER RPAREN { $$=mk_action(STRIP_T, 1, NUMBER_ST, (void*) $3); }
2295         | STRIP error { $$=0; yyerror("missing '(' or ')' ?"); }
2296         | STRIP LPAREN error RPAREN { $$=0; yyerror("bad argument, number expected"); }
2297         | APPEND_BRANCH LPAREN STRING COMMA STRING RPAREN {
2298                 qvalue_t q;
2299                 if (str2q(&q, $5, strlen($5)) < 0) {
2300                         yyerror("bad argument, q value expected");
2301                 }
2302                 $$=mk_action(APPEND_BRANCH_T, 2, STRING_ST, $3, NUMBER_ST, (void *)(long)q);
2303         }
2304         | APPEND_BRANCH LPAREN STRING RPAREN { $$=mk_action(APPEND_BRANCH_T, 2, STRING_ST, $3, NUMBER_ST, (void *)Q_UNSPECIFIED); }
2305         | APPEND_BRANCH LPAREN RPAREN { $$=mk_action(APPEND_BRANCH_T, 2, STRING_ST, 0, NUMBER_ST, (void *)Q_UNSPECIFIED); }
2306         | APPEND_BRANCH {  $$=mk_action( APPEND_BRANCH_T, 1, STRING_ST, 0); }
2307         | SET_HOSTPORT LPAREN STRING RPAREN { $$=mk_action(SET_HOSTPORT_T, 1, STRING_ST, $3); }
2308         | SET_HOSTPORT error { $$=0; yyerror("missing '(' or ')' ?"); }
2309         | SET_HOSTPORT LPAREN error RPAREN { $$=0; yyerror("bad argument, string expected"); }
2310         | SET_HOSTPORTTRANS LPAREN STRING RPAREN { $$=mk_action(SET_HOSTPORTTRANS_T, 1, STRING_ST, $3); }
2311         | SET_HOSTPORTTRANS error { $$=0; yyerror("missing '(' or ')' ?"); }
2312         | SET_HOSTPORTTRANS LPAREN error RPAREN { $$=0; yyerror("bad argument, string expected"); }
2313         | SET_PORT LPAREN STRING RPAREN { $$=mk_action(SET_PORT_T, 1, STRING_ST, $3); }
2314         | SET_PORT error { $$=0; yyerror("missing '(' or ')' ?"); }
2315         | SET_PORT LPAREN error RPAREN { $$=0; yyerror("bad argument, string expected"); }
2316         | SET_USER LPAREN STRING RPAREN { $$=mk_action(SET_USER_T, 1, STRING_ST, $3); }
2317         | SET_USER error { $$=0; yyerror("missing '(' or ')' ?"); }
2318         | SET_USER LPAREN error RPAREN { $$=0; yyerror("bad argument, string expected"); }
2319         | SET_USERPASS LPAREN STRING RPAREN { $$=mk_action(SET_USERPASS_T, 1, STRING_ST, $3); }
2320         | SET_USERPASS error { $$=0; yyerror("missing '(' or ')' ?"); }
2321         | SET_USERPASS LPAREN error RPAREN { $$=0; yyerror("bad argument, string expected"); }
2322         | SET_URI LPAREN STRING RPAREN { $$=mk_action(SET_URI_T, 1, STRING_ST,$3); }
2323         | SET_URI error { $$=0; yyerror("missing '(' or ')' ?"); }
2324         | SET_URI LPAREN error RPAREN { $$=0; yyerror("bad argument, string expected"); }
2325         | REVERT_URI LPAREN RPAREN { $$=mk_action(REVERT_URI_T, 0); }
2326         | REVERT_URI { $$=mk_action(REVERT_URI_T, 0); }
2327         | FORCE_RPORT LPAREN RPAREN     { $$=mk_action(FORCE_RPORT_T, 0); }
2328         | FORCE_RPORT   {$$=mk_action(FORCE_RPORT_T, 0); }
2329         | FORCE_TCP_ALIAS LPAREN NUMBER RPAREN  {
2330                 #ifdef USE_TCP
2331                         $$=mk_action(FORCE_TCP_ALIAS_T, 1, NUMBER_ST, (void*)$3);
2332                 #else
2333                         yyerror("tcp support not compiled in");
2334                 #endif
2335         }
2336         | FORCE_TCP_ALIAS LPAREN RPAREN {
2337                 #ifdef USE_TCP
2338                         $$=mk_action(FORCE_TCP_ALIAS_T, 0);
2339                 #else
2340                         yyerror("tcp support not compiled in");
2341                 #endif
2342         }
2343         | FORCE_TCP_ALIAS                               {
2344                 #ifdef USE_TCP
2345                         $$=mk_action(FORCE_TCP_ALIAS_T, 0);
2346                 #else
2347                         yyerror("tcp support not compiled in");
2348                 #endif
2349         }
2350         | FORCE_TCP_ALIAS LPAREN error RPAREN   {$$=0; yyerror("bad argument, number expected"); }
2351         | UDP_MTU_TRY_PROTO LPAREN proto RPAREN
2352                 { $$=mk_action(UDP_MTU_TRY_PROTO_T, 1, NUMBER_ST, $3); }
2353         | UDP_MTU_TRY_PROTO LPAREN error RPAREN
2354                 { $$=0; yyerror("bad argument, UDP, TCP, TLS or SCTP expected"); }
2355         | SET_ADV_ADDRESS LPAREN listen_id RPAREN {
2356                 $$=0;
2357                 if ((str_tmp=pkg_malloc(sizeof(str)))==0) {
2358                         LOG(L_CRIT, "ERROR: cfg. parser: out of memory.\n");
2359                 } else {
2360                         str_tmp->s=$3;
2361                         str_tmp->len=strlen($3);
2362                         $$=mk_action(SET_ADV_ADDR_T, 1, STR_ST, str_tmp);
2363                 }
2364         }
2365         | SET_ADV_ADDRESS LPAREN error RPAREN { $$=0; yyerror("bad argument, string expected"); }
2366         | SET_ADV_ADDRESS error {$$=0; yyerror("missing '(' or ')' ?"); }
2367         | SET_ADV_PORT LPAREN NUMBER RPAREN {
2368                 $$=0;
2369                 tmp=int2str($3, &i_tmp);
2370                 if ((str_tmp=pkg_malloc(sizeof(str)))==0) {
2371                         LOG(L_CRIT, "ERROR: cfg. parser: out of memory.\n");
2372                 } else {
2373                         if ((str_tmp->s=pkg_malloc(i_tmp))==0) {
2374                                 LOG(L_CRIT, "ERROR: cfg. parser: out of memory.\n");
2375                         } else {
2376                                 memcpy(str_tmp->s, tmp, i_tmp);
2377                                 str_tmp->len=i_tmp;
2378                                 $$=mk_action(SET_ADV_PORT_T, 1, STR_ST, str_tmp);
2379                         }
2380                 }
2381         }
2382         | SET_ADV_PORT LPAREN error RPAREN { $$=0; yyerror("bad argument, string expected"); }
2383         | SET_ADV_PORT  error {$$=0; yyerror("missing '(' or ')' ?"); }
2384         | FORCE_SEND_SOCKET LPAREN phostport RPAREN { 
2385                 $$=mk_action(FORCE_SEND_SOCKET_T, 1, SOCKID_ST, $3);
2386         }
2387         | FORCE_SEND_SOCKET LPAREN error RPAREN {
2388                 $$=0; yyerror("bad argument, [proto:]host[:port] expected");
2389         }
2390         | FORCE_SEND_SOCKET error {$$=0; yyerror("missing '(' or ')' ?"); }
2391         | ID {mod_func_action = mk_action(MODULE_T, 2, MODEXP_ST, NULL, NUMBER_ST, 0); } LPAREN func_params RPAREN      {
2392                 mod_func_action->val[0].u.data = find_export_record($1, mod_func_action->val[1].u.number, rt);
2393                 if (mod_func_action->val[0].u.data == 0) {
2394                         if (find_export_record($1, mod_func_action->val[1].u.number, 0) ) {
2395                                         yyerror("Command cannot be used in the block\n");
2396                         } else {
2397                                 yyerror("unknown command, missing loadmodule?\n");
2398                         }
2399                         pkg_free(mod_func_action);
2400                         mod_func_action=0;
2401                 }
2402                 $$ = mod_func_action;
2403         }
2404         ;
2405 func_params:
2406         /* empty */
2407         | func_params COMMA func_param { }
2408         | func_param {}
2409         | func_params error { yyerror("call params error\n"); YYABORT; }
2410         ;
2411 func_param:
2412         NUMBER {
2413                 if (mod_func_action->val[1].u.number < MAX_ACTIONS-2) {
2414                         mod_func_action->val[mod_func_action->val[1].u.number+2].type = NUMBER_ST;
2415                         mod_func_action->val[mod_func_action->val[1].u.number+2].u.number = $1;
2416                         mod_func_action->val[1].u.number++;
2417                 } else {
2418                         yyerror("Too many arguments\n");
2419                 }
2420         }
2421         | STRING {
2422                 if (mod_func_action->val[1].u.number < MAX_ACTIONS-2) {
2423                         mod_func_action->val[mod_func_action->val[1].u.number+2].type = STRING_ST;
2424                         mod_func_action->val[mod_func_action->val[1].u.number+2].u.string = $1;
2425                         mod_func_action->val[1].u.number++;
2426                 } else {
2427                         yyerror("Too many arguments\n");
2428                 }
2429         }
2430         ;
2431 %%
2432
2433 extern int line;
2434 extern int column;
2435 extern int startcolumn;
2436 static void warn(char* s)
2437 {
2438         LOG(L_WARN, "cfg. warning: (%d,%d-%d): %s\n", line, startcolumn,
2439                         column, s);
2440         cfg_warnings++;
2441 }
2442
2443 static void yyerror(char* s)
2444 {
2445         LOG(L_CRIT, "*** PARSE ERROR *** (%d,%d-%d): %s\n", line, startcolumn,
2446                         column, s);
2447         cfg_errors++;
2448 }
2449
2450
2451 static struct name_lst* mk_name_lst(char* host, int flags)
2452 {
2453         struct name_lst* l;
2454         l=pkg_malloc(sizeof(struct name_lst));
2455         if (l==0) {
2456                 LOG(L_CRIT,"ERROR: cfg. parser: out of memory.\n");
2457         } else {
2458                 l->name=host;
2459                 l->flags=flags;
2460                 l->next=0;
2461         }
2462         return l;
2463 }
2464
2465
2466 static struct socket_id* mk_listen_id(char* host, int proto, int port)
2467 {
2468         struct socket_id* l;
2469         l=pkg_malloc(sizeof(struct socket_id));
2470         if (l==0) {
2471                 LOG(L_CRIT,"ERROR: cfg. parser: out of memory.\n");
2472         } else {
2473                 l->addr_lst=mk_name_lst(host, 0);
2474                 if (l->addr_lst==0){
2475                         pkg_free(l);
2476                         return 0;
2477                 }
2478                 l->flags=0;
2479                 l->port=port;
2480                 l->proto=proto;
2481                 l->next=0;
2482         }
2483         return l;
2484 }
2485
2486
2487 static void free_name_lst(struct name_lst* lst)
2488 {
2489         struct name_lst* tmp;
2490         
2491         while(lst){
2492                 tmp=lst;
2493                 lst=lst->next;
2494                 pkg_free(tmp);
2495         }
2496 }
2497
2498
2499 static struct socket_id* mk_listen_id2(struct name_lst* addr_l, int proto,
2500                                                                                 int port)
2501 {
2502         struct socket_id* l;
2503         l=pkg_malloc(sizeof(struct socket_id));
2504         if (l==0) {
2505                 LOG(L_CRIT,"ERROR: cfg. parser: out of memory.\n");
2506         } else {
2507                 l->flags=addr_l->flags;
2508                 l->port=port;
2509                 l->proto=proto;
2510                 l->addr_lst=addr_l;
2511                 l->next=0;
2512         }
2513         return l;
2514 }
2515
2516
2517 static void free_socket_id(struct socket_id* i)
2518 {
2519         free_name_lst(i->addr_lst);
2520         pkg_free(i);
2521 }
2522
2523
2524 static void free_socket_id_lst(struct socket_id* lst)
2525 {
2526         struct socket_id* tmp;
2527         
2528         while(lst){
2529                 tmp=lst;
2530                 lst=lst->next;
2531                 free_socket_id(tmp);
2532         }
2533 }
2534
2535 /*
2536 int main(int argc, char ** argv)
2537 {
2538         if (yyparse()!=0)
2539                 fprintf(stderr, "parsing error\n");
2540 }
2541 */