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