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