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