core/corex: move send()/send_tcp() to corex module
[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  * 2008-11-18  support for variable parameter module functions (andrei)
92  * 2007-12-03  support for generalised lvalues and rvalues:
93  *               lval=rval_expr, where lval=avp|pvar  (andrei)
94  * 2007-12-06  expression are now evaluated in terms of rvalues;
95  *             NUMBER is now always positive; cleanup (andrei)
96  * 2009-01-26  case/switch() support (andrei)
97  * 2009-03-10  added SET_USERPHONE action (Miklos)
98  * 2009-05-04  switched if to rval_expr (andrei)
99  * 2010-01-10  init shm on first mod_param or route block;
100  *             added SHM_MEM_SZ (andrei)
101  * 2010-02-17  added blacklist imask (DST_BLST_*_IMASK) support (andrei)
102 */
103
104 %expect 6
105
106 %{
107
108 #include <stdlib.h>
109 #include <stdio.h>
110 #include <stdarg.h>
111 #include <sys/types.h>
112 #include <sys/socket.h>
113 #include <netinet/in.h>
114 #include <netinet/ip.h>
115 #include <arpa/inet.h>
116 #include <string.h>
117 #include <errno.h>
118 #include "route_struct.h"
119 #include "globals.h"
120 #ifdef SHM_MEM
121 #include "shm_init.h"
122 #endif /* SHM_MEM */
123 #include "route.h"
124 #include "switch.h"
125 #include "dprint.h"
126 #include "sr_module.h"
127 #include "modparam.h"
128 #include "ip_addr.h"
129 #include "resolve.h"
130 #include "socket_info.h"
131 #include "name_alias.h"
132 #include "ut.h"
133 #include "dset.h"
134 #include "select.h"
135 #include "flags.h"
136 #include "tcp_init.h"
137 #include "tcp_options.h"
138 #include "sctp_options.h"
139 #include "pvar.h"
140 #include "lvalue.h"
141 #include "rvalue.h"
142 #include "sr_compat.h"
143 #include "msg_translator.h"
144
145 #include "ppcfg.h"
146 #include "pvapi.h"
147 #include "config.h"
148 #include "cfg_core.h"
149 #include "cfg/cfg.h"
150 #ifdef CORE_TLS
151 #include "tls/tls_config.h"
152 #endif
153 #include "timer_ticks.h"
154
155 #ifdef DEBUG_DMALLOC
156 #include <dmalloc.h>
157 #endif
158
159 /* hack to avoid alloca usage in the generated C file (needed for compiler
160  with no built in alloca, like icc*/
161 #undef _ALLOCA_H
162
163 #define onsend_check(s) \
164         do{\
165                 if (rt!=ONSEND_ROUTE) yyerror( s " allowed only in onsend_routes");\
166         }while(0)
167
168 #ifdef USE_IPV6
169         #define IF_AUTO_BIND_IPV6(x) x
170 #else
171         #define IF_AUTO_BIND_IPV6(x) warn("IPV6 support not compiled");
172 #endif
173
174 #ifdef USE_DNS_CACHE
175         #define IF_DNS_CACHE(x) x
176 #else
177         #define IF_DNS_CACHE(x) warn("dns cache support not compiled in")
178 #endif
179
180 #ifdef USE_DNS_FAILOVER
181         #define IF_DNS_FAILOVER(x) x
182 #else
183         #define IF_DNS_FAILOVER(x) warn("dns failover support not compiled in")
184 #endif
185
186 #ifdef USE_NAPTR
187         #define IF_NAPTR(x) x
188 #else
189         #define IF_NAPTR(x) warn("dns naptr support not compiled in")
190 #endif
191
192 #ifdef USE_DST_BLACKLIST
193         #define IF_DST_BLACKLIST(x) x
194 #else
195         #define IF_DST_BLACKLIST(x) warn("dst blacklist support not compiled in")
196 #endif
197
198 #ifdef USE_STUN
199         #define IF_STUN(x) x
200 #else 
201         #define IF_STUN(x) warn("stun support not compiled in")
202 #endif
203
204 #ifdef USE_SCTP
205         #define IF_SCTP(x) x
206 #else
207         #define IF_SCTP(x) warn("sctp support not compiled in")
208 #endif
209
210 #ifdef USE_RAW_SOCKS
211         #define IF_RAW_SOCKS(x) x
212 #else
213         #define IF_RAW_SOCKS(x) warn("raw socket support not compiled in")
214 #endif
215
216
217 extern int yylex();
218 /* safer then using yytext which can be array or pointer */
219 extern char* yy_number_str;
220
221 static void yyerror(char* s, ...);
222 static void yyerror_at(struct cfg_pos* pos, char* s, ...);
223 static char* tmp;
224 static int i_tmp;
225 static unsigned u_tmp;
226 static struct socket_id* lst_tmp;
227 static struct name_lst*  nl_tmp;
228 static int rt;  /* Type of route block for find_export */
229 static str* str_tmp;
230 static str s_tmp;
231 static struct ip_addr* ip_tmp;
232 static struct avp_spec* s_attr;
233 static select_t sel;
234 static select_t* sel_ptr;
235 static pv_spec_t* pv_spec;
236 static struct action *mod_func_action;
237 static struct lvalue* lval_tmp;
238 static struct rvalue* rval_tmp;
239
240 static void warn(char* s, ...);
241 static void warn_at(struct cfg_pos* pos, char* s, ...);
242 static void get_cpos(struct cfg_pos* pos);
243 static struct rval_expr* mk_rve_rval(enum rval_type, void* v);
244 static struct rval_expr* mk_rve1(enum rval_expr_op op, struct rval_expr* rve1);
245 static struct rval_expr* mk_rve2(enum rval_expr_op op, struct rval_expr* rve1,
246                                                                         struct rval_expr* rve2);
247 static int rval_expr_int_check(struct rval_expr *rve);
248 static int warn_ct_rve(struct rval_expr *rve, char* name);
249 static struct socket_id* mk_listen_id(char*, int, int);
250 static struct name_lst* mk_name_lst(char* name, int flags);
251 static struct socket_id* mk_listen_id2(struct name_lst*, int, int);
252 static void free_name_lst(struct name_lst* lst);
253 static void free_socket_id_lst(struct socket_id* i);
254
255 static struct case_stms* mk_case_stm(struct rval_expr* ct, int is_re, 
256                                                                         struct action* a, int* err);
257 static int case_check_type(struct case_stms* stms);
258 static int case_check_default(struct case_stms* stms);
259 static int mod_f_params_pre_fixup(struct action* a);
260 static void free_mod_func_action(struct action* a);
261
262
263 extern int line;
264 extern int column;
265 extern int startcolumn;
266 extern int startline;
267 extern char *finame;
268
269 #define set_cfg_pos(x) \
270         do{\
271                 if(x) {\
272                 (x)->cline = line;\
273                 (x)->cfile = (finame!=0)?finame:((cfg_file!=0)?cfg_file:"default");\
274                 }\
275         }while(0)
276
277
278 %}
279
280 %union {
281         long intval;
282         unsigned long uval;
283         char* strval;
284         struct expr* expr;
285         struct action* action;
286         struct case_stms* case_stms;
287         struct net* ipnet;
288         struct ip_addr* ipaddr;
289         struct socket_id* sockid;
290         struct name_lst* name_l;
291         struct avp_spec* attr;
292         struct _pv_spec* pvar;
293         struct lvalue* lval;
294         struct rvalue* rval;
295         struct rval_expr* rv_expr;
296         select_t* select;
297 }
298
299 /* terminals */
300
301
302 /* keywords */
303 %token FORWARD
304 %token FORWARD_TCP
305 %token FORWARD_TLS
306 %token FORWARD_SCTP
307 %token FORWARD_UDP
308 %token EXIT
309 %token DROP
310 %token RETURN
311 %token BREAK
312 %token LOG_TOK
313 %token ERROR
314 %token ROUTE
315 %token ROUTE_REQUEST
316 %token ROUTE_FAILURE
317 %token ROUTE_ONREPLY
318 %token ROUTE_REPLY
319 %token ROUTE_BRANCH
320 %token ROUTE_SEND
321 %token ROUTE_EVENT
322 %token EXEC
323 %token SET_HOST
324 %token SET_HOSTPORT
325 %token SET_HOSTPORTTRANS
326 %token PREFIX
327 %token STRIP
328 %token STRIP_TAIL
329 %token SET_USERPHONE
330 %token APPEND_BRANCH
331 %token REMOVE_BRANCH
332 %token CLEAR_BRANCHES
333 %token SET_USER
334 %token SET_USERPASS
335 %token SET_PORT
336 %token SET_URI
337 %token REVERT_URI
338 %token FORCE_RPORT
339 %token ADD_LOCAL_RPORT
340 %token FORCE_TCP_ALIAS
341 %token UDP_MTU
342 %token UDP_MTU_TRY_PROTO
343 %token UDP4_RAW
344 %token UDP4_RAW_MTU
345 %token UDP4_RAW_TTL
346 %token IF
347 %token ELSE
348 %token SET_ADV_ADDRESS
349 %token SET_ADV_PORT
350 %token FORCE_SEND_SOCKET
351 %token SET_FWD_NO_CONNECT
352 %token SET_RPL_NO_CONNECT
353 %token SET_FWD_CLOSE
354 %token SET_RPL_CLOSE
355 %token SWITCH
356 %token CASE
357 %token DEFAULT
358 %token WHILE
359 %token CFG_SELECT
360 %token CFG_RESET
361 %token URIHOST
362 %token URIPORT
363 %token MAX_LEN
364 %token SETFLAG
365 %token RESETFLAG
366 %token ISFLAGSET
367 %token SETAVPFLAG
368 %token RESETAVPFLAG
369 %token ISAVPFLAGSET
370 %token METHOD
371 %token URI
372 %token FROM_URI
373 %token TO_URI
374 %token SRCIP
375 %token SRCPORT
376 %token DSTIP
377 %token DSTPORT
378 %token TOIP
379 %token TOPORT
380 %token SNDIP
381 %token SNDPORT
382 %token SNDPROTO
383 %token SNDAF
384 %token PROTO
385 %token AF
386 %token MYSELF
387 %token MSGLEN
388 %token UDP
389 %token TCP
390 %token TLS
391 %token SCTP
392 %token WS
393 %token WSS
394
395 /* config vars. */
396 %token DEBUG_V
397 %token FORK
398 %token FORK_DELAY
399 %token LOGSTDERROR
400 %token LOGFACILITY
401 %token LOGNAME
402 %token LOGCOLOR
403 %token LISTEN
404 %token ADVERTISE
405 %token ALIAS
406 %token SR_AUTO_ALIASES
407 %token DNS
408 %token REV_DNS
409 %token DNS_TRY_IPV6
410 %token DNS_TRY_NAPTR
411 %token DNS_SRV_LB
412 %token DNS_UDP_PREF
413 %token DNS_TCP_PREF
414 %token DNS_TLS_PREF
415 %token DNS_SCTP_PREF
416 %token DNS_RETR_TIME
417 %token DNS_RETR_NO
418 %token DNS_SERVERS_NO
419 %token DNS_USE_SEARCH
420 %token DNS_SEARCH_FMATCH
421 %token DNS_CACHE_INIT
422 %token DNS_USE_CACHE
423 %token DNS_USE_FAILOVER
424 %token DNS_CACHE_FLAGS
425 %token DNS_CACHE_NEG_TTL
426 %token DNS_CACHE_MIN_TTL
427 %token DNS_CACHE_MAX_TTL
428 %token DNS_CACHE_MEM
429 %token DNS_CACHE_GC_INT
430 %token DNS_CACHE_DEL_NONEXP
431
432 /* ipv6 auto bind */
433 %token AUTO_BIND_IPV6
434
435 /*blacklist*/
436 %token DST_BLST_INIT
437 %token USE_DST_BLST
438 %token DST_BLST_MEM
439 %token DST_BLST_TTL
440 %token DST_BLST_GC_INT
441 %token DST_BLST_UDP_IMASK
442 %token DST_BLST_TCP_IMASK
443 %token DST_BLST_TLS_IMASK
444 %token DST_BLST_SCTP_IMASK
445
446 %token PORT
447 %token STAT
448 %token CHILDREN
449 %token SOCKET_WORKERS
450 %token CHECK_VIA
451 %token PHONE2TEL
452 %token SYN_BRANCH
453 %token MEMLOG
454 %token MEMDBG
455 %token MEMSUM
456 %token MEMSAFETY
457 %token MEMJOIN
458 %token CORELOG
459 %token SIP_WARNING
460 %token SERVER_SIGNATURE
461 %token SERVER_HEADER
462 %token USER_AGENT_HEADER
463 %token REPLY_TO_VIA
464 %token LOADMODULE
465 %token LOADPATH
466 %token MODPARAM
467 %token MAXBUFFER
468 %token SQL_BUFFER_SIZE
469 %token USER
470 %token GROUP
471 %token CHROOT
472 %token WDIR
473 %token MHOMED
474 %token DISABLE_TCP
475 %token TCP_ACCEPT_ALIASES
476 %token TCP_CHILDREN
477 %token TCP_CONNECT_TIMEOUT
478 %token TCP_SEND_TIMEOUT
479 %token TCP_CON_LIFETIME
480 %token TCP_POLL_METHOD
481 %token TCP_MAX_CONNECTIONS
482 %token TLS_MAX_CONNECTIONS
483 %token TCP_NO_CONNECT
484 %token TCP_SOURCE_IPV4
485 %token TCP_SOURCE_IPV6
486 %token TCP_OPT_FD_CACHE
487 %token TCP_OPT_BUF_WRITE
488 %token TCP_OPT_CONN_WQ_MAX
489 %token TCP_OPT_WQ_MAX
490 %token TCP_OPT_RD_BUF
491 %token TCP_OPT_WQ_BLK
492 %token TCP_OPT_DEFER_ACCEPT
493 %token TCP_OPT_DELAYED_ACK
494 %token TCP_OPT_SYNCNT
495 %token TCP_OPT_LINGER2
496 %token TCP_OPT_KEEPALIVE
497 %token TCP_OPT_KEEPIDLE
498 %token TCP_OPT_KEEPINTVL
499 %token TCP_OPT_KEEPCNT
500 %token TCP_OPT_CRLF_PING
501 %token TCP_OPT_ACCEPT_NO_CL
502 %token TCP_CLONE_RCVBUF
503 %token DISABLE_TLS
504 %token ENABLE_TLS
505 %token TLSLOG
506 %token TLS_PORT_NO
507 %token TLS_METHOD
508 %token TLS_HANDSHAKE_TIMEOUT
509 %token TLS_SEND_TIMEOUT
510 %token SSLv23
511 %token SSLv2
512 %token SSLv3
513 %token TLSv1
514 %token TLS_VERIFY
515 %token TLS_REQUIRE_CERTIFICATE
516 %token TLS_CERTIFICATE
517 %token TLS_PRIVATE_KEY
518 %token TLS_CA_LIST
519 %token DISABLE_SCTP
520 %token ENABLE_SCTP
521 %token SCTP_CHILDREN
522 %token SCTP_SOCKET_RCVBUF
523 %token SCTP_SOCKET_SNDBUF
524 %token SCTP_AUTOCLOSE
525 %token SCTP_SEND_TTL
526 %token SCTP_SEND_RETRIES
527 %token SCTP_ASSOC_TRACKING
528 %token SCTP_ASSOC_REUSE
529 %token SCTP_MAX_ASSOCS
530 %token SCTP_SRTO_INITIAL
531 %token SCTP_SRTO_MAX
532 %token SCTP_SRTO_MIN
533 %token SCTP_ASOCMAXRXT
534 %token SCTP_INIT_MAX_ATTEMPTS
535 %token SCTP_INIT_MAX_TIMEO
536 %token SCTP_HBINTERVAL
537 %token SCTP_PATHMAXRXT
538 %token SCTP_SACK_DELAY
539 %token SCTP_SACK_FREQ
540 %token SCTP_MAX_BURST
541 %token ADVERTISED_ADDRESS
542 %token ADVERTISED_PORT
543 %token DISABLE_CORE
544 %token OPEN_FD_LIMIT
545 %token SHM_MEM_SZ
546 %token SHM_FORCE_ALLOC
547 %token MLOCK_PAGES
548 %token REAL_TIME
549 %token RT_PRIO
550 %token RT_POLICY
551 %token RT_TIMER1_PRIO
552 %token RT_TIMER1_POLICY
553 %token RT_TIMER2_PRIO
554 %token RT_TIMER2_POLICY
555 %token MCAST_LOOPBACK
556 %token MCAST_TTL
557 %token TOS
558 %token PMTU_DISCOVERY
559 %token KILL_TIMEOUT
560 %token MAX_WLOOPS
561 %token PVBUFSIZE
562 %token PVBUFSLOTS
563 %token HTTP_REPLY_HACK
564 %token CFG_DESCRIPTION
565 %token SERVER_ID
566 %token LATENCY_LOG
567 %token LATENCY_LIMIT_DB
568 %token LATENCY_LIMIT_ACTION
569 %token MSG_TIME
570
571 %token FLAGS_DECL
572 %token AVPFLAGS_DECL
573
574 %token ATTR_MARK
575 %token SELECT_MARK
576 %token ATTR_FROM
577 %token ATTR_TO
578 %token ATTR_FROMURI
579 %token ATTR_TOURI
580 %token ATTR_FROMUSER
581 %token ATTR_TOUSER
582 %token ATTR_FROMDOMAIN
583 %token ATTR_TODOMAIN
584 %token ATTR_GLOBAL
585 %token ADDEQ
586
587
588 %token STUN_REFRESH_INTERVAL
589 %token STUN_ALLOW_STUN
590 %token STUN_ALLOW_FP
591
592 /*pre-processor*/
593 %token SUBST
594 %token SUBSTDEF
595 %token SUBSTDEFS
596
597 /* operators, C like precedence */
598 %right EQUAL
599 %left LOG_OR
600 %left LOG_AND
601 %left BIN_OR
602 %left BIN_AND
603 %left BIN_XOR
604 %left BIN_LSHIFT
605 %left BIN_RSHIFT
606 %left EQUAL_T DIFF MATCH INTEQ INTDIFF STREQ STRDIFF
607 %left GT LT GTE LTE
608 %left PLUS MINUS
609 %left STAR SLASH MODULO
610 %right NOT UNARY BIN_NOT
611 %right DEFINED
612 %right INTCAST STRCAST
613 %left DOT
614
615 /* no precedence, they use () */
616 %token STRLEN
617 %token STREMPTY
618
619 /* values */
620 %token <intval> NUMBER
621 %token <strval> ID
622 %token <strval> NUM_ID
623 %token <strval> STRING
624 %token <strval> IPV6ADDR
625 %token <strval> PVAR
626 /* not clear yet if this is an avp or pvar */
627 %token <strval> AVP_OR_PVAR
628 %token <strval> EVENT_RT_NAME
629
630 /* other */
631 %token COMMA
632 %token SEMICOLON
633 %token RPAREN
634 %token LPAREN
635 %token LBRACE
636 %token RBRACE
637 %token LBRACK
638 %token RBRACK
639 %token CR
640 %token COLON
641
642
643 /*non-terminals */
644 /*%type <expr> exp */
645 %type <expr> exp_elem
646 %type <intval> intno eint_op eint_op_onsend
647 %type <intval> eip_op eip_op_onsend
648 %type <action> action actions cmd fcmd if_cmd stm /*exp_stm*/ assign_action
649 %type <action> switch_cmd while_cmd ret_cmd
650 %type <case_stms> single_case case_stms
651 %type <ipaddr> ipv4 ipv6 ipv6addr ip
652 %type <ipnet> ipnet
653 %type <strval> host host_or_if host_if_id
654 %type <strval> listen_id
655 %type <name_l> listen_id_lst
656 %type <name_l> listen_id2
657 %type <sockid>  id_lst
658 %type <sockid>  phostport
659 %type <sockid>  listen_phostport
660 %type <intval> proto eqproto port
661 %type <intval> equalop strop cmpop rve_cmpop rve_equalop
662 %type <intval> uri_type
663 %type <attr> attr_id
664 %type <attr> attr_id_num_idx
665 %type <attr> attr_id_no_idx
666 %type <attr> attr_id_ass
667 /*%type <attr> attr_id_val*/
668 %type <attr> attr_id_any
669 %type <attr> attr_id_any_str
670 %type <pvar> pvar
671 %type <lval> lval
672 %type <rv_expr> rval rval_expr ct_rval
673 %type <lval> avp_pvar
674 /* %type <intval> class_id */
675 %type <intval> assign_op
676 %type <select> select_id
677 %type <strval>  flag_name;
678 %type <strval>  route_name;
679 %type <intval> avpflag_oper
680 %type <intval> rve_un_op
681 %type <strval> cfg_var_id
682 /* %type <intval> rve_op */
683
684 /*%type <route_el> rules;
685   %type <route_el> rule;
686 */
687
688 %%
689
690
691 cfg:
692         statements
693         ;
694 statements:
695         statements statement {}
696         | statement {}
697         | statements error { yyerror(""); YYABORT;}
698         ;
699 statement:
700         assign_stm
701         | preprocess_stm
702         | flags_decl
703         | avpflags_decl
704         | module_stm
705         | {rt=REQUEST_ROUTE;} route_stm
706         | {rt=FAILURE_ROUTE;} failure_route_stm
707         | onreply_route_stm
708         | {rt=BRANCH_ROUTE;} branch_route_stm
709         | {rt=ONSEND_ROUTE;}   send_route_stm
710         | {rt=EVENT_ROUTE;}   event_route_stm
711         | SEMICOLON     /* null statement */
712         | CR    /* null statement*/
713         ;
714 listen_id:
715         ip {
716                 if ($1){
717                         tmp=ip_addr2a($1);
718                         if (tmp==0) {
719                                 LOG(L_CRIT, "ERROR: cfg. parser: bad ip "
720                                                 "address.\n");
721                                 $$=0;
722                         } else {
723                                 $$=pkg_malloc(strlen(tmp)+1);
724                                 if ($$==0) {
725                                         LOG(L_CRIT, "ERROR: cfg. parser: out of "
726                                                         "memory.\n");
727                                 } else {
728                                         strncpy($$, tmp, strlen(tmp)+1);
729                                 }
730                         }
731                 }
732         }
733         | STRING {
734                 $$=pkg_malloc(strlen($1)+1);
735                 if ($$==0) {
736                                 LOG(L_CRIT, "ERROR: cfg. parser: out of "
737                                                 "memory.\n");
738                 } else {
739                                 strncpy($$, $1, strlen($1)+1);
740                 }
741         }
742         | host_or_if {
743                 if ($1){
744                         $$=pkg_malloc(strlen($1)+1);
745                         if ($$==0) {
746                                         LOG(L_CRIT, "ERROR: cfg. parser: out of "
747                                                         "memory.\n");
748                         } else {
749                                         strncpy($$, $1, strlen($1)+1);
750                         }
751                 }
752         }
753         ;
754
755
756 listen_id_lst:
757         listen_id       { $$=mk_name_lst($1, SI_IS_MHOMED); }
758         | listen_id COMMA listen_id_lst { $$=mk_name_lst($1, SI_IS_MHOMED); 
759                                                                                 if ($$) $$->next=$3;
760                                                                         }
761         ;
762
763 listen_id2:
764         LPAREN listen_id_lst RPAREN { $$=$2; }
765         | listen_id     { $$=mk_name_lst($1, 0); }
766         ;
767
768 proto:
769         UDP     { $$=PROTO_UDP; }
770         | TCP   { $$=PROTO_TCP; }
771         | TLS   { $$=PROTO_TLS; }
772         | SCTP  { $$=PROTO_SCTP; }
773         | STAR  { $$=0; }
774         ;
775 eqproto:
776         UDP     { $$=PROTO_UDP; }
777         | TCP   { $$=PROTO_TCP; }
778         | TLS   { $$=PROTO_TLS; }
779         | SCTP  { $$=PROTO_SCTP; }
780         | WS    { $$=PROTO_WS; }
781         | WSS   { $$=PROTO_WSS; }
782         | STAR  { $$=0; }
783         ;
784 port:
785         NUMBER  { $$=$1; }
786         | STAR  { $$=0; }
787 ;
788 phostport:
789         listen_id               { $$=mk_listen_id($1, 0, 0); }
790         | listen_id COLON port  { $$=mk_listen_id($1, 0, $3); }
791         | proto COLON listen_id { $$=mk_listen_id($3, $1, 0); }
792         | proto COLON listen_id COLON port      { $$=mk_listen_id($3, $1, $5);}
793         | listen_id COLON error { $$=0; yyerror(" port number expected"); }
794         ;
795
796 listen_phostport:
797         listen_id2              { $$=mk_listen_id2($1, 0, 0); }
798         | listen_id2 COLON port { $$=mk_listen_id2($1, 0, $3); }
799         | proto COLON listen_id2        { $$=mk_listen_id2($3, $1, 0); }
800         | proto COLON listen_id2 COLON port     { $$=mk_listen_id2($3, $1, $5);}
801         | listen_id2 COLON error { $$=0; yyerror(" port number expected"); }
802         ;
803
804 id_lst:
805         listen_phostport                {  $$=$1 ; }
806         | listen_phostport id_lst       { $$=$1;  if ($$) $$->next=$2; }
807         ;
808
809 intno: NUMBER
810         |  MINUS NUMBER %prec UNARY { $$=-$2; }
811         ;
812
813 flags_decl:             FLAGS_DECL      flag_list
814                         |       FLAGS_DECL error { yyerror("flag list expected\n"); }
815 ;
816 flag_list:              flag_spec
817                         |       flag_spec COMMA flag_list
818 ;
819
820 flag_spec:              flag_name       { if (register_flag($1,-1)<0)
821                                                                 yyerror("register flag failed");
822                                                 }
823                         |       flag_name COLON NUMBER {
824                                                 if (register_flag($1, $3)<0)
825                                                                 yyerror("register flag failed");
826                                                                                 }
827 ;
828
829 flag_name:              STRING  { $$=$1; }
830                         |       ID              { $$=$1; }
831 ;
832
833 avpflags_decl:
834         AVPFLAGS_DECL avpflag_list
835         | AVPFLAGS_DECL error { yyerror("avpflag list expected\n"); }
836         ;
837 avpflag_list:
838         avpflag_spec
839         | avpflag_spec COMMA avpflag_list
840         ;
841 avpflag_spec:
842         flag_name {
843                 if (register_avpflag($1)==0)
844                         yyerror("cannot declare avpflag");
845         }
846         ;
847 assign_stm:
848         DEBUG_V EQUAL intno { default_core_cfg.debug=$3; }
849         | DEBUG_V EQUAL error  { yyerror("number  expected"); }
850         | FORK  EQUAL NUMBER { dont_fork= ! $3; }
851         | FORK  EQUAL error  { yyerror("boolean value expected"); }
852         | FORK_DELAY  EQUAL NUMBER { set_fork_delay($3); }
853         | FORK_DELAY  EQUAL error  { yyerror("number expected"); }
854         | LOGSTDERROR EQUAL NUMBER { if (!config_check)  /* if set from cmd line, don't overwrite from yyparse()*/ 
855                                         if(log_stderr == 0) log_stderr=$3; 
856                                    }
857         | LOGSTDERROR EQUAL error { yyerror("boolean value expected"); }
858         | LOGFACILITY EQUAL ID {
859                 if ( (i_tmp=str2facility($3))==-1)
860                         yyerror("bad facility (see syslog(3) man page)");
861                 if (!config_check)
862                         default_core_cfg.log_facility=i_tmp;
863         }
864         | LOGFACILITY EQUAL error { yyerror("ID expected"); }
865         | LOGNAME EQUAL STRING { log_name=$3; }
866         | LOGNAME EQUAL error { yyerror("string value expected"); }
867         | LOGCOLOR EQUAL NUMBER { log_color=$3; }
868         | LOGCOLOR EQUAL error { yyerror("boolean value expected"); }
869         | DNS EQUAL NUMBER   { received_dns|= ($3)?DO_DNS:0; }
870         | DNS EQUAL error { yyerror("boolean value expected"); }
871         | REV_DNS EQUAL NUMBER { received_dns|= ($3)?DO_REV_DNS:0; }
872         | REV_DNS EQUAL error { yyerror("boolean value expected"); }
873         | DNS_TRY_IPV6 EQUAL NUMBER   { default_core_cfg.dns_try_ipv6=$3; }
874         | DNS_TRY_IPV6 error { yyerror("boolean value expected"); }
875         | DNS_TRY_NAPTR EQUAL NUMBER   { IF_NAPTR(default_core_cfg.dns_try_naptr=$3); }
876         | DNS_TRY_NAPTR error { yyerror("boolean value expected"); }
877         | DNS_SRV_LB EQUAL NUMBER   { IF_DNS_FAILOVER(default_core_cfg.dns_srv_lb=$3); }
878         | DNS_SRV_LB error { yyerror("boolean value expected"); }
879         | DNS_UDP_PREF EQUAL intno { IF_NAPTR(default_core_cfg.dns_udp_pref=$3);}
880         | DNS_UDP_PREF error { yyerror("number expected"); }
881         | DNS_TCP_PREF EQUAL intno { IF_NAPTR(default_core_cfg.dns_tcp_pref=$3);}
882         | DNS_TCP_PREF error { yyerror("number expected"); }
883         | DNS_TLS_PREF EQUAL intno { IF_NAPTR(default_core_cfg.dns_tls_pref=$3);}
884         | DNS_TLS_PREF error { yyerror("number expected"); }
885         | DNS_SCTP_PREF EQUAL intno { 
886                                                                 IF_NAPTR(default_core_cfg.dns_sctp_pref=$3); }
887         | DNS_SCTP_PREF error { yyerror("number expected"); }
888         | DNS_RETR_TIME EQUAL NUMBER   { default_core_cfg.dns_retr_time=$3; }
889         | DNS_RETR_TIME error { yyerror("number expected"); }
890         | DNS_RETR_NO EQUAL NUMBER   { default_core_cfg.dns_retr_no=$3; }
891         | DNS_RETR_NO error { yyerror("number expected"); }
892         | DNS_SERVERS_NO EQUAL NUMBER   { default_core_cfg.dns_servers_no=$3; }
893         | DNS_SERVERS_NO error { yyerror("number expected"); }
894         | DNS_USE_SEARCH EQUAL NUMBER   { default_core_cfg.dns_search_list=$3; }
895         | DNS_USE_SEARCH error { yyerror("boolean value expected"); }
896         | DNS_SEARCH_FMATCH EQUAL NUMBER   { default_core_cfg.dns_search_fmatch=$3; }
897         | DNS_SEARCH_FMATCH error { yyerror("boolean value expected"); }
898         | DNS_CACHE_INIT EQUAL NUMBER   { IF_DNS_CACHE(dns_cache_init=$3); }
899         | DNS_CACHE_INIT error { yyerror("boolean value expected"); }
900         | DNS_USE_CACHE EQUAL NUMBER   { IF_DNS_CACHE(default_core_cfg.use_dns_cache=$3); }
901         | DNS_USE_CACHE error { yyerror("boolean value expected"); }
902         | DNS_USE_FAILOVER EQUAL NUMBER   { IF_DNS_FAILOVER(default_core_cfg.use_dns_failover=$3);}
903         | DNS_USE_FAILOVER error { yyerror("boolean value expected"); }
904         | DNS_CACHE_FLAGS EQUAL NUMBER   { IF_DNS_CACHE(default_core_cfg.dns_cache_flags=$3); }
905         | DNS_CACHE_FLAGS error { yyerror("boolean value expected"); }
906         | DNS_CACHE_NEG_TTL EQUAL NUMBER   { IF_DNS_CACHE(default_core_cfg.dns_neg_cache_ttl=$3); }
907         | DNS_CACHE_NEG_TTL error { yyerror("boolean value expected"); }
908         | DNS_CACHE_MAX_TTL EQUAL NUMBER   { IF_DNS_CACHE(default_core_cfg.dns_cache_max_ttl=$3); }
909         | DNS_CACHE_MAX_TTL error { yyerror("boolean value expected"); }
910         | DNS_CACHE_MIN_TTL EQUAL NUMBER   { IF_DNS_CACHE(default_core_cfg.dns_cache_min_ttl=$3); }
911         | DNS_CACHE_MIN_TTL error { yyerror("boolean value expected"); }
912         | DNS_CACHE_MEM EQUAL NUMBER   { IF_DNS_CACHE(default_core_cfg.dns_cache_max_mem=$3); }
913         | DNS_CACHE_MEM error { yyerror("boolean value expected"); }
914         | DNS_CACHE_GC_INT EQUAL NUMBER   { IF_DNS_CACHE(dns_timer_interval=$3); }
915         | DNS_CACHE_GC_INT error { yyerror("boolean value expected"); }
916         | DNS_CACHE_DEL_NONEXP EQUAL NUMBER   { IF_DNS_CACHE(default_core_cfg.dns_cache_del_nonexp=$3); }
917         | DNS_CACHE_DEL_NONEXP error { yyerror("boolean value expected"); }
918         | AUTO_BIND_IPV6 EQUAL NUMBER {IF_AUTO_BIND_IPV6(auto_bind_ipv6 = $3);}
919         | AUTO_BIND_IPV6 error { yyerror("boolean value expected"); }
920         | DST_BLST_INIT EQUAL NUMBER   { IF_DST_BLACKLIST(dst_blacklist_init=$3); }
921         | DST_BLST_INIT error { yyerror("boolean value expected"); }
922         | USE_DST_BLST EQUAL NUMBER {
923                 IF_DST_BLACKLIST(default_core_cfg.use_dst_blacklist=$3);
924         }
925         | USE_DST_BLST error { yyerror("boolean value expected"); }
926         | DST_BLST_MEM EQUAL NUMBER {
927                 IF_DST_BLACKLIST(default_core_cfg.blst_max_mem=$3); 
928         }
929         | DST_BLST_MEM error { yyerror("boolean value expected"); }
930         | DST_BLST_TTL EQUAL NUMBER {
931                 IF_DST_BLACKLIST(default_core_cfg.blst_timeout=$3);
932         }
933         | DST_BLST_TTL error { yyerror("boolean value expected"); }
934         | DST_BLST_GC_INT EQUAL NUMBER { IF_DST_BLACKLIST(blst_timer_interval=$3);}
935         | DST_BLST_GC_INT error { yyerror("boolean value expected"); }
936         | DST_BLST_UDP_IMASK EQUAL NUMBER {
937                 IF_DST_BLACKLIST(default_core_cfg.blst_udp_imask=$3);
938         }
939         | DST_BLST_UDP_IMASK error { yyerror("number(flags) expected"); }
940         | DST_BLST_TCP_IMASK EQUAL NUMBER {
941                 IF_DST_BLACKLIST(default_core_cfg.blst_tcp_imask=$3);
942         }
943         | DST_BLST_TCP_IMASK error { yyerror("number(flags) expected"); }
944         | DST_BLST_TLS_IMASK EQUAL NUMBER {
945                 IF_DST_BLACKLIST(default_core_cfg.blst_tls_imask=$3);
946         }
947         | DST_BLST_TLS_IMASK error { yyerror("number(flags) expected"); }
948         | DST_BLST_SCTP_IMASK EQUAL NUMBER {
949                 IF_DST_BLACKLIST(default_core_cfg.blst_sctp_imask=$3);
950         }
951         | DST_BLST_SCTP_IMASK error { yyerror("number(flags) expected"); }
952         | PORT EQUAL NUMBER   { port_no=$3; }
953         | STAT EQUAL STRING {
954                 #ifdef STATS
955                                 stat_file=$3;
956                 #endif
957         }
958         | MAXBUFFER EQUAL NUMBER { maxbuffer=$3; }
959         | MAXBUFFER EQUAL error { yyerror("number expected"); }
960     | SQL_BUFFER_SIZE EQUAL NUMBER { sql_buffer_size=$3; }
961         | SQL_BUFFER_SIZE EQUAL error { yyerror("number expected"); }
962         | PORT EQUAL error    { yyerror("number expected"); }
963         | CHILDREN EQUAL NUMBER { children_no=$3; }
964         | CHILDREN EQUAL error { yyerror("number expected"); }
965         | SOCKET_WORKERS EQUAL NUMBER { socket_workers=$3; }
966         | SOCKET_WORKERS EQUAL error { yyerror("number expected"); }
967         | CHECK_VIA EQUAL NUMBER { check_via=$3; }
968         | CHECK_VIA EQUAL error { yyerror("boolean value expected"); }
969         | PHONE2TEL EQUAL NUMBER { phone2tel=$3; }
970         | PHONE2TEL EQUAL error { yyerror("boolean value expected"); }
971         | SYN_BRANCH EQUAL NUMBER { syn_branch=$3; }
972         | SYN_BRANCH EQUAL error { yyerror("boolean value expected"); }
973         | MEMLOG EQUAL intno { default_core_cfg.memlog=$3; }
974         | MEMLOG EQUAL error { yyerror("int value expected"); }
975         | MEMDBG EQUAL intno { default_core_cfg.memdbg=$3; }
976         | MEMDBG EQUAL error { yyerror("int value expected"); }
977         | MEMSUM EQUAL intno { default_core_cfg.mem_summary=$3; }
978         | MEMSUM EQUAL error { yyerror("int value expected"); }
979         | MEMSAFETY EQUAL intno { default_core_cfg.mem_safety=$3; }
980         | MEMSAFETY EQUAL error { yyerror("int value expected"); }
981         | MEMJOIN EQUAL intno { default_core_cfg.mem_join=$3; }
982         | MEMJOIN EQUAL error { yyerror("int value expected"); }
983         | CORELOG EQUAL intno { default_core_cfg.corelog=$3; }
984         | CORELOG EQUAL error { yyerror("int value expected"); }
985         | SIP_WARNING EQUAL NUMBER { sip_warning=$3; }
986         | SIP_WARNING EQUAL error { yyerror("boolean value expected"); }
987         | USER EQUAL STRING     {
988                 if (shm_initialized())
989                         yyerror("user must be before any modparam or the"
990                                         " route blocks");
991                 else if (user==0)
992                         user=$3; 
993         }
994         | USER EQUAL ID         {
995                 if (shm_initialized())
996                         yyerror("user must be before any modparam or the"
997                                         " route blocks");
998                 else if (user==0)
999                         user=$3;
1000         }
1001         | USER EQUAL error      { yyerror("string value expected"); }
1002         | GROUP EQUAL STRING     { group=$3; }
1003         | GROUP EQUAL ID         { group=$3; }
1004         | GROUP EQUAL error      { yyerror("string value expected"); }
1005         | CHROOT EQUAL STRING     { chroot_dir=$3; }
1006         | CHROOT EQUAL ID         { chroot_dir=$3; }
1007         | CHROOT EQUAL error      { yyerror("string value expected"); }
1008         | WDIR EQUAL STRING     { working_dir=$3; }
1009         | WDIR EQUAL ID         { working_dir=$3; }
1010         | WDIR EQUAL error      { yyerror("string value expected"); }
1011         | MHOMED EQUAL NUMBER { mhomed=$3; }
1012         | MHOMED EQUAL error { yyerror("boolean value expected"); }
1013         | DISABLE_TCP EQUAL NUMBER {
1014                 #ifdef USE_TCP
1015                         tcp_disable=$3;
1016                 #else
1017                         warn("tcp support not compiled in");
1018                 #endif
1019         }
1020         | DISABLE_TCP EQUAL error { yyerror("boolean value expected"); }
1021         | TCP_ACCEPT_ALIASES EQUAL NUMBER {
1022                 #ifdef USE_TCP
1023                         tcp_default_cfg.accept_aliases=$3;
1024                 #else
1025                         warn("tcp support not compiled in");
1026                 #endif
1027         }
1028         | TCP_ACCEPT_ALIASES EQUAL error { yyerror("boolean value expected"); }
1029         | TCP_CHILDREN EQUAL NUMBER {
1030                 #ifdef USE_TCP
1031                         tcp_cfg_children_no=$3;
1032                 #else
1033                         warn("tcp support not compiled in");
1034                 #endif
1035         }
1036         | TCP_CHILDREN EQUAL error { yyerror("number expected"); }
1037         | TCP_CONNECT_TIMEOUT EQUAL intno {
1038                 #ifdef USE_TCP
1039                         tcp_default_cfg.connect_timeout_s=$3;
1040                 #else
1041                         warn("tcp support not compiled in");
1042                 #endif
1043         }
1044         | TCP_CONNECT_TIMEOUT EQUAL error { yyerror("number expected"); }
1045         | TCP_SEND_TIMEOUT EQUAL intno {
1046                 #ifdef USE_TCP
1047                         tcp_default_cfg.send_timeout=S_TO_TICKS($3);
1048                 #else
1049                         warn("tcp support not compiled in");
1050                 #endif
1051         }
1052         | TCP_SEND_TIMEOUT EQUAL error { yyerror("number expected"); }
1053         | TCP_CON_LIFETIME EQUAL intno {
1054                 #ifdef USE_TCP
1055                         if ($3<0)
1056                                 tcp_default_cfg.con_lifetime=-1;
1057                         else
1058                                 tcp_default_cfg.con_lifetime=S_TO_TICKS($3);
1059                 #else
1060                         warn("tcp support not compiled in");
1061                 #endif
1062         }
1063         | TCP_CON_LIFETIME EQUAL error { yyerror("number expected"); }
1064         | TCP_POLL_METHOD EQUAL ID {
1065                 #ifdef USE_TCP
1066                         tcp_poll_method=get_poll_type($3);
1067                         if (tcp_poll_method==POLL_NONE) {
1068                                 LOG(L_CRIT, "bad poll method name:"
1069                                                 " %s\n, try one of %s.\n",
1070                                                 $3, poll_support);
1071                                 yyerror("bad tcp_poll_method "
1072                                                 "value");
1073                         }
1074                 #else
1075                         warn("tcp support not compiled in");
1076                 #endif
1077         }
1078         | TCP_POLL_METHOD EQUAL STRING {
1079                 #ifdef USE_TCP
1080                         tcp_poll_method=get_poll_type($3);
1081                         if (tcp_poll_method==POLL_NONE) {
1082                                 LOG(L_CRIT, "bad poll method name:"
1083                                                 " %s\n, try one of %s.\n",
1084                                                 $3, poll_support);
1085                                 yyerror("bad tcp_poll_method "
1086                                                 "value");
1087                         }
1088                 #else
1089                         warn("tcp support not compiled in");
1090                 #endif
1091         }
1092         | TCP_POLL_METHOD EQUAL error { yyerror("poll method name expected"); }
1093         | TCP_MAX_CONNECTIONS EQUAL NUMBER {
1094                 #ifdef USE_TCP
1095                         tcp_max_connections=$3;
1096                 #else
1097                         warn("tcp support not compiled in");
1098                 #endif
1099         }
1100         | TCP_MAX_CONNECTIONS EQUAL error { yyerror("number expected"); }
1101         | TLS_MAX_CONNECTIONS EQUAL NUMBER {
1102                 #ifdef USE_TLS
1103                         tls_max_connections=$3;
1104                 #else
1105                         warn("tls support not compiled in");
1106                 #endif
1107         }
1108         | TLS_MAX_CONNECTIONS EQUAL error { yyerror("number expected"); }
1109         | TCP_NO_CONNECT EQUAL NUMBER {
1110                 #ifdef USE_TCP
1111                         tcp_default_cfg.no_connect=$3;
1112                 #else
1113                         warn("tcp support not compiled in");
1114                 #endif
1115         }
1116         | TCP_NO_CONNECT EQUAL error { yyerror("boolean value expected"); }
1117         | TCP_SOURCE_IPV4 EQUAL ipv4 {
1118                 #ifdef USE_TCP
1119                         if (tcp_set_src_addr($3)<0)
1120                                 warn("tcp_source_ipv4 failed");
1121                 #else
1122                         warn("tcp support not compiled in");
1123                 #endif
1124                 pkg_free($3);
1125         }
1126         | TCP_SOURCE_IPV4 EQUAL error { yyerror("IPv4 address expected"); }
1127         | TCP_SOURCE_IPV6 EQUAL ipv6 {
1128                 #ifdef USE_TCP
1129                         #ifdef USE_IPV6
1130                                 if (tcp_set_src_addr($3)<0)
1131                                         warn("tcp_source_ipv6 failed");
1132                         #else
1133                                 warn("IPv6 support not compiled in");
1134                         #endif
1135                 #else
1136                         warn("tcp support not compiled in");
1137                 #endif
1138                 pkg_free($3);
1139         }
1140         | TCP_SOURCE_IPV6 EQUAL error { yyerror("IPv6 address expected"); }
1141         | TCP_OPT_FD_CACHE EQUAL NUMBER {
1142                 #ifdef USE_TCP
1143                         tcp_default_cfg.fd_cache=$3;
1144                 #else
1145                         warn("tcp support not compiled in");
1146                 #endif
1147         }
1148         | TCP_OPT_FD_CACHE EQUAL error { yyerror("boolean value expected"); }
1149         | TCP_OPT_BUF_WRITE EQUAL NUMBER {
1150                 #ifdef USE_TCP
1151                         tcp_default_cfg.async=$3;
1152                 #else
1153                         warn("tcp support not compiled in");
1154                 #endif
1155         }
1156         | TCP_OPT_BUF_WRITE EQUAL error { yyerror("boolean value expected"); }
1157         | TCP_OPT_CONN_WQ_MAX EQUAL NUMBER {
1158                 #ifdef USE_TCP
1159                         tcp_default_cfg.tcpconn_wq_max=$3;
1160                 #else
1161                         warn("tcp support not compiled in");
1162                 #endif
1163         }
1164         | TCP_OPT_CONN_WQ_MAX error { yyerror("boolean value expected"); }
1165         | TCP_OPT_WQ_MAX EQUAL NUMBER {
1166                 #ifdef USE_TCP
1167                         tcp_default_cfg.tcp_wq_max=$3;
1168                 #else
1169                         warn("tcp support not compiled in");
1170                 #endif
1171         }
1172         | TCP_OPT_WQ_MAX error { yyerror("number expected"); }
1173         | TCP_OPT_RD_BUF EQUAL NUMBER {
1174                 #ifdef USE_TCP
1175                         tcp_default_cfg.rd_buf_size=$3;
1176                 #else
1177                         warn("tcp support not compiled in");
1178                 #endif
1179         }
1180         | TCP_OPT_RD_BUF error { yyerror("number expected"); }
1181         | TCP_OPT_WQ_BLK EQUAL NUMBER {
1182                 #ifdef USE_TCP
1183                         tcp_default_cfg.wq_blk_size=$3;
1184                 #else
1185                         warn("tcp support not compiled in");
1186                 #endif
1187         }
1188         | TCP_OPT_WQ_BLK error { yyerror("number expected"); }
1189         | TCP_OPT_DEFER_ACCEPT EQUAL NUMBER {
1190                 #ifdef USE_TCP
1191                         tcp_default_cfg.defer_accept=$3;
1192                 #else
1193                         warn("tcp support not compiled in");
1194                 #endif
1195         }
1196         | TCP_OPT_DEFER_ACCEPT EQUAL error { yyerror("boolean value expected"); }
1197         | TCP_OPT_DELAYED_ACK EQUAL NUMBER {
1198                 #ifdef USE_TCP
1199                         tcp_default_cfg.delayed_ack=$3;
1200                 #else
1201                         warn("tcp support not compiled in");
1202                 #endif
1203         }
1204         | TCP_OPT_DELAYED_ACK EQUAL error { yyerror("boolean value expected"); }
1205         | TCP_OPT_SYNCNT EQUAL NUMBER {
1206                 #ifdef USE_TCP
1207                         tcp_default_cfg.syncnt=$3;
1208                 #else
1209                         warn("tcp support not compiled in");
1210                 #endif
1211         }
1212         | TCP_OPT_SYNCNT EQUAL error { yyerror("number expected"); }
1213         | TCP_OPT_LINGER2 EQUAL NUMBER {
1214                 #ifdef USE_TCP
1215                         tcp_default_cfg.linger2=$3;
1216                 #else
1217                         warn("tcp support not compiled in");
1218                 #endif
1219         }
1220         | TCP_OPT_LINGER2 EQUAL error { yyerror("number expected"); }
1221         | TCP_OPT_KEEPALIVE EQUAL NUMBER {
1222                 #ifdef USE_TCP
1223                         tcp_default_cfg.keepalive=$3;
1224                 #else
1225                         warn("tcp support not compiled in");
1226                 #endif
1227         }
1228         | TCP_OPT_KEEPALIVE EQUAL error { yyerror("boolean value expected");}
1229         | TCP_OPT_KEEPIDLE EQUAL NUMBER {
1230                 #ifdef USE_TCP
1231                         tcp_default_cfg.keepidle=$3;
1232                 #else
1233                         warn("tcp support not compiled in");
1234                 #endif
1235         }
1236         | TCP_OPT_KEEPIDLE EQUAL error { yyerror("number expected"); }
1237         | TCP_OPT_KEEPINTVL EQUAL NUMBER {
1238                 #ifdef USE_TCP
1239                         tcp_default_cfg.keepintvl=$3;
1240                 #else
1241                         warn("tcp support not compiled in");
1242                 #endif
1243         }
1244         | TCP_OPT_KEEPINTVL EQUAL error { yyerror("number expected"); }
1245         | TCP_OPT_KEEPCNT EQUAL NUMBER {
1246                 #ifdef USE_TCP
1247                         tcp_default_cfg.keepcnt=$3;
1248                 #else
1249                         warn("tcp support not compiled in");
1250                 #endif
1251         }
1252         | TCP_OPT_KEEPCNT EQUAL error { yyerror("number expected"); }
1253         | TCP_OPT_CRLF_PING EQUAL NUMBER {
1254                 #ifdef USE_TCP
1255                         tcp_default_cfg.crlf_ping=$3;
1256                 #else
1257                         warn("tcp support not compiled in");
1258                 #endif
1259         }
1260         | TCP_OPT_CRLF_PING EQUAL error { yyerror("boolean value expected"); }
1261         | TCP_OPT_ACCEPT_NO_CL EQUAL NUMBER {
1262                 #ifdef USE_TCP
1263                         tcp_default_cfg.accept_no_cl=$3;
1264                 #else
1265                         warn("tcp support not compiled in");
1266                 #endif
1267         }
1268         | TCP_OPT_ACCEPT_NO_CL EQUAL error { yyerror("boolean value expected"); }
1269         | TCP_CLONE_RCVBUF EQUAL NUMBER {
1270                 #ifdef USE_TCP
1271                         tcp_set_clone_rcvbuf($3);
1272                 #else
1273                         warn("tcp support not compiled in");
1274                 #endif
1275         }
1276         | TCP_CLONE_RCVBUF EQUAL error { yyerror("number expected"); }
1277         | DISABLE_TLS EQUAL NUMBER {
1278                 #ifdef USE_TLS
1279                         tls_disable=$3;
1280                 #else
1281                         warn("tls support not compiled in");
1282                 #endif
1283         }
1284         | DISABLE_TLS EQUAL error { yyerror("boolean value expected"); }
1285         | ENABLE_TLS EQUAL NUMBER {
1286                 #ifdef USE_TLS
1287                         tls_disable=!($3);
1288                 #else
1289                         warn("tls support not compiled in");
1290                 #endif
1291         }
1292         | ENABLE_TLS EQUAL error { yyerror("boolean value expected"); }
1293         | TLSLOG EQUAL NUMBER {
1294                 #ifdef CORE_TLS
1295                         tls_log=$3;
1296                 #else
1297                         warn("tls-in-core support not compiled in");
1298                 #endif
1299         }
1300         | TLSLOG EQUAL error { yyerror("int value expected"); }
1301         | TLS_PORT_NO EQUAL NUMBER {
1302                 #ifdef USE_TLS
1303                         tls_port_no=$3;
1304                 #else
1305                         warn("tls support not compiled in");
1306                 #endif
1307         }
1308         | TLS_PORT_NO EQUAL error { yyerror("number expected"); }
1309         | TLS_METHOD EQUAL SSLv23 {
1310                 #ifdef CORE_TLS
1311                         tls_method=TLS_USE_SSLv23;
1312                 #else
1313                         warn("tls-in-core support not compiled in");
1314                 #endif
1315         }
1316         | TLS_METHOD EQUAL SSLv2 {
1317                 #ifdef CORE_TLS
1318                         tls_method=TLS_USE_SSLv2;
1319                 #else
1320                         warn("tls-in-core support not compiled in");
1321                 #endif
1322         }
1323         | TLS_METHOD EQUAL SSLv3 {
1324                 #ifdef CORE_TLS
1325                         tls_method=TLS_USE_SSLv3;
1326                 #else
1327                         warn("tls-in-core support not compiled in");
1328                 #endif
1329         }
1330         | TLS_METHOD EQUAL TLSv1 {
1331                 #ifdef CORE_TLS
1332                         tls_method=TLS_USE_TLSv1;
1333                 #else
1334                         warn("tls-in-core support not compiled in");
1335                 #endif
1336         }
1337         | TLS_METHOD EQUAL error {
1338                 #ifdef CORE_TLS
1339                         yyerror("SSLv23, SSLv2, SSLv3 or TLSv1 expected");
1340                 #else
1341                         warn("tls-in-core support not compiled in");
1342                 #endif
1343         }
1344         | TLS_VERIFY EQUAL NUMBER {
1345                 #ifdef CORE_TLS
1346                         tls_verify_cert=$3;
1347                 #else
1348                         warn("tls-in-core support not compiled in");
1349                 #endif
1350         }
1351         | TLS_VERIFY EQUAL error { yyerror("boolean value expected"); }
1352         | TLS_REQUIRE_CERTIFICATE EQUAL NUMBER {
1353                 #ifdef CORE_TLS
1354                         tls_require_cert=$3;
1355                 #else
1356                         warn( "tls-in-core support not compiled in");
1357                 #endif
1358         }
1359         | TLS_REQUIRE_CERTIFICATE EQUAL error { yyerror("boolean value expected"); }
1360         | TLS_CERTIFICATE EQUAL STRING {
1361                 #ifdef CORE_TLS
1362                         tls_cert_file=$3;
1363                 #else
1364                         warn("tls-in-core support not compiled in");
1365                 #endif
1366         }
1367         | TLS_CERTIFICATE EQUAL error { yyerror("string value expected"); }
1368         | TLS_PRIVATE_KEY EQUAL STRING {
1369                 #ifdef CORE_TLS
1370                         tls_pkey_file=$3;
1371                 #else
1372                         warn("tls-in-core support not compiled in");
1373                 #endif
1374         }
1375         | TLS_PRIVATE_KEY EQUAL error { yyerror("string value expected"); }
1376         | TLS_CA_LIST EQUAL STRING {
1377                 #ifdef CORE_TLS
1378                         tls_ca_file=$3;
1379                 #else
1380                         warn("tls-in-core support not compiled in");
1381                 #endif
1382         }
1383         | TLS_CA_LIST EQUAL error { yyerror("string value expected"); }
1384         | TLS_HANDSHAKE_TIMEOUT EQUAL NUMBER {
1385                 #ifdef CORE_TLS
1386                         tls_handshake_timeout=$3;
1387                 #else
1388                         warn("tls-in-core support not compiled in");
1389                 #endif
1390         }
1391         | TLS_HANDSHAKE_TIMEOUT EQUAL error { yyerror("number expected"); }
1392         | TLS_SEND_TIMEOUT EQUAL NUMBER {
1393                 #ifdef CORE_TLS
1394                         tls_send_timeout=$3;
1395                 #else
1396                         warn("tls-in-core support not compiled in");
1397                 #endif
1398         }
1399         | TLS_SEND_TIMEOUT EQUAL error { yyerror("number expected"); }
1400         | DISABLE_SCTP EQUAL NUMBER {
1401                 #ifdef USE_SCTP
1402                         sctp_disable=$3;
1403                 #else
1404                         warn("sctp support not compiled in");
1405                 #endif
1406         }
1407         | DISABLE_SCTP EQUAL error { yyerror("boolean value expected"); }
1408         | ENABLE_SCTP EQUAL NUMBER {
1409                 #ifdef USE_SCTP
1410                         sctp_disable=($3<=1)?!$3:$3;
1411                 #else
1412                         warn("sctp support not compiled in");
1413                 #endif
1414         }
1415         | ENABLE_SCTP EQUAL error { yyerror("boolean or number expected"); }
1416         | SCTP_CHILDREN EQUAL NUMBER {
1417                 #ifdef USE_SCTP
1418                         sctp_children_no=$3;
1419                 #else
1420                         warn("sctp support not compiled in");
1421                 #endif
1422         }
1423         | SCTP_CHILDREN EQUAL error { yyerror("number expected"); }
1424         | SCTP_SOCKET_RCVBUF EQUAL NUMBER {
1425                 #ifdef USE_SCTP
1426                         sctp_default_cfg.so_rcvbuf=$3;
1427                 #else
1428                         warn("sctp support not compiled in");
1429                 #endif
1430         }
1431         | SCTP_SOCKET_RCVBUF EQUAL error { yyerror("number expected"); }
1432         | SCTP_SOCKET_SNDBUF EQUAL NUMBER {
1433                 #ifdef USE_SCTP
1434                         sctp_default_cfg.so_sndbuf=$3;
1435                 #else
1436                         warn("sctp support not compiled in");
1437                 #endif
1438         }
1439         | SCTP_SOCKET_SNDBUF EQUAL error { yyerror("number expected"); }
1440         | SCTP_AUTOCLOSE EQUAL NUMBER {
1441                 #ifdef USE_SCTP
1442                         sctp_default_cfg.autoclose=$3;
1443                 #else
1444                         warn("sctp support not compiled in");
1445                 #endif
1446         }
1447         | SCTP_AUTOCLOSE EQUAL error { yyerror("number expected"); }
1448         | SCTP_SEND_TTL EQUAL NUMBER {
1449                 #ifdef USE_SCTP
1450                         sctp_default_cfg.send_ttl=$3;
1451                 #else
1452                         warn("sctp support not compiled in");
1453                 #endif
1454         }
1455         | SCTP_SEND_TTL EQUAL error { yyerror("number expected"); }
1456         | SCTP_SEND_RETRIES EQUAL NUMBER {
1457                 #ifdef USE_SCTP
1458                         sctp_default_cfg.send_retries=$3;
1459                 #else
1460                         warn("sctp support not compiled in");
1461                 #endif
1462         }
1463         | SCTP_SEND_RETRIES EQUAL error { yyerror("number expected"); }
1464         | SCTP_ASSOC_TRACKING EQUAL NUMBER {
1465                 #ifdef USE_SCTP
1466                         #ifdef SCTP_CONN_REUSE
1467                                 sctp_default_cfg.assoc_tracking=$3;
1468                         #else
1469                                 if ($3)
1470                                         warn("sctp association tracking/reuse (SCTP_CONN_REUSE) "
1471                                                         "support not compiled in");
1472                         #endif /* SCTP_CONN_REUSE */
1473                 #else
1474                         warn("sctp support not compiled in");
1475                 #endif /* USE_SCTP */
1476         }
1477         | SCTP_ASSOC_TRACKING EQUAL error { yyerror("number expected"); }
1478         | SCTP_ASSOC_REUSE EQUAL NUMBER {
1479                 #ifdef USE_SCTP
1480                         #ifdef SCTP_CONN_REUSE
1481                                 sctp_default_cfg.assoc_reuse=$3;
1482                         #else
1483                                 if ($3)
1484                                         warn("sctp association reuse (SCTP_CONN_REUSE) support"
1485                                                         " not compiled in");
1486                         #endif /* SCTP_CONN_REUSE */
1487                 #else
1488                         warn("sctp support not compiled in");
1489                 #endif /* USE_SCTP */
1490         }
1491         | SCTP_ASSOC_REUSE EQUAL error { yyerror("number expected"); }
1492         | SCTP_MAX_ASSOCS EQUAL intno {
1493                         IF_SCTP(sctp_default_cfg.max_assocs=$3);
1494         }
1495         | SCTP_MAX_ASSOCS EQUAL error { yyerror("number expected"); }
1496         | SCTP_SRTO_INITIAL EQUAL NUMBER {
1497                         IF_SCTP(sctp_default_cfg.srto_initial=$3);
1498         }
1499         | SCTP_SRTO_INITIAL EQUAL error { yyerror("number expected"); }
1500         | SCTP_SRTO_MAX EQUAL NUMBER {
1501                         IF_SCTP(sctp_default_cfg.srto_max=$3);
1502         }
1503         | SCTP_SRTO_MAX EQUAL error { yyerror("number expected"); }
1504         | SCTP_SRTO_MIN EQUAL NUMBER {
1505                         IF_SCTP(sctp_default_cfg.srto_min=$3);
1506         }
1507         | SCTP_SRTO_MIN EQUAL error { yyerror("number expected"); }
1508         | SCTP_ASOCMAXRXT EQUAL NUMBER {
1509                         IF_SCTP(sctp_default_cfg.asocmaxrxt=$3);
1510         }
1511         | SCTP_ASOCMAXRXT EQUAL error { yyerror("number expected"); }
1512         | SCTP_INIT_MAX_ATTEMPTS EQUAL NUMBER {
1513                         IF_SCTP(sctp_default_cfg.init_max_attempts=$3);
1514         }
1515         | SCTP_INIT_MAX_ATTEMPTS EQUAL error { yyerror("number expected"); }
1516         | SCTP_INIT_MAX_TIMEO EQUAL NUMBER {
1517                         IF_SCTP(sctp_default_cfg.init_max_timeo=$3);
1518         }
1519         | SCTP_INIT_MAX_TIMEO EQUAL error { yyerror("number expected"); }
1520         | SCTP_HBINTERVAL EQUAL intno {
1521                         IF_SCTP(sctp_default_cfg.hbinterval=$3);
1522         }
1523         | SCTP_HBINTERVAL EQUAL error { yyerror("number expected"); }
1524         | SCTP_PATHMAXRXT EQUAL NUMBER {
1525                         IF_SCTP(sctp_default_cfg.pathmaxrxt=$3);
1526         }
1527         | SCTP_PATHMAXRXT EQUAL error { yyerror("number expected"); }
1528         | SCTP_SACK_DELAY EQUAL NUMBER {
1529                         IF_SCTP(sctp_default_cfg.sack_delay=$3);
1530         }
1531         | SCTP_SACK_DELAY EQUAL error { yyerror("number expected"); }
1532         | SCTP_SACK_FREQ EQUAL NUMBER {
1533                         IF_SCTP(sctp_default_cfg.sack_freq=$3);
1534         }
1535         | SCTP_SACK_FREQ EQUAL error { yyerror("number expected"); }
1536         | SCTP_MAX_BURST EQUAL NUMBER {
1537                         IF_SCTP(sctp_default_cfg.max_burst=$3);
1538         }
1539         | SCTP_MAX_BURST EQUAL error { yyerror("number expected"); }
1540         | SERVER_SIGNATURE EQUAL NUMBER { server_signature=$3; }
1541         | SERVER_SIGNATURE EQUAL error { yyerror("boolean value expected"); }
1542         | SERVER_HEADER EQUAL STRING { server_hdr.s=$3;
1543                         server_hdr.len=strlen(server_hdr.s);
1544         }
1545         | SERVER_HEADER EQUAL error { yyerror("string value expected"); }
1546         | USER_AGENT_HEADER EQUAL STRING { user_agent_hdr.s=$3;
1547                         user_agent_hdr.len=strlen(user_agent_hdr.s);
1548         }
1549         | USER_AGENT_HEADER EQUAL error { yyerror("string value expected"); }
1550         | REPLY_TO_VIA EQUAL NUMBER { reply_to_via=$3; }
1551         | REPLY_TO_VIA EQUAL error { yyerror("boolean value expected"); }
1552         | LISTEN EQUAL id_lst {
1553                 for(lst_tmp=$3; lst_tmp; lst_tmp=lst_tmp->next) {
1554                         if (add_listen_iface(   lst_tmp->addr_lst->name,
1555                                                                         lst_tmp->addr_lst->next,
1556                                                                         lst_tmp->port, lst_tmp->proto,
1557                                                                         lst_tmp->flags)!=0) {
1558                                 LOG(L_CRIT,  "ERROR: cfg. parser: failed to add listen"
1559                                                                 " address\n");
1560                                 break;
1561                         }
1562                 }
1563                 free_socket_id_lst($3);
1564         }
1565         | LISTEN EQUAL id_lst ADVERTISE listen_id COLON NUMBER {
1566                 for(lst_tmp=$3; lst_tmp; lst_tmp=lst_tmp->next) {
1567                         if (add_listen_advertise_iface( lst_tmp->addr_lst->name,
1568                                                                         lst_tmp->addr_lst->next,
1569                                                                         lst_tmp->port, lst_tmp->proto,
1570                                                                         $5, $7,
1571                                                                         lst_tmp->flags)!=0) {
1572                                 LOG(L_CRIT,  "ERROR: cfg. parser: failed to add listen"
1573                                                                 " address\n");
1574                                 break;
1575                         }
1576                 }
1577                 free_socket_id_lst($3);
1578         }
1579         | LISTEN EQUAL  error { yyerror("ip address, interface name or"
1580                                                                         " hostname expected"); }
1581         | ALIAS EQUAL  id_lst {
1582                 for(lst_tmp=$3; lst_tmp; lst_tmp=lst_tmp->next){
1583                         add_alias(      lst_tmp->addr_lst->name,
1584                                                 strlen(lst_tmp->addr_lst->name),
1585                                                 lst_tmp->port, lst_tmp->proto);
1586                         for (nl_tmp=lst_tmp->addr_lst->next; nl_tmp; nl_tmp=nl_tmp->next)
1587                                 add_alias(nl_tmp->name, strlen(nl_tmp->name),
1588                                                         lst_tmp->port, lst_tmp->proto);
1589                 }
1590                 free_socket_id_lst($3);
1591         }
1592         | ALIAS  EQUAL error  { yyerror(" hostname expected"); }
1593         | SR_AUTO_ALIASES EQUAL NUMBER { sr_auto_aliases=$3; }
1594         | SR_AUTO_ALIASES EQUAL error  { yyerror("boolean value expected"); }
1595         | ADVERTISED_ADDRESS EQUAL listen_id {
1596                 if ($3){
1597                         default_global_address.s=$3;
1598                         default_global_address.len=strlen($3);
1599                 }
1600         }
1601         | ADVERTISED_ADDRESS EQUAL error {yyerror("ip address or hostname expected"); }
1602         | ADVERTISED_PORT EQUAL NUMBER {
1603                 tmp=int2str($3, &i_tmp);
1604                 if ((default_global_port.s=pkg_malloc(i_tmp))==0) {
1605                         LOG(L_CRIT, "ERROR: cfg. parser: out of memory.\n");
1606                         default_global_port.len=0;
1607                 } else {
1608                         default_global_port.len=i_tmp;
1609                         memcpy(default_global_port.s, tmp, default_global_port.len);
1610                 };
1611         }
1612         |ADVERTISED_PORT EQUAL error {yyerror("ip address or hostname expected"); }
1613         | DISABLE_CORE EQUAL NUMBER { disable_core_dump=$3; }
1614         | DISABLE_CORE EQUAL error { yyerror("boolean value expected"); }
1615         | OPEN_FD_LIMIT EQUAL NUMBER { open_files_limit=$3; }
1616         | OPEN_FD_LIMIT EQUAL error { yyerror("number expected"); }
1617         | SHM_MEM_SZ EQUAL NUMBER {
1618                 if (shm_initialized())
1619                         yyerror("shm/shm_mem_size must be before any modparam or the"
1620                                         " route blocks");
1621                 else if (shm_mem_size == 0)
1622                         shm_mem_size=$3 * 1024 * 1024;
1623         }
1624         | SHM_MEM_SZ EQUAL error { yyerror("number expected"); }
1625         | SHM_FORCE_ALLOC EQUAL NUMBER {
1626                 if (shm_initialized())
1627                         yyerror("shm_force_alloc must be before any modparam or the"
1628                                         " route blocks");
1629                 else
1630                         shm_force_alloc=$3;
1631         }
1632         | SHM_FORCE_ALLOC EQUAL error { yyerror("boolean value expected"); }
1633         | MLOCK_PAGES EQUAL NUMBER { mlock_pages=$3; }
1634         | MLOCK_PAGES EQUAL error { yyerror("boolean value expected"); }
1635         | REAL_TIME EQUAL NUMBER { real_time=$3; }
1636         | REAL_TIME EQUAL error { yyerror("boolean value expected"); }
1637         | RT_PRIO EQUAL NUMBER { rt_prio=$3; }
1638         | RT_PRIO EQUAL error { yyerror("boolean value expected"); }
1639         | RT_POLICY EQUAL NUMBER { rt_policy=$3; }
1640         | RT_POLICY EQUAL error { yyerror("boolean value expected"); }
1641         | RT_TIMER1_PRIO EQUAL NUMBER { rt_timer1_prio=$3; }
1642         | RT_TIMER1_PRIO EQUAL error { yyerror("boolean value expected"); }
1643         | RT_TIMER1_POLICY EQUAL NUMBER { rt_timer1_policy=$3; }
1644         | RT_TIMER1_POLICY EQUAL error { yyerror("boolean value expected"); }
1645         | RT_TIMER2_PRIO EQUAL NUMBER { rt_timer2_prio=$3; }
1646         | RT_TIMER2_PRIO EQUAL error { yyerror("boolean value expected"); }
1647         | RT_TIMER2_POLICY EQUAL NUMBER { rt_timer2_policy=$3; }
1648         | RT_TIMER2_POLICY EQUAL error { yyerror("boolean value expected"); }
1649         | MCAST_LOOPBACK EQUAL NUMBER {
1650                 #ifdef USE_MCAST
1651                         mcast_loopback=$3;
1652                 #else
1653                         warn("no multicast support compiled in");
1654                 #endif
1655         }
1656         | MCAST_LOOPBACK EQUAL error { yyerror("boolean value expected"); }
1657         | MCAST_TTL EQUAL NUMBER {
1658                 #ifdef USE_MCAST
1659                         mcast_ttl=$3;
1660                 #else
1661                         warn("no multicast support compiled in");
1662                 #endif
1663         }
1664         | MCAST_TTL EQUAL error { yyerror("number expected"); }
1665         | TOS EQUAL NUMBER { tos=$3; }
1666         | TOS EQUAL ID { if (strcasecmp($3,"IPTOS_LOWDELAY")) {
1667                         tos=IPTOS_LOWDELAY;
1668                 } else if (strcasecmp($3,"IPTOS_THROUGHPUT")) {
1669                         tos=IPTOS_THROUGHPUT;
1670                 } else if (strcasecmp($3,"IPTOS_RELIABILITY")) {
1671                         tos=IPTOS_RELIABILITY;
1672 #if defined(IPTOS_MINCOST)
1673                 } else if (strcasecmp($3,"IPTOS_MINCOST")) {
1674                         tos=IPTOS_MINCOST;
1675 #endif
1676 #if defined(IPTOS_LOWCOST)
1677                 } else if (strcasecmp($3,"IPTOS_LOWCOST")) {
1678                         tos=IPTOS_LOWCOST;
1679 #endif
1680                 } else {
1681                         yyerror("invalid tos value - allowed: "
1682                                 "IPTOS_LOWDELAY,IPTOS_THROUGHPUT,"
1683                                 "IPTOS_RELIABILITY"
1684 #if defined(IPTOS_LOWCOST)
1685                                 ",IPTOS_LOWCOST"
1686 #endif
1687 #if !defined(IPTOS_MINCOST)
1688                                 ",IPTOS_MINCOST"
1689 #endif
1690                                 "\n");
1691                 }
1692         }
1693         | TOS EQUAL error { yyerror("number expected"); }
1694         | PMTU_DISCOVERY EQUAL NUMBER { pmtu_discovery=$3; }
1695         | PMTU_DISCOVERY error { yyerror("number expected"); }
1696         | KILL_TIMEOUT EQUAL NUMBER { ser_kill_timeout=$3; }
1697         | KILL_TIMEOUT EQUAL error { yyerror("number expected"); }
1698         | MAX_WLOOPS EQUAL NUMBER { default_core_cfg.max_while_loops=$3; }
1699         | MAX_WLOOPS EQUAL error { yyerror("number expected"); }
1700         | PVBUFSIZE EQUAL NUMBER { pv_set_buffer_size($3); }
1701         | PVBUFSIZE EQUAL error { yyerror("number expected"); }
1702         | PVBUFSLOTS EQUAL NUMBER { pv_set_buffer_slots($3); }
1703         | PVBUFSLOTS EQUAL error { yyerror("number expected"); }
1704         | HTTP_REPLY_HACK EQUAL NUMBER { http_reply_hack=$3; }
1705         | HTTP_REPLY_HACK EQUAL error { yyerror("boolean value expected"); }
1706         | STUN_REFRESH_INTERVAL EQUAL NUMBER { IF_STUN(stun_refresh_interval=$3); }
1707         | STUN_REFRESH_INTERVAL EQUAL error{ yyerror("number expected"); }
1708         | STUN_ALLOW_STUN EQUAL NUMBER { IF_STUN(stun_allow_stun=$3); }
1709         | STUN_ALLOW_STUN EQUAL error{ yyerror("number expected"); }
1710         | STUN_ALLOW_FP EQUAL NUMBER { IF_STUN(stun_allow_fp=$3) ; }
1711         | STUN_ALLOW_FP EQUAL error{ yyerror("number expected"); }
1712     | SERVER_ID EQUAL NUMBER { server_id=$3; }
1713     | LATENCY_LOG EQUAL NUMBER { default_core_cfg.latency_log=$3; }
1714         | LATENCY_LOG EQUAL error  { yyerror("number  expected"); }
1715     | LATENCY_LIMIT_DB EQUAL NUMBER { default_core_cfg.latency_limit_db=$3; }
1716         | LATENCY_LIMIT_DB EQUAL error  { yyerror("number  expected"); }
1717     | LATENCY_LIMIT_ACTION EQUAL NUMBER { default_core_cfg.latency_limit_action=$3; }
1718         | LATENCY_LIMIT_ACTION EQUAL error  { yyerror("number  expected"); }
1719     | MSG_TIME EQUAL NUMBER { sr_msg_time=$3; }
1720         | MSG_TIME EQUAL error  { yyerror("number  expected"); }
1721         | UDP_MTU EQUAL NUMBER { default_core_cfg.udp_mtu=$3; }
1722         | UDP_MTU EQUAL error { yyerror("number expected"); }
1723         | FORCE_RPORT EQUAL NUMBER 
1724                 { default_core_cfg.force_rport=$3; fix_global_req_flags(0, 0); }
1725         | FORCE_RPORT EQUAL error { yyerror("boolean value expected"); }
1726         | UDP_MTU_TRY_PROTO EQUAL proto
1727                 { default_core_cfg.udp_mtu_try_proto=$3; fix_global_req_flags(0, 0); }
1728         | UDP_MTU_TRY_PROTO EQUAL error
1729                 { yyerror("TCP, TLS, SCTP or UDP expected"); }
1730         | UDP4_RAW EQUAL intno { IF_RAW_SOCKS(default_core_cfg.udp4_raw=$3); }
1731         | UDP4_RAW EQUAL error { yyerror("number expected"); }
1732         | UDP4_RAW_MTU EQUAL NUMBER {
1733                 IF_RAW_SOCKS(default_core_cfg.udp4_raw_mtu=$3);
1734         }
1735         | UDP4_RAW_MTU EQUAL error { yyerror("number expected"); }
1736         | UDP4_RAW_TTL EQUAL NUMBER {
1737                 IF_RAW_SOCKS(default_core_cfg.udp4_raw_ttl=$3);
1738         }
1739         | UDP4_RAW_TTL EQUAL error { yyerror("number expected"); }
1740         | cfg_var
1741         | error EQUAL { yyerror("unknown config variable"); }
1742         ;
1743         
1744 cfg_var_id: ID 
1745         | DEFAULT { $$="default" ; } /*needed to allow default as cfg var. name*/
1746         ;
1747         
1748 cfg_var:
1749         cfg_var_id DOT cfg_var_id EQUAL NUMBER {
1750                 if (cfg_declare_int($1, $3, $5, 0, 0, NULL)) {
1751                         yyerror("variable cannot be declared");
1752                 }
1753         }
1754         | cfg_var_id DOT cfg_var_id EQUAL STRING {
1755                 if (cfg_declare_str($1, $3, $5, NULL)) {
1756                         yyerror("variable cannot be declared");
1757                 }
1758         }
1759         | cfg_var_id DOT cfg_var_id EQUAL NUMBER CFG_DESCRIPTION STRING {
1760                 if (cfg_declare_int($1, $3, $5, 0, 0, $7)) {
1761                         yyerror("variable cannot be declared");
1762                 }
1763         }
1764         | cfg_var_id DOT cfg_var_id EQUAL STRING CFG_DESCRIPTION STRING {
1765                 if (cfg_declare_str($1, $3, $5, $7)) {
1766                         yyerror("variable cannot be declared");
1767                 }
1768         }
1769         | cfg_var_id DOT cfg_var_id EQUAL error { 
1770                 yyerror("number or string expected"); 
1771         }
1772         | cfg_var_id LBRACK NUMBER RBRACK DOT cfg_var_id EQUAL NUMBER {
1773                 if (cfg_ginst_var_int($1, $3, $6, $8)) {
1774                         yyerror("variable cannot be added to the group instance");
1775                 }
1776         }
1777         | cfg_var_id LBRACK NUMBER RBRACK DOT cfg_var_id EQUAL STRING {
1778                 if (cfg_ginst_var_string($1, $3, $6, $8)) {
1779                         yyerror("variable cannot be added to the group instance");
1780                 }
1781         }
1782         ;
1783
1784 module_stm:
1785         LOADMODULE STRING {
1786                 DBG("loading module %s\n", $2);
1787                         if (load_module($2)!=0) {
1788                                 yyerror("failed to load module");
1789                         }
1790         }
1791         | LOADMODULE error      { yyerror("string expected"); }
1792         | LOADPATH STRING {
1793                 DBG("loading modules under %s\n", $2);
1794                 printf("loading modules under %s\n", $2);
1795                 mods_dir = $2;
1796         }
1797         | LOADPATH error        { yyerror("string expected"); }
1798         | LOADPATH EQUAL STRING {
1799                 DBG("loading modules under %s\n", $3);
1800                 printf("loading modules under %s\n", $3);
1801                 mods_dir = $3;
1802         }
1803         | LOADPATH EQUAL error  { yyerror("string expected"); }
1804         | MODPARAM LPAREN STRING COMMA STRING COMMA STRING RPAREN {
1805         #ifdef SHM_MEM
1806                 if (!shm_initialized() && init_shm()<0) {
1807                         yyerror("Can't initialize shared memory");
1808                         YYABORT;
1809                 }
1810         #endif /* SHM_MEM */
1811                 if (set_mod_param_regex($3, $5, PARAM_STRING, $7) != 0) {
1812                          yyerror("Can't set module parameter");
1813                 }
1814         }
1815         | MODPARAM LPAREN STRING COMMA STRING COMMA intno RPAREN {
1816         #ifdef SHM_MEM
1817                 if (!shm_initialized() && init_shm()<0) {
1818                         yyerror("Can't initialize shared memory");
1819                         YYABORT;
1820                 }
1821         #endif /* SHM_MEM */
1822                 if (set_mod_param_regex($3, $5, PARAM_INT, (void*)$7) != 0) {
1823                          yyerror("Can't set module parameter");
1824                 }
1825         }
1826         | MODPARAM error { yyerror("Invalid arguments"); }
1827         ;
1828 ip:
1829         ipv4  { $$=$1; }
1830         | ipv6  { $$=$1; }
1831         ;
1832 ipv4:
1833         NUMBER DOT NUMBER DOT NUMBER DOT NUMBER {
1834                 $$=pkg_malloc(sizeof(struct ip_addr));
1835                 if ($$==0) {
1836                         LOG(L_CRIT, "ERROR: cfg. parser: out of memory.\n");
1837                 } else {
1838                         memset($$, 0, sizeof(struct ip_addr));
1839                         $$->af=AF_INET;
1840                         $$->len=4;
1841                         if (($1>255) || ($1<0) ||
1842                                 ($3>255) || ($3<0) ||
1843                                 ($5>255) || ($5<0) ||
1844                                 ($7>255) || ($7<0)) {
1845                                 yyerror("invalid ipv4 address");
1846                                 $$->u.addr32[0]=0;
1847                                 /* $$=0; */
1848                         } else {
1849                                 $$->u.addr[0]=$1;
1850                                 $$->u.addr[1]=$3;
1851                                 $$->u.addr[2]=$5;
1852                                 $$->u.addr[3]=$7;
1853                                 /*
1854                                 $$=htonl( ($1<<24)|
1855                                 ($3<<16)| ($5<<8)|$7 );
1856                                 */
1857                         }
1858                 }
1859         }
1860         ;
1861 ipv6addr:
1862         IPV6ADDR {
1863                 $$=pkg_malloc(sizeof(struct ip_addr));
1864                 if ($$==0) {
1865                         LOG(L_CRIT, "ERROR: cfg. parser: out of memory.\n");
1866                 } else {
1867                 #ifdef USE_IPV6
1868                         memset($$, 0, sizeof(struct ip_addr));
1869                         $$->af=AF_INET6;
1870                         $$->len=16;
1871                         if (inet_pton(AF_INET6, $1, $$->u.addr)<=0) {
1872                                 yyerror("bad ipv6 address");
1873                         }
1874                 #else
1875                         yyerror("ipv6 address & no ipv6 support compiled in");
1876                         YYABORT;
1877                 #endif
1878                 }
1879         }
1880         ;
1881 ipv6:
1882         ipv6addr { $$=$1; }
1883         | LBRACK ipv6addr RBRACK {$$=$2; }
1884 ;
1885
1886
1887 route_name:             NUMBER  {
1888                                         tmp=int2str($1, &i_tmp);
1889                                         if (($$=pkg_malloc(i_tmp+1))==0) {
1890                                                 yyerror("out of  memory");
1891                                                 YYABORT;
1892                                         } else {
1893                                                 memcpy($$, tmp, i_tmp);
1894                                                 $$[i_tmp]=0;
1895                                         }
1896                                                 }
1897                         |       ID              { $$=$1; }
1898                         |       STRING  { $$=$1; }
1899 ;
1900
1901
1902 route_main:     ROUTE { ; }
1903                   | ROUTE_REQUEST { ; }
1904 ;
1905
1906 route_stm:
1907         route_main LBRACE actions RBRACE {
1908         #ifdef SHM_MEM
1909                 if (!shm_initialized() && init_shm()<0) {
1910                         yyerror("Can't initialize shared memory");
1911                         YYABORT;
1912                 }
1913         #endif /* SHM_MEM */
1914                 push($3, &main_rt.rlist[DEFAULT_RT]);
1915         }
1916         | ROUTE LBRACK route_name RBRACK LBRACE actions RBRACE {
1917         #ifdef SHM_MEM
1918                 if (!shm_initialized() && init_shm()<0) {
1919                         yyerror("Can't initialize shared memory");
1920                         YYABORT;
1921                 }
1922         #endif /* SHM_MEM */
1923                 i_tmp=route_get(&main_rt, $3);
1924                 if (i_tmp==-1){
1925                         yyerror("internal error");
1926                         YYABORT;
1927                 }
1928                 if (main_rt.rlist[i_tmp]){
1929                         yyerror("duplicate route");
1930                         YYABORT;
1931                 }
1932                 push($6, &main_rt.rlist[i_tmp]);
1933         }
1934         | ROUTE error { yyerror("invalid  route  statement"); }
1935         | ROUTE_REQUEST error { yyerror("invalid  request_route  statement"); }
1936         ;
1937 failure_route_stm:
1938         ROUTE_FAILURE LBRACE actions RBRACE {
1939         #ifdef SHM_MEM
1940                 if (!shm_initialized() && init_shm()<0) {
1941                         yyerror("Can't initialize shared memory");
1942                         YYABORT;
1943                 }
1944         #endif /* SHM_MEM */
1945                 push($3, &failure_rt.rlist[DEFAULT_RT]);
1946         }
1947         | ROUTE_FAILURE LBRACK route_name RBRACK LBRACE actions RBRACE {
1948         #ifdef SHM_MEM
1949                 if (!shm_initialized() && init_shm()<0) {
1950                         yyerror("Can't initialize shared memory");
1951                         YYABORT;
1952                 }
1953         #endif /* SHM_MEM */
1954                 i_tmp=route_get(&failure_rt, $3);
1955                 if (i_tmp==-1){
1956                         yyerror("internal error");
1957                         YYABORT;
1958                 }
1959                 if (failure_rt.rlist[i_tmp]){
1960                         yyerror("duplicate route");
1961                         YYABORT;
1962                 }
1963                 push($6, &failure_rt.rlist[i_tmp]);
1964         }
1965         | ROUTE_FAILURE error { yyerror("invalid failure_route statement"); }
1966         ;
1967
1968
1969 route_reply_main:       ROUTE_ONREPLY { ; }
1970                   | ROUTE_REPLY { ; }
1971 ;
1972
1973
1974 onreply_route_stm:
1975         route_reply_main LBRACE {rt=CORE_ONREPLY_ROUTE;} actions RBRACE {
1976         #ifdef SHM_MEM
1977                 if (!shm_initialized() && init_shm()<0) {
1978                         yyerror("Can't initialize shared memory");
1979                         YYABORT;
1980                 }
1981         #endif /* SHM_MEM */
1982                 push($4, &onreply_rt.rlist[DEFAULT_RT]);
1983         }
1984         | ROUTE_ONREPLY error { yyerror("invalid onreply_route statement"); }
1985         | ROUTE_REPLY error { yyerror("invalid onreply_route statement"); }
1986         | ROUTE_ONREPLY LBRACK route_name RBRACK 
1987                 {rt=(*$3=='0' && $3[1]==0)?CORE_ONREPLY_ROUTE:TM_ONREPLY_ROUTE;}
1988                 LBRACE actions RBRACE {
1989         #ifdef SHM_MEM
1990                 if (!shm_initialized() && init_shm()<0) {
1991                         yyerror("Can't initialize shared memory");
1992                         YYABORT;
1993                 }
1994         #endif /* SHM_MEM */
1995                 if (*$3=='0' && $3[1]==0){
1996                         /* onreply_route[0] {} is equivalent with onreply_route {}*/
1997                         push($7, &onreply_rt.rlist[DEFAULT_RT]);
1998                 }else{
1999                         i_tmp=route_get(&onreply_rt, $3);
2000                         if (i_tmp==-1){
2001                                 yyerror("internal error");
2002                                 YYABORT;
2003                         }
2004                         if (onreply_rt.rlist[i_tmp]){
2005                                 yyerror("duplicate route");
2006                                 YYABORT;
2007                         }
2008                         push($7, &onreply_rt.rlist[i_tmp]);
2009                 }
2010         }
2011         | ROUTE_ONREPLY LBRACK route_name RBRACK error {
2012                 yyerror("invalid onreply_route statement");
2013         }
2014         ;
2015 branch_route_stm:
2016         ROUTE_BRANCH LBRACE actions RBRACE {
2017         #ifdef SHM_MEM
2018                 if (!shm_initialized() && init_shm()<0) {
2019                         yyerror("Can't initialize shared memory");
2020                         YYABORT;
2021                 }
2022         #endif /* SHM_MEM */
2023                 push($3, &branch_rt.rlist[DEFAULT_RT]);
2024         }
2025         | ROUTE_BRANCH LBRACK route_name RBRACK LBRACE actions RBRACE {
2026         #ifdef SHM_MEM
2027                 if (!shm_initialized() && init_shm()<0) {
2028                         yyerror("Can't initialize shared memory");
2029                         YYABORT;
2030                 }
2031         #endif /* SHM_MEM */
2032                 i_tmp=route_get(&branch_rt, $3);
2033                 if (i_tmp==-1){
2034                         yyerror("internal error");
2035                         YYABORT;
2036                 }
2037                 if (branch_rt.rlist[i_tmp]){
2038                         yyerror("duplicate route");
2039                         YYABORT;
2040                 }
2041                 push($6, &branch_rt.rlist[i_tmp]);
2042         }
2043         | ROUTE_BRANCH error { yyerror("invalid branch_route statement"); }
2044         ;
2045 send_route_stm: ROUTE_SEND LBRACE actions RBRACE {
2046         #ifdef SHM_MEM
2047                 if (!shm_initialized() && init_shm()<0) {
2048                         yyerror("Can't initialize shared memory");
2049                         YYABORT;
2050                 }
2051         #endif /* SHM_MEM */
2052                 push($3, &onsend_rt.rlist[DEFAULT_RT]);
2053         }
2054         | ROUTE_SEND LBRACK route_name RBRACK LBRACE actions RBRACE {
2055         #ifdef SHM_MEM
2056                 if (!shm_initialized() && init_shm()<0) {
2057                         yyerror("Can't initialize shared memory");
2058                         YYABORT;
2059                 }
2060         #endif /* SHM_MEM */
2061                 i_tmp=route_get(&onsend_rt, $3);
2062                 if (i_tmp==-1){
2063                         yyerror("internal error");
2064                         YYABORT;
2065                 }
2066                 if (onsend_rt.rlist[i_tmp]){
2067                         yyerror("duplicate route");
2068                         YYABORT;
2069                 }
2070                 push($6, &onsend_rt.rlist[i_tmp]);
2071         }
2072         | ROUTE_SEND error { yyerror("invalid onsend_route statement"); }
2073         ;
2074 event_route_stm: ROUTE_EVENT LBRACK EVENT_RT_NAME RBRACK LBRACE actions RBRACE {
2075         #ifdef SHM_MEM
2076                 if (!shm_initialized() && init_shm()<0) {
2077                         yyerror("Can't initialize shared memory");
2078                         YYABORT;
2079                 }
2080         #endif /* SHM_MEM */
2081                 i_tmp=route_get(&event_rt, $3);
2082                 if (i_tmp==-1){
2083                         yyerror("internal error");
2084                         YYABORT;
2085                 }
2086                 if (event_rt.rlist[i_tmp]){
2087                         yyerror("duplicate route");
2088                         YYABORT;
2089                 }
2090                 push($6, &event_rt.rlist[i_tmp]);
2091         }
2092
2093         | ROUTE_EVENT error { yyerror("invalid event_route statement"); }
2094         ;
2095 preprocess_stm:
2096         SUBST STRING { if(pp_subst_add($2)<0) YYERROR; }
2097         | SUBST error { yyerror("invalid subst preprocess statement"); }
2098         | SUBSTDEF STRING { if(pp_substdef_add($2, 0)<0) YYERROR; }
2099         | SUBSTDEF error { yyerror("invalid substdef preprocess statement"); }
2100         | SUBSTDEFS STRING { if(pp_substdef_add($2, 1)<0) YYERROR; }
2101         | SUBSTDEFS error { yyerror("invalid substdefs preprocess statement"); }
2102         ;
2103
2104 /*exp:  rval_expr
2105                 {
2106                         if ($1==0){
2107                                 yyerror("invalid expression");
2108                                 $$=0;
2109                         }else if (!rve_check_type((enum rval_type*)&i_tmp, $1, 0, 0 ,0)){
2110                                 yyerror("invalid expression");
2111                                 $$=0;
2112                         }else if (i_tmp!=RV_INT && i_tmp!=RV_NONE){
2113                                 yyerror("invalid expression type, int expected\n");
2114                                 $$=0;
2115                         }else
2116                                 $$=mk_elem(NO_OP, RVEXP_O, $1, 0, 0);
2117                 }
2118         ;
2119 */
2120
2121 /* exp elem operators */
2122 equalop:
2123         EQUAL_T {$$=EQUAL_OP; }
2124         | DIFF  {$$=DIFF_OP; }
2125         | STREQ {$$=EQUAL_OP; }  /* for expr. elems equiv. to EQUAL_T*/
2126         | STRDIFF {$$=DIFF_OP; } /* for expr. elems. equiv. to DIFF */
2127         ;
2128 cmpop:
2129           GT    {$$=GT_OP; }
2130         | LT    {$$=LT_OP; }
2131         | GTE   {$$=GTE_OP; }
2132         | LTE   {$$=LTE_OP; }
2133         ;
2134 strop:
2135         equalop {$$=$1; }
2136         | MATCH {$$=MATCH_OP; }
2137         ;
2138
2139
2140 /* rve expr. operators */
2141 rve_equalop:
2142         EQUAL_T {$$=RVE_EQ_OP; }
2143         | DIFF  {$$=RVE_DIFF_OP; }
2144         | INTEQ {$$=RVE_IEQ_OP; }
2145         | INTDIFF {$$=RVE_IDIFF_OP; }
2146         | STREQ {$$=RVE_STREQ_OP; }
2147         | STRDIFF {$$=RVE_STRDIFF_OP; }
2148         | MATCH {$$=RVE_MATCH_OP; }
2149         ;
2150 rve_cmpop:
2151           GT    {$$=RVE_GT_OP; }
2152         | LT    {$$=RVE_LT_OP; }
2153         | GTE   {$$=RVE_GTE_OP; }
2154         | LTE   {$$=RVE_LTE_OP; }
2155         ;
2156
2157
2158
2159 /* boolean expression uri operands */
2160 uri_type:
2161         URI             {$$=URI_O;}
2162         | FROM_URI      {$$=FROM_URI_O;}
2163         | TO_URI        {$$=TO_URI_O;}
2164         ;
2165
2166
2167 /* boolean expression integer operands, available only in the
2168   onsend route */
2169 eint_op_onsend:
2170                         SNDPORT         { $$=SNDPORT_O; }
2171                 |       TOPORT          { $$=TOPORT_O; }
2172                 |       SNDAF           { $$=SNDAF_O; }
2173                 ;
2174
2175 /* boolean expression integer operands */
2176 eint_op:        SRCPORT         { $$=SRCPORT_O; }
2177                 |       DSTPORT         { $$=DSTPORT_O; }
2178                 |       AF                      { $$=AF_O; }
2179                 |       MSGLEN          { $$=MSGLEN_O; }
2180                 | eint_op_onsend
2181         ;
2182
2183 /* boolean expression ip/ipnet operands */
2184 eip_op_onsend:
2185                         SNDIP           { onsend_check("snd_ip"); $$=SNDIP_O; }
2186                 |       TOIP            { onsend_check("to_ip");  $$=TOIP_O; }
2187                 ;
2188
2189 eip_op:         SRCIP           { $$=SRCIP_O; }
2190                 |       DSTIP           { $$=DSTIP_O; }
2191                 | eip_op_onsend
2192                 ;
2193
2194
2195
2196 exp_elem:
2197         METHOD strop rval_expr %prec EQUAL_T
2198                 {$$= mk_elem($2, METHOD_O, 0, RVE_ST, $3);}
2199         | METHOD strop ID %prec EQUAL_T
2200                 {$$ = mk_elem($2, METHOD_O, 0, STRING_ST,$3); }
2201         | METHOD strop error { $$=0; yyerror("string expected"); }
2202         | METHOD error  
2203                 { $$=0; yyerror("invalid operator,== , !=, or =~ expected"); }
2204         | uri_type strop rval_expr %prec EQUAL_T
2205                 {$$ = mk_elem($2, $1, 0, RVE_ST, $3); }
2206         | uri_type strop MYSELF %prec EQUAL_T
2207                 {$$=mk_elem($2, $1, 0, MYSELF_ST, 0); }
2208         | uri_type strop error %prec EQUAL_T
2209                 { $$=0; yyerror("string or MYSELF expected"); }
2210         | uri_type error
2211                 { $$=0; yyerror("invalid operator, == , != or =~ expected"); }
2212         | eint_op cmpop rval_expr %prec GT { $$=mk_elem($2, $1, 0, RVE_ST, $3 ); }
2213         | eint_op equalop rval_expr %prec EQUAL_T
2214                 { $$=mk_elem($2, $1, 0, RVE_ST, $3 ); }
2215         | eint_op cmpop error   { $$=0; yyerror("number expected"); }
2216         | eint_op equalop error { $$=0; yyerror("number expected"); }
2217         | eint_op error { $$=0; yyerror("==, !=, <,>, >= or <=  expected"); }
2218         | PROTO equalop eqproto %prec EQUAL_T
2219                 { $$=mk_elem($2, PROTO_O, 0, NUMBER_ST, (void*)$3 ); }
2220         | PROTO equalop rval_expr %prec EQUAL_T
2221                 { $$=mk_elem($2, PROTO_O, 0, RVE_ST, $3 ); }
2222         | PROTO equalop error
2223                 { $$=0; yyerror("protocol expected (udp, tcp, tls, sctp, ws, or wss)"); }
2224         | SNDPROTO equalop eqproto %prec EQUAL_T
2225                 { $$=mk_elem($2, SNDPROTO_O, 0, NUMBER_ST, (void*)$3 ); }
2226         | SNDPROTO equalop rval_expr %prec EQUAL_T
2227                 { $$=mk_elem($2, SNDPROTO_O, 0, RVE_ST, $3 ); }
2228         | SNDPROTO equalop error
2229                 { $$=0; yyerror("protocol expected (udp, tcp, tls, sctp, ws, or wss)"); }
2230         | eip_op strop ipnet %prec EQUAL_T { $$=mk_elem($2, $1, 0, NET_ST, $3); }
2231         | eip_op strop rval_expr %prec EQUAL_T {
2232                         s_tmp.s=0;
2233                         $$=0;
2234                         if (rve_is_constant($3)){
2235                                 i_tmp=rve_guess_type($3);
2236                                 if (i_tmp==RV_INT)
2237                                         yyerror("string expected");
2238                                 else if (i_tmp==RV_STR){
2239                                         if (((rval_tmp=rval_expr_eval(0, 0, $3))==0) ||
2240                                                                 (rval_get_str(0, 0, &s_tmp, rval_tmp, 0)<0)){
2241                                                 rval_destroy(rval_tmp);
2242                                                 yyerror("bad rvalue expression");
2243                                         }else{
2244                                                 rval_destroy(rval_tmp);
2245                                         }
2246                                 }else{
2247                                         yyerror("BUG: unexpected dynamic type");
2248                                 }
2249                         }else{
2250                                         /* warn("non constant rvalue in ip comparison") */;
2251                         }
2252                         if (s_tmp.s){
2253                                 ip_tmp=str2ip(&s_tmp);
2254                         #ifdef USE_IPV6
2255                                 if (ip_tmp==0)
2256                                         ip_tmp=str2ip6(&s_tmp);
2257                         #endif
2258                                 pkg_free(s_tmp.s);
2259                                 if (ip_tmp) {
2260                                         $$=mk_elem($2, $1, 0, NET_ST, 
2261                                                                 mk_new_net_bitlen(ip_tmp, ip_tmp->len*8) );
2262                                 } else {
2263                                         $$=mk_elem($2, $1, 0, RVE_ST, $3);
2264                                 }
2265                         }else{
2266                                 $$=mk_elem($2, $1, 0, RVE_ST, $3);
2267                         }
2268                 }
2269         | eip_op strop host %prec EQUAL_T
2270                 { $$=mk_elem($2, $1, 0, STRING_ST, $3); }
2271         | eip_op strop MYSELF %prec EQUAL_T
2272                 { $$=mk_elem($2, $1, 0, MYSELF_ST, 0); }
2273         | eip_op strop error %prec EQUAL_T
2274                 { $$=0; yyerror( "ip address or hostname expected" ); }
2275         | eip_op error
2276                 { $$=0; yyerror("invalid operator, ==, != or =~ expected");}
2277         
2278         | MYSELF equalop uri_type %prec EQUAL_T
2279                 { $$=mk_elem($2, $3, 0, MYSELF_ST, 0); }
2280         | MYSELF equalop eip_op %prec EQUAL_T
2281                 { $$=mk_elem($2, $3, 0, MYSELF_ST, 0); }
2282         | MYSELF equalop error %prec EQUAL_T
2283                 { $$=0; yyerror(" URI, SRCIP or DSTIP expected"); }
2284         | MYSELF error  { $$=0; yyerror ("invalid operator, == or != expected"); }
2285         ;
2286 /*
2287 exp_elem2:
2288         rval_expr cmpop rval_expr %prec GT
2289                 { $$=mk_elem( $2, RVE_ST, $1, RVE_ST, $3);}
2290         |
2291         rval_expr equalop rval_expr %prec EQUAL_T
2292                 { $$=mk_elem( $2, RVE_ST, $1, RVE_ST, $3);}
2293         | rval_expr LOG_AND rval_expr
2294                 { $$=mk_exp_rve(LOGAND_OP, $1, $3);}
2295         | rval_expr LOG_OR rval_expr
2296                 { $$=mk_exp_rve(LOGOR_OP, $1, $3);}
2297 ;
2298 */
2299
2300 ipnet:
2301         ip SLASH ip     { $$=mk_new_net($1, $3); }
2302         | ip SLASH NUMBER {
2303                 if (($3<0) || ($3>$1->len*8)) {
2304                         yyerror("invalid bit number in netmask");
2305                         $$=0;
2306                 } else {
2307                         $$=mk_new_net_bitlen($1, $3);
2308                 /*
2309                         $$=mk_new_net($1, htonl( ($3)?~( (1<<(32-$3))-1 ):0 ) );
2310                 */
2311                 }
2312         }
2313         | ip    { $$=mk_new_net_bitlen($1, $1->len*8); }
2314         | ip SLASH error { $$=0; yyerror("netmask (eg:255.0.0.0 or 8) expected"); }
2315         ;
2316
2317 host:
2318         ID { $$=$1; }
2319         | host DOT ID {
2320                 if ($1){
2321                         $$=(char*)pkg_malloc(strlen($1)+1+strlen($3)+1);
2322                         if ($$==0) {
2323                                 LOG(L_CRIT, "ERROR: cfg. parser: memory allocation"
2324                                                         " failure while parsing host\n");
2325                         } else {
2326                                 memcpy($$, $1, strlen($1));
2327                                 $$[strlen($1)]='.';
2328                                 memcpy($$+strlen($1)+1, $3, strlen($3));
2329                                 $$[strlen($1)+1+strlen($3)]=0;
2330                         }
2331                         pkg_free($1);
2332                 }
2333                 if ($3) pkg_free($3);
2334         }
2335         | host MINUS ID {
2336                 if ($1){
2337                         $$=(char*)pkg_malloc(strlen($1)+1+strlen($3)+1);
2338                         if ($$==0) {
2339                                 LOG(L_CRIT, "ERROR: cfg. parser: memory allocation"
2340                                                         " failure while parsing host\n");
2341                         } else {
2342                                 memcpy($$, $1, strlen($1));
2343                                 $$[strlen($1)]='-';
2344                                 memcpy($$+strlen($1)+1, $3, strlen($3));
2345                                 $$[strlen($1)+1+strlen($3)]=0;
2346                         }
2347                         pkg_free($1);
2348                 }
2349                 if ($3) pkg_free($3);
2350         }
2351         | host DOT error { $$=0; pkg_free($1); yyerror("invalid hostname"); }
2352         | host MINUS error { $$=0; pkg_free($1); yyerror("invalid hostname"); }
2353         ;
2354
2355 host_if_id: ID
2356                 | NUM_ID
2357                 | NUMBER {
2358                         /* get string version */
2359                         $$=pkg_malloc(strlen(yy_number_str)+1);
2360                         if ($$)
2361                                 strcpy($$, yy_number_str);
2362                 }
2363                 ;
2364
2365 host_or_if:
2366         host_if_id { $$=$1; }
2367         | host_or_if DOT host_if_id {
2368                 if ($1){
2369                         $$=(char*)pkg_malloc(strlen($1)+1+strlen($3)+1);
2370                         if ($$==0) {
2371                                 LOG(L_CRIT, "ERROR: cfg. parser: memory allocation"
2372                                                         " failure while parsing host/interface name\n");
2373                         } else {
2374                                 memcpy($$, $1, strlen($1));
2375                                 $$[strlen($1)]='.';
2376                                 memcpy($$+strlen($1)+1, $3, strlen($3));
2377                                 $$[strlen($1)+1+strlen($3)]=0;
2378                         }
2379                         pkg_free($1);
2380                 }
2381                 if ($3) pkg_free($3);
2382         }
2383         | host_or_if MINUS host_if_id {
2384                 if ($1){
2385                         $$=(char*)pkg_malloc(strlen($1)+1+strlen($3)+1);
2386                         if ($$==0) {
2387                                 LOG(L_CRIT, "ERROR: cfg. parser: memory allocation"
2388                                                         " failure while parsing host/interface name\n");
2389                         } else {
2390                                 memcpy($$, $1, strlen($1));
2391                                 $$[strlen($1)]='-';
2392                                 memcpy($$+strlen($1)+1, $3, strlen($3));
2393                                 $$[strlen($1)+1+strlen($3)]=0;
2394                         }
2395                         pkg_free($1);
2396                 }
2397                 if ($3) pkg_free($3);
2398         }
2399         | host_or_if DOT error { $$=0; pkg_free($1);
2400                                                                 yyerror("invalid host or interface name"); }
2401         | host_or_if MINUS error { $$=0; pkg_free($1);
2402                                                                 yyerror("invalid host or interface name"); }
2403         ;
2404
2405
2406 /* filtered cmd */
2407 fcmd:
2408         cmd {
2409                 /* check if allowed */
2410                 if ($1 && rt==ONSEND_ROUTE) {
2411                         switch($1->type) {
2412                                 case DROP_T:
2413                                 case LOG_T:
2414                                 case SETFLAG_T:
2415                                 case RESETFLAG_T:
2416                                 case ISFLAGSET_T:
2417                                 case IF_T:
2418                                 case MODULE0_T:
2419                                 case MODULE1_T:
2420                                 case MODULE2_T:
2421                                 case MODULE3_T:
2422                                 case MODULE4_T:
2423                                 case MODULE5_T:
2424                                 case MODULE6_T:
2425                                 case MODULEX_T:
2426                                 case SET_FWD_NO_CONNECT_T:
2427                                 case SET_RPL_NO_CONNECT_T:
2428                                 case SET_FWD_CLOSE_T:
2429                                 case SET_RPL_CLOSE_T:
2430                                         $$=$1;
2431                                         break;
2432                                 default:
2433                                         $$=0;
2434                                         yyerror("command not allowed in onsend_route\n");
2435                         }
2436                 } else {
2437                         $$=$1;
2438                 }
2439         }
2440         ;
2441 /*
2442 exp_stm:
2443         fcmd    { $$=$1; }
2444         | if_cmd        { $$=$1; }
2445         | assign_action { $$ = $1; }
2446         | LBRACE actions RBRACE { $$=$2; }
2447         ;
2448 */
2449 stm:
2450         action  { $$=$1; }
2451         | LBRACE actions RBRACE { $$=$2; }
2452         ;
2453 actions:
2454         actions action  {$$=append_action($1, $2); }
2455         | action        {$$=$1;}
2456         | actions error { $$=0; yyerror("bad command"); }
2457         ;
2458 action:
2459         fcmd SEMICOLON {$$=$1;}
2460         | if_cmd {$$=$1;}
2461         | switch_cmd {$$=$1;}
2462         | while_cmd { $$=$1; }
2463         | ret_cmd SEMICOLON { $$=$1; }
2464         | assign_action SEMICOLON {$$=$1;}
2465         | SEMICOLON /* null action */ {$$=0;}
2466         | fcmd error { $$=0; yyerror("bad command: missing ';'?"); }
2467         ;
2468 if_cmd:
2469         IF rval_expr stm        {
2470                 if ($2 && rval_expr_int_check($2)>=0){
2471                         warn_ct_rve($2, "if");
2472                         $$=mk_action( IF_T, 3, RVE_ST, $2, ACTIONS_ST, $3, NOSUBTYPE, 0);
2473                         set_cfg_pos($$);
2474                 }else
2475                         YYERROR;
2476         }
2477         | IF rval_expr stm ELSE stm     { 
2478                 if ($2 && rval_expr_int_check($2)>=0){
2479                         warn_ct_rve($2, "if");
2480                         $$=mk_action( IF_T, 3, RVE_ST, $2, ACTIONS_ST, $3, ACTIONS_ST, $5);
2481                         set_cfg_pos($$);
2482                 }else
2483                         YYERROR;
2484         }
2485         ;
2486
2487 ct_rval: rval_expr {
2488                         $$=0;
2489                         if ($1 && !rve_is_constant($1)){
2490                                 yyerror("constant expected");
2491                                 YYERROR;
2492                         /*
2493                         } else if ($1 &&
2494                                                 !rve_check_type((enum rval_type*)&i_tmp, $1, 0, 0 ,0)){
2495                                 yyerror("invalid expression (bad type)");
2496                         }else if ($1 && i_tmp!=RV_INT){
2497                                 yyerror("invalid expression type, int expected\n");
2498                         */
2499                         }else
2500                                 $$=$1;
2501                 }
2502 ;
2503 single_case:
2504         CASE ct_rval COLON actions {
2505                 $$=0;
2506                 if ($2==0) { yyerror ("bad case label"); YYERROR; }
2507                 else if ((($$=mk_case_stm($2, 0, $4, &i_tmp))==0) && (i_tmp==-10)){
2508                                 YYABORT;
2509                 }
2510         }
2511 | CASE SLASH ct_rval COLON actions {
2512                 $$=0;
2513                 if ($3==0) { yyerror ("bad case label"); YYERROR; }
2514                 else if ((($$=mk_case_stm($3, 1, $5, &i_tmp))==0) && (i_tmp==-10)){
2515                                 YYABORT;
2516                 }
2517         }
2518         | CASE ct_rval COLON {
2519                 $$=0;
2520                 if ($2==0) { yyerror ("bad case label"); YYERROR; }
2521                 else if ((($$=mk_case_stm($2, 0, 0, &i_tmp))==0) && (i_tmp==-10)){
2522                                 YYABORT;
2523                 }
2524         }
2525         | CASE SLASH ct_rval COLON {
2526                 $$=0;
2527                 if ($3==0) { yyerror ("bad regex case label"); YYERROR; }
2528                 else if ((($$=mk_case_stm($3, 1, 0, &i_tmp))==0) && (i_tmp==-10)){
2529                                 YYABORT;
2530                 }
2531         }
2532         | DEFAULT COLON actions {
2533                 if ((($$=mk_case_stm(0, 0, $3, &i_tmp))==0) && (i_tmp=-10)){
2534                                 YYABORT;
2535                 }
2536         }
2537         | DEFAULT COLON {
2538                 if ((($$=mk_case_stm(0, 0, 0, &i_tmp))==0) && (i_tmp==-10)){
2539                                 YYABORT;
2540                 }
2541         }
2542         | CASE error COLON actions { $$=0; yyerror("bad case label"); }
2543         | CASE SLASH error COLON actions { $$=0; yyerror("bad case regex label"); }
2544         | CASE error COLON { $$=0; yyerror("bad case label"); }
2545         | CASE SLASH error COLON { $$=0; yyerror("bad case regex label"); }
2546         | CASE ct_rval COLON error { $$=0; yyerror ("bad case body"); }
2547 ;
2548 case_stms:
2549         case_stms single_case {
2550                 $$=$1;
2551                 if ($2==0) yyerror ("bad case");
2552                 if ($$){
2553                         *($$->append)=$2;
2554                         if (*($$->append)!=0)
2555                                 $$->append=&((*($$->append))->next);
2556                 }
2557         }
2558         | single_case {
2559                 $$=$1;
2560                 if ($1==0) yyerror ("bad case");
2561                 else $$->append=&($$->next);
2562         }
2563 ;
2564 switch_cmd:
2565           SWITCH rval_expr LBRACE case_stms RBRACE { 
2566                 $$=0;
2567                 if ($2==0){
2568                         yyerror("bad expression in switch(...)");
2569                         YYERROR;
2570                 }else if ($4==0){
2571                         yyerror ("bad switch body");
2572                         YYERROR;
2573                 }else if (case_check_default($4)!=0){
2574                         yyerror_at(&$2->fpos, "bad switch(): too many "
2575                                                         "\"default:\" labels\n");
2576                         YYERROR;
2577                 }else if (case_check_type($4)!=0){
2578                         yyerror_at(&$2->fpos, "bad switch(): mixed integer and"
2579                                                         " string/RE cases not allowed\n");
2580                         YYERROR;
2581                 }else{
2582                         $$=mk_action(SWITCH_T, 2, RVE_ST, $2, CASE_ST, $4);
2583                         if ($$==0) {
2584                                 yyerror("internal error");
2585                                 YYABORT;
2586                         }
2587                         set_cfg_pos($$);
2588                 }
2589         }
2590         | SWITCH rval_expr LBRACE RBRACE {
2591                 $$=0;
2592                 warn("empty switch()");
2593                 if ($2==0){
2594                         yyerror("bad expression in switch(...)");
2595                         YYERROR;
2596                 }else{
2597                         /* it might have sideffects, so leave it for the optimizer */
2598                         $$=mk_action(SWITCH_T, 2, RVE_ST, $2, CASE_ST, 0);
2599                         if ($$==0) {
2600                                 yyerror("internal error");
2601                                 YYABORT;
2602                         }
2603                         set_cfg_pos($$);
2604                 }
2605         }
2606         | SWITCH error { $$=0; yyerror ("bad expression in switch(...)"); }
2607         | SWITCH rval_expr LBRACE error RBRACE 
2608                 {$$=0; yyerror ("bad switch body"); }
2609 ;
2610
2611 while_cmd:
2612         WHILE rval_expr stm {
2613                 if ($2 && rval_expr_int_check($2)>=0){
2614                         warn_ct_rve($2, "while");
2615                         $$=mk_action( WHILE_T, 2, RVE_ST, $2, ACTIONS_ST, $3);
2616                         set_cfg_pos($$);
2617                 }else{
2618                         yyerror_at(&$2->fpos, "bad while(...) expression");
2619                         YYERROR;
2620                 }
2621         }
2622 ;
2623
2624 /* class_id:
2625         LBRACK ATTR_USER RBRACK { $$ = AVP_CLASS_USER; }
2626         | LBRACK ATTR_DOMAIN RBRACK { $$ = AVP_CLASS_DOMAIN; }
2627         | LBRACK ATTR_GLOBAL RBRACK { $$ = AVP_CLASS_GLOBAL; }
2628         ;
2629 */
2630 select_param:
2631         ID {
2632                 if (sel.n >= MAX_SELECT_PARAMS-1) {
2633                         yyerror("Select identifier too long\n");
2634                 }
2635                 sel.params[sel.n].type = SEL_PARAM_STR;
2636                 sel.params[sel.n].v.s.s = $1;
2637                 sel.params[sel.n].v.s.len = strlen($1);
2638                 sel.n++;
2639         }
2640         | ID LBRACK intno RBRACK {
2641                 if (sel.n >= MAX_SELECT_PARAMS-2) {
2642                         yyerror("Select identifier too long\n");
2643                 }
2644                 sel.params[sel.n].type = SEL_PARAM_STR;
2645                 sel.params[sel.n].v.s.s = $1;
2646                 sel.params[sel.n].v.s.len = strlen($1);
2647                 sel.n++;
2648                 sel.params[sel.n].type = SEL_PARAM_INT;
2649                 sel.params[sel.n].v.i = $3;
2650                 sel.n++;
2651         }
2652         | ID LBRACK STRING RBRACK {
2653                 if (sel.n >= MAX_SELECT_PARAMS-2) {
2654                         yyerror("Select identifier too long\n");
2655                 }
2656                 sel.params[sel.n].type = SEL_PARAM_STR;
2657                 sel.params[sel.n].v.s.s = $1;
2658                 sel.params[sel.n].v.s.len = strlen($1);
2659                 sel.n++;
2660                 sel.params[sel.n].type = SEL_PARAM_STR;
2661                 sel.params[sel.n].v.s.s = $3;
2662                 sel.params[sel.n].v.s.len = strlen($3);
2663                 sel.n++;
2664         }
2665         ;
2666 select_params:
2667         select_params DOT select_param
2668         | select_param
2669         ;
2670 select_id:
2671         SELECT_MARK { sel.n = 0; sel.f[0] = 0; } select_params {
2672                 sel_ptr = (select_t*)pkg_malloc(sizeof(select_t));
2673                 if (!sel_ptr) {
2674                         yyerror("No memory left to allocate select structure\n");
2675                 }
2676                 memcpy(sel_ptr, &sel, sizeof(select_t));
2677                 $$ = sel_ptr;
2678         }
2679         ;
2680 attr_class_spec:
2681         ATTR_FROM { s_attr->type |= AVP_TRACK_FROM; }
2682         | ATTR_TO { s_attr->type |= AVP_TRACK_TO; }
2683         | ATTR_FROMURI { s_attr->type |= AVP_TRACK_FROM | AVP_CLASS_URI; }
2684         | ATTR_TOURI { s_attr->type |= AVP_TRACK_TO | AVP_CLASS_URI; }
2685         | ATTR_FROMUSER { s_attr->type |= AVP_TRACK_FROM | AVP_CLASS_USER; }
2686         | ATTR_TOUSER { s_attr->type |= AVP_TRACK_TO | AVP_CLASS_USER; }
2687         | ATTR_FROMDOMAIN { s_attr->type |= AVP_TRACK_FROM | AVP_CLASS_DOMAIN; }
2688         | ATTR_TODOMAIN { s_attr->type |= AVP_TRACK_TO | AVP_CLASS_DOMAIN; }
2689         | ATTR_GLOBAL { s_attr->type |= AVP_TRACK_ALL | AVP_CLASS_GLOBAL; }
2690         ;
2691 attr_name_spec:
2692         ID { s_attr->type |= AVP_NAME_STR; s_attr->name.s.s = $1; s_attr->name.s.len = strlen ($1); }
2693         ;
2694 attr_spec:
2695         attr_name_spec
2696         | attr_class_spec DOT attr_name_spec
2697         ;
2698 attr_mark:
2699         ATTR_MARK {
2700                 s_attr = (struct avp_spec*)pkg_malloc(sizeof(struct avp_spec));
2701                 if (!s_attr) { yyerror("No memory left"); YYABORT; }
2702                 else s_attr->type = 0;
2703         }
2704         ;
2705 attr_id:
2706         attr_mark attr_spec { $$ = s_attr; }
2707         ;
2708 attr_id_num_idx:
2709         attr_mark attr_spec LBRACK intno RBRACK {
2710                 s_attr->type|= (AVP_NAME_STR | ($4<0?AVP_INDEX_BACKWARD:AVP_INDEX_FORWARD));
2711                 s_attr->index = ($4<0?-$4:$4);
2712                 $$ = s_attr;
2713         }
2714         ;
2715 attr_id_no_idx:
2716         attr_mark attr_spec LBRACK RBRACK {
2717                 s_attr->type|= AVP_INDEX_ALL;
2718                 $$ = s_attr;
2719         }
2720         ;
2721 attr_id_ass:
2722         attr_id
2723         | attr_id_no_idx
2724         ;
2725 /*
2726 attr_id_val:
2727         attr_id
2728         | attr_id_num_idx
2729         ;
2730 */
2731 attr_id_any:
2732         attr_id
2733         | attr_id_no_idx
2734         | attr_id_num_idx
2735 ;
2736 attr_id_any_str:
2737         attr_id
2738         | avp_pvar {
2739                 if ($1->type==LV_AVP){
2740                         s_attr = pkg_malloc(sizeof(struct avp_spec));
2741                         if (!s_attr) { yyerror("No memory left"); YYABORT; }
2742                         else{
2743                                 *s_attr=$1->lv.avps;
2744                         }
2745                         $$=s_attr;
2746                 }else
2747                         $$=0; /* not an avp, a pvar */
2748                 pkg_free($1);
2749         }
2750         | STRING {
2751                 avp_spec_t *avp_spec;
2752                 str s;
2753                 int type, idx;
2754                 avp_spec = pkg_malloc(sizeof(*avp_spec));
2755                 if (!avp_spec) {
2756                         yyerror("Not enough memory");
2757                         YYABORT;
2758                 }
2759                 s.s = $1;
2760                 if (s.s[0] == '$')
2761                         s.s++;
2762                 s.len = strlen(s.s);
2763                 if (parse_avp_name(&s, &type, &avp_spec->name, &idx)) {
2764                         yyerror("error when parsing AVP");
2765                         pkg_free(avp_spec);
2766                         YYABORT;
2767                 }
2768                 avp_spec->type = type;
2769                 avp_spec->index = idx;
2770                 $$ = avp_spec;
2771         }
2772         ;
2773
2774 pvar:   PVAR {
2775                         pv_spec=pkg_malloc(sizeof(*pv_spec));
2776                         if (!pv_spec) {
2777                                 yyerror("Not enough memory");
2778                                 YYABORT;
2779                         }
2780                         memset(pv_spec, 0, sizeof(*pv_spec));
2781                         s_tmp.s=$1; s_tmp.len=strlen($1);
2782                         if (pv_parse_spec(&s_tmp, pv_spec)==0){
2783                                 yyerror("unknown script pseudo variable %s", $1 );
2784                                 pkg_free(pv_spec);
2785                                 pv_spec=0;
2786                                 YYABORT;
2787                         }
2788                         $$=pv_spec;
2789                 }
2790         ;
2791
2792 avp_pvar:       AVP_OR_PVAR {
2793                                 lval_tmp=pkg_malloc(sizeof(*lval_tmp));
2794                                 if (!lval_tmp) {
2795                                         yyerror("Not enough memory");
2796                                         YYABORT;
2797                                 }
2798                                 memset(lval_tmp, 0, sizeof(*lval_tmp));
2799                                 s_tmp.s=$1; s_tmp.len=strlen(s_tmp.s);
2800                                 if (pv_parse_spec2(&s_tmp, &lval_tmp->lv.pvs, 1)==0){
2801                                         /* not a pvar, try avps */
2802                                         /* lval_tmp might be partially filled by the failed
2803                                            pv_parse_spec2() (especially if the avp name is the
2804                                            same as a pv class) => clean it again */
2805                                         memset(lval_tmp, 0, sizeof(*lval_tmp));
2806                                         lval_tmp->lv.avps.type|= AVP_NAME_STR;
2807                                         lval_tmp->lv.avps.name.s.s = s_tmp.s+1;
2808                                         lval_tmp->lv.avps.name.s.len = s_tmp.len-1;
2809                                         lval_tmp->type=LV_AVP;
2810                                 }else{
2811                                         lval_tmp->type=LV_PVAR;
2812                                 }
2813                                 $$ = lval_tmp;
2814                                 DBG("parsed ambigous avp/pvar \"%.*s\" to %d\n",
2815                                                         s_tmp.len, s_tmp.s, lval_tmp->type);
2816                         }
2817         ;
2818
2819
2820 /*
2821 assign_op:
2822         ADDEQ { $$ = ADD_T; }
2823         | EQUAL { $$ = ASSIGN_T; }
2824         ;
2825 */
2826 assign_op:
2827         EQUAL { $$ = ASSIGN_T; }
2828         ;
2829
2830
2831 lval: attr_id_ass {
2832                                         lval_tmp=pkg_malloc(sizeof(*lval_tmp));
2833                                         if (!lval_tmp) {
2834                                                 yyerror("Not enough memory");
2835                                                 YYABORT;
2836                                         }
2837                                         lval_tmp->type=LV_AVP; lval_tmp->lv.avps=*$1;
2838                                         pkg_free($1); /* free the avp spec we just copied */
2839                                         $$=lval_tmp;
2840                                 }
2841         | pvar        {
2842                                         if (!pv_is_w($1))
2843                                                 yyerror("read only pvar in assignment left side");
2844                                         if ($1->trans!=0)
2845                                                 yyerror("pvar with transformations in assignment"
2846                                                                 " left side");
2847                                         lval_tmp=pkg_malloc(sizeof(*lval_tmp));
2848                                         if (!lval_tmp) {
2849                                                 yyerror("Not enough memory");
2850                                                 YYABORT;
2851                                         }
2852                                         lval_tmp->type=LV_PVAR; lval_tmp->lv.pvs=*($1);
2853                                         pkg_free($1); /* free the pvar spec we just copied */
2854                                         $$=lval_tmp;
2855                                 }
2856         | avp_pvar    {
2857                                         if (($1)->type==LV_PVAR){
2858                                                 if (!pv_is_w(&($1)->lv.pvs))
2859                                                         yyerror("read only pvar in assignment left side");
2860                                                 if ($1->lv.pvs.trans!=0)
2861                                                         yyerror("pvar with transformations in assignment"
2862                                                                         " left side");
2863                                         }
2864                                         $$=$1;
2865                                 }
2866         ;
2867
2868 rval: intno                     {$$=mk_rve_rval(RV_INT, (void*)$1); }
2869         | STRING                        {       s_tmp.s=$1; s_tmp.len=strlen($1);
2870                                                         $$=mk_rve_rval(RV_STR, &s_tmp); }
2871         | attr_id_any           {$$=mk_rve_rval(RV_AVP, $1); pkg_free($1); }
2872         | pvar                          {$$=mk_rve_rval(RV_PVAR, $1); pkg_free($1); }
2873         | avp_pvar                      {
2874                                                         switch($1->type){
2875                                                                 case LV_AVP:
2876                                                                         $$=mk_rve_rval(RV_AVP, &$1->lv.avps);
2877                                                                         break;
2878                                                                 case LV_PVAR:
2879                                                                         $$=mk_rve_rval(RV_PVAR, &$1->lv.pvs);
2880                                                                         break;
2881                                                                 default:
2882                                                                         yyerror("BUG: invalid lvalue type ");
2883                                                                         YYABORT;
2884                                                         }
2885                                                         pkg_free($1); /* not needed anymore */
2886                                                 }
2887         | select_id                     {$$=mk_rve_rval(RV_SEL, $1); pkg_free($1); }
2888         | fcmd                          {$$=mk_rve_rval(RV_ACTION_ST, $1); }
2889         | exp_elem { $$=mk_rve_rval(RV_BEXPR, $1); }
2890         | LBRACE actions RBRACE {$$=mk_rve_rval(RV_ACTION_ST, $2); }
2891         | LBRACE error RBRACE   { $$=0; yyerror("bad command block"); }
2892         | LPAREN assign_action RPAREN   {$$=mk_rve_rval(RV_ACTION_ST, $2); }
2893         | LPAREN error RPAREN   { $$=0; yyerror("bad expression"); }
2894         ;
2895
2896
2897 rve_un_op: NOT  { $$=RVE_LNOT_OP; }
2898                 |  BIN_NOT      { $$=RVE_BNOT_OP; }
2899                 |  MINUS %prec UNARY    { $$=RVE_UMINUS_OP; }
2900                 /* TODO: RVE_BOOL_OP, RVE_NOT_OP? */
2901         ;
2902
2903 /*
2904 rve_op:         PLUS            { $$=RVE_PLUS_OP; }
2905                 |       MINUS           { $$=RVE_MINUS_OP; }
2906                 |       STAR            { $$=RVE_MUL_OP; }
2907                 |       SLASH           { $$=RVE_DIV_OP; }
2908                 |       MODULO          { $$=RVE_MOD_OP; }
2909         ;
2910 */
2911
2912 rval_expr: rval                                         { $$=$1;
2913                                                                                 if ($$==0){
2914                                                                                         /*yyerror("out of memory\n");*/
2915                                                                                         YYERROR;
2916                                                                                 }
2917                                                                         }
2918                 | rve_un_op rval_expr %prec UNARY       {$$=mk_rve1($1, $2); }
2919                 | INTCAST rval_expr                             {$$=mk_rve1(RVE_INT_OP, $2); }
2920                 | STRCAST rval_expr                             {$$=mk_rve1(RVE_STR_OP, $2); }
2921                 | rval_expr PLUS rval_expr              {$$=mk_rve2(RVE_PLUS_OP, $1, $3); }
2922                 | rval_expr MINUS rval_expr             {$$=mk_rve2(RVE_MINUS_OP, $1, $3); }
2923                 | rval_expr STAR rval_expr              {$$=mk_rve2(RVE_MUL_OP, $1, $3); }
2924                 | rval_expr SLASH rval_expr             {$$=mk_rve2(RVE_DIV_OP, $1, $3); }
2925                 | rval_expr MODULO rval_expr    {$$=mk_rve2(RVE_MOD_OP, $1, $3); }
2926                 | rval_expr BIN_OR rval_expr    {$$=mk_rve2(RVE_BOR_OP, $1,  $3); }
2927                 | rval_expr BIN_AND rval_expr   {$$=mk_rve2(RVE_BAND_OP, $1,  $3);}
2928                 | rval_expr BIN_XOR rval_expr   {$$=mk_rve2(RVE_BXOR_OP, $1,  $3);}
2929                 | rval_expr BIN_LSHIFT rval_expr {$$=mk_rve2(RVE_BLSHIFT_OP, $1,  $3);}
2930                 | rval_expr BIN_RSHIFT rval_expr {$$=mk_rve2(RVE_BRSHIFT_OP, $1,  $3);}
2931                 | rval_expr rve_cmpop rval_expr %prec GT { $$=mk_rve2( $2, $1, $3);}
2932                 | rval_expr rve_equalop rval_expr %prec EQUAL_T
2933                         { $$=mk_rve2( $2, $1, $3);}
2934                 | rval_expr LOG_AND rval_expr   { $$=mk_rve2(RVE_LAND_OP, $1, $3);}
2935                 | rval_expr LOG_OR rval_expr    { $$=mk_rve2(RVE_LOR_OP, $1, $3);}
2936                 | LPAREN rval_expr RPAREN               { $$=$2;}
2937                 | STRLEN LPAREN rval_expr RPAREN { $$=mk_rve1(RVE_STRLEN_OP, $3);}
2938                 | STREMPTY LPAREN rval_expr RPAREN {$$=mk_rve1(RVE_STREMPTY_OP, $3);}
2939                 | DEFINED rval_expr                             { $$=mk_rve1(RVE_DEFINED_OP, $2);}
2940                 | rve_un_op error %prec UNARY           { $$=0; yyerror("bad expression"); }
2941                 | INTCAST error                                 { $$=0; yyerror("bad expression"); }
2942                 | STRCAST error                                 { $$=0; yyerror("bad expression"); }
2943                 | rval_expr PLUS error                  { $$=0; yyerror("bad expression"); }
2944                 | rval_expr MINUS error                 { $$=0; yyerror("bad expression"); }
2945                 | rval_expr STAR error                  { $$=0; yyerror("bad expression"); }
2946                 | rval_expr SLASH error                 { $$=0; yyerror("bad expression"); }
2947                 | rval_expr MODULO error                        { $$=0; yyerror("bad expression"); }
2948                 | rval_expr BIN_OR error                { $$=0; yyerror("bad expression"); }
2949                 | rval_expr BIN_AND error               { $$=0; yyerror("bad expression"); }
2950                 | rval_expr rve_cmpop error %prec GT
2951                         { $$=0; yyerror("bad expression"); }
2952                 | rval_expr rve_equalop error %prec EQUAL_T
2953                         { $$=0; yyerror("bad expression"); }
2954                 | rval_expr LOG_AND error               { $$=0; yyerror("bad expression"); }
2955                 | rval_expr LOG_OR error                { $$=0; yyerror("bad expression"); }
2956                 | STRLEN LPAREN error RPAREN    { $$=0; yyerror("bad expression"); }
2957                 | STREMPTY LPAREN error RPAREN  { $$=0; yyerror("bad expression"); }
2958                 | DEFINED error                                 { $$=0; yyerror("bad expression"); }
2959                 ;
2960
2961 assign_action: lval assign_op  rval_expr        { $$=mk_action($2, 2, LVAL_ST, $1, 
2962                                                                                                                           RVE_ST, $3);
2963                                                                                         set_cfg_pos($$);
2964                                                                                 }
2965         ;
2966
2967 /*
2968 assign_action:
2969         attr_id_ass assign_op STRING  { $$=mk_action($2, 2, AVP_ST, $1, STRING_ST, $3); }
2970         | attr_id_ass assign_op NUMBER  { $$=mk_action($2, 2, AVP_ST, $1, NUMBER_ST, (void*)$3); }
2971         | attr_id_ass assign_op fcmd    { $$=mk_action($2, 2, AVP_ST, $1, ACTION_ST, $3); }
2972         | attr_id_ass assign_op attr_id_any { $$=mk_action($2, 2, AVP_ST, $1, AVP_ST, $3); }
2973         | attr_id_ass assign_op select_id { $$=mk_action($2, 2, AVP_ST, (void*)$1, SELECT_ST, (void*)$3); }
2974         | attr_id_ass assign_op LPAREN exp RPAREN { $$ = mk_action($2, 2, AVP_ST, $1, EXPR_ST, $4); }
2975         ;
2976 */
2977
2978 avpflag_oper:
2979         SETAVPFLAG { $$ = 1; }
2980         | RESETAVPFLAG { $$ = 0; }
2981         | ISAVPFLAGSET { $$ = -1; }
2982         ;
2983 cmd:
2984         FORWARD LPAREN RPAREN { $$=mk_action(FORWARD_T, 2, URIHOST_ST, 0, URIPORT_ST, 0); set_cfg_pos($$); }
2985         | FORWARD LPAREN host RPAREN    { $$=mk_action( FORWARD_T, 2, STRING_ST, $3, NUMBER_ST, 0); set_cfg_pos($$); }
2986         | FORWARD LPAREN STRING RPAREN  { $$=mk_action( FORWARD_T, 2, STRING_ST, $3, NUMBER_ST, 0); set_cfg_pos($$); }
2987         | FORWARD LPAREN ip RPAREN      { $$=mk_action( FORWARD_T, 2, IP_ST, (void*)$3, NUMBER_ST, 0); set_cfg_pos($$); }
2988         | FORWARD LPAREN host COMMA NUMBER RPAREN { $$=mk_action(FORWARD_T, 2, STRING_ST, $3, NUMBER_ST, (void*)$5); set_cfg_pos($$); }
2989         | FORWARD LPAREN STRING COMMA NUMBER RPAREN {$$=mk_action(FORWARD_T, 2, STRING_ST, $3, NUMBER_ST, (void*)$5); set_cfg_pos($$); }
2990         | FORWARD LPAREN ip COMMA NUMBER RPAREN { $$=mk_action(FORWARD_T, 2, IP_ST, (void*)$3, NUMBER_ST, (void*)$5); set_cfg_pos($$); }
2991         | FORWARD LPAREN URIHOST COMMA URIPORT RPAREN { $$=mk_action(FORWARD_T, 2, URIHOST_ST, 0, URIPORT_ST, 0); set_cfg_pos($$); }
2992         | FORWARD LPAREN URIHOST COMMA NUMBER RPAREN {$$=mk_action(FORWARD_T, 2, URIHOST_ST, 0, NUMBER_ST, (void*)$5); set_cfg_pos($$); }
2993         | FORWARD LPAREN URIHOST RPAREN { $$=mk_action(FORWARD_T, 2, URIHOST_ST, 0, NUMBER_ST, 0); set_cfg_pos($$); }
2994         | FORWARD error { $$=0; yyerror("missing '(' or ')' ?"); }
2995         | FORWARD LPAREN error RPAREN { $$=0; yyerror("bad forward argument"); }
2996         | FORWARD_UDP LPAREN host RPAREN        { $$=mk_action(FORWARD_UDP_T, 2, STRING_ST, $3, NUMBER_ST, 0); set_cfg_pos($$); }
2997         | FORWARD_UDP LPAREN STRING RPAREN      { $$=mk_action(FORWARD_UDP_T, 2, STRING_ST, $3, NUMBER_ST, 0); set_cfg_pos($$); }
2998         | FORWARD_UDP LPAREN ip RPAREN  { $$=mk_action(FORWARD_UDP_T, 2, IP_ST, (void*)$3, NUMBER_ST, 0); set_cfg_pos($$); }
2999         | FORWARD_UDP LPAREN host COMMA NUMBER RPAREN { $$=mk_action(FORWARD_UDP_T, 2, STRING_ST, $3, NUMBER_ST, (void*)$5); set_cfg_pos($$); }
3000         | FORWARD_UDP LPAREN STRING COMMA NUMBER RPAREN {$$=mk_action(FORWARD_UDP_T, 2, STRING_ST, $3, NUMBER_ST, (void*)$5); set_cfg_pos($$); }
3001         | FORWARD_UDP LPAREN ip COMMA NUMBER RPAREN { $$=mk_action(FORWARD_UDP_T, 2, IP_ST, (void*)$3, NUMBER_ST, (void*)$5); set_cfg_pos($$); }
3002         | FORWARD_UDP LPAREN URIHOST COMMA URIPORT RPAREN {$$=mk_action(FORWARD_UDP_T, 2, URIHOST_ST, 0, URIPORT_ST, 0); set_cfg_pos($$); }
3003         | FORWARD_UDP LPAREN URIHOST COMMA NUMBER RPAREN { $$=mk_action(FORWARD_UDP_T, 2, URIHOST_ST, 0, NUMBER_ST, (void*)$5); set_cfg_pos($$); }
3004         | FORWARD_UDP LPAREN URIHOST RPAREN { $$=mk_action(FORWARD_UDP_T, 2, URIHOST_ST, 0, NUMBER_ST, 0); set_cfg_pos($$); }
3005         | FORWARD_UDP error { $$=0; yyerror("missing '(' or ')' ?"); }
3006         | FORWARD_UDP LPAREN error RPAREN { $$=0; yyerror("bad forward_udp argument"); }
3007         | FORWARD_TCP LPAREN host RPAREN        { $$=mk_action(FORWARD_TCP_T, 2, STRING_ST, $3, NUMBER_ST, 0); set_cfg_pos($$); }
3008         | FORWARD_TCP LPAREN STRING RPAREN      { $$=mk_action(FORWARD_TCP_T, 2, STRING_ST, $3, NUMBER_ST, 0); set_cfg_pos($$); }
3009         | FORWARD_TCP LPAREN ip RPAREN  { $$=mk_action(FORWARD_TCP_T, 2, IP_ST, (void*)$3, NUMBER_ST, 0); set_cfg_pos($$); }
3010         | FORWARD_TCP LPAREN host COMMA NUMBER RPAREN { $$=mk_action(FORWARD_TCP_T, 2, STRING_ST, $3, NUMBER_ST, (void*)$5); set_cfg_pos($$); }
3011         | FORWARD_TCP LPAREN STRING COMMA NUMBER RPAREN {$$=mk_action(FORWARD_TCP_T, 2, STRING_ST, $3, NUMBER_ST, (void*)$5); set_cfg_pos($$); }
3012         | FORWARD_TCP LPAREN ip COMMA NUMBER RPAREN { $$=mk_action(FORWARD_TCP_T, 2, IP_ST, (void*)$3, NUMBER_ST, (void*)$5); set_cfg_pos($$); }
3013         | FORWARD_TCP LPAREN URIHOST COMMA URIPORT RPAREN {$$=mk_action(FORWARD_TCP_T, 2, URIHOST_ST, 0, URIPORT_ST, 0); set_cfg_pos($$); }
3014         | FORWARD_TCP LPAREN URIHOST COMMA NUMBER RPAREN { $$=mk_action(FORWARD_TCP_T, 2, URIHOST_ST, 0, NUMBER_ST, (void*)$5); set_cfg_pos($$); }
3015         | FORWARD_TCP LPAREN URIHOST RPAREN { $$=mk_action(FORWARD_TCP_T, 2, URIHOST_ST, 0, NUMBER_ST, 0); set_cfg_pos($$); }
3016         | FORWARD_TCP error { $$=0; yyerror("missing '(' or ')' ?"); }
3017         | FORWARD_TCP LPAREN error RPAREN { $$=0; yyerror("bad forward_tcp argument"); }
3018         | FORWARD_TLS LPAREN host RPAREN {
3019                 #ifdef USE_TLS
3020                         $$=mk_action(FORWARD_TLS_T, 2, STRING_ST, $3, NUMBER_ST, 0); set_cfg_pos($$);
3021                 #else
3022                         $$=0;
3023                         yyerror("tls support not compiled in");
3024                 #endif
3025         }
3026         | FORWARD_TLS LPAREN STRING RPAREN {
3027                 #ifdef USE_TLS
3028                         $$=mk_action(FORWARD_TLS_T, 2, STRING_ST, $3, NUMBER_ST, 0); set_cfg_pos($$);
3029                 #else
3030                         $$=0;
3031                         yyerror("tls support not compiled in");
3032                 #endif
3033         }
3034         | FORWARD_TLS LPAREN ip RPAREN  {
3035                 #ifdef USE_TLS
3036                         $$=mk_action(FORWARD_TLS_T, 2, IP_ST, (void*)$3, NUMBER_ST, 0); set_cfg_pos($$);
3037                 #else
3038                         $$=0;
3039                         yyerror("tls support not compiled in");
3040                 #endif
3041         }
3042         | FORWARD_TLS LPAREN host COMMA NUMBER RPAREN {
3043                 #ifdef USE_TLS
3044                         $$=mk_action(FORWARD_TLS_T, 2, STRING_ST, $3, NUMBER_ST, (void*)$5); set_cfg_pos($$);
3045                 #else
3046                         $$=0;
3047                         yyerror("tls support not compiled in");
3048                 #endif
3049         }
3050         | FORWARD_TLS LPAREN STRING COMMA NUMBER RPAREN {
3051                 #ifdef USE_TLS
3052                         $$=mk_action(FORWARD_TLS_T, 2, STRING_ST, $3, NUMBER_ST, (void*)$5); set_cfg_pos($$);
3053                 #else
3054                         $$=0;
3055                         yyerror("tls support not compiled in");
3056                 #endif
3057         }
3058         | FORWARD_TLS LPAREN ip COMMA NUMBER RPAREN {
3059                 #ifdef USE_TLS
3060                         $$=mk_action(FORWARD_TLS_T, 2, IP_ST, (void*)$3, NUMBER_ST, (void*)$5); set_cfg_pos($$);
3061                 #else
3062                         $$=0;
3063                         yyerror("tls support not compiled in");
3064                 #endif
3065                                         }
3066         | FORWARD_TLS LPAREN URIHOST COMMA URIPORT RPAREN {
3067                 #ifdef USE_TLS
3068                         $$=mk_action(FORWARD_TLS_T, 2, URIHOST_ST, 0, URIPORT_ST, 0); set_cfg_pos($$);
3069                 #else
3070                         $$=0;
3071                         yyerror("tls support not compiled in");
3072                 #endif
3073         }
3074         | FORWARD_TLS LPAREN URIHOST COMMA NUMBER RPAREN {
3075                 #ifdef USE_TLS
3076                         $$=mk_action(FORWARD_TLS_T, 2, URIHOST_ST, 0, NUMBER_ST, (void*)$5); set_cfg_pos($$);
3077                 #else
3078                         $$=0;
3079                         yyerror("tls support not compiled in");
3080                 #endif
3081         }
3082         | FORWARD_TLS LPAREN URIHOST RPAREN {
3083                 #ifdef USE_TLS
3084                         $$=mk_action(FORWARD_TLS_T, 2, URIHOST_ST, 0, NUMBER_ST, 0); set_cfg_pos($$);
3085                 #else
3086                         $$=0;
3087                         yyerror("tls support not compiled in");
3088                 #endif
3089         }
3090         | FORWARD_TLS error { $$=0; yyerror("missing '(' or ')' ?"); }
3091         | FORWARD_TLS LPAREN error RPAREN { $$=0; 
3092                                                                         yyerror("bad forward_tls argument"); }
3093         | FORWARD_SCTP LPAREN host RPAREN {
3094                 #ifdef USE_SCTP
3095                         $$=mk_action(FORWARD_SCTP_T, 2, STRING_ST, $3, NUMBER_ST, 0); set_cfg_pos($$);
3096                 #else
3097                         $$=0;
3098                         yyerror("sctp support not compiled in");
3099                 #endif
3100         }
3101         | FORWARD_SCTP LPAREN STRING RPAREN {
3102                 #ifdef USE_SCTP
3103                         $$=mk_action(FORWARD_SCTP_T, 2, STRING_ST, $3, NUMBER_ST, 0); set_cfg_pos($$);
3104                 #else
3105                         $$=0;
3106                         yyerror("sctp support not compiled in");
3107                 #endif
3108         }
3109         | FORWARD_SCTP LPAREN ip RPAREN {
3110                 #ifdef USE_SCTP
3111                         $$=mk_action(FORWARD_SCTP_T, 2, IP_ST, (void*)$3, NUMBER_ST, 0); set_cfg_pos($$);
3112                 #else
3113                         $$=0;
3114                         yyerror("sctp support not compiled in");
3115                 #endif
3116         }
3117         | FORWARD_SCTP LPAREN host COMMA NUMBER RPAREN {
3118                 #ifdef USE_SCTP
3119                         $$=mk_action(FORWARD_SCTP_T, 2, STRING_ST, $3, NUMBER_ST,
3120                                                         (void*)$5); set_cfg_pos($$);
3121                 #else
3122                         $$=0;
3123                         yyerror("sctp support not compiled in");
3124                 #endif
3125         }
3126         | FORWARD_SCTP LPAREN STRING COMMA NUMBER RPAREN {
3127                 #ifdef USE_SCTP
3128                         $$=mk_action(FORWARD_SCTP_T, 2, STRING_ST, $3, NUMBER_ST,
3129                                                         (void*)$5); set_cfg_pos($$);
3130                 #else
3131                         $$=0;
3132                         yyerror("sctp support not compiled in");
3133                 #endif
3134         }
3135         | FORWARD_SCTP LPAREN ip COMMA NUMBER RPAREN {
3136                 #ifdef USE_SCTP
3137                         $$=mk_action(FORWARD_SCTP_T, 2, IP_ST, (void*)$3, NUMBER_ST, 
3138                                                         (void*)$5); set_cfg_pos($$);
3139                 #else
3140                         $$=0;
3141                         yyerror("sctp support not compiled in");
3142                 #endif
3143                                         }
3144         | FORWARD_SCTP LPAREN URIHOST COMMA URIPORT RPAREN {
3145                 #ifdef USE_SCTP
3146                         $$=mk_action(FORWARD_SCTP_T, 2, URIHOST_ST, 0, URIPORT_ST, 0); set_cfg_pos($$);
3147                 #else
3148                         $$=0;
3149                         yyerror("sctp support not compiled in");
3150                 #endif
3151         }
3152         | FORWARD_SCTP LPAREN URIHOST COMMA NUMBER RPAREN {
3153                 #ifdef USE_SCTP
3154                         $$=mk_action(FORWARD_SCTP_T, 2, URIHOST_ST, 0, NUMBER_ST,