6 * Copyright (C) 2001-2003 FhG Fokus
8 * This file is part of ser, a free SIP server.
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
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:
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.
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
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
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
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
77 * 2006-10-13 added STUN_ALLOW_STUN, STUN_ALLOW_FP, STUN_REFRESH_INTERVAL
79 * 2007-02-09 separated command needed for tls-in-core and for tls in general
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)
111 #include <sys/types.h>
112 #include <sys/socket.h>
113 #include <netinet/in.h>
114 #include <arpa/inet.h>
117 #include "route_struct.h"
120 #include "shm_init.h"
125 #include "sr_module.h"
126 #include "modparam.h"
129 #include "socket_info.h"
130 #include "name_alias.h"
135 #include "tcp_init.h"
136 #include "tcp_options.h"
137 #include "sctp_options.h"
141 #include "sr_compat.h"
142 #include "msg_translator.h"
145 #include "cfg_core.h"
148 #include "tls/tls_config.h"
150 #include "timer_ticks.h"
156 /* hack to avoid alloca usage in the generated C file (needed for compiler
157 with no built in alloca, like icc*/
160 #define onsend_check(s) \
162 if (rt!=ONSEND_ROUTE) yyerror( s " allowed only in onsend_routes");\
167 #define IF_DNS_CACHE(x) x
169 #define IF_DNS_CACHE(x) warn("dns cache support not compiled in")
172 #ifdef USE_DNS_FAILOVER
173 #define IF_DNS_FAILOVER(x) x
175 #define IF_DNS_FAILOVER(x) warn("dns failover support not compiled in")
179 #define IF_NAPTR(x) x
181 #define IF_NAPTR(x) warn("dns naptr support not compiled in")
184 #ifdef USE_DST_BLACKLIST
185 #define IF_DST_BLACKLIST(x) x
187 #define IF_DST_BLACKLIST(x) warn("dst blacklist support not compiled in")
193 #define IF_STUN(x) warn("stun support not compiled in")
199 #define IF_SCTP(x) warn("sctp support not compiled in")
204 /* safer then using yytext which can be array or pointer */
205 extern char* yy_number_str;
207 static void yyerror(char* s, ...);
208 static void yyerror_at(struct cfg_pos* pos, char* s, ...);
211 static unsigned u_tmp;
212 static struct socket_id* lst_tmp;
213 static struct name_lst* nl_tmp;
214 static int rt; /* Type of route block for find_export */
217 static struct ip_addr* ip_tmp;
218 static struct avp_spec* s_attr;
220 static select_t* sel_ptr;
221 static pv_spec_t* pv_spec;
222 static struct action *mod_func_action;
223 static struct lvalue* lval_tmp;
224 static struct rvalue* rval_tmp;
226 static void warn(char* s, ...);
227 static void warn_at(struct cfg_pos* pos, char* s, ...);
228 static void get_cpos(struct cfg_pos* pos);
229 static struct rval_expr* mk_rve_rval(enum rval_type, void* v);
230 static struct rval_expr* mk_rve1(enum rval_expr_op op, struct rval_expr* rve1);
231 static struct rval_expr* mk_rve2(enum rval_expr_op op, struct rval_expr* rve1,
232 struct rval_expr* rve2);
233 static int rval_expr_int_check(struct rval_expr *rve);
234 static int warn_ct_rve(struct rval_expr *rve, char* name);
235 static struct socket_id* mk_listen_id(char*, int, int);
236 static struct name_lst* mk_name_lst(char* name, int flags);
237 static struct socket_id* mk_listen_id2(struct name_lst*, int, int);
238 static void free_name_lst(struct name_lst* lst);
239 static void free_socket_id_lst(struct socket_id* i);
241 static struct case_stms* mk_case_stm(struct rval_expr* ct, int is_re,
242 struct action* a, int* err);
243 static int case_check_type(struct case_stms* stms);
244 static int case_check_default(struct case_stms* stms);
245 static int mod_f_params_pre_fixup(struct action* a);
246 static void free_mod_func_action(struct action* a);
251 extern int startcolumn;
252 extern int startline;
255 #define set_cfg_pos(x) \
259 (x)->cfile = (finame!=0)?finame:((cfg_file!=0)?cfg_file:"default");\
271 struct action* action;
272 struct case_stms* case_stms;
274 struct ip_addr* ipaddr;
275 struct socket_id* sockid;
276 struct name_lst* name_l;
277 struct avp_spec* attr;
278 struct _pv_spec* pvar;
281 struct rval_expr* rv_expr;
311 %token SET_HOSTPORTTRANS
323 %token ADD_LOCAL_RPORT
324 %token FORCE_TCP_ALIAS
326 %token UDP_MTU_TRY_PROTO
329 %token SET_ADV_ADDRESS
331 %token FORCE_SEND_SOCKET
332 %token SET_FWD_NO_CONNECT
333 %token SET_RPL_NO_CONNECT
380 %token SR_AUTO_ALIASES
392 %token DNS_SERVERS_NO
393 %token DNS_USE_SEARCH
394 %token DNS_SEARCH_FMATCH
395 %token DNS_CACHE_INIT
397 %token DNS_USE_FAILOVER
398 %token DNS_CACHE_FLAGS
399 %token DNS_CACHE_NEG_TTL
400 %token DNS_CACHE_MIN_TTL
401 %token DNS_CACHE_MAX_TTL
403 %token DNS_CACHE_GC_INT
404 %token DNS_CACHE_DEL_NONEXP
410 %token DST_BLST_GC_INT
411 %token DST_BLST_UDP_IMASK
412 %token DST_BLST_TCP_IMASK
413 %token DST_BLST_TLS_IMASK
414 %token DST_BLST_SCTP_IMASK
426 %token SERVER_SIGNATURE
428 %token USER_AGENT_HEADER
440 %token TCP_ACCEPT_ALIASES
442 %token TCP_CONNECT_TIMEOUT
443 %token TCP_SEND_TIMEOUT
444 %token TCP_CON_LIFETIME
445 %token TCP_POLL_METHOD
446 %token TCP_MAX_CONNECTIONS
447 %token TCP_NO_CONNECT
448 %token TCP_SOURCE_IPV4
449 %token TCP_SOURCE_IPV6
450 %token TCP_OPT_FD_CACHE
451 %token TCP_OPT_BUF_WRITE
452 %token TCP_OPT_CONN_WQ_MAX
453 %token TCP_OPT_WQ_MAX
454 %token TCP_OPT_RD_BUF
455 %token TCP_OPT_WQ_BLK
456 %token TCP_OPT_DEFER_ACCEPT
457 %token TCP_OPT_DELAYED_ACK
458 %token TCP_OPT_SYNCNT
459 %token TCP_OPT_LINGER2
460 %token TCP_OPT_KEEPALIVE
461 %token TCP_OPT_KEEPIDLE
462 %token TCP_OPT_KEEPINTVL
463 %token TCP_OPT_KEEPCNT
464 %token TCP_OPT_CRLF_PING
470 %token TLS_HANDSHAKE_TIMEOUT
471 %token TLS_SEND_TIMEOUT
477 %token TLS_REQUIRE_CERTIFICATE
478 %token TLS_CERTIFICATE
479 %token TLS_PRIVATE_KEY
484 %token SCTP_SOCKET_RCVBUF
485 %token SCTP_SOCKET_SNDBUF
486 %token SCTP_AUTOCLOSE
488 %token SCTP_SEND_RETRIES
489 %token SCTP_ASSOC_TRACKING
490 %token SCTP_ASSOC_REUSE
491 %token SCTP_MAX_ASSOCS
492 %token SCTP_SRTO_INITIAL
495 %token SCTP_ASOCMAXRXT
496 %token SCTP_INIT_MAX_ATTEMPTS
497 %token SCTP_INIT_MAX_TIMEO
498 %token SCTP_HBINTERVAL
499 %token SCTP_PATHMAXRXT
500 %token SCTP_SACK_DELAY
501 %token SCTP_SACK_FREQ
502 %token SCTP_MAX_BURST
503 %token ADVERTISED_ADDRESS
504 %token ADVERTISED_PORT
508 %token SHM_FORCE_ALLOC
513 %token RT_TIMER1_PRIO
514 %token RT_TIMER1_POLICY
515 %token RT_TIMER2_PRIO
516 %token RT_TIMER2_POLICY
517 %token MCAST_LOOPBACK
520 %token PMTU_DISCOVERY
523 %token CFG_DESCRIPTION
537 %token ATTR_FROMDOMAIN
543 %token STUN_REFRESH_INTERVAL
544 %token STUN_ALLOW_STUN
548 /* operators, C like precedence */
554 %left EQUAL_T DIFF MATCH INTEQ INTDIFF STREQ STRDIFF
557 %left STAR SLASH MODULO
560 %right INTCAST STRCAST
563 /* no precedence, they use () */
568 %token <intval> NUMBER
570 %token <strval> NUM_ID
571 %token <strval> STRING
572 %token <strval> IPV6ADDR
574 /* not clear yet if this is an avp or pvar */
575 %token <strval> AVP_OR_PVAR
576 %token <strval> EVENT_RT_NAME
592 /*%type <expr> exp */
593 %type <expr> exp_elem
594 %type <intval> intno eint_op eint_op_onsend
595 %type <intval> eip_op eip_op_onsend
596 %type <action> action actions cmd fcmd if_cmd stm /*exp_stm*/ assign_action
597 %type <action> switch_cmd while_cmd ret_cmd
598 %type <case_stms> single_case case_stms
599 %type <ipaddr> ipv4 ipv6 ipv6addr ip
601 %type <strval> host host_or_if host_if_id
602 %type <strval> listen_id
603 %type <name_l> listen_id_lst
604 %type <name_l> listen_id2
605 %type <sockid> id_lst
606 %type <sockid> phostport
607 %type <sockid> listen_phostport
608 %type <intval> proto port
609 %type <intval> equalop strop cmpop rve_cmpop rve_equalop
610 %type <intval> uri_type
612 %type <attr> attr_id_num_idx
613 %type <attr> attr_id_no_idx
614 %type <attr> attr_id_ass
615 /*%type <attr> attr_id_val*/
616 %type <attr> attr_id_any
617 %type <attr> attr_id_any_str
620 %type <rv_expr> rval rval_expr ct_rval
621 %type <lval> avp_pvar
622 /* %type <intval> class_id */
623 %type <intval> assign_op
624 %type <select> select_id
625 %type <strval> flag_name;
626 %type <strval> route_name;
627 %type <intval> avpflag_oper
628 %type <intval> rve_un_op
629 %type <strval> cfg_var_id
630 /* %type <intval> rve_op */
632 /*%type <route_el> rules;
633 %type <route_el> rule;
643 statements statement {}
645 | statements error { yyerror(""); YYABORT;}
652 | {rt=REQUEST_ROUTE;} route_stm
653 | {rt=FAILURE_ROUTE;} failure_route_stm
655 | {rt=BRANCH_ROUTE;} branch_route_stm
656 | {rt=ONSEND_ROUTE;} send_route_stm
657 | {rt=EVENT_ROUTE;} event_route_stm
658 | SEMICOLON /* null statement */
659 | CR /* null statement*/
666 LOG(L_CRIT, "ERROR: cfg. parser: bad ip "
670 $$=pkg_malloc(strlen(tmp)+1);
672 LOG(L_CRIT, "ERROR: cfg. parser: out of "
675 strncpy($$, tmp, strlen(tmp)+1);
681 $$=pkg_malloc(strlen($1)+1);
683 LOG(L_CRIT, "ERROR: cfg. parser: out of "
686 strncpy($$, $1, strlen($1)+1);
691 $$=pkg_malloc(strlen($1)+1);
693 LOG(L_CRIT, "ERROR: cfg. parser: out of "
696 strncpy($$, $1, strlen($1)+1);
704 listen_id { $$=mk_name_lst($1, SI_IS_MHOMED); }
705 | listen_id COMMA listen_id_lst { $$=mk_name_lst($1, SI_IS_MHOMED);
711 LPAREN listen_id_lst RPAREN { $$=$2; }
712 | listen_id { $$=mk_name_lst($1, 0); }
716 UDP { $$=PROTO_UDP; }
717 | TCP { $$=PROTO_TCP; }
718 | TLS { $$=PROTO_TLS; }
719 | SCTP { $$=PROTO_SCTP; }
727 listen_id { $$=mk_listen_id($1, 0, 0); }
728 | listen_id COLON port { $$=mk_listen_id($1, 0, $3); }
729 | proto COLON listen_id { $$=mk_listen_id($3, $1, 0); }
730 | proto COLON listen_id COLON port { $$=mk_listen_id($3, $1, $5);}
731 | listen_id COLON error { $$=0; yyerror(" port number expected"); }
735 listen_id2 { $$=mk_listen_id2($1, 0, 0); }
736 | listen_id2 COLON port { $$=mk_listen_id2($1, 0, $3); }
737 | proto COLON listen_id2 { $$=mk_listen_id2($3, $1, 0); }
738 | proto COLON listen_id2 COLON port { $$=mk_listen_id2($3, $1, $5);}
739 | listen_id2 COLON error { $$=0; yyerror(" port number expected"); }
743 listen_phostport { $$=$1 ; }
744 | listen_phostport id_lst { $$=$1; if ($$) $$->next=$2; }
748 | MINUS NUMBER %prec UNARY { $$=-$2; }
751 flags_decl: FLAGS_DECL flag_list
752 | FLAGS_DECL error { yyerror("flag list expected\n"); }
755 | flag_spec COMMA flag_list
758 flag_spec: flag_name { if (register_flag($1,-1)<0)
759 yyerror("register flag failed");
761 | flag_name COLON NUMBER {
762 if (register_flag($1, $3)<0)
763 yyerror("register flag failed");
767 flag_name: STRING { $$=$1; }
772 AVPFLAGS_DECL avpflag_list
773 | AVPFLAGS_DECL error { yyerror("avpflag list expected\n"); }
777 | avpflag_spec COMMA avpflag_list
781 if (register_avpflag($1)==0)
782 yyerror("cannot declare avpflag");
786 DEBUG_V EQUAL intno { default_core_cfg.debug=$3; }
787 | DEBUG_V EQUAL error { yyerror("number expected"); }
788 | FORK EQUAL NUMBER { dont_fork= ! $3; }
789 | FORK EQUAL error { yyerror("boolean value expected"); }
790 | LOGSTDERROR EQUAL NUMBER { if (!config_check) log_stderr=$3; }
791 | LOGSTDERROR EQUAL error { yyerror("boolean value expected"); }
792 | LOGFACILITY EQUAL ID {
793 if ( (i_tmp=str2facility($3))==-1)
794 yyerror("bad facility (see syslog(3) man page)");
796 default_core_cfg.log_facility=i_tmp;
798 | LOGFACILITY EQUAL error { yyerror("ID expected"); }
799 | LOGNAME EQUAL STRING { log_name=$3; }
800 | LOGNAME EQUAL error { yyerror("string value expected"); }
801 | DNS EQUAL NUMBER { received_dns|= ($3)?DO_DNS:0; }
802 | DNS EQUAL error { yyerror("boolean value expected"); }
803 | REV_DNS EQUAL NUMBER { received_dns|= ($3)?DO_REV_DNS:0; }
804 | REV_DNS EQUAL error { yyerror("boolean value expected"); }
805 | DNS_TRY_IPV6 EQUAL NUMBER { default_core_cfg.dns_try_ipv6=$3; }
806 | DNS_TRY_IPV6 error { yyerror("boolean value expected"); }
807 | DNS_TRY_NAPTR EQUAL NUMBER { IF_NAPTR(default_core_cfg.dns_try_naptr=$3); }
808 | DNS_TRY_NAPTR error { yyerror("boolean value expected"); }
809 | DNS_SRV_LB EQUAL NUMBER { IF_DNS_FAILOVER(default_core_cfg.dns_srv_lb=$3); }
810 | DNS_SRV_LB error { yyerror("boolean value expected"); }
811 | DNS_UDP_PREF EQUAL intno { IF_NAPTR(default_core_cfg.dns_udp_pref=$3);}
812 | DNS_UDP_PREF error { yyerror("number expected"); }
813 | DNS_TCP_PREF EQUAL intno { IF_NAPTR(default_core_cfg.dns_tcp_pref=$3);}
814 | DNS_TCP_PREF error { yyerror("number expected"); }
815 | DNS_TLS_PREF EQUAL intno { IF_NAPTR(default_core_cfg.dns_tls_pref=$3);}
816 | DNS_TLS_PREF error { yyerror("number expected"); }
817 | DNS_SCTP_PREF EQUAL intno {
818 IF_NAPTR(default_core_cfg.dns_sctp_pref=$3); }
819 | DNS_SCTP_PREF error { yyerror("number expected"); }
820 | DNS_RETR_TIME EQUAL NUMBER { default_core_cfg.dns_retr_time=$3; }
821 | DNS_RETR_TIME error { yyerror("number expected"); }
822 | DNS_RETR_NO EQUAL NUMBER { default_core_cfg.dns_retr_no=$3; }
823 | DNS_RETR_NO error { yyerror("number expected"); }
824 | DNS_SERVERS_NO EQUAL NUMBER { default_core_cfg.dns_servers_no=$3; }
825 | DNS_SERVERS_NO error { yyerror("number expected"); }
826 | DNS_USE_SEARCH EQUAL NUMBER { default_core_cfg.dns_search_list=$3; }
827 | DNS_USE_SEARCH error { yyerror("boolean value expected"); }
828 | DNS_SEARCH_FMATCH EQUAL NUMBER { default_core_cfg.dns_search_fmatch=$3; }
829 | DNS_SEARCH_FMATCH error { yyerror("boolean value expected"); }
830 | DNS_CACHE_INIT EQUAL NUMBER { IF_DNS_CACHE(dns_cache_init=$3); }
831 | DNS_CACHE_INIT error { yyerror("boolean value expected"); }
832 | DNS_USE_CACHE EQUAL NUMBER { IF_DNS_CACHE(default_core_cfg.use_dns_cache=$3); }
833 | DNS_USE_CACHE error { yyerror("boolean value expected"); }
834 | DNS_USE_FAILOVER EQUAL NUMBER { IF_DNS_FAILOVER(default_core_cfg.use_dns_failover=$3);}
835 | DNS_USE_FAILOVER error { yyerror("boolean value expected"); }
836 | DNS_CACHE_FLAGS EQUAL NUMBER { IF_DNS_CACHE(default_core_cfg.dns_cache_flags=$3); }
837 | DNS_CACHE_FLAGS error { yyerror("boolean value expected"); }
838 | DNS_CACHE_NEG_TTL EQUAL NUMBER { IF_DNS_CACHE(default_core_cfg.dns_neg_cache_ttl=$3); }
839 | DNS_CACHE_NEG_TTL error { yyerror("boolean value expected"); }
840 | DNS_CACHE_MAX_TTL EQUAL NUMBER { IF_DNS_CACHE(default_core_cfg.dns_cache_max_ttl=$3); }
841 | DNS_CACHE_MAX_TTL error { yyerror("boolean value expected"); }
842 | DNS_CACHE_MIN_TTL EQUAL NUMBER { IF_DNS_CACHE(default_core_cfg.dns_cache_min_ttl=$3); }
843 | DNS_CACHE_MIN_TTL error { yyerror("boolean value expected"); }
844 | DNS_CACHE_MEM EQUAL NUMBER { IF_DNS_CACHE(default_core_cfg.dns_cache_max_mem=$3); }
845 | DNS_CACHE_MEM error { yyerror("boolean value expected"); }
846 | DNS_CACHE_GC_INT EQUAL NUMBER { IF_DNS_CACHE(dns_timer_interval=$3); }
847 | DNS_CACHE_GC_INT error { yyerror("boolean value expected"); }
848 | DNS_CACHE_DEL_NONEXP EQUAL NUMBER { IF_DNS_CACHE(default_core_cfg.dns_cache_del_nonexp=$3); }
849 | DNS_CACHE_DEL_NONEXP error { yyerror("boolean value expected"); }
850 | DST_BLST_INIT EQUAL NUMBER { IF_DST_BLACKLIST(dst_blacklist_init=$3); }
851 | DST_BLST_INIT error { yyerror("boolean value expected"); }
852 | USE_DST_BLST EQUAL NUMBER {
853 IF_DST_BLACKLIST(default_core_cfg.use_dst_blacklist=$3);
855 | USE_DST_BLST error { yyerror("boolean value expected"); }
856 | DST_BLST_MEM EQUAL NUMBER {
857 IF_DST_BLACKLIST(default_core_cfg.blst_max_mem=$3);
859 | DST_BLST_MEM error { yyerror("boolean value expected"); }
860 | DST_BLST_TTL EQUAL NUMBER {
861 IF_DST_BLACKLIST(default_core_cfg.blst_timeout=$3);
863 | DST_BLST_TTL error { yyerror("boolean value expected"); }
864 | DST_BLST_GC_INT EQUAL NUMBER { IF_DST_BLACKLIST(blst_timer_interval=$3);}
865 | DST_BLST_GC_INT error { yyerror("boolean value expected"); }
866 | DST_BLST_UDP_IMASK EQUAL NUMBER {
867 IF_DST_BLACKLIST(default_core_cfg.blst_udp_imask=$3);
869 | DST_BLST_UDP_IMASK error { yyerror("number(flags) expected"); }
870 | DST_BLST_TCP_IMASK EQUAL NUMBER {
871 IF_DST_BLACKLIST(default_core_cfg.blst_tcp_imask=$3);
873 | DST_BLST_TCP_IMASK error { yyerror("number(flags) expected"); }
874 | DST_BLST_TLS_IMASK EQUAL NUMBER {
875 IF_DST_BLACKLIST(default_core_cfg.blst_tls_imask=$3);
877 | DST_BLST_TLS_IMASK error { yyerror("number(flags) expected"); }
878 | DST_BLST_SCTP_IMASK EQUAL NUMBER {
879 IF_DST_BLACKLIST(default_core_cfg.blst_sctp_imask=$3);
881 | DST_BLST_SCTP_IMASK error { yyerror("number(flags) expected"); }
882 | PORT EQUAL NUMBER { port_no=$3; }
883 | STAT EQUAL STRING {
888 | MAXBUFFER EQUAL NUMBER { maxbuffer=$3; }
889 | MAXBUFFER EQUAL error { yyerror("number expected"); }
890 | PORT EQUAL error { yyerror("number expected"); }
891 | CHILDREN EQUAL NUMBER { children_no=$3; }
892 | CHILDREN EQUAL error { yyerror("number expected"); }
893 | CHECK_VIA EQUAL NUMBER { check_via=$3; }
894 | CHECK_VIA EQUAL error { yyerror("boolean value expected"); }
895 | PHONE2TEL EQUAL NUMBER { phone2tel=$3; }
896 | PHONE2TEL EQUAL error { yyerror("boolean value expected"); }
897 | SYN_BRANCH EQUAL NUMBER { syn_branch=$3; }
898 | SYN_BRANCH EQUAL error { yyerror("boolean value expected"); }
899 | MEMLOG EQUAL intno { default_core_cfg.memlog=$3; }
900 | MEMLOG EQUAL error { yyerror("int value expected"); }
901 | MEMDBG EQUAL intno { default_core_cfg.memdbg=$3; }
902 | MEMDBG EQUAL error { yyerror("int value expected"); }
903 | MEMSUM EQUAL intno { default_core_cfg.mem_summary=$3; }
904 | MEMSUM EQUAL error { yyerror("int value expected"); }
905 | SIP_WARNING EQUAL NUMBER { sip_warning=$3; }
906 | SIP_WARNING EQUAL error { yyerror("boolean value expected"); }
907 | USER EQUAL STRING {
908 if (shm_initialized())
909 yyerror("user must be before any modparam or the"
915 if (shm_initialized())
916 yyerror("user must be before any modparam or the"
921 | USER EQUAL error { yyerror("string value expected"); }
922 | GROUP EQUAL STRING { group=$3; }
923 | GROUP EQUAL ID { group=$3; }
924 | GROUP EQUAL error { yyerror("string value expected"); }
925 | CHROOT EQUAL STRING { chroot_dir=$3; }
926 | CHROOT EQUAL ID { chroot_dir=$3; }
927 | CHROOT EQUAL error { yyerror("string value expected"); }
928 | WDIR EQUAL STRING { working_dir=$3; }
929 | WDIR EQUAL ID { working_dir=$3; }
930 | WDIR EQUAL error { yyerror("string value expected"); }
931 | MHOMED EQUAL NUMBER { mhomed=$3; }
932 | MHOMED EQUAL error { yyerror("boolean value expected"); }
933 | DISABLE_TCP EQUAL NUMBER {
937 warn("tcp support not compiled in");
940 | DISABLE_TCP EQUAL error { yyerror("boolean value expected"); }
941 | TCP_ACCEPT_ALIASES EQUAL NUMBER {
943 tcp_default_cfg.accept_aliases=$3;
945 warn("tcp support not compiled in");
948 | TCP_ACCEPT_ALIASES EQUAL error { yyerror("boolean value expected"); }
949 | TCP_CHILDREN EQUAL NUMBER {
953 warn("tcp support not compiled in");
956 | TCP_CHILDREN EQUAL error { yyerror("number expected"); }
957 | TCP_CONNECT_TIMEOUT EQUAL intno {
959 tcp_default_cfg.connect_timeout_s=$3;
961 warn("tcp support not compiled in");
964 | TCP_CONNECT_TIMEOUT EQUAL error { yyerror("number expected"); }
965 | TCP_SEND_TIMEOUT EQUAL intno {
967 tcp_default_cfg.send_timeout=S_TO_TICKS($3);
969 warn("tcp support not compiled in");
972 | TCP_SEND_TIMEOUT EQUAL error { yyerror("number expected"); }
973 | TCP_CON_LIFETIME EQUAL intno {
976 tcp_default_cfg.con_lifetime=-1;
978 tcp_default_cfg.con_lifetime=S_TO_TICKS($3);
980 warn("tcp support not compiled in");
983 | TCP_CON_LIFETIME EQUAL error { yyerror("number expected"); }
984 | TCP_POLL_METHOD EQUAL ID {
986 tcp_poll_method=get_poll_type($3);
987 if (tcp_poll_method==POLL_NONE) {
988 LOG(L_CRIT, "bad poll method name:"
989 " %s\n, try one of %s.\n",
991 yyerror("bad tcp_poll_method "
995 warn("tcp support not compiled in");
998 | TCP_POLL_METHOD EQUAL STRING {
1000 tcp_poll_method=get_poll_type($3);
1001 if (tcp_poll_method==POLL_NONE) {
1002 LOG(L_CRIT, "bad poll method name:"
1003 " %s\n, try one of %s.\n",
1005 yyerror("bad tcp_poll_method "
1009 warn("tcp support not compiled in");
1012 | TCP_POLL_METHOD EQUAL error { yyerror("poll method name expected"); }
1013 | TCP_MAX_CONNECTIONS EQUAL NUMBER {
1015 tcp_max_connections=$3;
1017 warn("tcp support not compiled in");
1020 | TCP_MAX_CONNECTIONS EQUAL error { yyerror("number expected"); }
1021 | TCP_NO_CONNECT EQUAL NUMBER {
1023 tcp_default_cfg.no_connect=$3;
1025 warn("tcp support not compiled in");
1028 | TCP_NO_CONNECT EQUAL error { yyerror("boolean value expected"); }
1029 | TCP_SOURCE_IPV4 EQUAL ipv4 {
1031 if (tcp_set_src_addr($3)<0)
1032 warn("tcp_source_ipv4 failed");
1034 warn("tcp support not compiled in");
1038 | TCP_SOURCE_IPV4 EQUAL error { yyerror("IPv4 address expected"); }
1039 | TCP_SOURCE_IPV6 EQUAL ipv6 {
1042 if (tcp_set_src_addr($3)<0)
1043 warn("tcp_source_ipv6 failed");
1045 warn("IPv6 support not compiled in");
1048 warn("tcp support not compiled in");
1052 | TCP_SOURCE_IPV6 EQUAL error { yyerror("IPv6 address expected"); }
1053 | TCP_OPT_FD_CACHE EQUAL NUMBER {
1055 tcp_default_cfg.fd_cache=$3;
1057 warn("tcp support not compiled in");
1060 | TCP_OPT_FD_CACHE EQUAL error { yyerror("boolean value expected"); }
1061 | TCP_OPT_BUF_WRITE EQUAL NUMBER {
1063 tcp_default_cfg.async=$3;
1065 warn("tcp support not compiled in");
1068 | TCP_OPT_BUF_WRITE EQUAL error { yyerror("boolean value expected"); }
1069 | TCP_OPT_CONN_WQ_MAX EQUAL NUMBER {
1071 tcp_default_cfg.tcpconn_wq_max=$3;
1073 warn("tcp support not compiled in");
1076 | TCP_OPT_CONN_WQ_MAX error { yyerror("boolean value expected"); }
1077 | TCP_OPT_WQ_MAX EQUAL NUMBER {
1079 tcp_default_cfg.tcp_wq_max=$3;
1081 warn("tcp support not compiled in");
1084 | TCP_OPT_WQ_MAX error { yyerror("number expected"); }
1085 | TCP_OPT_RD_BUF EQUAL NUMBER {
1087 tcp_default_cfg.rd_buf_size=$3;
1089 warn("tcp support not compiled in");
1092 | TCP_OPT_RD_BUF error { yyerror("number expected"); }
1093 | TCP_OPT_WQ_BLK EQUAL NUMBER {
1095 tcp_default_cfg.wq_blk_size=$3;
1097 warn("tcp support not compiled in");
1100 | TCP_OPT_WQ_BLK error { yyerror("number expected"); }
1101 | TCP_OPT_DEFER_ACCEPT EQUAL NUMBER {
1103 tcp_default_cfg.defer_accept=$3;
1105 warn("tcp support not compiled in");
1108 | TCP_OPT_DEFER_ACCEPT EQUAL error { yyerror("boolean value expected"); }
1109 | TCP_OPT_DELAYED_ACK EQUAL NUMBER {
1111 tcp_default_cfg.delayed_ack=$3;
1113 warn("tcp support not compiled in");
1116 | TCP_OPT_DELAYED_ACK EQUAL error { yyerror("boolean value expected"); }
1117 | TCP_OPT_SYNCNT EQUAL NUMBER {
1119 tcp_default_cfg.syncnt=$3;
1121 warn("tcp support not compiled in");
1124 | TCP_OPT_SYNCNT EQUAL error { yyerror("number expected"); }
1125 | TCP_OPT_LINGER2 EQUAL NUMBER {
1127 tcp_default_cfg.linger2=$3;
1129 warn("tcp support not compiled in");
1132 | TCP_OPT_LINGER2 EQUAL error { yyerror("number expected"); }
1133 | TCP_OPT_KEEPALIVE EQUAL NUMBER {
1135 tcp_default_cfg.keepalive=$3;
1137 warn("tcp support not compiled in");
1140 | TCP_OPT_KEEPALIVE EQUAL error { yyerror("boolean value expected");}
1141 | TCP_OPT_KEEPIDLE EQUAL NUMBER {
1143 tcp_default_cfg.keepidle=$3;
1145 warn("tcp support not compiled in");
1148 | TCP_OPT_KEEPIDLE EQUAL error { yyerror("number expected"); }
1149 | TCP_OPT_KEEPINTVL EQUAL NUMBER {
1151 tcp_default_cfg.keepintvl=$3;
1153 warn("tcp support not compiled in");
1156 | TCP_OPT_KEEPINTVL EQUAL error { yyerror("number expected"); }
1157 | TCP_OPT_KEEPCNT EQUAL NUMBER {
1159 tcp_default_cfg.keepcnt=$3;
1161 warn("tcp support not compiled in");
1164 | TCP_OPT_KEEPCNT EQUAL error { yyerror("number expected"); }
1165 | TCP_OPT_CRLF_PING EQUAL NUMBER {
1167 tcp_default_cfg.crlf_ping=$3;
1169 warn("tcp support not compiled in");
1172 | TCP_OPT_CRLF_PING EQUAL error { yyerror("boolean value expected"); }
1173 | DISABLE_TLS EQUAL NUMBER {
1177 warn("tls support not compiled in");
1180 | DISABLE_TLS EQUAL error { yyerror("boolean value expected"); }
1181 | ENABLE_TLS EQUAL NUMBER {
1185 warn("tls support not compiled in");
1188 | ENABLE_TLS EQUAL error { yyerror("boolean value expected"); }
1189 | TLSLOG EQUAL NUMBER {
1193 warn("tls-in-core support not compiled in");
1196 | TLSLOG EQUAL error { yyerror("int value expected"); }
1197 | TLS_PORT_NO EQUAL NUMBER {
1201 warn("tls support not compiled in");
1204 | TLS_PORT_NO EQUAL error { yyerror("number expected"); }
1205 | TLS_METHOD EQUAL SSLv23 {
1207 tls_method=TLS_USE_SSLv23;
1209 warn("tls-in-core support not compiled in");
1212 | TLS_METHOD EQUAL SSLv2 {
1214 tls_method=TLS_USE_SSLv2;
1216 warn("tls-in-core support not compiled in");
1219 | TLS_METHOD EQUAL SSLv3 {
1221 tls_method=TLS_USE_SSLv3;
1223 warn("tls-in-core support not compiled in");
1226 | TLS_METHOD EQUAL TLSv1 {
1228 tls_method=TLS_USE_TLSv1;
1230 warn("tls-in-core support not compiled in");
1233 | TLS_METHOD EQUAL error {
1235 yyerror("SSLv23, SSLv2, SSLv3 or TLSv1 expected");
1237 warn("tls-in-core support not compiled in");
1240 | TLS_VERIFY EQUAL NUMBER {
1244 warn("tls-in-core support not compiled in");
1247 | TLS_VERIFY EQUAL error { yyerror("boolean value expected"); }
1248 | TLS_REQUIRE_CERTIFICATE EQUAL NUMBER {
1250 tls_require_cert=$3;
1252 warn( "tls-in-core support not compiled in");
1255 | TLS_REQUIRE_CERTIFICATE EQUAL error { yyerror("boolean value expected"); }
1256 | TLS_CERTIFICATE EQUAL STRING {
1260 warn("tls-in-core support not compiled in");
1263 | TLS_CERTIFICATE EQUAL error { yyerror("string value expected"); }
1264 | TLS_PRIVATE_KEY EQUAL STRING {
1268 warn("tls-in-core support not compiled in");
1271 | TLS_PRIVATE_KEY EQUAL error { yyerror("string value expected"); }
1272 | TLS_CA_LIST EQUAL STRING {
1276 warn("tls-in-core support not compiled in");
1279 | TLS_CA_LIST EQUAL error { yyerror("string value expected"); }
1280 | TLS_HANDSHAKE_TIMEOUT EQUAL NUMBER {
1282 tls_handshake_timeout=$3;
1284 warn("tls-in-core support not compiled in");
1287 | TLS_HANDSHAKE_TIMEOUT EQUAL error { yyerror("number expected"); }
1288 | TLS_SEND_TIMEOUT EQUAL NUMBER {
1290 tls_send_timeout=$3;
1292 warn("tls-in-core support not compiled in");
1295 | TLS_SEND_TIMEOUT EQUAL error { yyerror("number expected"); }
1296 | DISABLE_SCTP EQUAL NUMBER {
1300 warn("sctp support not compiled in");
1303 | DISABLE_SCTP EQUAL error { yyerror("boolean value expected"); }
1304 | ENABLE_SCTP EQUAL NUMBER {
1306 sctp_disable=($3<=1)?!$3:$3;
1308 warn("sctp support not compiled in");
1311 | ENABLE_SCTP EQUAL error { yyerror("boolean or number expected"); }
1312 | SCTP_CHILDREN EQUAL NUMBER {
1314 sctp_children_no=$3;
1316 warn("sctp support not compiled in");
1319 | SCTP_CHILDREN EQUAL error { yyerror("number expected"); }
1320 | SCTP_SOCKET_RCVBUF EQUAL NUMBER {
1322 sctp_default_cfg.so_rcvbuf=$3;
1324 warn("sctp support not compiled in");
1327 | SCTP_SOCKET_RCVBUF EQUAL error { yyerror("number expected"); }
1328 | SCTP_SOCKET_SNDBUF EQUAL NUMBER {
1330 sctp_default_cfg.so_sndbuf=$3;
1332 warn("sctp support not compiled in");
1335 | SCTP_SOCKET_SNDBUF EQUAL error { yyerror("number expected"); }
1336 | SCTP_AUTOCLOSE EQUAL NUMBER {
1338 sctp_default_cfg.autoclose=$3;
1340 warn("sctp support not compiled in");
1343 | SCTP_AUTOCLOSE EQUAL error { yyerror("number expected"); }
1344 | SCTP_SEND_TTL EQUAL NUMBER {
1346 sctp_default_cfg.send_ttl=$3;
1348 warn("sctp support not compiled in");
1351 | SCTP_SEND_TTL EQUAL error { yyerror("number expected"); }
1352 | SCTP_SEND_RETRIES EQUAL NUMBER {
1354 sctp_default_cfg.send_retries=$3;
1356 warn("sctp support not compiled in");
1359 | SCTP_SEND_RETRIES EQUAL error { yyerror("number expected"); }
1360 | SCTP_ASSOC_TRACKING EQUAL NUMBER {
1362 #ifdef SCTP_CONN_REUSE
1363 sctp_default_cfg.assoc_tracking=$3;
1366 warn("sctp association tracking/reuse (SCTP_CONN_REUSE) "
1367 "support not compiled in");
1368 #endif /* SCTP_CONN_REUSE */
1370 warn("sctp support not compiled in");
1371 #endif /* USE_SCTP */
1373 | SCTP_ASSOC_TRACKING EQUAL error { yyerror("number expected"); }
1374 | SCTP_ASSOC_REUSE EQUAL NUMBER {
1376 #ifdef SCTP_CONN_REUSE
1377 sctp_default_cfg.assoc_reuse=$3;
1380 warn("sctp association reuse (SCTP_CONN_REUSE) support"
1381 " not compiled in");
1382 #endif /* SCTP_CONN_REUSE */
1384 warn("sctp support not compiled in");
1385 #endif /* USE_SCTP */
1387 | SCTP_ASSOC_REUSE EQUAL error { yyerror("number expected"); }
1388 | SCTP_MAX_ASSOCS EQUAL intno {
1389 IF_SCTP(sctp_default_cfg.max_assocs=$3);
1391 | SCTP_MAX_ASSOCS EQUAL error { yyerror("number expected"); }
1392 | SCTP_SRTO_INITIAL EQUAL NUMBER {
1393 IF_SCTP(sctp_default_cfg.srto_initial=$3);
1395 | SCTP_SRTO_INITIAL EQUAL error { yyerror("number expected"); }
1396 | SCTP_SRTO_MAX EQUAL NUMBER {
1397 IF_SCTP(sctp_default_cfg.srto_max=$3);
1399 | SCTP_SRTO_MAX EQUAL error { yyerror("number expected"); }
1400 | SCTP_SRTO_MIN EQUAL NUMBER {
1401 IF_SCTP(sctp_default_cfg.srto_min=$3);
1403 | SCTP_SRTO_MIN EQUAL error { yyerror("number expected"); }
1404 | SCTP_ASOCMAXRXT EQUAL NUMBER {
1405 IF_SCTP(sctp_default_cfg.asocmaxrxt=$3);
1407 | SCTP_ASOCMAXRXT EQUAL error { yyerror("number expected"); }
1408 | SCTP_INIT_MAX_ATTEMPTS EQUAL NUMBER {
1409 IF_SCTP(sctp_default_cfg.init_max_attempts=$3);
1411 | SCTP_INIT_MAX_ATTEMPTS EQUAL error { yyerror("number expected"); }
1412 | SCTP_INIT_MAX_TIMEO EQUAL NUMBER {
1413 IF_SCTP(sctp_default_cfg.init_max_timeo=$3);
1415 | SCTP_INIT_MAX_TIMEO EQUAL error { yyerror("number expected"); }
1416 | SCTP_HBINTERVAL EQUAL intno {
1417 IF_SCTP(sctp_default_cfg.hbinterval=$3);
1419 | SCTP_HBINTERVAL EQUAL error { yyerror("number expected"); }
1420 | SCTP_PATHMAXRXT EQUAL NUMBER {
1421 IF_SCTP(sctp_default_cfg.pathmaxrxt=$3);
1423 | SCTP_PATHMAXRXT EQUAL error { yyerror("number expected"); }
1424 | SCTP_SACK_DELAY EQUAL NUMBER {
1425 IF_SCTP(sctp_default_cfg.sack_delay=$3);
1427 | SCTP_SACK_DELAY EQUAL error { yyerror("number expected"); }
1428 | SCTP_SACK_FREQ EQUAL NUMBER {
1429 IF_SCTP(sctp_default_cfg.sack_freq=$3);
1431 | SCTP_SACK_FREQ EQUAL error { yyerror("number expected"); }
1432 | SCTP_MAX_BURST EQUAL NUMBER {
1433 IF_SCTP(sctp_default_cfg.max_burst=$3);
1435 | SCTP_MAX_BURST EQUAL error { yyerror("number expected"); }
1436 | SERVER_SIGNATURE EQUAL NUMBER { server_signature=$3; }
1437 | SERVER_SIGNATURE EQUAL error { yyerror("boolean value expected"); }
1438 | SERVER_HEADER EQUAL STRING { server_hdr.s=$3;
1439 server_hdr.len=strlen(server_hdr.s);
1441 | SERVER_HEADER EQUAL error { yyerror("string value expected"); }
1442 | USER_AGENT_HEADER EQUAL STRING { user_agent_hdr.s=$3;
1443 user_agent_hdr.len=strlen(user_agent_hdr.s);
1445 | USER_AGENT_HEADER EQUAL error { yyerror("string value expected"); }
1446 | REPLY_TO_VIA EQUAL NUMBER { reply_to_via=$3; }
1447 | REPLY_TO_VIA EQUAL error { yyerror("boolean value expected"); }
1448 | LISTEN EQUAL id_lst {
1449 for(lst_tmp=$3; lst_tmp; lst_tmp=lst_tmp->next) {
1450 if (add_listen_iface( lst_tmp->addr_lst->name,
1451 lst_tmp->addr_lst->next,
1452 lst_tmp->port, lst_tmp->proto,
1453 lst_tmp->flags)!=0) {
1454 LOG(L_CRIT, "ERROR: cfg. parser: failed to add listen"
1459 free_socket_id_lst($3);
1461 | LISTEN EQUAL error { yyerror("ip address, interface name or"
1462 " hostname expected"); }
1463 | ALIAS EQUAL id_lst {
1464 for(lst_tmp=$3; lst_tmp; lst_tmp=lst_tmp->next){
1465 add_alias( lst_tmp->addr_lst->name,
1466 strlen(lst_tmp->addr_lst->name),
1467 lst_tmp->port, lst_tmp->proto);
1468 for (nl_tmp=lst_tmp->addr_lst->next; nl_tmp; nl_tmp=nl_tmp->next)
1469 add_alias(nl_tmp->name, strlen(nl_tmp->name),
1470 lst_tmp->port, lst_tmp->proto);
1472 free_socket_id_lst($3);
1474 | ALIAS EQUAL error { yyerror(" hostname expected"); }
1475 | SR_AUTO_ALIASES EQUAL NUMBER { sr_auto_aliases=$3; }
1476 | SR_AUTO_ALIASES EQUAL error { yyerror("boolean value expected"); }
1477 | ADVERTISED_ADDRESS EQUAL listen_id {
1479 default_global_address.s=$3;
1480 default_global_address.len=strlen($3);
1483 | ADVERTISED_ADDRESS EQUAL error {yyerror("ip address or hostname expected"); }
1484 | ADVERTISED_PORT EQUAL NUMBER {
1485 tmp=int2str($3, &i_tmp);
1486 if ((default_global_port.s=pkg_malloc(i_tmp))==0) {
1487 LOG(L_CRIT, "ERROR: cfg. parser: out of memory.\n");
1488 default_global_port.len=0;
1490 default_global_port.len=i_tmp;
1491 memcpy(default_global_port.s, tmp, default_global_port.len);
1494 |ADVERTISED_PORT EQUAL error {yyerror("ip address or hostname expected"); }
1495 | DISABLE_CORE EQUAL NUMBER { disable_core_dump=$3; }
1496 | DISABLE_CORE EQUAL error { yyerror("boolean value expected"); }
1497 | OPEN_FD_LIMIT EQUAL NUMBER { open_files_limit=$3; }
1498 | OPEN_FD_LIMIT EQUAL error { yyerror("number expected"); }
1499 | SHM_MEM_SZ EQUAL NUMBER {
1500 if (shm_initialized())
1501 yyerror("shm/shm_mem_size must be before any modparam or the"
1503 else if (shm_mem_size == 0)
1504 shm_mem_size=$3 * 1024 * 1024;
1506 | SHM_MEM_SZ EQUAL error { yyerror("number expected"); }
1507 | SHM_FORCE_ALLOC EQUAL NUMBER {
1508 if (shm_initialized())
1509 yyerror("shm_force_alloc must be before any modparam or the"
1514 | SHM_FORCE_ALLOC EQUAL error { yyerror("boolean value expected"); }
1515 | MLOCK_PAGES EQUAL NUMBER { mlock_pages=$3; }
1516 | MLOCK_PAGES EQUAL error { yyerror("boolean value expected"); }
1517 | REAL_TIME EQUAL NUMBER { real_time=$3; }
1518 | REAL_TIME EQUAL error { yyerror("boolean value expected"); }
1519 | RT_PRIO EQUAL NUMBER { rt_prio=$3; }
1520 | RT_PRIO EQUAL error { yyerror("boolean value expected"); }
1521 | RT_POLICY EQUAL NUMBER { rt_policy=$3; }
1522 | RT_POLICY EQUAL error { yyerror("boolean value expected"); }
1523 | RT_TIMER1_PRIO EQUAL NUMBER { rt_timer1_prio=$3; }
1524 | RT_TIMER1_PRIO EQUAL error { yyerror("boolean value expected"); }
1525 | RT_TIMER1_POLICY EQUAL NUMBER { rt_timer1_policy=$3; }
1526 | RT_TIMER1_POLICY EQUAL error { yyerror("boolean value expected"); }
1527 | RT_TIMER2_PRIO EQUAL NUMBER { rt_timer2_prio=$3; }
1528 | RT_TIMER2_PRIO EQUAL error { yyerror("boolean value expected"); }
1529 | RT_TIMER2_POLICY EQUAL NUMBER { rt_timer2_policy=$3; }
1530 | RT_TIMER2_POLICY EQUAL error { yyerror("boolean value expected"); }
1531 | MCAST_LOOPBACK EQUAL NUMBER {
1535 warn("no multicast support compiled in");
1538 | MCAST_LOOPBACK EQUAL error { yyerror("boolean value expected"); }
1539 | MCAST_TTL EQUAL NUMBER {
1543 warn("no multicast support compiled in");
1546 | MCAST_TTL EQUAL error { yyerror("number expected"); }
1547 | TOS EQUAL NUMBER { tos=$3; }
1548 | TOS EQUAL error { yyerror("number expected"); }
1549 | PMTU_DISCOVERY EQUAL NUMBER { pmtu_discovery=$3; }
1550 | PMTU_DISCOVERY error { yyerror("number expected"); }
1551 | KILL_TIMEOUT EQUAL NUMBER { ser_kill_timeout=$3; }
1552 | KILL_TIMEOUT EQUAL error { yyerror("number expected"); }
1553 | MAX_WLOOPS EQUAL NUMBER { default_core_cfg.max_while_loops=$3; }
1554 | MAX_WLOOPS EQUAL error { yyerror("number expected"); }
1555 | STUN_REFRESH_INTERVAL EQUAL NUMBER { IF_STUN(stun_refresh_interval=$3); }
1556 | STUN_REFRESH_INTERVAL EQUAL error{ yyerror("number expected"); }
1557 | STUN_ALLOW_STUN EQUAL NUMBER { IF_STUN(stun_allow_stun=$3); }
1558 | STUN_ALLOW_STUN EQUAL error{ yyerror("number expected"); }
1559 | STUN_ALLOW_FP EQUAL NUMBER { IF_STUN(stun_allow_fp=$3) ; }
1560 | STUN_ALLOW_FP EQUAL error{ yyerror("number expected"); }
1561 | SERVER_ID EQUAL NUMBER { server_id=$3; }
1562 | UDP_MTU EQUAL NUMBER { default_core_cfg.udp_mtu=$3; }
1563 | UDP_MTU EQUAL error { yyerror("number expected"); }
1564 | FORCE_RPORT EQUAL NUMBER
1565 { default_core_cfg.force_rport=$3; fix_global_req_flags(0, 0); }
1566 | FORCE_RPORT EQUAL error { yyerror("boolean value expected"); }
1567 | UDP_MTU_TRY_PROTO EQUAL proto
1568 { default_core_cfg.udp_mtu_try_proto=$3; fix_global_req_flags(0, 0); }
1569 | UDP_MTU_TRY_PROTO EQUAL error
1570 { yyerror("TCP, TLS, SCTP or UDP expected"); }
1572 | error EQUAL { yyerror("unknown config variable"); }
1576 | DEFAULT { $$="default" ; } /*needed to allow default as cfg var. name*/
1580 cfg_var_id DOT cfg_var_id EQUAL NUMBER {
1581 if (cfg_declare_int($1, $3, $5, 0, 0, NULL)) {
1582 yyerror("variable cannot be declared");
1585 | cfg_var_id DOT cfg_var_id EQUAL STRING {
1586 if (cfg_declare_str($1, $3, $5, NULL)) {
1587 yyerror("variable cannot be declared");
1590 | cfg_var_id DOT cfg_var_id EQUAL NUMBER CFG_DESCRIPTION STRING {
1591 if (cfg_declare_int($1, $3, $5, 0, 0, $7)) {
1592 yyerror("variable cannot be declared");
1595 | cfg_var_id DOT cfg_var_id EQUAL STRING CFG_DESCRIPTION STRING {
1596 if (cfg_declare_str($1, $3, $5, $7)) {
1597 yyerror("variable cannot be declared");
1600 | cfg_var_id DOT cfg_var_id EQUAL error {
1601 yyerror("number or string expected");
1607 DBG("loading module %s\n", $2);
1608 if (load_module($2)!=0) {
1609 yyerror("failed to load module");
1612 | LOADMODULE error { yyerror("string expected"); }
1614 DBG("loading modules under %s\n", $2);
1615 printf("loading modules under %s\n", $2);
1618 | LOADPATH error { yyerror("string expected"); }
1619 | LOADPATH EQUAL STRING {
1620 DBG("loading modules under %s\n", $3);
1621 printf("loading modules under %s\n", $3);
1624 | LOADPATH EQUAL error { yyerror("string expected"); }
1625 | MODPARAM LPAREN STRING COMMA STRING COMMA STRING RPAREN {
1627 if (!shm_initialized() && init_shm()<0) {
1628 yyerror("Can't initialize shared memory");
1631 #endif /* SHM_MEM */
1632 if (set_mod_param_regex($3, $5, PARAM_STRING, $7) != 0) {
1633 yyerror("Can't set module parameter");
1636 | MODPARAM LPAREN STRING COMMA STRING COMMA NUMBER RPAREN {
1638 if (!shm_initialized() && init_shm()<0) {
1639 yyerror("Can't initialize shared memory");
1642 #endif /* SHM_MEM */
1643 if (set_mod_param_regex($3, $5, PARAM_INT, (void*)$7) != 0) {
1644 yyerror("Can't set module parameter");
1647 | MODPARAM error { yyerror("Invalid arguments"); }
1654 NUMBER DOT NUMBER DOT NUMBER DOT NUMBER {
1655 $$=pkg_malloc(sizeof(struct ip_addr));
1657 LOG(L_CRIT, "ERROR: cfg. parser: out of memory.\n");
1659 memset($$, 0, sizeof(struct ip_addr));
1662 if (($1>255) || ($1<0) ||
1663 ($3>255) || ($3<0) ||
1664 ($5>255) || ($5<0) ||
1665 ($7>255) || ($7<0)) {
1666 yyerror("invalid ipv4 address");
1676 ($3<<16)| ($5<<8)|$7 );
1684 $$=pkg_malloc(sizeof(struct ip_addr));
1686 LOG(L_CRIT, "ERROR: cfg. parser: out of memory.\n");
1689 memset($$, 0, sizeof(struct ip_addr));
1692 if (inet_pton(AF_INET6, $1, $$->u.addr)<=0) {
1693 yyerror("bad ipv6 address");
1696 yyerror("ipv6 address & no ipv6 support compiled in");
1704 | LBRACK ipv6addr RBRACK {$$=$2; }
1708 route_name: NUMBER {
1709 tmp=int2str($1, &i_tmp);
1710 if (($$=pkg_malloc(i_tmp+1))==0) {
1711 yyerror("out of memory");
1714 memcpy($$, tmp, i_tmp);
1723 ROUTE LBRACE actions RBRACE {
1725 if (!shm_initialized() && init_shm()<0) {
1726 yyerror("Can't initialize shared memory");
1729 #endif /* SHM_MEM */
1730 push($3, &main_rt.rlist[DEFAULT_RT]);
1732 | ROUTE LBRACK route_name RBRACK LBRACE actions RBRACE {
1734 if (!shm_initialized() && init_shm()<0) {
1735 yyerror("Can't initialize shared memory");
1738 #endif /* SHM_MEM */
1739 i_tmp=route_get(&main_rt, $3);
1741 yyerror("internal error");
1744 if (main_rt.rlist[i_tmp]){
1745 yyerror("duplicate route");
1748 push($6, &main_rt.rlist[i_tmp]);
1750 | ROUTE error { yyerror("invalid route statement"); }
1753 ROUTE_FAILURE LBRACE actions RBRACE {
1755 if (!shm_initialized() && init_shm()<0) {
1756 yyerror("Can't initialize shared memory");
1759 #endif /* SHM_MEM */
1760 push($3, &failure_rt.rlist[DEFAULT_RT]);
1762 | ROUTE_FAILURE LBRACK route_name RBRACK LBRACE actions RBRACE {
1764 if (!shm_initialized() && init_shm()<0) {
1765 yyerror("Can't initialize shared memory");
1768 #endif /* SHM_MEM */
1769 i_tmp=route_get(&failure_rt, $3);
1771 yyerror("internal error");
1774 if (failure_rt.rlist[i_tmp]){
1775 yyerror("duplicate route");
1778 push($6, &failure_rt.rlist[i_tmp]);
1780 | ROUTE_FAILURE error { yyerror("invalid failure_route statement"); }
1784 ROUTE_ONREPLY LBRACE {rt=CORE_ONREPLY_ROUTE;} actions RBRACE {
1786 if (!shm_initialized() && init_shm()<0) {
1787 yyerror("Can't initialize shared memory");
1790 #endif /* SHM_MEM */
1791 push($4, &onreply_rt.rlist[DEFAULT_RT]);
1793 | ROUTE_ONREPLY error { yyerror("invalid onreply_route statement"); }
1794 | ROUTE_ONREPLY LBRACK route_name RBRACK
1795 {rt=(*$3=='0' && $3[1]==0)?CORE_ONREPLY_ROUTE:TM_ONREPLY_ROUTE;}
1796 LBRACE actions RBRACE {
1798 if (!shm_initialized() && init_shm()<0) {
1799 yyerror("Can't initialize shared memory");
1802 #endif /* SHM_MEM */
1803 if (*$3=='0' && $3[1]==0){
1804 /* onreply_route[0] {} is equivalent with onreply_route {}*/
1805 push($7, &onreply_rt.rlist[DEFAULT_RT]);
1807 i_tmp=route_get(&onreply_rt, $3);
1809 yyerror("internal error");
1812 if (onreply_rt.rlist[i_tmp]){
1813 yyerror("duplicate route");
1816 push($7, &onreply_rt.rlist[i_tmp]);
1819 | ROUTE_ONREPLY LBRACK route_name RBRACK error {
1820 yyerror("invalid onreply_route statement");
1824 ROUTE_BRANCH LBRACE actions RBRACE {
1826 if (!shm_initialized() && init_shm()<0) {
1827 yyerror("Can't initialize shared memory");
1830 #endif /* SHM_MEM */
1831 push($3, &branch_rt.rlist[DEFAULT_RT]);
1833 | ROUTE_BRANCH LBRACK route_name RBRACK LBRACE actions RBRACE {
1835 if (!shm_initialized() && init_shm()<0) {
1836 yyerror("Can't initialize shared memory");
1839 #endif /* SHM_MEM */
1840 i_tmp=route_get(&branch_rt, $3);
1842 yyerror("internal error");
1845 if (branch_rt.rlist[i_tmp]){
1846 yyerror("duplicate route");
1849 push($6, &branch_rt.rlist[i_tmp]);
1851 | ROUTE_BRANCH error { yyerror("invalid branch_route statement"); }
1853 send_route_stm: ROUTE_SEND LBRACE actions RBRACE {
1855 if (!shm_initialized() && init_shm()<0) {
1856 yyerror("Can't initialize shared memory");
1859 #endif /* SHM_MEM */
1860 push($3, &onsend_rt.rlist[DEFAULT_RT]);
1862 | ROUTE_SEND LBRACK route_name RBRACK LBRACE actions RBRACE {
1864 if (!shm_initialized() && init_shm()<0) {
1865 yyerror("Can't initialize shared memory");
1868 #endif /* SHM_MEM */
1869 i_tmp=route_get(&onsend_rt, $3);
1871 yyerror("internal error");
1874 if (onsend_rt.rlist[i_tmp]){
1875 yyerror("duplicate route");
1878 push($6, &onsend_rt.rlist[i_tmp]);
1880 | ROUTE_SEND error { yyerror("invalid onsend_route statement"); }
1882 event_route_stm: ROUTE_EVENT LBRACK EVENT_RT_NAME RBRACK LBRACE actions RBRACE {
1884 if (!shm_initialized() && init_shm()<0) {
1885 yyerror("Can't initialize shared memory");
1888 #endif /* SHM_MEM */
1889 i_tmp=route_get(&event_rt, $3);
1891 yyerror("internal error");
1894 if (event_rt.rlist[i_tmp]){
1895 yyerror("duplicate route");
1898 push($6, &event_rt.rlist[i_tmp]);
1901 | ROUTE_EVENT error { yyerror("invalid event_route statement"); }
1907 yyerror("invalid expression");
1909 }else if (!rve_check_type((enum rval_type*)&i_tmp, $1, 0, 0 ,0)){
1910 yyerror("invalid expression");
1912 }else if (i_tmp!=RV_INT && i_tmp!=RV_NONE){
1913 yyerror("invalid expression type, int expected\n");
1916 $$=mk_elem(NO_OP, RVEXP_O, $1, 0, 0);
1921 /* exp elem operators */
1923 EQUAL_T {$$=EQUAL_OP; }
1924 | DIFF {$$=DIFF_OP; }
1925 | STREQ {$$=EQUAL_OP; } /* for expr. elems equiv. to EQUAL_T*/
1926 | STRDIFF {$$=DIFF_OP; } /* for expr. elems. equiv. to DIFF */
1936 | MATCH {$$=MATCH_OP; }
1940 /* rve expr. operators */
1942 EQUAL_T {$$=RVE_EQ_OP; }
1943 | DIFF {$$=RVE_DIFF_OP; }
1944 | INTEQ {$$=RVE_IEQ_OP; }
1945 | INTDIFF {$$=RVE_IDIFF_OP; }
1946 | STREQ {$$=RVE_STREQ_OP; }
1947 | STRDIFF {$$=RVE_STRDIFF_OP; }
1948 | MATCH {$$=RVE_MATCH_OP; }
1952 | LT {$$=RVE_LT_OP; }
1953 | GTE {$$=RVE_GTE_OP; }
1954 | LTE {$$=RVE_LTE_OP; }
1959 /* boolean expression uri operands */
1962 | FROM_URI {$$=FROM_URI_O;}
1963 | TO_URI {$$=TO_URI_O;}
1967 /* boolean expression integer operands, available only in the
1970 SNDPORT { $$=SNDPORT_O; }
1971 | TOPORT { $$=TOPORT_O; }
1972 | SNDAF { $$=SNDAF_O; }
1975 /* boolean expression integer operands */
1976 eint_op: SRCPORT { $$=SRCPORT_O; }
1977 | DSTPORT { $$=DSTPORT_O; }
1979 | MSGLEN { $$=MSGLEN_O; }
1983 /* boolean expression ip/ipnet operands */
1985 SNDIP { onsend_check("snd_ip"); $$=SNDIP_O; }
1986 | TOIP { onsend_check("to_ip"); $$=TOIP_O; }
1989 eip_op: SRCIP { $$=SRCIP_O; }
1990 | DSTIP { $$=DSTIP_O; }
1997 METHOD strop rval_expr %prec EQUAL_T
1998 {$$= mk_elem($2, METHOD_O, 0, RVE_ST, $3);}
1999 | METHOD strop ID %prec EQUAL_T
2000 {$$ = mk_elem($2, METHOD_O, 0, STRING_ST,$3); }
2001 | METHOD strop error { $$=0; yyerror("string expected"); }
2003 { $$=0; yyerror("invalid operator,== , !=, or =~ expected"); }
2004 | uri_type strop rval_expr %prec EQUAL_T
2005 {$$ = mk_elem($2, $1, 0, RVE_ST, $3); }
2006 | uri_type strop MYSELF %prec EQUAL_T
2007 {$$=mk_elem($2, $1, 0, MYSELF_ST, 0); }
2008 | uri_type strop error %prec EQUAL_T
2009 { $$=0; yyerror("string or MYSELF expected"); }
2011 { $$=0; yyerror("invalid operator, == , != or =~ expected"); }
2012 | eint_op cmpop rval_expr %prec GT { $$=mk_elem($2, $1, 0, RVE_ST, $3 ); }
2013 | eint_op equalop rval_expr %prec EQUAL_T
2014 { $$=mk_elem($2, $1, 0, RVE_ST, $3 ); }
2015 | eint_op cmpop error { $$=0; yyerror("number expected"); }
2016 | eint_op equalop error { $$=0; yyerror("number expected"); }
2017 | eint_op error { $$=0; yyerror("==, !=, <,>, >= or <= expected"); }
2018 | PROTO equalop proto %prec EQUAL_T
2019 { $$=mk_elem($2, PROTO_O, 0, NUMBER_ST, (void*)$3 ); }
2020 | PROTO equalop rval_expr %prec EQUAL_T
2021 { $$=mk_elem($2, PROTO_O, 0, RVE_ST, $3 ); }
2022 | PROTO equalop error
2023 { $$=0; yyerror("protocol expected (udp, tcp, tls or sctp)"); }
2024 | SNDPROTO equalop proto %prec EQUAL_T
2025 { $$=mk_elem($2, SNDPROTO_O, 0, NUMBER_ST, (void*)$3 ); }
2026 | SNDPROTO equalop rval_expr %prec EQUAL_T
2027 { $$=mk_elem($2, SNDPROTO_O, 0, RVE_ST, $3 ); }
2028 | SNDPROTO equalop error
2029 { $$=0; yyerror("protocol expected (udp, tcp, tls or sctp)"); }
2030 | eip_op strop ipnet %prec EQUAL_T { $$=mk_elem($2, $1, 0, NET_ST, $3); }
2031 | eip_op strop rval_expr %prec EQUAL_T {
2034 if (rve_is_constant($3)){
2035 i_tmp=rve_guess_type($3);
2037 yyerror("string expected");
2038 else if (i_tmp==RV_STR){
2039 if (((rval_tmp=rval_expr_eval(0, 0, $3))==0) ||
2040 (rval_get_str(0, 0, &s_tmp, rval_tmp, 0)<0)){
2041 rval_destroy(rval_tmp);
2042 yyerror("bad rvalue expression");
2044 rval_destroy(rval_tmp);
2047 yyerror("BUG: unexpected dynamic type");
2050 warn("non constant rvalue in ip comparison");
2053 ip_tmp=str2ip(&s_tmp);
2056 ip_tmp=str2ip6(&s_tmp);
2060 $$=mk_elem($2, $1, 0, NET_ST,
2061 mk_net_bitlen(ip_tmp, ip_tmp->len*8) );
2063 $$=mk_elem($2, $1, 0, RVE_ST, $3);
2066 $$=mk_elem($2, $1, 0, RVE_ST, $3);
2069 | eip_op strop host %prec EQUAL_T
2070 { $$=mk_elem($2, $1, 0, STRING_ST, $3); }
2071 | eip_op strop MYSELF %prec EQUAL_T
2072 { $$=mk_elem($2, $1, 0, MYSELF_ST, 0); }
2073 | eip_op strop error %prec EQUAL_T
2074 { $$=0; yyerror( "ip address or hostname expected" ); }
2076 { $$=0; yyerror("invalid operator, ==, != or =~ expected");}
2078 | MYSELF equalop uri_type %prec EQUAL_T
2079 { $$=mk_elem($2, $3, 0, MYSELF_ST, 0); }
2080 | MYSELF equalop eip_op %prec EQUAL_T
2081 { $$=mk_elem($2, $3, 0, MYSELF_ST, 0); }
2082 | MYSELF equalop error %prec EQUAL_T
2083 { $$=0; yyerror(" URI, SRCIP or DSTIP expected"); }
2084 | MYSELF error { $$=0; yyerror ("invalid operator, == or != expected"); }
2088 rval_expr cmpop rval_expr %prec GT
2089 { $$=mk_elem( $2, RVE_ST, $1, RVE_ST, $3);}
2091 rval_expr equalop rval_expr %prec EQUAL_T
2092 { $$=mk_elem( $2, RVE_ST, $1, RVE_ST, $3);}
2093 | rval_expr LOG_AND rval_expr
2094 { $$=mk_exp_rve(LOGAND_OP, $1, $3);}
2095 | rval_expr LOG_OR rval_expr
2096 { $$=mk_exp_rve(LOGOR_OP, $1, $3);}
2101 ip SLASH ip { $$=mk_net($1, $3); }
2103 if (($3<0) || ($3>$1->len*8)) {
2104 yyerror("invalid bit number in netmask");
2107 $$=mk_net_bitlen($1, $3);
2109 $$=mk_net($1, htonl( ($3)?~( (1<<(32-$3))-1 ):0 ) );
2113 | ip { $$=mk_net_bitlen($1, $1->len*8); }
2114 | ip SLASH error { $$=0; yyerror("netmask (eg:255.0.0.0 or 8) expected"); }
2121 $$=(char*)pkg_malloc(strlen($1)+1+strlen($3)+1);
2123 LOG(L_CRIT, "ERROR: cfg. parser: memory allocation"
2124 " failure while parsing host\n");
2126 memcpy($$, $1, strlen($1));
2128 memcpy($$+strlen($1)+1, $3, strlen($3));
2129 $$[strlen($1)+1+strlen($3)]=0;
2133 if ($3) pkg_free($3);
2137 $$=(char*)pkg_malloc(strlen($1)+1+strlen($3)+1);
2139 LOG(L_CRIT, "ERROR: cfg. parser: memory allocation"
2140 " failure while parsing host\n");
2142 memcpy($$, $1, strlen($1));
2144 memcpy($$+strlen($1)+1, $3, strlen($3));
2145 $$[strlen($1)+1+strlen($3)]=0;
2149 if ($3) pkg_free($3);
2151 | host DOT error { $$=0; pkg_free($1); yyerror("invalid hostname"); }
2152 | host MINUS error { $$=0; pkg_free($1); yyerror("invalid hostname"); }
2158 /* get string version */
2159 $$=pkg_malloc(strlen(yy_number_str)+1);
2161 strcpy($$, yy_number_str);
2166 host_if_id { $$=$1; }
2167 | host_or_if DOT host_if_id {
2169 $$=(char*)pkg_malloc(strlen($1)+1+strlen($3)+1);
2171 LOG(L_CRIT, "ERROR: cfg. parser: memory allocation"
2172 " failure while parsing host/interface name\n");
2174 memcpy($$, $1, strlen($1));
2176 memcpy($$+strlen($1)+1, $3, strlen($3));
2177 $$[strlen($1)+1+strlen($3)]=0;
2181 if ($3) pkg_free($3);
2183 | host_or_if MINUS host_if_id {
2185 $$=(char*)pkg_malloc(strlen($1)+1+strlen($3)+1);
2187 LOG(L_CRIT, "ERROR: cfg. parser: memory allocation"
2188 " failure while parsing host/interface name\n");
2190 memcpy($$, $1, strlen($1));
2192 memcpy($$+strlen($1)+1, $3, strlen($3));
2193 $$[strlen($1)+1+strlen($3)]=0;
2197 if ($3) pkg_free($3);
2199 | host_or_if DOT error { $$=0; pkg_free($1);
2200 yyerror("invalid host or interface name"); }
2201 | host_or_if MINUS error { $$=0; pkg_free($1);
2202 yyerror("invalid host or interface name"); }
2209 /* check if allowed */
2210 if ($1 && rt==ONSEND_ROUTE) {
2228 case SET_FWD_NO_CONNECT_T:
2229 case SET_RPL_NO_CONNECT_T:
2230 case SET_FWD_CLOSE_T:
2231 case SET_RPL_CLOSE_T:
2236 yyerror("command not allowed in onsend_route\n");
2247 | assign_action { $$ = $1; }
2248 | LBRACE actions RBRACE { $$=$2; }
2253 | LBRACE actions RBRACE { $$=$2; }
2256 actions action {$$=append_action($1, $2); }
2258 | actions error { $$=0; yyerror("bad command"); }
2261 fcmd SEMICOLON {$$=$1;}
2263 | switch_cmd {$$=$1;}
2264 | while_cmd { $$=$1; }
2265 | ret_cmd SEMICOLON { $$=$1; }
2266 | assign_action SEMICOLON {$$=$1;}
2267 | SEMICOLON /* null action */ {$$=0;}
2268 | fcmd error { $$=0; yyerror("bad command: missing ';'?"); }
2272 if ($2 && rval_expr_int_check($2)>=0){
2273 warn_ct_rve($2, "if");
2274 $$=mk_action( IF_T, 3, RVE_ST, $2, ACTIONS_ST, $3, NOSUBTYPE, 0);
2279 | IF rval_expr stm ELSE stm {
2280 if ($2 && rval_expr_int_check($2)>=0){
2281 warn_ct_rve($2, "if");
2282 $$=mk_action( IF_T, 3, RVE_ST, $2, ACTIONS_ST, $3, ACTIONS_ST, $5);
2289 ct_rval: rval_expr {
2291 if ($1 && !rve_is_constant($1)){
2292 yyerror("constant expected");
2296 !rve_check_type((enum rval_type*)&i_tmp, $1, 0, 0 ,0)){
2297 yyerror("invalid expression (bad type)");
2298 }else if ($1 && i_tmp!=RV_INT){
2299 yyerror("invalid expression type, int expected\n");
2306 CASE ct_rval COLON actions {
2308 if ($2==0) { yyerror ("bad case label"); YYERROR; }
2309 else if ((($$=mk_case_stm($2, 0, $4, &i_tmp))==0) && (i_tmp==-10)){
2313 | CASE SLASH ct_rval COLON actions {
2315 if ($3==0) { yyerror ("bad case label"); YYERROR; }
2316 else if ((($$=mk_case_stm($3, 1, $5, &i_tmp))==0) && (i_tmp==-10)){
2320 | CASE ct_rval COLON {
2322 if ($2==0) { yyerror ("bad case label"); YYERROR; }
2323 else if ((($$=mk_case_stm($2, 0, 0, &i_tmp))==0) && (i_tmp==-10)){
2327 | CASE SLASH ct_rval COLON {
2329 if ($3==0) { yyerror ("bad regex case label"); YYERROR; }
2330 else if ((($$=mk_case_stm($3, 1, 0, &i_tmp))==0) && (i_tmp==-10)){
2334 | DEFAULT COLON actions {
2335 if ((($$=mk_case_stm(0, 0, $3, &i_tmp))==0) && (i_tmp=-10)){
2340 if ((($$=mk_case_stm(0, 0, 0, &i_tmp))==0) && (i_tmp==-10)){
2344 | CASE error COLON actions { $$=0; yyerror("bad case label"); }
2345 | CASE SLASH error COLON actions { $$=0; yyerror("bad case regex label"); }
2346 | CASE error COLON { $$=0; yyerror("bad case label"); }
2347 | CASE SLASH error COLON { $$=0; yyerror("bad case regex label"); }
2348 | CASE ct_rval COLON error { $$=0; yyerror ("bad case body"); }
2351 case_stms single_case {
2353 if ($2==0) yyerror ("bad case");
2356 if (*($$->append)!=0)
2357 $$->append=&((*($$->append))->next);
2362 if ($1==0) yyerror ("bad case");
2363 else $$->append=&($$->next);
2367 SWITCH rval_expr LBRACE case_stms RBRACE {
2370 yyerror("bad expression in switch(...)");
2373 yyerror ("bad switch body");
2375 }else if (case_check_default($4)!=0){
2376 yyerror_at(&$2->fpos, "bad switch(): too many "
2377 "\"default:\" labels\n");
2379 }else if (case_check_type($4)!=0){
2380 yyerror_at(&$2->fpos, "bad switch(): mixed integer and"
2381 " string/RE cases not allowed\n");
2384 $$=mk_action(SWITCH_T, 2, RVE_ST, $2, CASE_ST, $4);
2386 yyerror("internal error");
2392 | SWITCH rval_expr LBRACE RBRACE {
2394 warn("empty switch()");
2396 yyerror("bad expression in switch(...)");
2399 /* it might have sideffects, so leave it for the optimizer */
2400 $$=mk_action(SWITCH_T, 2, RVE_ST, $2, CASE_ST, 0);
2402 yyerror("internal error");
2408 | SWITCH error { $$=0; yyerror ("bad expression in switch(...)"); }
2409 | SWITCH rval_expr LBRACE error RBRACE
2410 {$$=0; yyerror ("bad switch body"); }
2414 WHILE rval_expr stm {
2415 if ($2 && rval_expr_int_check($2)>=0){
2416 warn_ct_rve($2, "while");
2417 $$=mk_action( WHILE_T, 2, RVE_ST, $2, ACTIONS_ST, $3);
2420 yyerror_at(&$2->fpos, "bad while(...) expression");
2427 LBRACK ATTR_USER RBRACK { $$ = AVP_CLASS_USER; }
2428 | LBRACK ATTR_DOMAIN RBRACK { $$ = AVP_CLASS_DOMAIN; }
2429 | LBRACK ATTR_GLOBAL RBRACK { $$ = AVP_CLASS_GLOBAL; }
2434 if (sel.n >= MAX_SELECT_PARAMS-1) {
2435 yyerror("Select identifier too long\n");
2437 sel.params[sel.n].type = SEL_PARAM_STR;
2438 sel.params[sel.n].v.s.s = $1;
2439 sel.params[sel.n].v.s.len = strlen($1);
2442 | ID LBRACK intno RBRACK {
2443 if (sel.n >= MAX_SELECT_PARAMS-2) {
2444 yyerror("Select identifier too long\n");
2446 sel.params[sel.n].type = SEL_PARAM_STR;
2447 sel.params[sel.n].v.s.s = $1;
2448 sel.params[sel.n].v.s.len = strlen($1);
2450 sel.params[sel.n].type = SEL_PARAM_INT;
2451 sel.params[sel.n].v.i = $3;
2454 | ID LBRACK STRING RBRACK {
2455 if (sel.n >= MAX_SELECT_PARAMS-2) {
2456 yyerror("Select identifier too long\n");
2458 sel.params[sel.n].type = SEL_PARAM_STR;
2459 sel.params[sel.n].v.s.s = $1;
2460 sel.params[sel.n].v.s.len = strlen($1);
2462 sel.params[sel.n].type = SEL_PARAM_STR;
2463 sel.params[sel.n].v.s.s = $3;
2464 sel.params[sel.n].v.s.len = strlen($3);
2469 select_params DOT select_param
2473 SELECT_MARK { sel.n = 0; sel.f[0] = 0; } select_params {
2474 sel_ptr = (select_t*)pkg_malloc(sizeof(select_t));
2476 yyerror("No memory left to allocate select structure\n");
2478 memcpy(sel_ptr, &sel, sizeof(select_t));
2483 ATTR_FROM { s_attr->type |= AVP_TRACK_FROM; }
2484 | ATTR_TO { s_attr->type |= AVP_TRACK_TO; }
2485 | ATTR_FROMURI { s_attr->type |= AVP_TRACK_FROM | AVP_CLASS_URI; }
2486 | ATTR_TOURI { s_attr->type |= AVP_TRACK_TO | AVP_CLASS_URI; }
2487 | ATTR_FROMUSER { s_attr->type |= AVP_TRACK_FROM | AVP_CLASS_USER; }
2488 | ATTR_TOUSER { s_attr->type |= AVP_TRACK_TO | AVP_CLASS_USER; }
2489 | ATTR_FROMDOMAIN { s_attr->type |= AVP_TRACK_FROM | AVP_CLASS_DOMAIN; }
2490 | ATTR_TODOMAIN { s_attr->type |= AVP_TRACK_TO | AVP_CLASS_DOMAIN; }
2491 | ATTR_GLOBAL { s_attr->type |= AVP_TRACK_ALL | AVP_CLASS_GLOBAL; }
2494 ID { s_attr->type |= AVP_NAME_STR; s_attr->name.s.s = $1; s_attr->name.s.len = strlen ($1); }
2498 | attr_class_spec DOT attr_name_spec
2502 s_attr = (struct avp_spec*)pkg_malloc(sizeof(struct avp_spec));
2503 if (!s_attr) { yyerror("No memory left"); YYABORT; }
2504 else s_attr->type = 0;
2508 attr_mark attr_spec { $$ = s_attr; }
2511 attr_mark attr_spec LBRACK intno RBRACK {
2512 s_attr->type|= (AVP_NAME_STR | ($4<0?AVP_INDEX_BACKWARD:AVP_INDEX_FORWARD));
2513 s_attr->index = ($4<0?-$4:$4);
2518 attr_mark attr_spec LBRACK RBRACK {
2519 s_attr->type|= AVP_INDEX_ALL;
2541 if ($1->type==LV_AVP){
2542 s_attr = pkg_malloc(sizeof(struct avp_spec));
2543 if (!s_attr) { yyerror("No memory left"); YYABORT; }
2545 *s_attr=$1->lv.avps;
2549 $$=0; /* not an avp, a pvar */
2553 avp_spec_t *avp_spec;
2556 avp_spec = pkg_malloc(sizeof(*avp_spec));
2558 yyerror("Not enough memory");
2564 s.len = strlen(s.s);
2565 if (parse_avp_name(&s, &type, &avp_spec->name, &idx)) {
2566 yyerror("error when parsing AVP");
2570 avp_spec->type = type;
2571 avp_spec->index = idx;
2577 pv_spec=pkg_malloc(sizeof(*pv_spec));
2579 yyerror("Not enough memory");
2582 memset(pv_spec, 0, sizeof(*pv_spec));
2583 s_tmp.s=$1; s_tmp.len=strlen($1);
2584 if (pv_parse_spec(&s_tmp, pv_spec)==0){
2585 yyerror("unknown script pseudo variable %s", $1 );
2594 avp_pvar: AVP_OR_PVAR {
2595 lval_tmp=pkg_malloc(sizeof(*lval_tmp));
2597 yyerror("Not enough memory");
2600 memset(lval_tmp, 0, sizeof(*lval_tmp));
2601 s_tmp.s=$1; s_tmp.len=strlen(s_tmp.s);
2602 if (pv_parse_spec2(&s_tmp, &lval_tmp->lv.pvs, 1)==0){
2603 /* not a pvar, try avps */
2604 /* lval_tmp might be partially filled by the failed
2605 pv_parse_spec2() (especially if the avp name is the
2606 same as a pv class) => clean it again */
2607 memset(lval_tmp, 0, sizeof(*lval_tmp));
2608 lval_tmp->lv.avps.type|= AVP_NAME_STR;
2609 lval_tmp->lv.avps.name.s.s = s_tmp.s+1;
2610 lval_tmp->lv.avps.name.s.len = s_tmp.len-1;
2611 lval_tmp->type=LV_AVP;
2613 lval_tmp->type=LV_PVAR;
2616 DBG("parsed ambigous avp/pvar \"%.*s\" to %d\n",
2617 s_tmp.len, s_tmp.s, lval_tmp->type);
2624 ADDEQ { $$ = ADD_T; }
2625 | EQUAL { $$ = ASSIGN_T; }
2629 EQUAL { $$ = ASSIGN_T; }
2634 lval_tmp=pkg_malloc(sizeof(*lval_tmp));
2636 yyerror("Not enough memory");
2639 lval_tmp->type=LV_AVP; lval_tmp->lv.avps=*$1;
2640 pkg_free($1); /* free the avp spec we just copied */
2645 yyerror("read only pvar in assignment left side");
2647 yyerror("pvar with transformations in assignment"
2649 lval_tmp=pkg_malloc(sizeof(*lval_tmp));
2651 yyerror("Not enough memory");
2654 lval_tmp->type=LV_PVAR; lval_tmp->lv.pvs=*($1);
2655 pkg_free($1); /* free the pvar spec we just copied */
2659 if (($1)->type==LV_PVAR){
2660 if (!pv_is_w(&($1)->lv.pvs))
2661 yyerror("read only pvar in assignment left side");
2662 if ($1->lv.pvs.trans!=0)
2663 yyerror("pvar with transformations in assignment"
2670 rval: intno {$$=mk_rve_rval(RV_INT, (void*)$1); }
2671 | STRING { s_tmp.s=$1; s_tmp.len=strlen($1);
2672 $$=mk_rve_rval(RV_STR, &s_tmp); }
2673 | attr_id_any {$$=mk_rve_rval(RV_AVP, $1); pkg_free($1); }
2674 | pvar {$$=mk_rve_rval(RV_PVAR, $1); pkg_free($1); }
2678 $$=mk_rve_rval(RV_AVP, &$1->lv.avps);
2681 $$=mk_rve_rval(RV_PVAR, &$1->lv.pvs);
2684 yyerror("BUG: invalid lvalue type ");
2687 pkg_free($1); /* not needed anymore */
2689 | select_id {$$=mk_rve_rval(RV_SEL, $1); pkg_free($1); }
2690 | fcmd {$$=mk_rve_rval(RV_ACTION_ST, $1); }
2691 | exp_elem { $$=mk_rve_rval(RV_BEXPR, $1); }
2692 | LBRACE actions RBRACE {$$=mk_rve_rval(RV_ACTION_ST, $2); }
2693 | LBRACE error RBRACE { $$=0; yyerror("bad command block"); }
2694 | LPAREN assign_action RPAREN {$$=mk_rve_rval(RV_ACTION_ST, $2); }
2695 | LPAREN error RPAREN { $$=0; yyerror("bad expression"); }
2699 rve_un_op: NOT { $$=RVE_LNOT_OP; }
2700 | MINUS %prec UNARY { $$=RVE_UMINUS_OP; }
2701 /* TODO: RVE_BOOL_OP, RVE_NOT_OP? */
2705 rve_op: PLUS { $$=RVE_PLUS_OP; }
2706 | MINUS { $$=RVE_MINUS_OP; }
2707 | STAR { $$=RVE_MUL_OP; }
2708 | SLASH { $$=RVE_DIV_OP; }
2709 | MODULO { $$=RVE_MOD_OP; }
2713 rval_expr: rval { $$=$1;
2715 /*yyerror("out of memory\n");*/
2719 | rve_un_op rval_expr %prec UNARY {$$=mk_rve1($1, $2); }
2720 | INTCAST rval_expr {$$=mk_rve1(RVE_INT_OP, $2); }
2721 | STRCAST rval_expr {$$=mk_rve1(RVE_STR_OP, $2); }
2722 | rval_expr PLUS rval_expr {$$=mk_rve2(RVE_PLUS_OP, $1, $3); }
2723 | rval_expr MINUS rval_expr {$$=mk_rve2(RVE_MINUS_OP, $1, $3); }
2724 | rval_expr STAR rval_expr {$$=mk_rve2(RVE_MUL_OP, $1, $3); }
2725 | rval_expr SLASH rval_expr {$$=mk_rve2(RVE_DIV_OP, $1, $3); }
2726 | rval_expr MODULO rval_expr {$$=mk_rve2(RVE_MOD_OP, $1, $3); }
2727 | rval_expr BIN_OR rval_expr {$$=mk_rve2(RVE_BOR_OP, $1, $3); }
2728 | rval_expr BIN_AND rval_expr {$$=mk_rve2(RVE_BAND_OP, $1, $3);}
2729 | rval_expr rve_cmpop rval_expr %prec GT { $$=mk_rve2( $2, $1, $3);}
2730 | rval_expr rve_equalop rval_expr %prec EQUAL_T
2731 { $$=mk_rve2( $2, $1, $3);}
2732 | rval_expr LOG_AND rval_expr { $$=mk_rve2(RVE_LAND_OP, $1, $3);}
2733 | rval_expr LOG_OR rval_expr { $$=mk_rve2(RVE_LOR_OP, $1, $3);}
2734 | LPAREN rval_expr RPAREN { $$=$2;}
2735 | STRLEN LPAREN rval_expr RPAREN { $$=mk_rve1(RVE_STRLEN_OP, $3);}
2736 | STREMPTY LPAREN rval_expr RPAREN {$$=mk_rve1(RVE_STREMPTY_OP, $3);}
2737 | DEFINED rval_expr { $$=mk_rve1(RVE_DEFINED_OP, $2);}
2738 | rve_un_op error %prec UNARY { $$=0; yyerror("bad expression"); }
2739 | INTCAST error { $$=0; yyerror("bad expression"); }
2740 | STRCAST error { $$=0; yyerror("bad expression"); }
2741 | rval_expr PLUS error { $$=0; yyerror("bad expression"); }
2742 | rval_expr MINUS error { $$=0; yyerror("bad expression"); }
2743 | rval_expr STAR error { $$=0; yyerror("bad expression"); }
2744 | rval_expr SLASH error { $$=0; yyerror("bad expression"); }
2745 | rval_expr MODULO error { $$=0; yyerror("bad expression"); }
2746 | rval_expr BIN_OR error { $$=0; yyerror("bad expression"); }
2747 | rval_expr BIN_AND error { $$=0; yyerror("bad expression"); }
2748 | rval_expr rve_cmpop error %prec GT
2749 { $$=0; yyerror("bad expression"); }
2750 | rval_expr rve_equalop error %prec EQUAL_T
2751 { $$=0; yyerror("bad expression"); }
2752 | rval_expr LOG_AND error { $$=0; yyerror("bad expression"); }
2753 | rval_expr LOG_OR error { $$=0; yyerror("bad expression"); }
2754 | STRLEN LPAREN error RPAREN { $$=0; yyerror("bad expression"); }
2755 | STREMPTY LPAREN error RPAREN { $$=0; yyerror("bad expression"); }
2756 | DEFINED error { $$=0; yyerror("bad expression"); }
2759 assign_action: lval assign_op rval_expr { $$=mk_action($2, 2, LVAL_ST, $1,
2767 attr_id_ass assign_op STRING { $$=mk_action($2, 2, AVP_ST, $1, STRING_ST, $3); }
2768 | attr_id_ass assign_op NUMBER { $$=mk_action($2, 2, AVP_ST, $1, NUMBER_ST, (void*)$3); }
2769 | attr_id_ass assign_op fcmd { $$=mk_action($2, 2, AVP_ST, $1, ACTION_ST, $3); }
2770 | attr_id_ass assign_op attr_id_any { $$=mk_action($2, 2, AVP_ST, $1, AVP_ST, $3); }
2771 | attr_id_ass assign_op select_id { $$=mk_action($2, 2, AVP_ST, (void*)$1, SELECT_ST, (void*)$3); }
2772 | attr_id_ass assign_op LPAREN exp RPAREN { $$ = mk_action($2, 2, AVP_ST, $1, EXPR_ST, $4); }
2777 SETAVPFLAG { $$ = 1; }
2778 | RESETAVPFLAG { $$ = 0; }
2779 | ISAVPFLAGSET { $$ = -1; }
2782 FORWARD LPAREN RPAREN { $$=mk_action(FORWARD_T, 2, URIHOST_ST, 0, URIPORT_ST, 0); set_cfg_pos($$); }
2783 | FORWARD LPAREN host RPAREN { $$=mk_action( FORWARD_T, 2, STRING_ST, $3, NUMBER_ST, 0); set_cfg_pos($$); }
2784 | FORWARD LPAREN STRING RPAREN { $$=mk_action( FORWARD_T, 2, STRING_ST, $3, NUMBER_ST, 0); set_cfg_pos($$); }
2785 | FORWARD LPAREN ip RPAREN { $$=mk_action( FORWARD_T, 2, IP_ST, (void*)$3, NUMBER_ST, 0); set_cfg_pos($$); }
2786 | FORWARD LPAREN host COMMA NUMBER RPAREN { $$=mk_action(FORWARD_T, 2, STRING_ST, $3, NUMBER_ST, (void*)$5); set_cfg_pos($$); }
2787 | FORWARD LPAREN STRING COMMA NUMBER RPAREN {$$=mk_action(FORWARD_T, 2, STRING_ST, $3, NUMBER_ST, (void*)$5); set_cfg_pos($$); }
2788 | FORWARD LPAREN ip COMMA NUMBER RPAREN { $$=mk_action(FORWARD_T, 2, IP_ST, (void*)$3, NUMBER_ST, (void*)$5); set_cfg_pos($$); }
2789 | FORWARD LPAREN URIHOST COMMA URIPORT RPAREN { $$=mk_action(FORWARD_T, 2, URIHOST_ST, 0, URIPORT_ST, 0); set_cfg_pos($$); }
2790 | FORWARD LPAREN URIHOST COMMA NUMBER RPAREN {$$=mk_action(FORWARD_T, 2, URIHOST_ST, 0, NUMBER_ST, (void*)$5); set_cfg_pos($$); }
2791 | FORWARD LPAREN URIHOST RPAREN { $$=mk_action(FORWARD_T, 2, URIHOST_ST, 0, NUMBER_ST, 0); set_cfg_pos($$); }
2792 | FORWARD error { $$=0; yyerror("missing '(' or ')' ?"); }
2793 | FORWARD LPAREN error RPAREN { $$=0; yyerror("bad forward argument"); }
2794 | FORWARD_UDP LPAREN host RPAREN { $$=mk_action(FORWARD_UDP_T, 2, STRING_ST, $3, NUMBER_ST, 0); set_cfg_pos($$); }
2795 | FORWARD_UDP LPAREN STRING RPAREN { $$=mk_action(FORWARD_UDP_T, 2, STRING_ST, $3, NUMBER_ST, 0); set_cfg_pos($$); }
2796 | FORWARD_UDP LPAREN ip RPAREN { $$=mk_action(FORWARD_UDP_T, 2, IP_ST, (void*)$3, NUMBER_ST, 0); set_cfg_pos($$); }
2797 | FORWARD_UDP LPAREN host COMMA NUMBER RPAREN { $$=mk_action(FORWARD_UDP_T, 2, STRING_ST, $3, NUMBER_ST, (void*)$5); set_cfg_pos($$); }
2798 | FORWARD_UDP LPAREN STRING COMMA NUMBER RPAREN {$$=mk_action(FORWARD_UDP_T, 2, STRING_ST, $3, NUMBER_ST, (void*)$5); set_cfg_pos($$); }
2799 | FORWARD_UDP LPAREN ip COMMA NUMBER RPAREN { $$=mk_action(FORWARD_UDP_T, 2, IP_ST, (void*)$3, NUMBER_ST, (void*)$5); set_cfg_pos($$); }
2800 | FORWARD_UDP LPAREN URIHOST COMMA URIPORT RPAREN {$$=mk_action(FORWARD_UDP_T, 2, URIHOST_ST, 0, URIPORT_ST, 0); set_cfg_pos($$); }
2801 | FORWARD_UDP LPAREN URIHOST COMMA NUMBER RPAREN { $$=mk_action(FORWARD_UDP_T, 2, URIHOST_ST, 0, NUMBER_ST, (void*)$5); set_cfg_pos($$); }
2802 | FORWARD_UDP LPAREN URIHOST RPAREN { $$=mk_action(FORWARD_UDP_T, 2, URIHOST_ST, 0, NUMBER_ST, 0); set_cfg_pos($$); }
2803 | FORWARD_UDP error { $$=0; yyerror("missing '(' or ')' ?"); }
2804 | FORWARD_UDP LPAREN error RPAREN { $$=0; yyerror("bad forward_udp argument"); }
2805 | FORWARD_TCP LPAREN host RPAREN { $$=mk_action(FORWARD_TCP_T, 2, STRING_ST, $3, NUMBER_ST, 0); set_cfg_pos($$); }
2806 | FORWARD_TCP LPAREN STRING RPAREN { $$=mk_action(FORWARD_TCP_T, 2, STRING_ST, $3, NUMBER_ST, 0); set_cfg_pos($$); }
2807 | FORWARD_TCP LPAREN ip RPAREN { $$=mk_action(FORWARD_TCP_T, 2, IP_ST, (void*)$3, NUMBER_ST, 0); set_cfg_pos($$); }
2808 | FORWARD_TCP LPAREN host COMMA NUMBER RPAREN { $$=mk_action(FORWARD_TCP_T, 2, STRING_ST, $3, NUMBER_ST, (void*)$5); set_cfg_pos($$); }
2809 | FORWARD_TCP LPAREN STRING COMMA NUMBER RPAREN {$$=mk_action(FORWARD_TCP_T, 2, STRING_ST, $3, NUMBER_ST, (void*)$5); set_cfg_pos($$); }
2810 | FORWARD_TCP LPAREN ip COMMA NUMBER RPAREN { $$=mk_action(FORWARD_TCP_T, 2, IP_ST, (void*)$3, NUMBER_ST, (void*)$5); set_cfg_pos($$); }
2811 | FORWARD_TCP LPAREN URIHOST COMMA URIPORT RPAREN {$$=mk_action(FORWARD_TCP_T, 2, URIHOST_ST, 0, URIPORT_ST, 0); set_cfg_pos($$); }
2812 | FORWARD_TCP LPAREN URIHOST COMMA NUMBER RPAREN { $$=mk_action(FORWARD_TCP_T, 2, URIHOST_ST, 0, NUMBER_ST, (void*)$5); set_cfg_pos($$); }
2813 | FORWARD_TCP LPAREN URIHOST RPAREN { $$=mk_action(FORWARD_TCP_T, 2, URIHOST_ST, 0, NUMBER_ST, 0); set_cfg_pos($$); }
2814 | FORWARD_TCP error { $$=0; yyerror("missing '(' or ')' ?"); }
2815 | FORWARD_TCP LPAREN error RPAREN { $$=0; yyerror("bad forward_tcp argument"); }
2816 | FORWARD_TLS LPAREN host RPAREN {
2818 $$=mk_action(FORWARD_TLS_T, 2, STRING_ST, $3, NUMBER_ST, 0); set_cfg_pos($$);
2821 yyerror("tls support not compiled in");
2824 | FORWARD_TLS LPAREN STRING RPAREN {
2826 $$=mk_action(FORWARD_TLS_T, 2, STRING_ST, $3, NUMBER_ST, 0); set_cfg_pos($$);
2829 yyerror("tls support not compiled in");
2832 | FORWARD_TLS LPAREN ip RPAREN {
2834 $$=mk_action(FORWARD_TLS_T, 2, IP_ST, (void*)$3, NUMBER_ST, 0); set_cfg_pos($$);
2837 yyerror("tls support not compiled in");
2840 | FORWARD_TLS LPAREN host COMMA NUMBER RPAREN {
2842 $$=mk_action(FORWARD_TLS_T, 2, STRING_ST, $3, NUMBER_ST, (void*)$5); set_cfg_pos($$);
2845 yyerror("tls support not compiled in");
2848 | FORWARD_TLS LPAREN STRING COMMA NUMBER RPAREN {
2850 $$=mk_action(FORWARD_TLS_T, 2, STRING_ST, $3, NUMBER_ST, (void*)$5); set_cfg_pos($$);
2853 yyerror("tls support not compiled in");
2856 | FORWARD_TLS LPAREN ip COMMA NUMBER RPAREN {
2858 $$=mk_action(FORWARD_TLS_T, 2, IP_ST, (void*)$3, NUMBER_ST, (void*)$5); set_cfg_pos($$);
2861 yyerror("tls support not compiled in");
2864 | FORWARD_TLS LPAREN URIHOST COMMA URIPORT RPAREN {
2866 $$=mk_action(FORWARD_TLS_T, 2, URIHOST_ST, 0, URIPORT_ST, 0); set_cfg_pos($$);
2869 yyerror("tls support not compiled in");
2872 | FORWARD_TLS LPAREN URIHOST COMMA NUMBER RPAREN {
2874 $$=mk_action(FORWARD_TLS_T, 2, URIHOST_ST, 0, NUMBER_ST, (void*)$5); set_cfg_pos($$);
2877 yyerror("tls support not compiled in");
2880 | FORWARD_TLS LPAREN URIHOST RPAREN {
2882 $$=mk_action(FORWARD_TLS_T, 2, URIHOST_ST, 0, NUMBER_ST, 0); set_cfg_pos($$);
2885 yyerror("tls support not compiled in");
2888 | FORWARD_TLS error { $$=0; yyerror("missing '(' or ')' ?"); }
2889 | FORWARD_TLS LPAREN error RPAREN { $$=0;
2890 yyerror("bad forward_tls argument"); }
2891 | FORWARD_SCTP LPAREN host RPAREN {
2893 $$=mk_action(FORWARD_SCTP_T, 2, STRING_ST, $3, NUMBER_ST, 0); set_cfg_pos($$);
2896 yyerror("sctp support not compiled in");
2899 | FORWARD_SCTP LPAREN STRING RPAREN {
2901 $$=mk_action(FORWARD_SCTP_T, 2, STRING_ST, $3, NUMBER_ST, 0); set_cfg_pos($$);
2904 yyerror("sctp support not compiled in");
2907 | FORWARD_SCTP LPAREN ip RPAREN {
2909 $$=mk_action(FORWARD_SCTP_T, 2, IP_ST, (void*)$3, NUMBER_ST, 0); set_cfg_pos($$);
2912 yyerror("sctp support not compiled in");
2915 | FORWARD_SCTP LPAREN host COMMA NUMBER RPAREN {
2917 $$=mk_action(FORWARD_SCTP_T, 2, STRING_ST, $3, NUMBER_ST,
2918 (void*)$5); set_cfg_pos($$);
2921 yyerror("sctp support not compiled in");
2924 | FORWARD_SCTP LPAREN STRING COMMA NUMBER RPAREN {
2926 $$=mk_action(FORWARD_SCTP_T, 2, STRING_ST, $3, NUMBER_ST,
2927 (void*)$5); set_cfg_pos($$);
2930 yyerror("sctp support not compiled in");
2933 | FORWARD_SCTP LPAREN ip COMMA NUMBER RPAREN {
2935 $$=mk_action(FORWARD_SCTP_T, 2, IP_ST, (void*)$3, NUMBER_ST,
2936 (void*)$5); set_cfg_pos($$);
2939 yyerror("sctp support not compiled in");
2942 | FORWARD_SCTP LPAREN URIHOST COMMA URIPORT RPAREN {
2944 $$=mk_action(FORWARD_SCTP_T, 2, URIHOST_ST, 0, URIPORT_ST, 0); set_cfg_pos($$);
2947 yyerror("sctp support not compiled in");
2950 | FORWARD_SCTP LPAREN URIHOST COMMA NUMBER RPAREN {
2952 $$=mk_action(FORWARD_SCTP_T, 2, URIHOST_ST, 0, NUMBER_ST,
2953 (void*)$5); set_cfg_pos($$);
2956 yyerror("sctp support not compiled in");
2959 | FORWARD_SCTP LPAREN URIHOST RPAREN {
2961 $$=mk_action(FORWARD_SCTP_T, 2, URIHOST_ST, 0, NUMBER_ST, 0); set_cfg_pos($$);
2964 yyerror("tls support not compiled in");
2967 | FORWARD_SCTP error { $$=0; yyerror("missing '(' or ')' ?"); }
2968 | FORWARD_SCTP LPAREN error RPAREN { $$=0;
2969 yyerror("bad forward_tls argument"); }
2970 | SEND LPAREN host RPAREN { $$=mk_action(SEND_T, 2, STRING_ST, $3, NUMBER_ST, 0); set_cfg_pos($$); }
2971 | SEND LPAREN STRING RPAREN { $$=mk_action(SEND_T, 2, STRING_ST, $3, NUMBER_ST, 0); set_cfg_pos($$); }
2972 | SEND LPAREN ip RPAREN { $$=mk_action(SEND_T, 2, IP_ST, (void*)$3, NUMBER_ST, 0); set_cfg_pos($$); }
2973 | SEND LPAREN host COMMA NUMBER RPAREN { $$=mk_action(SEND_T, 2, STRING_ST, $3, NUMBER_ST, (void*)$5); set_cfg_pos($$); }
2974 | SEND LPAREN STRING COMMA NUMBER RPAREN {$$=mk_action(SEND_T, 2, STRING_ST, $3, NUMBER_ST, (void*)$5); set_cfg_pos($$); }
2975 | SEND LPAREN ip COMMA NUMBER RPAREN { $$=mk_action(SEND_T, 2, IP_ST, (void*)$3, NUMBER_ST, (void*)$5); set_cfg_pos($$); }
2976 | SEND error { $$=0; yyerror("missing '(' or ')' ?"); }
2977 | SEND LPAREN error RPAREN { $$=0; yyerror("bad send argument"); }
2978 | SEND_TCP LPAREN host RPAREN { $$=mk_action(SEND_TCP_T, 2, STRING_ST, $3, NUMBER_ST, 0); set_cfg_pos($$); }
2979 | SEND_TCP LPAREN STRING RPAREN { $$=mk_action(SEND_TCP_T, 2, STRING_ST, $3, NUMBER_ST, 0); set_cfg_pos($$); }
2980 | SEND_TCP LPAREN ip RPAREN { $$=mk_action(SEND_TCP_T, 2, IP_ST, (void*)$3, NUMBER_ST, 0); set_cfg_pos($$); }
2981 | SEND_TCP LPAREN host COMMA NUMBER RPAREN { $$=mk_action( SEND_TCP_T, 2, STRING_ST, $3, NUMBER_ST, (void*)$5); set_cfg_pos($$);}
2982 | SEND_TCP LPAREN STRING COMMA NUMBER RPAREN {$$=mk_action(SEND_TCP_T, 2, STRING_ST, $3, NUMBER_ST, (void*)$5); set_cfg_pos($$); }
2983 | SEND_TCP LPAREN ip COMMA NUMBER RPAREN { $$=mk_action(SEND_TCP_T, 2, IP_ST, (void*)$3, NUMBER_ST, (void*)$5); set_cfg_pos($$); }
2984 | SEND_TCP error { $$=0; yyerror("missing '(' or ')' ?"); }
2985 | SEND_TCP LPAREN error RPAREN { $$=0; yyerror("bad send_tcp argument"); }
2986 | LOG_TOK LPAREN STRING RPAREN {$$=mk_action(LOG_T, 2, NUMBER_ST,
2987 (void*)(L_DBG+1), STRING_ST, $3);
2989 | LOG_TOK LPAREN NUMBER COMMA STRING RPAREN {$$=mk_action(LOG_T, 2, NUMBER_ST, (void*)$3, STRING_ST, $5); set_cfg_pos($$); }
2990 | LOG_TOK error { $$=0; yyerror("missing '(' or ')' ?"); }
2991 | LOG_TOK LPAREN error RPAREN { $$=0; yyerror("bad log argument"); }
2992 | SETFLAG LPAREN NUMBER RPAREN {
2993 if (check_flag($3)==-1)
2994 yyerror("bad flag value");
2995 $$=mk_action(SETFLAG_T, 1, NUMBER_ST,
2999 | SETFLAG LPAREN flag_name RPAREN {
3000 i_tmp=get_flag_no($3, strlen($3));
3001 if (i_tmp<0) yyerror("flag not declared");
3002 $$=mk_action(SETFLAG_T, 1, NUMBER_ST,
3003 (void*)(long)i_tmp);
3006 | SETFLAG error { $$=0; yyerror("missing '(' or ')'?"); }
3007 | RESETFLAG LPAREN NUMBER RPAREN {
3008 if (check_flag($3)==-1)
3009 yyerror("bad flag value");
3010 $$=mk_action(RESETFLAG_T, 1, NUMBER_ST, (void*)$3);
3013 | RESETFLAG LPAREN flag_name RPAREN {
3014 i_tmp=get_flag_no($3, strlen($3));
3015 if (i_tmp<0) yyerror("flag not declared");
3016 $$=mk_action(RESETFLAG_T, 1, NUMBER_ST,
3017 (void*)(long)i_tmp);
3020 | RESETFLAG error { $$=0; yyerror("missing '(' or ')'?"); }
3021 | ISFLAGSET LPAREN NUMBER RPAREN {
3022 if (check_flag($3)==-1)
3023 yyerror("bad flag value");
3024 $$=mk_action(ISFLAGSET_T, 1, NUMBER_ST, (void*)$3);
3027 | ISFLAGSET LPAREN flag_name RPAREN {
3028 i_tmp=get_flag_no($3, strlen($3));
3029 if (i_tmp<0) yyerror("flag not declared");
3030 $$=mk_action(ISFLAGSET_T, 1, NUMBER_ST,
3031 (void*)(long)i_tmp);
3034 | ISFLAGSET error { $$=0; yyerror("missing '(' or ')'?"); }
3035 | avpflag_oper LPAREN attr_id_any_str COMMA flag_name RPAREN {
3036 i_tmp=get_avpflag_no($5);
3037 if (i_tmp==0) yyerror("avpflag not declared");
3038 $$=mk_action(AVPFLAG_OPER_T, 3, AVP_ST, $3, NUMBER_ST, (void*)(long)i_tmp, NUMBER_ST, (void*)$1);
3041 | avpflag_oper LPAREN attr_id_any_str COMMA error RPAREN {
3042 $$=0; yyerror("error parsing flag name");
3044 | avpflag_oper LPAREN error COMMA flag_name RPAREN {
3045 $$=0; yyerror("error parsing first parameter (avp or string)");
3047 | avpflag_oper LPAREN error RPAREN { $$=0; yyerror("bad parameters"); }
3048 | avpflag_oper error { $$=0; yyerror("missing '(' or ')'?"); }
3049 | ERROR LPAREN STRING COMMA STRING RPAREN {$$=mk_action(ERROR_T, 2, STRING_ST, $3, STRING_ST, $5);
3052 | ERROR error { $$=0; yyerror("missing '(' or ')' ?"); }
3053 | ERROR LPAREN error RPAREN { $$=0; yyerror("bad error argument"); }
3054 | ROUTE LPAREN route_name RPAREN {
3055 i_tmp=route_get(&main_rt, $3);
3057 yyerror("internal error");
3060 $$=mk_action(ROUTE_T, 1, NUMBER_ST,(void*)(long)i_tmp);
3063 | ROUTE error { $$=0; yyerror("missing '(' or ')' ?"); }
3064 | ROUTE LPAREN error RPAREN { $$=0; yyerror("bad route argument"); }
3065 | EXEC LPAREN STRING RPAREN { $$=mk_action(EXEC_T, 1, STRING_ST, $3); set_cfg_pos($$); }
3066 | SET_HOST LPAREN STRING RPAREN { $$=mk_action(SET_HOST_T, 1, STRING_ST, $3); set_cfg_pos($$); }
3067 | SET_HOST error { $$=0; yyerror("missing '(' or ')' ?"); }
3068 | SET_HOST LPAREN error RPAREN { $$=0; yyerror("bad argument, string expected"); }
3069 | PREFIX LPAREN STRING RPAREN { $$=mk_action(PREFIX_T, 1, STRING_ST, $3); set_cfg_pos($$); }
3070 | PREFIX error { $$=0; yyerror("missing '(' or ')' ?"); }
3071 | PREFIX LPAREN error RPAREN { $$=0; yyerror("bad argument, string expected"); }
3072 | STRIP_TAIL LPAREN NUMBER RPAREN { $$=mk_action(STRIP_TAIL_T, 1, NUMBER_ST, (void*)$3); set_cfg_pos($$); }
3073 | STRIP_TAIL error { $$=0; yyerror("missing '(' or ')' ?"); }
3074 | STRIP_TAIL LPAREN error RPAREN { $$=0; yyerror("bad argument, number expected"); }
3075 | STRIP LPAREN NUMBER RPAREN { $$=mk_action(STRIP_T, 1, NUMBER_ST, (void*) $3); set_cfg_pos($$); }
3076 | STRIP error { $$=0; yyerror("missing '(' or ')' ?"); }
3077 | STRIP LPAREN error RPAREN { $$=0; yyerror("bad argument, number expected"); }
3078 | SET_USERPHONE LPAREN RPAREN { $$=mk_action(SET_USERPHONE_T, 0); set_cfg_pos($$); }
3079 | SET_USERPHONE error { $$=0; yyerror("missing '(' or ')' ?"); }
3080 | APPEND_BRANCH LPAREN STRING COMMA STRING RPAREN {
3082 if (str2q(&q, $5, strlen($5)) < 0) {
3083 yyerror("bad argument, q value expected");
3085 $$=mk_action(APPEND_BRANCH_T, 2, STRING_ST, $3, NUMBER_ST, (void *)(long)q);
3088 | APPEND_BRANCH LPAREN STRING RPAREN { $$=mk_action(APPEND_BRANCH_T, 2, STRING_ST, $3, NUMBER_ST, (void *)Q_UNSPECIFIED); set_cfg_pos($$); }
3089 | APPEND_BRANCH LPAREN RPAREN { $$=mk_action(APPEND_BRANCH_T, 2, STRING_ST, 0, NUMBER_ST, (void *)Q_UNSPECIFIED); set_cfg_pos($$); }
3090 | APPEND_BRANCH { $$=mk_action( APPEND_BRANCH_T, 1, STRING_ST, 0); set_cfg_pos($$); }
3091 | SET_HOSTPORT LPAREN STRING RPAREN { $$=mk_action(SET_HOSTPORT_T, 1, STRING_ST, $3); set_cfg_pos($$); }
3092 | SET_HOSTPORT error { $$=0; yyerror("missing '(' or ')' ?"); }
3093 | SET_HOSTPORT LPAREN error RPAREN { $$=0; yyerror("bad argument, string expecte