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