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