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);
249 extern int startcolumn;
250 extern int startline;
253 #define set_cfg_pos(x) \
257 (x)->cfile = (finame!=0)?finame:((cfg_file!=0)?cfg_file:"default");\
269 struct action* action;
270 struct case_stms* case_stms;
272 struct ip_addr* ipaddr;
273 struct socket_id* sockid;
274 struct name_lst* name_l;
275 struct avp_spec* attr;
276 struct _pv_spec* pvar;
279 struct rval_expr* rv_expr;
309 %token SET_HOSTPORTTRANS
321 %token ADD_LOCAL_RPORT
322 %token FORCE_TCP_ALIAS
324 %token UDP_MTU_TRY_PROTO
327 %token SET_ADV_ADDRESS
329 %token FORCE_SEND_SOCKET
330 %token SET_FWD_NO_CONNECT
331 %token SET_RPL_NO_CONNECT
378 %token SR_AUTO_ALIASES
390 %token DNS_SERVERS_NO
391 %token DNS_USE_SEARCH
392 %token DNS_SEARCH_FMATCH
393 %token DNS_CACHE_INIT
395 %token DNS_USE_FAILOVER
396 %token DNS_CACHE_FLAGS
397 %token DNS_CACHE_NEG_TTL
398 %token DNS_CACHE_MIN_TTL
399 %token DNS_CACHE_MAX_TTL
401 %token DNS_CACHE_GC_INT
402 %token DNS_CACHE_DEL_NONEXP
408 %token DST_BLST_GC_INT
409 %token DST_BLST_UDP_IMASK
410 %token DST_BLST_TCP_IMASK
411 %token DST_BLST_TLS_IMASK
412 %token DST_BLST_SCTP_IMASK
424 %token SERVER_SIGNATURE
426 %token USER_AGENT_HEADER
438 %token TCP_ACCEPT_ALIASES
440 %token TCP_CONNECT_TIMEOUT
441 %token TCP_SEND_TIMEOUT
442 %token TCP_CON_LIFETIME
443 %token TCP_POLL_METHOD
444 %token TCP_MAX_CONNECTIONS
445 %token TCP_NO_CONNECT
446 %token TCP_SOURCE_IPV4
447 %token TCP_SOURCE_IPV6
448 %token TCP_OPT_FD_CACHE
449 %token TCP_OPT_BUF_WRITE
450 %token TCP_OPT_CONN_WQ_MAX
451 %token TCP_OPT_WQ_MAX
452 %token TCP_OPT_RD_BUF
453 %token TCP_OPT_WQ_BLK
454 %token TCP_OPT_DEFER_ACCEPT
455 %token TCP_OPT_DELAYED_ACK
456 %token TCP_OPT_SYNCNT
457 %token TCP_OPT_LINGER2
458 %token TCP_OPT_KEEPALIVE
459 %token TCP_OPT_KEEPIDLE
460 %token TCP_OPT_KEEPINTVL
461 %token TCP_OPT_KEEPCNT
462 %token TCP_OPT_CRLF_PING
468 %token TLS_HANDSHAKE_TIMEOUT
469 %token TLS_SEND_TIMEOUT
475 %token TLS_REQUIRE_CERTIFICATE
476 %token TLS_CERTIFICATE
477 %token TLS_PRIVATE_KEY
482 %token SCTP_SOCKET_RCVBUF
483 %token SCTP_SOCKET_SNDBUF
484 %token SCTP_AUTOCLOSE
486 %token SCTP_SEND_RETRIES
487 %token SCTP_ASSOC_TRACKING
488 %token SCTP_ASSOC_REUSE
489 %token SCTP_MAX_ASSOCS
490 %token SCTP_SRTO_INITIAL
493 %token SCTP_ASOCMAXRXT
494 %token SCTP_INIT_MAX_ATTEMPTS
495 %token SCTP_INIT_MAX_TIMEO
496 %token SCTP_HBINTERVAL
497 %token SCTP_PATHMAXRXT
498 %token SCTP_SACK_DELAY
499 %token SCTP_SACK_FREQ
500 %token SCTP_MAX_BURST
501 %token ADVERTISED_ADDRESS
502 %token ADVERTISED_PORT
506 %token SHM_FORCE_ALLOC
511 %token RT_TIMER1_PRIO
512 %token RT_TIMER1_POLICY
513 %token RT_TIMER2_PRIO
514 %token RT_TIMER2_POLICY
515 %token MCAST_LOOPBACK
518 %token PMTU_DISCOVERY
521 %token CFG_DESCRIPTION
535 %token ATTR_FROMDOMAIN
541 %token STUN_REFRESH_INTERVAL
542 %token STUN_ALLOW_STUN
546 /* operators, C like precedence */
552 %left EQUAL_T DIFF MATCH INTEQ INTDIFF STREQ STRDIFF
555 %left STAR SLASH MODULO
558 %right INTCAST STRCAST
561 /* no precedence, they use () */
566 %token <intval> NUMBER
568 %token <strval> NUM_ID
569 %token <strval> STRING
570 %token <strval> IPV6ADDR
572 /* not clear yet if this is an avp or pvar */
573 %token <strval> AVP_OR_PVAR
574 %token <strval> EVENT_RT_NAME
590 /*%type <expr> exp */
591 %type <expr> exp_elem
592 %type <intval> intno eint_op eint_op_onsend
593 %type <intval> eip_op eip_op_onsend
594 %type <action> action actions cmd fcmd if_cmd stm /*exp_stm*/ assign_action
595 %type <action> switch_cmd while_cmd ret_cmd
596 %type <case_stms> single_case case_stms
597 %type <ipaddr> ipv4 ipv6 ipv6addr ip
599 %type <strval> host host_or_if host_if_id
600 %type <strval> listen_id
601 %type <name_l> listen_id_lst
602 %type <name_l> listen_id2
603 %type <sockid> id_lst
604 %type <sockid> phostport
605 %type <sockid> listen_phostport
606 %type <intval> proto port
607 %type <intval> equalop strop cmpop rve_cmpop rve_equalop
608 %type <intval> uri_type
610 %type <attr> attr_id_num_idx
611 %type <attr> attr_id_no_idx
612 %type <attr> attr_id_ass
613 /*%type <attr> attr_id_val*/
614 %type <attr> attr_id_any
615 %type <attr> attr_id_any_str
618 %type <rv_expr> rval rval_expr ct_rval
619 %type <lval> avp_pvar
620 /* %type <intval> class_id */
621 %type <intval> assign_op
622 %type <select> select_id
623 %type <strval> flag_name;
624 %type <strval> route_name;
625 %type <intval> avpflag_oper
626 %type <intval> rve_un_op
627 %type <strval> cfg_var_id
628 /* %type <intval> rve_op */
630 /*%type <route_el> rules;
631 %type <route_el> rule;
641 statements statement {}
643 | statements error { yyerror(""); YYABORT;}
650 | {rt=REQUEST_ROUTE;} route_stm
651 | {rt=FAILURE_ROUTE;} failure_route_stm
653 | {rt=BRANCH_ROUTE;} branch_route_stm
654 | {rt=ONSEND_ROUTE;} send_route_stm
655 | {rt=EVENT_ROUTE;} event_route_stm
656 | SEMICOLON /* null statement */
657 | CR /* null statement*/
664 LOG(L_CRIT, "ERROR: cfg. parser: bad ip "
668 $$=pkg_malloc(strlen(tmp)+1);
670 LOG(L_CRIT, "ERROR: cfg. parser: out of "
673 strncpy($$, tmp, strlen(tmp)+1);
679 $$=pkg_malloc(strlen($1)+1);
681 LOG(L_CRIT, "ERROR: cfg. parser: out of "
684 strncpy($$, $1, strlen($1)+1);
689 $$=pkg_malloc(strlen($1)+1);
691 LOG(L_CRIT, "ERROR: cfg. parser: out of "
694 strncpy($$, $1, strlen($1)+1);
702 listen_id { $$=mk_name_lst($1, SI_IS_MHOMED); }
703 | listen_id COMMA listen_id_lst { $$=mk_name_lst($1, SI_IS_MHOMED);
709 LPAREN listen_id_lst RPAREN { $$=$2; }
710 | listen_id { $$=mk_name_lst($1, 0); }
714 UDP { $$=PROTO_UDP; }
715 | TCP { $$=PROTO_TCP; }
716 | TLS { $$=PROTO_TLS; }
717 | SCTP { $$=PROTO_SCTP; }
725 listen_id { $$=mk_listen_id($1, 0, 0); }
726 | listen_id COLON port { $$=mk_listen_id($1, 0, $3); }
727 | proto COLON listen_id { $$=mk_listen_id($3, $1, 0); }
728 | proto COLON listen_id COLON port { $$=mk_listen_id($3, $1, $5);}
729 | listen_id COLON error { $$=0; yyerror(" port number expected"); }
733 listen_id2 { $$=mk_listen_id2($1, 0, 0); }
734 | listen_id2 COLON port { $$=mk_listen_id2($1, 0, $3); }
735 | proto COLON listen_id2 { $$=mk_listen_id2($3, $1, 0); }
736 | proto COLON listen_id2 COLON port { $$=mk_listen_id2($3, $1, $5);}
737 | listen_id2 COLON error { $$=0; yyerror(" port number expected"); }
741 listen_phostport { $$=$1 ; }
742 | listen_phostport id_lst { $$=$1; if ($$) $$->next=$2; }
746 | MINUS NUMBER %prec UNARY { $$=-$2; }
749 flags_decl: FLAGS_DECL flag_list
750 | FLAGS_DECL error { yyerror("flag list expected\n"); }
753 | flag_spec COMMA flag_list
756 flag_spec: flag_name { if (register_flag($1,-1)<0)
757 yyerror("register flag failed");
759 | flag_name COLON NUMBER {
760 if (register_flag($1, $3)<0)
761 yyerror("register flag failed");
765 flag_name: STRING { $$=$1; }
770 AVPFLAGS_DECL avpflag_list
771 | AVPFLAGS_DECL error { yyerror("avpflag list expected\n"); }
775 | avpflag_spec COMMA avpflag_list
779 if (register_avpflag($1)==0)
780 yyerror("cannot declare avpflag");
784 DEBUG_V EQUAL intno { default_core_cfg.debug=$3; }
785 | DEBUG_V EQUAL error { yyerror("number expected"); }
786 | FORK EQUAL NUMBER { dont_fork= ! $3; }
787 | FORK EQUAL error { yyerror("boolean value expected"); }
788 | LOGSTDERROR EQUAL NUMBER { if (!config_check) log_stderr=$3; }
789 | LOGSTDERROR EQUAL error { yyerror("boolean value expected"); }
790 | LOGFACILITY EQUAL ID {
791 if ( (i_tmp=str2facility($3))==-1)
792 yyerror("bad facility (see syslog(3) man page)");
794 default_core_cfg.log_facility=i_tmp;
796 | LOGFACILITY EQUAL error { yyerror("ID expected"); }
797 | LOGNAME EQUAL STRING { log_name=$3; }
798 | LOGNAME EQUAL error { yyerror("string value expected"); }
799 | DNS EQUAL NUMBER { received_dns|= ($3)?DO_DNS:0; }
800 | DNS EQUAL error { yyerror("boolean value expected"); }
801 | REV_DNS EQUAL NUMBER { received_dns|= ($3)?DO_REV_DNS:0; }
802 | REV_DNS EQUAL error { yyerror("boolean value expected"); }
803 | DNS_TRY_IPV6 EQUAL NUMBER { default_core_cfg.dns_try_ipv6=$3; }
804 | DNS_TRY_IPV6 error { yyerror("boolean value expected"); }
805 | DNS_TRY_NAPTR EQUAL NUMBER { IF_NAPTR(default_core_cfg.dns_try_naptr=$3); }
806 | DNS_TRY_NAPTR error { yyerror("boolean value expected"); }
807 | DNS_SRV_LB EQUAL NUMBER { IF_DNS_FAILOVER(default_core_cfg.dns_srv_lb=$3); }
808 | DNS_SRV_LB error { yyerror("boolean value expected"); }
809 | DNS_UDP_PREF EQUAL intno { IF_NAPTR(default_core_cfg.dns_udp_pref=$3);}
810 | DNS_UDP_PREF error { yyerror("number expected"); }
811 | DNS_TCP_PREF EQUAL intno { IF_NAPTR(default_core_cfg.dns_tcp_pref=$3);}
812 | DNS_TCP_PREF error { yyerror("number expected"); }
813 | DNS_TLS_PREF EQUAL intno { IF_NAPTR(default_core_cfg.dns_tls_pref=$3);}
814 | DNS_TLS_PREF error { yyerror("number expected"); }
815 | DNS_SCTP_PREF EQUAL intno {
816 IF_NAPTR(default_core_cfg.dns_sctp_pref=$3); }
817 | DNS_SCTP_PREF error { yyerror("number expected"); }
818 | DNS_RETR_TIME EQUAL NUMBER { default_core_cfg.dns_retr_time=$3; }
819 | DNS_RETR_TIME error { yyerror("number expected"); }
820 | DNS_RETR_NO EQUAL NUMBER { default_core_cfg.dns_retr_no=$3; }
821 | DNS_RETR_NO error { yyerror("number expected"); }
822 | DNS_SERVERS_NO EQUAL NUMBER { default_core_cfg.dns_servers_no=$3; }
823 | DNS_SERVERS_NO error { yyerror("number expected"); }
824 | DNS_USE_SEARCH EQUAL NUMBER { default_core_cfg.dns_search_list=$3; }
825 | DNS_USE_SEARCH error { yyerror("boolean value expected"); }
826 | DNS_SEARCH_FMATCH EQUAL NUMBER { default_core_cfg.dns_search_fmatch=$3; }
827 | DNS_SEARCH_FMATCH error { yyerror("boolean value expected"); }
828 | DNS_CACHE_INIT EQUAL NUMBER { IF_DNS_CACHE(dns_cache_init=$3); }
829 | DNS_CACHE_INIT error { yyerror("boolean value expected"); }
830 | DNS_USE_CACHE EQUAL NUMBER { IF_DNS_CACHE(default_core_cfg.use_dns_cache=$3); }
831 | DNS_USE_CACHE error { yyerror("boolean value expected"); }
832 | DNS_USE_FAILOVER EQUAL NUMBER { IF_DNS_FAILOVER(default_core_cfg.use_dns_failover=$3);}
833 | DNS_USE_FAILOVER error { yyerror("boolean value expected"); }
834 | DNS_CACHE_FLAGS EQUAL NUMBER { IF_DNS_CACHE(default_core_cfg.dns_cache_flags=$3); }
835 | DNS_CACHE_FLAGS error { yyerror("boolean value expected"); }
836 | DNS_CACHE_NEG_TTL EQUAL NUMBER { IF_DNS_CACHE(default_core_cfg.dns_neg_cache_ttl=$3); }
837 | DNS_CACHE_NEG_TTL error { yyerror("boolean value expected"); }
838 | DNS_CACHE_MAX_TTL EQUAL NUMBER { IF_DNS_CACHE(default_core_cfg.dns_cache_max_ttl=$3); }
839 | DNS_CACHE_MAX_TTL error { yyerror("boolean value expected"); }
840 | DNS_CACHE_MIN_TTL EQUAL NUMBER { IF_DNS_CACHE(default_core_cfg.dns_cache_min_ttl=$3); }
841 | DNS_CACHE_MIN_TTL error { yyerror("boolean value expected"); }
842 | DNS_CACHE_MEM EQUAL NUMBER { IF_DNS_CACHE(default_core_cfg.dns_cache_max_mem=$3); }
843 | DNS_CACHE_MEM error { yyerror("boolean value expected"); }
844 | DNS_CACHE_GC_INT EQUAL NUMBER { IF_DNS_CACHE(dns_timer_interval=$3); }
845 | DNS_CACHE_GC_INT error { yyerror("boolean value expected"); }
846 | DNS_CACHE_DEL_NONEXP EQUAL NUMBER { IF_DNS_CACHE(default_core_cfg.dns_cache_del_nonexp=$3); }
847 | DNS_CACHE_DEL_NONEXP error { yyerror("boolean value expected"); }
848 | DST_BLST_INIT EQUAL NUMBER { IF_DST_BLACKLIST(dst_blacklist_init=$3); }
849 | DST_BLST_INIT error { yyerror("boolean value expected"); }
850 | USE_DST_BLST EQUAL NUMBER {
851 IF_DST_BLACKLIST(default_core_cfg.use_dst_blacklist=$3);
853 | USE_DST_BLST error { yyerror("boolean value expected"); }
854 | DST_BLST_MEM EQUAL NUMBER {
855 IF_DST_BLACKLIST(default_core_cfg.blst_max_mem=$3);
857 | DST_BLST_MEM error { yyerror("boolean value expected"); }
858 | DST_BLST_TTL EQUAL NUMBER {
859 IF_DST_BLACKLIST(default_core_cfg.blst_timeout=$3);
861 | DST_BLST_TTL error { yyerror("boolean value expected"); }
862 | DST_BLST_GC_INT EQUAL NUMBER { IF_DST_BLACKLIST(blst_timer_interval=$3);}
863 | DST_BLST_GC_INT error { yyerror("boolean value expected"); }
864 | DST_BLST_UDP_IMASK EQUAL NUMBER {
865 IF_DST_BLACKLIST(default_core_cfg.blst_udp_imask=$3);
867 | DST_BLST_UDP_IMASK error { yyerror("number(flags) expected"); }
868 | DST_BLST_TCP_IMASK EQUAL NUMBER {
869 IF_DST_BLACKLIST(default_core_cfg.blst_tcp_imask=$3);
871 | DST_BLST_TCP_IMASK error { yyerror("number(flags) expected"); }
872 | DST_BLST_TLS_IMASK EQUAL NUMBER {
873 IF_DST_BLACKLIST(default_core_cfg.blst_tls_imask=$3);
875 | DST_BLST_TLS_IMASK error { yyerror("number(flags) expected"); }
876 | DST_BLST_SCTP_IMASK EQUAL NUMBER {
877 IF_DST_BLACKLIST(default_core_cfg.blst_sctp_imask=$3);
879 | DST_BLST_SCTP_IMASK error { yyerror("number(flags) expected"); }
880 | PORT EQUAL NUMBER { port_no=$3; }
881 | STAT EQUAL STRING {
886 | MAXBUFFER EQUAL NUMBER { maxbuffer=$3; }
887 | MAXBUFFER EQUAL error { yyerror("number expected"); }
888 | PORT EQUAL error { yyerror("number expected"); }
889 | CHILDREN EQUAL NUMBER { children_no=$3; }
890 | CHILDREN EQUAL error { yyerror("number expected"); }
891 | CHECK_VIA EQUAL NUMBER { check_via=$3; }
892 | CHECK_VIA EQUAL error { yyerror("boolean value expected"); }
893 | PHONE2TEL EQUAL NUMBER { phone2tel=$3; }
894 | PHONE2TEL EQUAL error { yyerror("boolean value expected"); }
895 | SYN_BRANCH EQUAL NUMBER { syn_branch=$3; }
896 | SYN_BRANCH EQUAL error { yyerror("boolean value expected"); }
897 | MEMLOG EQUAL intno { default_core_cfg.memlog=$3; }
898 | MEMLOG EQUAL error { yyerror("int value expected"); }
899 | MEMDBG EQUAL intno { default_core_cfg.memdbg=$3; }
900 | MEMDBG EQUAL error { yyerror("int value expected"); }
901 | MEMSUM EQUAL intno { default_core_cfg.mem_summary=$3; }
902 | MEMSUM EQUAL error { yyerror("int value expected"); }
903 | SIP_WARNING EQUAL NUMBER { sip_warning=$3; }
904 | SIP_WARNING EQUAL error { yyerror("boolean value expected"); }
905 | USER EQUAL STRING {
906 if (shm_initialized())
907 yyerror("user must be before any modparam or the"
913 if (shm_initialized())
914 yyerror("user must be before any modparam or the"
919 | USER EQUAL error { yyerror("string value expected"); }
920 | GROUP EQUAL STRING { group=$3; }
921 | GROUP EQUAL ID { group=$3; }
922 | GROUP EQUAL error { yyerror("string value expected"); }
923 | CHROOT EQUAL STRING { chroot_dir=$3; }
924 | CHROOT EQUAL ID { chroot_dir=$3; }
925 | CHROOT EQUAL error { yyerror("string value expected"); }
926 | WDIR EQUAL STRING { working_dir=$3; }
927 | WDIR EQUAL ID { working_dir=$3; }
928 | WDIR EQUAL error { yyerror("string value expected"); }
929 | MHOMED EQUAL NUMBER { mhomed=$3; }
930 | MHOMED EQUAL error { yyerror("boolean value expected"); }
931 | DISABLE_TCP EQUAL NUMBER {
935 warn("tcp support not compiled in");
938 | DISABLE_TCP EQUAL error { yyerror("boolean value expected"); }
939 | TCP_ACCEPT_ALIASES EQUAL NUMBER {
941 tcp_default_cfg.accept_aliases=$3;
943 warn("tcp support not compiled in");
946 | TCP_ACCEPT_ALIASES EQUAL error { yyerror("boolean value expected"); }
947 | TCP_CHILDREN EQUAL NUMBER {
951 warn("tcp support not compiled in");
954 | TCP_CHILDREN EQUAL error { yyerror("number expected"); }
955 | TCP_CONNECT_TIMEOUT EQUAL intno {
957 tcp_default_cfg.connect_timeout_s=$3;
959 warn("tcp support not compiled in");
962 | TCP_CONNECT_TIMEOUT EQUAL error { yyerror("number expected"); }
963 | TCP_SEND_TIMEOUT EQUAL intno {
965 tcp_default_cfg.send_timeout=S_TO_TICKS($3);
967 warn("tcp support not compiled in");
970 | TCP_SEND_TIMEOUT EQUAL error { yyerror("number expected"); }
971 | TCP_CON_LIFETIME EQUAL intno {
974 tcp_default_cfg.con_lifetime=-1;
976 tcp_default_cfg.con_lifetime=S_TO_TICKS($3);
978 warn("tcp support not compiled in");
981 | TCP_CON_LIFETIME EQUAL error { yyerror("number expected"); }
982 | TCP_POLL_METHOD EQUAL ID {
984 tcp_poll_method=get_poll_type($3);
985 if (tcp_poll_method==POLL_NONE) {
986 LOG(L_CRIT, "bad poll method name:"
987 " %s\n, try one of %s.\n",
989 yyerror("bad tcp_poll_method "
993 warn("tcp support not compiled in");
996 | TCP_POLL_METHOD EQUAL STRING {
998 tcp_poll_method=get_poll_type($3);
999 if (tcp_poll_method==POLL_NONE) {
1000 LOG(L_CRIT, "bad poll method name:"
1001 " %s\n, try one of %s.\n",
1003 yyerror("bad tcp_poll_method "
1007 warn("tcp support not compiled in");
1010 | TCP_POLL_METHOD EQUAL error { yyerror("poll method name expected"); }
1011 | TCP_MAX_CONNECTIONS EQUAL NUMBER {
1013 tcp_max_connections=$3;
1015 warn("tcp support not compiled in");
1018 | TCP_MAX_CONNECTIONS EQUAL error { yyerror("number expected"); }
1019 | TCP_NO_CONNECT EQUAL NUMBER {
1021 tcp_default_cfg.no_connect=$3;
1023 warn("tcp support not compiled in");
1026 | TCP_NO_CONNECT EQUAL error { yyerror("boolean value expected"); }
1027 | TCP_SOURCE_IPV4 EQUAL ipv4 {
1029 if (tcp_set_src_addr($3)<0)
1030 warn("tcp_source_ipv4 failed");
1032 warn("tcp support not compiled in");
1036 | TCP_SOURCE_IPV4 EQUAL error { yyerror("IPv4 address expected"); }
1037 | TCP_SOURCE_IPV6 EQUAL ipv6 {
1040 if (tcp_set_src_addr($3)<0)
1041 warn("tcp_source_ipv6 failed");
1043 warn("IPv6 support not compiled in");
1046 warn("tcp support not compiled in");
1050 | TCP_SOURCE_IPV6 EQUAL error { yyerror("IPv6 address expected"); }
1051 | TCP_OPT_FD_CACHE EQUAL NUMBER {
1053 tcp_default_cfg.fd_cache=$3;
1055 warn("tcp support not compiled in");
1058 | TCP_OPT_FD_CACHE EQUAL error { yyerror("boolean value expected"); }
1059 | TCP_OPT_BUF_WRITE EQUAL NUMBER {
1061 tcp_default_cfg.async=$3;
1063 warn("tcp support not compiled in");
1066 | TCP_OPT_BUF_WRITE EQUAL error { yyerror("boolean value expected"); }
1067 | TCP_OPT_CONN_WQ_MAX EQUAL NUMBER {
1069 tcp_default_cfg.tcpconn_wq_max=$3;
1071 warn("tcp support not compiled in");
1074 | TCP_OPT_CONN_WQ_MAX error { yyerror("boolean value expected"); }
1075 | TCP_OPT_WQ_MAX EQUAL NUMBER {
1077 tcp_default_cfg.tcp_wq_max=$3;
1079 warn("tcp support not compiled in");
1082 | TCP_OPT_WQ_MAX error { yyerror("number expected"); }
1083 | TCP_OPT_RD_BUF EQUAL NUMBER {
1085 tcp_default_cfg.rd_buf_size=$3;
1087 warn("tcp support not compiled in");
1090 | TCP_OPT_RD_BUF error { yyerror("number expected"); }
1091 | TCP_OPT_WQ_BLK EQUAL NUMBER {
1093 tcp_default_cfg.wq_blk_size=$3;
1095 warn("tcp support not compiled in");
1098 | TCP_OPT_WQ_BLK error { yyerror("number expected"); }
1099 | TCP_OPT_DEFER_ACCEPT EQUAL NUMBER {
1101 tcp_default_cfg.defer_accept=$3;
1103 warn("tcp support not compiled in");
1106 | TCP_OPT_DEFER_ACCEPT EQUAL error { yyerror("boolean value expected"); }
1107 | TCP_OPT_DELAYED_ACK EQUAL NUMBER {
1109 tcp_default_cfg.delayed_ack=$3;
1111 warn("tcp support not compiled in");
1114 | TCP_OPT_DELAYED_ACK EQUAL error { yyerror("boolean value expected"); }
1115 | TCP_OPT_SYNCNT EQUAL NUMBER {
1117 tcp_default_cfg.syncnt=$3;
1119 warn("tcp support not compiled in");
1122 | TCP_OPT_SYNCNT EQUAL error { yyerror("number expected"); }
1123 | TCP_OPT_LINGER2 EQUAL NUMBER {
1125 tcp_default_cfg.linger2=$3;
1127 warn("tcp support not compiled in");
1130 | TCP_OPT_LINGER2 EQUAL error { yyerror("number expected"); }
1131 | TCP_OPT_KEEPALIVE EQUAL NUMBER {
1133 tcp_default_cfg.keepalive=$3;
1135 warn("tcp support not compiled in");
1138 | TCP_OPT_KEEPALIVE EQUAL error { yyerror("boolean value expected");}
1139 | TCP_OPT_KEEPIDLE EQUAL NUMBER {
1141 tcp_default_cfg.keepidle=$3;
1143 warn("tcp support not compiled in");
1146 | TCP_OPT_KEEPIDLE EQUAL error { yyerror("number expected"); }
1147 | TCP_OPT_KEEPINTVL EQUAL NUMBER {
1149 tcp_default_cfg.keepintvl=$3;
1151 warn("tcp support not compiled in");
1154 | TCP_OPT_KEEPINTVL EQUAL error { yyerror("number expected"); }
1155 | TCP_OPT_KEEPCNT EQUAL NUMBER {
1157 tcp_default_cfg.keepcnt=$3;
1159 warn("tcp support not compiled in");
1162 | TCP_OPT_KEEPCNT EQUAL error { yyerror("number expected"); }
1163 | TCP_OPT_CRLF_PING EQUAL NUMBER {
1165 tcp_default_cfg.crlf_ping=$3;
1167 warn("tcp support not compiled in");
1170 | TCP_OPT_CRLF_PING EQUAL error { yyerror("boolean value expected"); }
1171 | DISABLE_TLS EQUAL NUMBER {
1175 warn("tls support not compiled in");
1178 | DISABLE_TLS EQUAL error { yyerror("boolean value expected"); }
1179 | ENABLE_TLS EQUAL NUMBER {
1183 warn("tls support not compiled in");
1186 | ENABLE_TLS EQUAL error { yyerror("boolean value expected"); }
1187 | TLSLOG EQUAL NUMBER {
1191 warn("tls-in-core support not compiled in");
1194 | TLSLOG EQUAL error { yyerror("int value expected"); }
1195 | TLS_PORT_NO EQUAL NUMBER {
1199 warn("tls support not compiled in");
1202 | TLS_PORT_NO EQUAL error { yyerror("number expected"); }
1203 | TLS_METHOD EQUAL SSLv23 {
1205 tls_method=TLS_USE_SSLv23;
1207 warn("tls-in-core support not compiled in");
1210 | TLS_METHOD EQUAL SSLv2 {
1212 tls_method=TLS_USE_SSLv2;
1214 warn("tls-in-core support not compiled in");
1217 | TLS_METHOD EQUAL SSLv3 {
1219 tls_method=TLS_USE_SSLv3;
1221 warn("tls-in-core support not compiled in");
1224 | TLS_METHOD EQUAL TLSv1 {
1226 tls_method=TLS_USE_TLSv1;
1228 warn("tls-in-core support not compiled in");
1231 | TLS_METHOD EQUAL error {
1233 yyerror("SSLv23, SSLv2, SSLv3 or TLSv1 expected");
1235 warn("tls-in-core support not compiled in");
1238 | TLS_VERIFY EQUAL NUMBER {
1242 warn("tls-in-core support not compiled in");
1245 | TLS_VERIFY EQUAL error { yyerror("boolean value expected"); }
1246 | TLS_REQUIRE_CERTIFICATE EQUAL NUMBER {
1248 tls_require_cert=$3;
1250 warn( "tls-in-core support not compiled in");
1253 | TLS_REQUIRE_CERTIFICATE EQUAL error { yyerror("boolean value expected"); }
1254 | TLS_CERTIFICATE EQUAL STRING {
1258 warn("tls-in-core support not compiled in");
1261 | TLS_CERTIFICATE EQUAL error { yyerror("string value expected"); }
1262 | TLS_PRIVATE_KEY EQUAL STRING {
1266 warn("tls-in-core support not compiled in");
1269 | TLS_PRIVATE_KEY EQUAL error { yyerror("string value expected"); }
1270 | TLS_CA_LIST EQUAL STRING {
1274 warn("tls-in-core support not compiled in");
1277 | TLS_CA_LIST EQUAL error { yyerror("string value expected"); }
1278 | TLS_HANDSHAKE_TIMEOUT EQUAL NUMBER {
1280 tls_handshake_timeout=$3;
1282 warn("tls-in-core support not compiled in");
1285 | TLS_HANDSHAKE_TIMEOUT EQUAL error { yyerror("number expected"); }
1286 | TLS_SEND_TIMEOUT EQUAL NUMBER {
1288 tls_send_timeout=$3;
1290 warn("tls-in-core support not compiled in");
1293 | TLS_SEND_TIMEOUT EQUAL error { yyerror("number expected"); }
1294 | DISABLE_SCTP EQUAL NUMBER {
1298 warn("sctp support not compiled in");
1301 | DISABLE_SCTP EQUAL error { yyerror("boolean value expected"); }
1302 | ENABLE_SCTP EQUAL NUMBER {
1304 sctp_disable=($3<=1)?!$3:$3;
1306 warn("sctp support not compiled in");
1309 | ENABLE_SCTP EQUAL error { yyerror("boolean or number expected"); }
1310 | SCTP_CHILDREN EQUAL NUMBER {
1312 sctp_children_no=$3;
1314 warn("sctp support not compiled in");
1317 | SCTP_CHILDREN EQUAL error { yyerror("number expected"); }
1318 | SCTP_SOCKET_RCVBUF EQUAL NUMBER {
1320 sctp_default_cfg.so_rcvbuf=$3;
1322 warn("sctp support not compiled in");
1325 | SCTP_SOCKET_RCVBUF EQUAL error { yyerror("number expected"); }
1326 | SCTP_SOCKET_SNDBUF EQUAL NUMBER {
1328 sctp_default_cfg.so_sndbuf=$3;
1330 warn("sctp support not compiled in");
1333 | SCTP_SOCKET_SNDBUF EQUAL error { yyerror("number expected"); }
1334 | SCTP_AUTOCLOSE EQUAL NUMBER {
1336 sctp_default_cfg.autoclose=$3;
1338 warn("sctp support not compiled in");
1341 | SCTP_AUTOCLOSE EQUAL error { yyerror("number expected"); }
1342 | SCTP_SEND_TTL EQUAL NUMBER {
1344 sctp_default_cfg.send_ttl=$3;
1346 warn("sctp support not compiled in");
1349 | SCTP_SEND_TTL EQUAL error { yyerror("number expected"); }
1350 | SCTP_SEND_RETRIES EQUAL NUMBER {
1352 sctp_default_cfg.send_retries=$3;
1354 warn("sctp support not compiled in");
1357 | SCTP_SEND_RETRIES EQUAL error { yyerror("number expected"); }
1358 | SCTP_ASSOC_TRACKING EQUAL NUMBER {
1360 #ifdef SCTP_CONN_REUSE
1361 sctp_default_cfg.assoc_tracking=$3;
1364 warn("sctp association tracking/reuse (SCTP_CONN_REUSE) "
1365 "support not compiled in");
1366 #endif /* SCTP_CONN_REUSE */
1368 warn("sctp support not compiled in");
1369 #endif /* USE_SCTP */
1371 | SCTP_ASSOC_TRACKING EQUAL error { yyerror("number expected"); }
1372 | SCTP_ASSOC_REUSE EQUAL NUMBER {
1374 #ifdef SCTP_CONN_REUSE
1375 sctp_default_cfg.assoc_reuse=$3;
1378 warn("sctp association reuse (SCTP_CONN_REUSE) support"
1379 " not compiled in");
1380 #endif /* SCTP_CONN_REUSE */
1382 warn("sctp support not compiled in");
1383 #endif /* USE_SCTP */
1385 | SCTP_ASSOC_REUSE EQUAL error { yyerror("number expected"); }
1386 | SCTP_MAX_ASSOCS EQUAL intno {
1387 IF_SCTP(sctp_default_cfg.max_assocs=$3);
1389 | SCTP_MAX_ASSOCS EQUAL error { yyerror("number expected"); }
1390 | SCTP_SRTO_INITIAL EQUAL NUMBER {
1391 IF_SCTP(sctp_default_cfg.srto_initial=$3);
1393 | SCTP_SRTO_INITIAL EQUAL error { yyerror("number expected"); }
1394 | SCTP_SRTO_MAX EQUAL NUMBER {
1395 IF_SCTP(sctp_default_cfg.srto_max=$3);
1397 | SCTP_SRTO_MAX EQUAL error { yyerror("number expected"); }
1398 | SCTP_SRTO_MIN EQUAL NUMBER {
1399 IF_SCTP(sctp_default_cfg.srto_min=$3);
1401 | SCTP_SRTO_MIN EQUAL error { yyerror("number expected"); }
1402 | SCTP_ASOCMAXRXT EQUAL NUMBER {
1403 IF_SCTP(sctp_default_cfg.asocmaxrxt=$3);
1405 | SCTP_ASOCMAXRXT EQUAL error { yyerror("number expected"); }
1406 | SCTP_INIT_MAX_ATTEMPTS EQUAL NUMBER {
1407 IF_SCTP(sctp_default_cfg.init_max_attempts=$3);
1409 | SCTP_INIT_MAX_ATTEMPTS EQUAL error { yyerror("number expected"); }
1410 | SCTP_INIT_MAX_TIMEO EQUAL NUMBER {
1411 IF_SCTP(sctp_default_cfg.init_max_timeo=$3);
1413 | SCTP_INIT_MAX_TIMEO EQUAL error { yyerror("number expected"); }
1414 | SCTP_HBINTERVAL EQUAL intno {
1415 IF_SCTP(sctp_default_cfg.hbinterval=$3);
1417 | SCTP_HBINTERVAL EQUAL error { yyerror("number expected"); }
1418 | SCTP_PATHMAXRXT EQUAL NUMBER {
1419 IF_SCTP(sctp_default_cfg.pathmaxrxt=$3);
1421 | SCTP_PATHMAXRXT EQUAL error { yyerror("number expected"); }
1422 | SCTP_SACK_DELAY EQUAL NUMBER {
1423 IF_SCTP(sctp_default_cfg.sack_delay=$3);
1425 | SCTP_SACK_DELAY EQUAL error { yyerror("number expected"); }
1426 | SCTP_SACK_FREQ EQUAL NUMBER {
1427 IF_SCTP(sctp_default_cfg.sack_freq=$3);
1429 | SCTP_SACK_FREQ EQUAL error { yyerror("number expected"); }
1430 | SCTP_MAX_BURST EQUAL NUMBER {
1431 IF_SCTP(sctp_default_cfg.max_burst=$3);
1433 | SCTP_MAX_BURST EQUAL error { yyerror("number expected"); }
1434 | SERVER_SIGNATURE EQUAL NUMBER { server_signature=$3; }
1435 | SERVER_SIGNATURE EQUAL error { yyerror("boolean value expected"); }
1436 | SERVER_HEADER EQUAL STRING { server_hdr.s=$3;
1437 server_hdr.len=strlen(server_hdr.s);
1439 | SERVER_HEADER EQUAL error { yyerror("string value expected"); }
1440 | USER_AGENT_HEADER EQUAL STRING { user_agent_hdr.s=$3;
1441 user_agent_hdr.len=strlen(user_agent_hdr.s);
1443 | USER_AGENT_HEADER EQUAL error { yyerror("string value expected"); }
1444 | REPLY_TO_VIA EQUAL NUMBER { reply_to_via=$3; }
1445 | REPLY_TO_VIA EQUAL error { yyerror("boolean value expected"); }
1446 | LISTEN EQUAL id_lst {
1447 for(lst_tmp=$3; lst_tmp; lst_tmp=lst_tmp->next) {
1448 if (add_listen_iface( lst_tmp->addr_lst->name,
1449 lst_tmp->addr_lst->next,
1450 lst_tmp->port, lst_tmp->proto,
1451 lst_tmp->flags)!=0) {
1452 LOG(L_CRIT, "ERROR: cfg. parser: failed to add listen"
1457 free_socket_id_lst($3);
1459 | LISTEN EQUAL error { yyerror("ip address, interface name or"
1460 " hostname expected"); }
1461 | ALIAS EQUAL id_lst {
1462 for(lst_tmp=$3; lst_tmp; lst_tmp=lst_tmp->next){
1463 add_alias( lst_tmp->addr_lst->name,
1464 strlen(lst_tmp->addr_lst->name),
1465 lst_tmp->port, lst_tmp->proto);
1466 for (nl_tmp=lst_tmp->addr_lst->next; nl_tmp; nl_tmp=nl_tmp->next)
1467 add_alias(nl_tmp->name, strlen(nl_tmp->name),
1468 lst_tmp->port, lst_tmp->proto);
1470 free_socket_id_lst($3);
1472 | ALIAS EQUAL error { yyerror(" hostname expected"); }
1473 | SR_AUTO_ALIASES EQUAL NUMBER { sr_auto_aliases=$3; }
1474 | SR_AUTO_ALIASES EQUAL error { yyerror("boolean value expected"); }
1475 | ADVERTISED_ADDRESS EQUAL listen_id {
1477 default_global_address.s=$3;
1478 default_global_address.len=strlen($3);
1481 | ADVERTISED_ADDRESS EQUAL error {yyerror("ip address or hostname expected"); }
1482 | ADVERTISED_PORT EQUAL NUMBER {
1483 tmp=int2str($3, &i_tmp);
1484 if ((default_global_port.s=pkg_malloc(i_tmp))==0) {
1485 LOG(L_CRIT, "ERROR: cfg. parser: out of memory.\n");
1486 default_global_port.len=0;
1488 default_global_port.len=i_tmp;
1489 memcpy(default_global_port.s, tmp, default_global_port.len);
1492 |ADVERTISED_PORT EQUAL error {yyerror("ip address or hostname expected"); }
1493 | DISABLE_CORE EQUAL NUMBER { disable_core_dump=$3; }
1494 | DISABLE_CORE EQUAL error { yyerror("boolean value expected"); }
1495 | OPEN_FD_LIMIT EQUAL NUMBER { open_files_limit=$3; }
1496 | OPEN_FD_LIMIT EQUAL error { yyerror("number expected"); }
1497 | SHM_MEM_SZ EQUAL NUMBER {
1498 if (shm_initialized())
1499 yyerror("shm/shm_mem_size must be before any modparam or the"
1501 else if (shm_mem_size == 0)
1502 shm_mem_size=$3 * 1024 * 1024;
1504 | SHM_MEM_SZ EQUAL error { yyerror("number expected"); }
1505 | SHM_FORCE_ALLOC EQUAL NUMBER {
1506 if (shm_initialized())
1507 yyerror("shm_force_alloc must be before any modparam or the"
1512 | SHM_FORCE_ALLOC EQUAL error { yyerror("boolean value expected"); }
1513 | MLOCK_PAGES EQUAL NUMBER { mlock_pages=$3; }
1514 | MLOCK_PAGES EQUAL error { yyerror("boolean value expected"); }
1515 | REAL_TIME EQUAL NUMBER { real_time=$3; }
1516 | REAL_TIME EQUAL error { yyerror("boolean value expected"); }
1517 | RT_PRIO EQUAL NUMBER { rt_prio=$3; }
1518 | RT_PRIO EQUAL error { yyerror("boolean value expected"); }
1519 | RT_POLICY EQUAL NUMBER { rt_policy=$3; }
1520 | RT_POLICY EQUAL error { yyerror("boolean value expected"); }
1521 | RT_TIMER1_PRIO EQUAL NUMBER { rt_timer1_prio=$3; }
1522 | RT_TIMER1_PRIO EQUAL error { yyerror("boolean value expected"); }
1523 | RT_TIMER1_POLICY EQUAL NUMBER { rt_timer1_policy=$3; }
1524 | RT_TIMER1_POLICY EQUAL error { yyerror("boolean value expected"); }
1525 | RT_TIMER2_PRIO EQUAL NUMBER { rt_timer2_prio=$3; }
1526 | RT_TIMER2_PRIO EQUAL error { yyerror("boolean value expected"); }
1527 | RT_TIMER2_POLICY EQUAL NUMBER { rt_timer2_policy=$3; }
1528 | RT_TIMER2_POLICY EQUAL error { yyerror("boolean value expected"); }
1529 | MCAST_LOOPBACK EQUAL NUMBER {
1533 warn("no multicast support compiled in");
1536 | MCAST_LOOPBACK EQUAL error { yyerror("boolean value expected"); }
1537 | MCAST_TTL EQUAL NUMBER {
1541 warn("no multicast support compiled in");
1544 | MCAST_TTL EQUAL error { yyerror("number expected"); }
1545 | TOS EQUAL NUMBER { tos=$3; }
1546 | TOS EQUAL error { yyerror("number expected"); }
1547 | PMTU_DISCOVERY EQUAL NUMBER { pmtu_discovery=$3; }
1548 | PMTU_DISCOVERY error { yyerror("number expected"); }
1549 | KILL_TIMEOUT EQUAL NUMBER { ser_kill_timeout=$3; }
1550 | KILL_TIMEOUT EQUAL error { yyerror("number expected"); }
1551 | MAX_WLOOPS EQUAL NUMBER { default_core_cfg.max_while_loops=$3; }
1552 | MAX_WLOOPS EQUAL error { yyerror("number expected"); }
1553 | STUN_REFRESH_INTERVAL EQUAL NUMBER { IF_STUN(stun_refresh_interval=$3); }
1554 | STUN_REFRESH_INTERVAL EQUAL error{ yyerror("number expected"); }
1555 | STUN_ALLOW_STUN EQUAL NUMBER { IF_STUN(stun_allow_stun=$3); }
1556 | STUN_ALLOW_STUN EQUAL error{ yyerror("number expected"); }
1557 | STUN_ALLOW_FP EQUAL NUMBER { IF_STUN(stun_allow_fp=$3) ; }
1558 | STUN_ALLOW_FP EQUAL error{ yyerror("number expected"); }
1559 | SERVER_ID EQUAL NUMBER { server_id=$3; }
1560 | UDP_MTU EQUAL NUMBER { default_core_cfg.udp_mtu=$3; }
1561 | UDP_MTU EQUAL error { yyerror("number expected"); }
1562 | FORCE_RPORT EQUAL NUMBER
1563 { default_core_cfg.force_rport=$3; fix_global_req_flags(0, 0); }
1564 | FORCE_RPORT EQUAL error { yyerror("boolean value expected"); }
1565 | UDP_MTU_TRY_PROTO EQUAL proto
1566 { default_core_cfg.udp_mtu_try_proto=$3; fix_global_req_flags(0, 0); }
1567 | UDP_MTU_TRY_PROTO EQUAL error
1568 { yyerror("TCP, TLS, SCTP or UDP expected"); }
1570 | error EQUAL { yyerror("unknown config variable"); }
1574 | DEFAULT { $$="default" ; } /*needed to allow default as cfg var. name*/
1578 cfg_var_id DOT cfg_var_id EQUAL NUMBER {
1579 if (cfg_declare_int($1, $3, $5, 0, 0, NULL)) {
1580 yyerror("variable cannot be declared");
1583 | cfg_var_id DOT cfg_var_id EQUAL STRING {
1584 if (cfg_declare_str($1, $3, $5, NULL)) {
1585 yyerror("variable cannot be declared");
1588 | cfg_var_id DOT cfg_var_id EQUAL NUMBER CFG_DESCRIPTION STRING {
1589 if (cfg_declare_int($1, $3, $5, 0, 0, $7)) {
1590 yyerror("variable cannot be declared");
1593 | cfg_var_id DOT cfg_var_id EQUAL STRING CFG_DESCRIPTION STRING {
1594 if (cfg_declare_str($1, $3, $5, $7)) {
1595 yyerror("variable cannot be declared");
1598 | cfg_var_id DOT cfg_var_id EQUAL error {
1599 yyerror("number or string expected");
1605 DBG("loading module %s\n", $2);
1606 if (load_module($2)!=0) {
1607 yyerror("failed to load module");
1610 | LOADMODULE error { yyerror("string expected"); }
1612 DBG("loading modules under %s\n", $2);
1613 printf("loading modules under %s\n", $2);
1616 | LOADPATH error { yyerror("string expected"); }
1617 | LOADPATH EQUAL STRING {
1618 DBG("loading modules under %s\n", $3);
1619 printf("loading modules under %s\n", $3);
1622 | LOADPATH EQUAL error { yyerror("string expected"); }
1623 | MODPARAM LPAREN STRING COMMA STRING COMMA STRING RPAREN {
1625 if (!shm_initialized() && init_shm()<0) {
1626 yyerror("Can't initialize shared memory");
1629 #endif /* SHM_MEM */
1630 if (set_mod_param_regex($3, $5, PARAM_STRING, $7) != 0) {
1631 yyerror("Can't set module parameter");
1634 | MODPARAM LPAREN STRING COMMA STRING COMMA NUMBER RPAREN {
1636 if (!shm_initialized() && init_shm()<0) {
1637 yyerror("Can't initialize shared memory");
1640 #endif /* SHM_MEM */
1641 if (set_mod_param_regex($3, $5, PARAM_INT, (void*)$7) != 0) {
1642 yyerror("Can't set module parameter");
1645 | MODPARAM error { yyerror("Invalid arguments"); }
1652 NUMBER DOT NUMBER DOT NUMBER DOT NUMBER {
1653 $$=pkg_malloc(sizeof(struct ip_addr));
1655 LOG(L_CRIT, "ERROR: cfg. parser: out of memory.\n");
1657 memset($$, 0, sizeof(struct ip_addr));
1660 if (($1>255) || ($1<0) ||
1661 ($3>255) || ($3<0) ||
1662 ($5>255) || ($5<0) ||
1663 ($7>255) || ($7<0)) {
1664 yyerror("invalid ipv4 address");
1674 ($3<<16)| ($5<<8)|$7 );
1682 $$=pkg_malloc(sizeof(struct ip_addr));
1684 LOG(L_CRIT, "ERROR: cfg. parser: out of memory.\n");
1687 memset($$, 0, sizeof(struct ip_addr));
1690 if (inet_pton(AF_INET6, $1, $$->u.addr)<=0) {
1691 yyerror("bad ipv6 address");
1694 yyerror("ipv6 address & no ipv6 support compiled in");
1702 | LBRACK ipv6addr RBRACK {$$=$2; }
1706 route_name: NUMBER {
1707 tmp=int2str($1, &i_tmp);
1708 if (($$=pkg_malloc(i_tmp+1))==0) {
1709 yyerror("out of memory");
1712 memcpy($$, tmp, i_tmp);
1721 ROUTE LBRACE actions RBRACE {
1723 if (!shm_initialized() && init_shm()<0) {
1724 yyerror("Can't initialize shared memory");
1727 #endif /* SHM_MEM */
1728 push($3, &main_rt.rlist[DEFAULT_RT]);
1730 | ROUTE LBRACK route_name RBRACK LBRACE actions RBRACE {
1732 if (!shm_initialized() && init_shm()<0) {
1733 yyerror("Can't initialize shared memory");
1736 #endif /* SHM_MEM */
1737 i_tmp=route_get(&main_rt, $3);
1739 yyerror("internal error");
1742 if (main_rt.rlist[i_tmp]){
1743 yyerror("duplicate route");
1746 push($6, &main_rt.rlist[i_tmp]);
1748 | ROUTE error { yyerror("invalid route statement"); }
1751 ROUTE_FAILURE LBRACE actions RBRACE {
1753 if (!shm_initialized() && init_shm()<0) {
1754 yyerror("Can't initialize shared memory");
1757 #endif /* SHM_MEM */
1758 push($3, &failure_rt.rlist[DEFAULT_RT]);
1760 | ROUTE_FAILURE LBRACK route_name RBRACK LBRACE actions RBRACE {
1762 if (!shm_initialized() && init_shm()<0) {
1763 yyerror("Can't initialize shared memory");
1766 #endif /* SHM_MEM */
1767 i_tmp=route_get(&failure_rt, $3);
1769 yyerror("internal error");
1772 if (failure_rt.rlist[i_tmp]){
1773 yyerror("duplicate route");
1776 push($6, &failure_rt.rlist[i_tmp]);
1778 | ROUTE_FAILURE error { yyerror("invalid failure_route statement"); }
1782 ROUTE_ONREPLY LBRACE {rt=CORE_ONREPLY_ROUTE;} actions RBRACE {
1784 if (!shm_initialized() && init_shm()<0) {
1785 yyerror("Can't initialize shared memory");
1788 #endif /* SHM_MEM */
1789 push($4, &onreply_rt.rlist[DEFAULT_RT]);
1791 | ROUTE_ONREPLY error { yyerror("invalid onreply_route statement"); }
1792 | ROUTE_ONREPLY LBRACK route_name RBRACK
1793 {rt=(*$3=='0' && $3[1]==0)?CORE_ONREPLY_ROUTE:TM_ONREPLY_ROUTE;}
1794 LBRACE actions RBRACE {
1796 if (!shm_initialized() && init_shm()<0) {
1797 yyerror("Can't initialize shared memory");
1800 #endif /* SHM_MEM */
1801 if (*$3=='0' && $3[1]==0){
1802 /* onreply_route[0] {} is equivalent with onreply_route {}*/
1803 push($7, &onreply_rt.rlist[DEFAULT_RT]);
1805 i_tmp=route_get(&onreply_rt, $3);
1807 yyerror("internal error");
1810 if (onreply_rt.rlist[i_tmp]){
1811 yyerror("duplicate route");
1814 push($7, &onreply_rt.rlist[i_tmp]);
1817 | ROUTE_ONREPLY LBRACK route_name RBRACK error {
1818 yyerror("invalid onreply_route statement");
1822 ROUTE_BRANCH LBRACE actions RBRACE {
1824 if (!shm_initialized() && init_shm()<0) {
1825 yyerror("Can't initialize shared memory");
1828 #endif /* SHM_MEM */
1829 push($3, &branch_rt.rlist[DEFAULT_RT]);
1831 | ROUTE_BRANCH LBRACK route_name RBRACK LBRACE actions RBRACE {
1833 if (!shm_initialized() && init_shm()<0) {
1834 yyerror("Can't initialize shared memory");
1837 #endif /* SHM_MEM */
1838 i_tmp=route_get(&branch_rt, $3);
1840 yyerror("internal error");
1843 if (branch_rt.rlist[i_tmp]){
1844 yyerror("duplicate route");
1847 push($6, &branch_rt.rlist[i_tmp]);
1849 | ROUTE_BRANCH error { yyerror("invalid branch_route statement"); }
1851 send_route_stm: ROUTE_SEND LBRACE actions RBRACE {
1853 if (!shm_initialized() && init_shm()<0) {
1854 yyerror("Can't initialize shared memory");
1857 #endif /* SHM_MEM */
1858 push($3, &onsend_rt.rlist[DEFAULT_RT]);
1860 | ROUTE_SEND LBRACK route_name RBRACK LBRACE actions RBRACE {
1862 if (!shm_initialized() && init_shm()<0) {
1863 yyerror("Can't initialize shared memory");
1866 #endif /* SHM_MEM */
1867 i_tmp=route_get(&onsend_rt, $3);
1869 yyerror("internal error");
1872 if (onsend_rt.rlist[i_tmp]){
1873 yyerror("duplicate route");
1876 push($6, &onsend_rt.rlist[i_tmp]);
1878 | ROUTE_SEND error { yyerror("invalid onsend_route statement"); }
1880 event_route_stm: ROUTE_EVENT LBRACK EVENT_RT_NAME RBRACK LBRACE actions RBRACE {
1882 if (!shm_initialized() && init_shm()<0) {
1883 yyerror("Can't initialize shared memory");
1886 #endif /* SHM_MEM */
1887 i_tmp=route_get(&event_rt, $3);
1889 yyerror("internal error");
1892 if (event_rt.rlist[i_tmp]){
1893 yyerror("duplicate route");
1896 push($6, &event_rt.rlist[i_tmp]);
1899 | ROUTE_EVENT error { yyerror("invalid event_route statement"); }
1905 yyerror("invalid expression");
1907 }else if (!rve_check_type((enum rval_type*)&i_tmp, $1, 0, 0 ,0)){
1908 yyerror("invalid expression");
1910 }else if (i_tmp!=RV_INT && i_tmp!=RV_NONE){
1911 yyerror("invalid expression type, int expected\n");
1914 $$=mk_elem(NO_OP, RVEXP_O, $1, 0, 0);
1919 /* exp elem operators */
1921 EQUAL_T {$$=EQUAL_OP; }
1922 | DIFF {$$=DIFF_OP; }
1923 | STREQ {$$=EQUAL_OP; } /* for expr. elems equiv. to EQUAL_T*/
1924 | STRDIFF {$$=DIFF_OP; } /* for expr. elems. equiv. to DIFF */
1934 | MATCH {$$=MATCH_OP; }
1938 /* rve expr. operators */
1940 EQUAL_T {$$=RVE_EQ_OP; }
1941 | DIFF {$$=RVE_DIFF_OP; }
1942 | INTEQ {$$=RVE_IEQ_OP; }
1943 | INTDIFF {$$=RVE_IDIFF_OP; }
1944 | STREQ {$$=RVE_STREQ_OP; }
1945 | STRDIFF {$$=RVE_STRDIFF_OP; }
1946 | MATCH {$$=RVE_MATCH_OP; }
1950 | LT {$$=RVE_LT_OP; }
1951 | GTE {$$=RVE_GTE_OP; }
1952 | LTE {$$=RVE_LTE_OP; }
1957 /* boolean expression uri operands */
1960 | FROM_URI {$$=FROM_URI_O;}
1961 | TO_URI {$$=TO_URI_O;}
1965 /* boolean expression integer operands, available only in the
1968 SNDPORT { $$=SNDPORT_O; }
1969 | TOPORT { $$=TOPORT_O; }
1970 | SNDAF { $$=SNDAF_O; }
1973 /* boolean expression integer operands */
1974 eint_op: SRCPORT { $$=SRCPORT_O; }
1975 | DSTPORT { $$=DSTPORT_O; }
1977 | MSGLEN { $$=MSGLEN_O; }
1981 /* boolean expression ip/ipnet operands */
1983 SNDIP { onsend_check("snd_ip"); $$=SNDIP_O; }
1984 | TOIP { onsend_check("to_ip"); $$=TOIP_O; }
1987 eip_op: SRCIP { $$=SRCIP_O; }
1988 | DSTIP { $$=DSTIP_O; }
1995 METHOD strop rval_expr %prec EQUAL_T
1996 {$$= mk_elem($2, METHOD_O, 0, RVE_ST, $3);}
1997 | METHOD strop ID %prec EQUAL_T
1998 {$$ = mk_elem($2, METHOD_O, 0, STRING_ST,$3); }
1999 | METHOD strop error { $$=0; yyerror("string expected"); }
2001 { $$=0; yyerror("invalid operator,== , !=, or =~ expected"); }
2002 | uri_type strop rval_expr %prec EQUAL_T
2003 {$$ = mk_elem($2, $1, 0, RVE_ST, $3); }
2004 | uri_type strop MYSELF %prec EQUAL_T
2005 {$$=mk_elem($2, $1, 0, MYSELF_ST, 0); }
2006 | uri_type strop error %prec EQUAL_T
2007 { $$=0; yyerror("string or MYSELF expected"); }
2009 { $$=0; yyerror("invalid operator, == , != or =~ expected"); }
2010 | eint_op cmpop rval_expr %prec GT { $$=mk_elem($2, $1, 0, RVE_ST, $3 ); }
2011 | eint_op equalop rval_expr %prec EQUAL_T
2012 { $$=mk_elem($2, $1, 0, RVE_ST, $3 ); }
2013 | eint_op cmpop error { $$=0; yyerror("number expected"); }
2014 | eint_op equalop error { $$=0; yyerror("number expected"); }
2015 | eint_op error { $$=0; yyerror("==, !=, <,>, >= or <= expected"); }
2016 | PROTO equalop proto %prec EQUAL_T
2017 { $$=mk_elem($2, PROTO_O, 0, NUMBER_ST, (void*)$3 ); }
2018 | PROTO equalop rval_expr %prec EQUAL_T
2019 { $$=mk_elem($2, PROTO_O, 0, RVE_ST, $3 ); }
2020 | PROTO equalop error
2021 { $$=0; yyerror("protocol expected (udp, tcp, tls or sctp)"); }
2022 | SNDPROTO equalop proto %prec EQUAL_T
2023 { $$=mk_elem($2, SNDPROTO_O, 0, NUMBER_ST, (void*)$3 ); }
2024 | SNDPROTO equalop rval_expr %prec EQUAL_T
2025 { $$=mk_elem($2, SNDPROTO_O, 0, RVE_ST, $3 ); }
2026 | SNDPROTO equalop error
2027 { $$=0; yyerror("protocol expected (udp, tcp, tls or sctp)"); }
2028 | eip_op strop ipnet %prec EQUAL_T { $$=mk_elem($2, $1, 0, NET_ST, $3); }
2029 | eip_op strop rval_expr %prec EQUAL_T {
2032 if (rve_is_constant($3)){
2033 i_tmp=rve_guess_type($3);
2035 yyerror("string expected");
2036 else if (i_tmp==RV_STR){
2037 if (((rval_tmp=rval_expr_eval(0, 0, $3))==0) ||
2038 (rval_get_str(0, 0, &s_tmp, rval_tmp, 0)<0)){
2039 rval_destroy(rval_tmp);
2040 yyerror("bad rvalue expression");
2042 rval_destroy(rval_tmp);
2045 yyerror("BUG: unexpected dynamic type");
2048 warn("non constant rvalue in ip comparison");
2051 ip_tmp=str2ip(&s_tmp);
2054 ip_tmp=str2ip6(&s_tmp);
2058 $$=mk_elem($2, $1, 0, NET_ST,
2059 mk_net_bitlen(ip_tmp, ip_tmp->len*8) );
2061 $$=mk_elem($2, $1, 0, RVE_ST, $3);
2064 $$=mk_elem($2, $1, 0, RVE_ST, $3);
2067 | eip_op strop host %prec EQUAL_T
2068 { $$=mk_elem($2, $1, 0, STRING_ST, $3); }
2069 | eip_op strop MYSELF %prec EQUAL_T
2070 { $$=mk_elem($2, $1, 0, MYSELF_ST, 0); }
2071 | eip_op strop error %prec EQUAL_T
2072 { $$=0; yyerror( "ip address or hostname expected" ); }
2074 { $$=0; yyerror("invalid operator, ==, != or =~ expected");}
2076 | MYSELF equalop uri_type %prec EQUAL_T
2077 { $$=mk_elem($2, $3, 0, MYSELF_ST, 0); }
2078 | MYSELF equalop eip_op %prec EQUAL_T
2079 { $$=mk_elem($2, $3, 0, MYSELF_ST, 0); }
2080 | MYSELF equalop error %prec EQUAL_T
2081 { $$=0; yyerror(" URI, SRCIP or DSTIP expected"); }
2082 | MYSELF error { $$=0; yyerror ("invalid operator, == or != expected"); }
2086 rval_expr cmpop rval_expr %prec GT
2087 { $$=mk_elem( $2, RVE_ST, $1, RVE_ST, $3);}
2089 rval_expr equalop rval_expr %prec EQUAL_T
2090 { $$=mk_elem( $2, RVE_ST, $1, RVE_ST, $3);}
2091 | rval_expr LOG_AND rval_expr
2092 { $$=mk_exp_rve(LOGAND_OP, $1, $3);}
2093 | rval_expr LOG_OR rval_expr
2094 { $$=mk_exp_rve(LOGOR_OP, $1, $3);}
2099 ip SLASH ip { $$=mk_net($1, $3); }
2101 if (($3<0) || ($3>$1->len*8)) {
2102 yyerror("invalid bit number in netmask");
2105 $$=mk_net_bitlen($1, $3);
2107 $$=mk_net($1, htonl( ($3)?~( (1<<(32-$3))-1 ):0 ) );
2111 | ip { $$=mk_net_bitlen($1, $1->len*8); }
2112 | ip SLASH error { $$=0; yyerror("netmask (eg:255.0.0.0 or 8) expected"); }
2119 $$=(char*)pkg_malloc(strlen($1)+1+strlen($3)+1);
2121 LOG(L_CRIT, "ERROR: cfg. parser: memory allocation"
2122 " failure while parsing host\n");
2124 memcpy($$, $1, strlen($1));
2126 memcpy($$+strlen($1)+1, $3, strlen($3));
2127 $$[strlen($1)+1+strlen($3)]=0;
2131 if ($3) pkg_free($3);
2135 $$=(char*)pkg_malloc(strlen($1)+1+strlen($3)+1);
2137 LOG(L_CRIT, "ERROR: cfg. parser: memory allocation"
2138 " failure while parsing host\n");
2140 memcpy($$, $1, strlen($1));
2142 memcpy($$+strlen($1)+1, $3, strlen($3));
2143 $$[strlen($1)+1+strlen($3)]=0;
2147 if ($3) pkg_free($3);
2149 | host DOT error { $$=0; pkg_free($1); yyerror("invalid hostname"); }
2150 | host MINUS error { $$=0; pkg_free($1); yyerror("invalid hostname"); }
2156 /* get string version */
2157 $$=pkg_malloc(strlen(yy_number_str)+1);
2159 strcpy($$, yy_number_str);
2164 host_if_id { $$=$1; }
2165 | host_or_if DOT host_if_id {
2167 $$=(char*)pkg_malloc(strlen($1)+1+strlen($3)+1);
2169 LOG(L_CRIT, "ERROR: cfg. parser: memory allocation"
2170 " failure while parsing host/interface name\n");
2172 memcpy($$, $1, strlen($1));
2174 memcpy($$+strlen($1)+1, $3, strlen($3));
2175 $$[strlen($1)+1+strlen($3)]=0;
2179 if ($3) pkg_free($3);
2181 | host_or_if MINUS host_if_id {
2183 $$=(char*)pkg_malloc(strlen($1)+1+strlen($3)+1);
2185 LOG(L_CRIT, "ERROR: cfg. parser: memory allocation"
2186 " failure while parsing host/interface name\n");
2188 memcpy($$, $1, strlen($1));
2190 memcpy($$+strlen($1)+1, $3, strlen($3));
2191 $$[strlen($1)+1+strlen($3)]=0;
2195 if ($3) pkg_free($3);
2197 | host_or_if DOT error { $$=0; pkg_free($1);
2198 yyerror("invalid host or interface name"); }
2199 | host_or_if MINUS error { $$=0; pkg_free($1);
2200 yyerror("invalid host or interface name"); }
2207 /* check if allowed */
2208 if ($1 && rt==ONSEND_ROUTE) {
2219 case SET_FWD_NO_CONNECT_T:
2220 case SET_RPL_NO_CONNECT_T:
2221 case SET_FWD_CLOSE_T:
2222 case SET_RPL_CLOSE_T:
2227 yyerror("command not allowed in onsend_route\n");
2238 | assign_action { $$ = $1; }
2239 | LBRACE actions RBRACE { $$=$2; }
2244 | LBRACE actions RBRACE { $$=$2; }
2247 actions action {$$=append_action($1, $2); }
2249 | actions error { $$=0; yyerror("bad command"); }
2252 fcmd SEMICOLON {$$=$1;}
2254 | switch_cmd {$$=$1;}
2255 | while_cmd { $$=$1; }
2256 | ret_cmd SEMICOLON { $$=$1; }
2257 | assign_action SEMICOLON {$$=$1;}
2258 | SEMICOLON /* null action */ {$$=0;}
2259 | fcmd error { $$=0; yyerror("bad command: missing ';'?"); }
2263 if ($2 && rval_expr_int_check($2)>=0){
2264 warn_ct_rve($2, "if");
2265 $$=mk_action( IF_T, 3, RVE_ST, $2, ACTIONS_ST, $3, NOSUBTYPE, 0);
2270 | IF rval_expr stm ELSE stm {
2271 if ($2 && rval_expr_int_check($2)>=0){
2272 warn_ct_rve($2, "if");
2273 $$=mk_action( IF_T, 3, RVE_ST, $2, ACTIONS_ST, $3, ACTIONS_ST, $5);
2280 ct_rval: rval_expr {
2282 if ($1 && !rve_is_constant($1)){
2283 yyerror("constant expected");
2287 !rve_check_type((enum rval_type*)&i_tmp, $1, 0, 0 ,0)){
2288 yyerror("invalid expression (bad type)");
2289 }else if ($1 && i_tmp!=RV_INT){
2290 yyerror("invalid expression type, int expected\n");
2297 CASE ct_rval COLON actions {
2299 if ($2==0) { yyerror ("bad case label"); YYERROR; }
2300 else if ((($$=mk_case_stm($2, 0, $4, &i_tmp))==0) && (i_tmp==-10)){
2304 | CASE SLASH ct_rval COLON actions {
2306 if ($3==0) { yyerror ("bad case label"); YYERROR; }
2307 else if ((($$=mk_case_stm($3, 1, $5, &i_tmp))==0) && (i_tmp==-10)){
2311 | CASE ct_rval COLON {
2313 if ($2==0) { yyerror ("bad case label"); YYERROR; }
2314 else if ((($$=mk_case_stm($2, 0, 0, &i_tmp))==0) && (i_tmp==-10)){
2318 | CASE SLASH ct_rval COLON {
2320 if ($3==0) { yyerror ("bad regex case label"); YYERROR; }
2321 else if ((($$=mk_case_stm($3, 1, 0, &i_tmp))==0) && (i_tmp==-10)){
2325 | DEFAULT COLON actions {
2326 if ((($$=mk_case_stm(0, 0, $3, &i_tmp))==0) && (i_tmp=-10)){
2331 if ((($$=mk_case_stm(0, 0, 0, &i_tmp))==0) && (i_tmp==-10)){
2335 | CASE error COLON actions { $$=0; yyerror("bad case label"); }
2336 | CASE SLASH error COLON actions { $$=0; yyerror("bad case regex label"); }
2337 | CASE error COLON { $$=0; yyerror("bad case label"); }
2338 | CASE SLASH error COLON { $$=0; yyerror("bad case regex label"); }
2339 | CASE ct_rval COLON error { $$=0; yyerror ("bad case body"); }
2342 case_stms single_case {
2344 if ($2==0) yyerror ("bad case");
2347 if (*($$->append)!=0)
2348 $$->append=&((*($$->append))->next);
2353 if ($1==0) yyerror ("bad case");
2354 else $$->append=&($$->next);
2358 SWITCH rval_expr LBRACE case_stms RBRACE {
2361 yyerror("bad expression in switch(...)");
2364 yyerror ("bad switch body");
2366 }else if (case_check_default($4)!=0){
2367 yyerror_at(&$2->fpos, "bad switch(): too many "
2368 "\"default:\" labels\n");
2370 }else if (case_check_type($4)!=0){
2371 yyerror_at(&$2->fpos, "bad switch(): mixed integer and"
2372 " string/RE cases not allowed\n");
2375 $$=mk_action(SWITCH_T, 2, RVE_ST, $2, CASE_ST, $4);
2377 yyerror("internal error");
2383 | SWITCH rval_expr LBRACE RBRACE {
2385 warn("empty switch()");
2387 yyerror("bad expression in switch(...)");
2390 /* it might have sideffects, so leave it for the optimizer */
2391 $$=mk_action(SWITCH_T, 2, RVE_ST, $2, CASE_ST, 0);
2393 yyerror("internal error");
2399 | SWITCH error { $$=0; yyerror ("bad expression in switch(...)"); }
2400 | SWITCH rval_expr LBRACE error RBRACE
2401 {$$=0; yyerror ("bad switch body"); }
2405 WHILE rval_expr stm {
2406 if ($2 && rval_expr_int_check($2)>=0){
2407 warn_ct_rve($2, "while");
2408 $$=mk_action( WHILE_T, 2, RVE_ST, $2, ACTIONS_ST, $3);
2411 yyerror_at(&$2->fpos, "bad while(...) expression");
2418 LBRACK ATTR_USER RBRACK { $$ = AVP_CLASS_USER; }
2419 | LBRACK ATTR_DOMAIN RBRACK { $$ = AVP_CLASS_DOMAIN; }
2420 | LBRACK ATTR_GLOBAL RBRACK { $$ = AVP_CLASS_GLOBAL; }
2425 if (sel.n >= MAX_SELECT_PARAMS-1) {
2426 yyerror("Select identifier too long\n");
2428 sel.params[sel.n].type = SEL_PARAM_STR;
2429 sel.params[sel.n].v.s.s = $1;
2430 sel.params[sel.n].v.s.len = strlen($1);
2433 | ID LBRACK intno RBRACK {
2434 if (sel.n >= MAX_SELECT_PARAMS-2) {
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);
2441 sel.params[sel.n].type = SEL_PARAM_INT;
2442 sel.params[sel.n].v.i = $3;
2445 | ID LBRACK STRING RBRACK {
2446 if (sel.n >= MAX_SELECT_PARAMS-2) {
2447 yyerror("Select identifier too long\n");
2449 sel.params[sel.n].type = SEL_PARAM_STR;
2450 sel.params[sel.n].v.s.s = $1;
2451 sel.params[sel.n].v.s.len = strlen($1);
2453 sel.params[sel.n].type = SEL_PARAM_STR;
2454 sel.params[sel.n].v.s.s = $3;
2455 sel.params[sel.n].v.s.len = strlen($3);
2460 select_params DOT select_param
2464 SELECT_MARK { sel.n = 0; sel.f[0] = 0; } select_params {
2465 sel_ptr = (select_t*)pkg_malloc(sizeof(select_t));
2467 yyerror("No memory left to allocate select structure\n");
2469 memcpy(sel_ptr, &sel, sizeof(select_t));
2474 ATTR_FROM { s_attr->type |= AVP_TRACK_FROM; }
2475 | ATTR_TO { s_attr->type |= AVP_TRACK_TO; }
2476 | ATTR_FROMURI { s_attr->type |= AVP_TRACK_FROM | AVP_CLASS_URI; }
2477 | ATTR_TOURI { s_attr->type |= AVP_TRACK_TO | AVP_CLASS_URI; }
2478 | ATTR_FROMUSER { s_attr->type |= AVP_TRACK_FROM | AVP_CLASS_USER; }
2479 | ATTR_TOUSER { s_attr->type |= AVP_TRACK_TO | AVP_CLASS_USER; }
2480 | ATTR_FROMDOMAIN { s_attr->type |= AVP_TRACK_FROM | AVP_CLASS_DOMAIN; }
2481 | ATTR_TODOMAIN { s_attr->type |= AVP_TRACK_TO | AVP_CLASS_DOMAIN; }
2482 | ATTR_GLOBAL { s_attr->type |= AVP_TRACK_ALL | AVP_CLASS_GLOBAL; }
2485 ID { s_attr->type |= AVP_NAME_STR; s_attr->name.s.s = $1; s_attr->name.s.len = strlen ($1); }
2489 | attr_class_spec DOT attr_name_spec
2493 s_attr = (struct avp_spec*)pkg_malloc(sizeof(struct avp_spec));
2494 if (!s_attr) { yyerror("No memory left"); YYABORT; }
2495 else s_attr->type = 0;
2499 attr_mark attr_spec { $$ = s_attr; }
2502 attr_mark attr_spec LBRACK intno RBRACK {
2503 s_attr->type|= (AVP_NAME_STR | ($4<0?AVP_INDEX_BACKWARD:AVP_INDEX_FORWARD));
2504 s_attr->index = ($4<0?-$4:$4);
2509 attr_mark attr_spec LBRACK RBRACK {
2510 s_attr->type|= AVP_INDEX_ALL;
2532 if ($1->type==LV_AVP){
2533 s_attr = pkg_malloc(sizeof(struct avp_spec));
2534 if (!s_attr) { yyerror("No memory left"); YYABORT; }
2536 *s_attr=$1->lv.avps;
2540 $$=0; /* not an avp, a pvar */
2544 avp_spec_t *avp_spec;
2547 avp_spec = pkg_malloc(sizeof(*avp_spec));
2549 yyerror("Not enough memory");
2555 s.len = strlen(s.s);
2556 if (parse_avp_name(&s, &type, &avp_spec->name, &idx)) {
2557 yyerror("error when parsing AVP");
2561 avp_spec->type = type;
2562 avp_spec->index = idx;
2568 pv_spec=pkg_malloc(sizeof(*pv_spec));
2570 yyerror("Not enough memory");
2573 memset(pv_spec, 0, sizeof(*pv_spec));
2574 s_tmp.s=$1; s_tmp.len=strlen($1);
2575 if (pv_parse_spec(&s_tmp, pv_spec)==0){
2576 yyerror("unknown script pseudo variable %s", $1 );
2585 avp_pvar: AVP_OR_PVAR {
2586 lval_tmp=pkg_malloc(sizeof(*lval_tmp));
2588 yyerror("Not enough memory");
2591 memset(lval_tmp, 0, sizeof(*lval_tmp));
2592 s_tmp.s=$1; s_tmp.len=strlen(s_tmp.s);
2593 if (pv_parse_spec2(&s_tmp, &lval_tmp->lv.pvs, 1)==0){
2594 /* not a pvar, try avps */
2595 /* lval_tmp might be partially filled by the failed
2596 pv_parse_spec2() (especially if the avp name is the
2597 same as a pv class) => clean it again */
2598 memset(lval_tmp, 0, sizeof(*lval_tmp));
2599 lval_tmp->lv.avps.type|= AVP_NAME_STR;
2600 lval_tmp->lv.avps.name.s.s = s_tmp.s+1;
2601 lval_tmp->lv.avps.name.s.len = s_tmp.len-1;
2602 lval_tmp->type=LV_AVP;
2604 lval_tmp->type=LV_PVAR;
2607 DBG("parsed ambigous avp/pvar \"%.*s\" to %d\n",
2608 s_tmp.len, s_tmp.s, lval_tmp->type);
2615 ADDEQ { $$ = ADD_T; }
2616 | EQUAL { $$ = ASSIGN_T; }
2620 EQUAL { $$ = ASSIGN_T; }
2625 lval_tmp=pkg_malloc(sizeof(*lval_tmp));
2627 yyerror("Not enough memory");
2630 lval_tmp->type=LV_AVP; lval_tmp->lv.avps=*$1;
2631 pkg_free($1); /* free the avp spec we just copied */
2636 yyerror("read only pvar in assignment left side");
2638 yyerror("pvar with transformations in assignment"
2640 lval_tmp=pkg_malloc(sizeof(*lval_tmp));
2642 yyerror("Not enough memory");
2645 lval_tmp->type=LV_PVAR; lval_tmp->lv.pvs=*($1);
2646 pkg_free($1); /* free the pvar spec we just copied */
2650 if (($1)->type==LV_PVAR){
2651 if (!pv_is_w(&($1)->lv.pvs))
2652 yyerror("read only pvar in assignment left side");
2653 if ($1->lv.pvs.trans!=0)
2654 yyerror("pvar with transformations in assignment"
2661 rval: intno {$$=mk_rve_rval(RV_INT, (void*)$1); }
2662 | STRING { s_tmp.s=$1; s_tmp.len=strlen($1);
2663 $$=mk_rve_rval(RV_STR, &s_tmp); }
2664 | attr_id_any {$$=mk_rve_rval(RV_AVP, $1); pkg_free($1); }
2665 | pvar {$$=mk_rve_rval(RV_PVAR, $1); pkg_free($1); }
2669 $$=mk_rve_rval(RV_AVP, &$1->lv.avps);
2672 $$=mk_rve_rval(RV_PVAR, &$1->lv.pvs);
2675 yyerror("BUG: invalid lvalue type ");
2678 pkg_free($1); /* not needed anymore */
2680 | select_id {$$=mk_rve_rval(RV_SEL, $1); pkg_free($1); }
2681 | fcmd {$$=mk_rve_rval(RV_ACTION_ST, $1); }
2682 | exp_elem { $$=mk_rve_rval(RV_BEXPR, $1); }
2683 | LBRACE actions RBRACE {$$=mk_rve_rval(RV_ACTION_ST, $2); }
2684 | LBRACE error RBRACE { $$=0; yyerror("bad command block"); }
2685 | LPAREN assign_action RPAREN {$$=mk_rve_rval(RV_ACTION_ST, $2); }
2686 | LPAREN error RPAREN { $$=0; yyerror("bad expression"); }
2690 rve_un_op: NOT { $$=RVE_LNOT_OP; }
2691 | MINUS %prec UNARY { $$=RVE_UMINUS_OP; }
2692 /* TODO: RVE_BOOL_OP, RVE_NOT_OP? */
2696 rve_op: PLUS { $$=RVE_PLUS_OP; }
2697 | MINUS { $$=RVE_MINUS_OP; }
2698 | STAR { $$=RVE_MUL_OP; }
2699 | SLASH { $$=RVE_DIV_OP; }
2700 | MODULO { $$=RVE_MOD_OP; }
2704 rval_expr: rval { $$=$1;
2706 /*yyerror("out of memory\n");*/
2710 | rve_un_op rval_expr %prec UNARY {$$=mk_rve1($1, $2); }
2711 | INTCAST rval_expr {$$=mk_rve1(RVE_INT_OP, $2); }
2712 | STRCAST rval_expr {$$=mk_rve1(RVE_STR_OP, $2); }
2713 | rval_expr PLUS rval_expr {$$=mk_rve2(RVE_PLUS_OP, $1, $3); }
2714 | rval_expr MINUS rval_expr {$$=mk_rve2(RVE_MINUS_OP, $1, $3); }
2715 | rval_expr STAR rval_expr {$$=mk_rve2(RVE_MUL_OP, $1, $3); }
2716 | rval_expr SLASH rval_expr {$$=mk_rve2(RVE_DIV_OP, $1, $3); }
2717 | rval_expr MODULO rval_expr {$$=mk_rve2(RVE_MOD_OP, $1, $3); }
2718 | rval_expr BIN_OR rval_expr {$$=mk_rve2(RVE_BOR_OP, $1, $3); }
2719 | rval_expr BIN_AND rval_expr {$$=mk_rve2(RVE_BAND_OP, $1, $3);}
2720 | rval_expr rve_cmpop rval_expr %prec GT { $$=mk_rve2( $2, $1, $3);}
2721 | rval_expr rve_equalop rval_expr %prec EQUAL_T
2722 { $$=mk_rve2( $2, $1, $3);}
2723 | rval_expr LOG_AND rval_expr { $$=mk_rve2(RVE_LAND_OP, $1, $3);}
2724 | rval_expr LOG_OR rval_expr { $$=mk_rve2(RVE_LOR_OP, $1, $3);}
2725 | LPAREN rval_expr RPAREN { $$=$2;}
2726 | STRLEN LPAREN rval_expr RPAREN { $$=mk_rve1(RVE_STRLEN_OP, $3);}
2727 | STREMPTY LPAREN rval_expr RPAREN {$$=mk_rve1(RVE_STREMPTY_OP, $3);}
2728 | DEFINED rval_expr { $$=mk_rve1(RVE_DEFINED_OP, $2);}
2729 | rve_un_op error %prec UNARY { $$=0; yyerror("bad expression"); }
2730 | INTCAST error { $$=0; yyerror("bad expression"); }
2731 | STRCAST error { $$=0; yyerror("bad expression"); }
2732 | rval_expr PLUS error { $$=0; yyerror("bad expression"); }
2733 | rval_expr MINUS error { $$=0; yyerror("bad expression"); }
2734 | rval_expr STAR error { $$=0; yyerror("bad expression"); }
2735 | rval_expr SLASH error { $$=0; yyerror("bad expression"); }
2736 | rval_expr MODULO error { $$=0; yyerror("bad expression"); }
2737 | rval_expr BIN_OR error { $$=0; yyerror("bad expression"); }
2738 | rval_expr BIN_AND error { $$=0; yyerror("bad expression"); }
2739 | rval_expr rve_cmpop error %prec GT
2740 { $$=0; yyerror("bad expression"); }
2741 | rval_expr rve_equalop error %prec EQUAL_T
2742 { $$=0; yyerror("bad expression"); }
2743 | rval_expr LOG_AND error { $$=0; yyerror("bad expression"); }
2744 | rval_expr LOG_OR error { $$=0; yyerror("bad expression"); }
2745 | STRLEN LPAREN error RPAREN { $$=0; yyerror("bad expression"); }
2746 | STREMPTY LPAREN error RPAREN { $$=0; yyerror("bad expression"); }
2747 | DEFINED error { $$=0; yyerror("bad expression"); }
2750 assign_action: lval assign_op rval_expr { $$=mk_action($2, 2, LVAL_ST, $1,
2758 attr_id_ass assign_op STRING { $$=mk_action($2, 2, AVP_ST, $1, STRING_ST, $3); }
2759 | attr_id_ass assign_op NUMBER { $$=mk_action($2, 2, AVP_ST, $1, NUMBER_ST, (void*)$3); }
2760 | attr_id_ass assign_op fcmd { $$=mk_action($2, 2, AVP_ST, $1, ACTION_ST, $3); }
2761 | attr_id_ass assign_op attr_id_any { $$=mk_action($2, 2, AVP_ST, $1, AVP_ST, $3); }
2762 | attr_id_ass assign_op select_id { $$=mk_action($2, 2, AVP_ST, (void*)$1, SELECT_ST, (void*)$3); }
2763 | attr_id_ass assign_op LPAREN exp RPAREN { $$ = mk_action($2, 2, AVP_ST, $1, EXPR_ST, $4); }
2768 SETAVPFLAG { $$ = 1; }
2769 | RESETAVPFLAG { $$ = 0; }
2770 | ISAVPFLAGSET { $$ = -1; }
2773 FORWARD LPAREN RPAREN { $$=mk_action(FORWARD_T, 2, URIHOST_ST, 0, URIPORT_ST, 0); set_cfg_pos($$); }
2774 | FORWARD LPAREN host RPAREN { $$=mk_action( FORWARD_T, 2, STRING_ST, $3, NUMBER_ST, 0); set_cfg_pos($$); }
2775 | FORWARD LPAREN STRING RPAREN { $$=mk_action( FORWARD_T, 2, STRING_ST, $3, NUMBER_ST, 0); set_cfg_pos($$); }
2776 | FORWARD LPAREN ip RPAREN { $$=mk_action( FORWARD_T, 2, IP_ST, (void*)$3, NUMBER_ST, 0); set_cfg_pos($$); }
2777 | FORWARD LPAREN host COMMA NUMBER RPAREN { $$=mk_action(FORWARD_T, 2, STRING_ST, $3, NUMBER_ST, (void*)$5); set_cfg_pos($$); }
2778 | FORWARD LPAREN STRING COMMA NUMBER RPAREN {$$=mk_action(FORWARD_T, 2, STRING_ST, $3, NUMBER_ST, (void*)$5); set_cfg_pos($$); }
2779 | FORWARD LPAREN ip COMMA NUMBER RPAREN { $$=mk_action(FORWARD_T, 2, IP_ST, (void*)$3, NUMBER_ST, (void*)$5); set_cfg_pos($$); }
2780 | FORWARD LPAREN URIHOST COMMA URIPORT RPAREN { $$=mk_action(FORWARD_T, 2, URIHOST_ST, 0, URIPORT_ST, 0); set_cfg_pos($$); }
2781 | FORWARD LPAREN URIHOST COMMA NUMBER RPAREN {$$=mk_action(FORWARD_T, 2, URIHOST_ST, 0, NUMBER_ST, (void*)$5); set_cfg_pos($$); }
2782 | FORWARD LPAREN URIHOST RPAREN { $$=mk_action(FORWARD_T, 2, URIHOST_ST, 0, NUMBER_ST, 0); set_cfg_pos($$); }
2783 | FORWARD error { $$=0; yyerror("missing '(' or ')' ?"); }
2784 | FORWARD LPAREN error RPAREN { $$=0; yyerror("bad forward argument"); }
2785 | FORWARD_UDP LPAREN host RPAREN { $$=mk_action(FORWARD_UDP_T, 2, STRING_ST, $3, NUMBER_ST, 0); set_cfg_pos($$); }
2786 | FORWARD_UDP LPAREN STRING RPAREN { $$=mk_action(FORWARD_UDP_T, 2, STRING_ST, $3, NUMBER_ST, 0); set_cfg_pos($$); }
2787 | FORWARD_UDP LPAREN ip RPAREN { $$=mk_action(FORWARD_UDP_T, 2, IP_ST, (void*)$3, NUMBER_ST, 0); set_cfg_pos($$); }
2788 | FORWARD_UDP LPAREN host COMMA NUMBER RPAREN { $$=mk_action(FORWARD_UDP_T, 2, STRING_ST, $3, NUMBER_ST, (void*)$5); set_cfg_pos($$); }
2789 | FORWARD_UDP LPAREN STRING COMMA NUMBER RPAREN {$$=mk_action(FORWARD_UDP_T, 2, STRING_ST, $3, NUMBER_ST, (void*)$5); set_cfg_pos($$); }
2790 | FORWARD_UDP LPAREN ip COMMA NUMBER RPAREN { $$=mk_action(FORWARD_UDP_T, 2, IP_ST, (void*)$3, NUMBER_ST, (void*)$5); set_cfg_pos($$); }
2791 | FORWARD_UDP LPAREN URIHOST COMMA URIPORT RPAREN {$$=mk_action(FORWARD_UDP_T, 2, URIHOST_ST, 0, URIPORT_ST, 0); set_cfg_pos($$); }
2792 | FORWARD_UDP LPAREN URIHOST COMMA NUMBER RPAREN { $$=mk_action(FORWARD_UDP_T, 2, URIHOST_ST, 0, NUMBER_ST, (void*)$5); set_cfg_pos($$); }
2793 | FORWARD_UDP LPAREN URIHOST RPAREN { $$=mk_action(FORWARD_UDP_T, 2, URIHOST_ST, 0, NUMBER_ST, 0); set_cfg_pos($$); }
2794 | FORWARD_UDP error { $$=0; yyerror("missing '(' or ')' ?"); }
2795 | FORWARD_UDP LPAREN error RPAREN { $$=0; yyerror("bad forward_udp argument"); }
2796 | FORWARD_TCP LPAREN host RPAREN { $$=mk_action(FORWARD_TCP_T, 2, STRING_ST, $3, NUMBER_ST, 0); set_cfg_pos($$); }
2797 | FORWARD_TCP LPAREN STRING RPAREN { $$=mk_action(FORWARD_TCP_T, 2, STRING_ST, $3, NUMBER_ST, 0); set_cfg_pos($$); }
2798 | FORWARD_TCP LPAREN ip RPAREN { $$=mk_action(FORWARD_TCP_T, 2, IP_ST, (void*)$3, NUMBER_ST, 0); set_cfg_pos($$); }
2799 | FORWARD_TCP LPAREN host COMMA NUMBER RPAREN { $$=mk_action(FORWARD_TCP_T, 2, STRING_ST, $3, NUMBER_ST, (void*)$5); set_cfg_pos($$); }
2800 | FORWARD_TCP LPAREN STRING COMMA NUMBER RPAREN {$$=mk_action(FORWARD_TCP_T, 2, STRING_ST, $3, NUMBER_ST, (void*)$5); set_cfg_pos($$); }
2801 | FORWARD_TCP LPAREN ip COMMA NUMBER RPAREN { $$=mk_action(FORWARD_TCP_T, 2, IP_ST, (void*)$3, NUMBER_ST, (void*)$5); set_cfg_pos($$); }
2802 | FORWARD_TCP LPAREN URIHOST COMMA URIPORT RPAREN {$$=mk_action(FORWARD_TCP_T, 2, URIHOST_ST, 0, URIPORT_ST, 0); set_cfg_pos($$); }
2803 | FORWARD_TCP LPAREN URIHOST COMMA NUMBER RPAREN { $$=mk_action(FORWARD_TCP_T, 2, URIHOST_ST, 0, NUMBER_ST, (void*)$5); set_cfg_pos($$); }
2804 | FORWARD_TCP LPAREN URIHOST RPAREN { $$=mk_action(FORWARD_TCP_T, 2, URIHOST_ST, 0, NUMBER_ST, 0); set_cfg_pos($$); }
2805 | FORWARD_TCP error { $$=0; yyerror("missing '(' or ')' ?"); }
2806 | FORWARD_TCP LPAREN error RPAREN { $$=0; yyerror("bad forward_tcp argument"); }
2807 | FORWARD_TLS LPAREN host RPAREN {
2809 $$=mk_action(FORWARD_TLS_T, 2, STRING_ST, $3, NUMBER_ST, 0); set_cfg_pos($$);
2812 yyerror("tls support not compiled in");
2815 | FORWARD_TLS LPAREN STRING RPAREN {
2817 $$=mk_action(FORWARD_TLS_T, 2, STRING_ST, $3, NUMBER_ST, 0); set_cfg_pos($$);
2820 yyerror("tls support not compiled in");
2823 | FORWARD_TLS LPAREN ip RPAREN {
2825 $$=mk_action(FORWARD_TLS_T, 2, IP_ST, (void*)$3, NUMBER_ST, 0); set_cfg_pos($$);
2828 yyerror("tls support not compiled in");
2831 | FORWARD_TLS LPAREN host COMMA NUMBER RPAREN {
2833 $$=mk_action(FORWARD_TLS_T, 2, STRING_ST, $3, NUMBER_ST, (void*)$5); set_cfg_pos($$);
2836 yyerror("tls support not compiled in");
2839 | FORWARD_TLS LPAREN STRING COMMA NUMBER RPAREN {
2841 $$=mk_action(FORWARD_TLS_T, 2, STRING_ST, $3, NUMBER_ST, (void*)$5); set_cfg_pos($$);
2844 yyerror("tls support not compiled in");
2847 | FORWARD_TLS LPAREN ip COMMA NUMBER RPAREN {
2849 $$=mk_action(FORWARD_TLS_T, 2, IP_ST, (void*)$3, NUMBER_ST, (void*)$5); set_cfg_pos($$);
2852 yyerror("tls support not compiled in");
2855 | FORWARD_TLS LPAREN URIHOST COMMA URIPORT RPAREN {
2857 $$=mk_action(FORWARD_TLS_T, 2, URIHOST_ST, 0, URIPORT_ST, 0); set_cfg_pos($$);
2860 yyerror("tls support not compiled in");
2863 | FORWARD_TLS LPAREN URIHOST COMMA NUMBER RPAREN {
2865 $$=mk_action(FORWARD_TLS_T, 2, URIHOST_ST, 0, NUMBER_ST, (void*)$5); set_cfg_pos($$);
2868 yyerror("tls support not compiled in");
2871 | FORWARD_TLS LPAREN URIHOST RPAREN {
2873 $$=mk_action(FORWARD_TLS_T, 2, URIHOST_ST, 0, NUMBER_ST, 0); set_cfg_pos($$);
2876 yyerror("tls support not compiled in");
2879 | FORWARD_TLS error { $$=0; yyerror("missing '(' or ')' ?"); }
2880 | FORWARD_TLS LPAREN error RPAREN { $$=0;
2881 yyerror("bad forward_tls argument"); }
2882 | FORWARD_SCTP LPAREN host RPAREN {
2884 $$=mk_action(FORWARD_SCTP_T, 2, STRING_ST, $3, NUMBER_ST, 0); set_cfg_pos($$);
2887 yyerror("sctp support not compiled in");
2890 | FORWARD_SCTP LPAREN STRING RPAREN {
2892 $$=mk_action(FORWARD_SCTP_T, 2, STRING_ST, $3, NUMBER_ST, 0); set_cfg_pos($$);
2895 yyerror("sctp support not compiled in");
2898 | FORWARD_SCTP LPAREN ip RPAREN {
2900 $$=mk_action(FORWARD_SCTP_T, 2, IP_ST, (void*)$3, NUMBER_ST, 0); set_cfg_pos($$);
2903 yyerror("sctp support not compiled in");
2906 | FORWARD_SCTP LPAREN host COMMA NUMBER RPAREN {
2908 $$=mk_action(FORWARD_SCTP_T, 2, STRING_ST, $3, NUMBER_ST,
2909 (void*)$5); set_cfg_pos($$);
2912 yyerror("sctp support not compiled in");
2915 | FORWARD_SCTP LPAREN STRING 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 ip COMMA NUMBER RPAREN {
2926 $$=mk_action(FORWARD_SCTP_T, 2, IP_ST, (void*)$3, NUMBER_ST,
2927 (void*)$5); set_cfg_pos($$);
2930 yyerror("sctp support not compiled in");
2933 | FORWARD_SCTP LPAREN URIHOST COMMA URIPORT RPAREN {
2935 $$=mk_action(FORWARD_SCTP_T, 2, URIHOST_ST, 0, URIPORT_ST, 0); set_cfg_pos($$);
2938 yyerror("sctp support not compiled in");
2941 | FORWARD_SCTP LPAREN URIHOST COMMA NUMBER RPAREN {
2943 $$=mk_action(FORWARD_SCTP_T, 2, URIHOST_ST, 0, NUMBER_ST,
2944 (void*)$5); set_cfg_pos($$);
2947 yyerror("sctp support not compiled in");
2950 | FORWARD_SCTP LPAREN URIHOST RPAREN {
2952 $$=mk_action(FORWARD_SCTP_T, 2, URIHOST_ST, 0, NUMBER_ST, 0); set_cfg_pos($$);
2955 yyerror("tls support not compiled in");
2958 | FORWARD_SCTP error { $$=0; yyerror("missing '(' or ')' ?"); }
2959 | FORWARD_SCTP LPAREN error RPAREN { $$=0;
2960 yyerror("bad forward_tls argument"); }
2961 | SEND LPAREN host RPAREN { $$=mk_action(SEND_T, 2, STRING_ST, $3, NUMBER_ST, 0); set_cfg_pos($$); }
2962 | SEND LPAREN STRING RPAREN { $$=mk_action(SEND_T, 2, STRING_ST, $3, NUMBER_ST, 0); set_cfg_pos($$); }
2963 | SEND LPAREN ip RPAREN { $$=mk_action(SEND_T, 2, IP_ST, (void*)$3, NUMBER_ST, 0); set_cfg_pos($$); }
2964 | SEND LPAREN host COMMA NUMBER RPAREN { $$=mk_action(SEND_T, 2, STRING_ST, $3, NUMBER_ST, (void*)$5); set_cfg_pos($$); }
2965 | SEND LPAREN STRING COMMA NUMBER RPAREN {$$=mk_action(SEND_T, 2, STRING_ST, $3, NUMBER_ST, (void*)$5); set_cfg_pos($$); }
2966 | SEND LPAREN ip COMMA NUMBER RPAREN { $$=mk_action(SEND_T, 2, IP_ST, (void*)$3, NUMBER_ST, (void*)$5); set_cfg_pos($$); }
2967 | SEND error { $$=0; yyerror("missing '(' or ')' ?"); }
2968 | SEND LPAREN error RPAREN { $$=0; yyerror("bad send argument"); }
2969 | SEND_TCP LPAREN host RPAREN { $$=mk_action(SEND_TCP_T, 2, STRING_ST, $3, NUMBER_ST, 0); set_cfg_pos($$); }
2970 | SEND_TCP LPAREN STRING RPAREN { $$=mk_action(SEND_TCP_T, 2, STRING_ST, $3, NUMBER_ST, 0); set_cfg_pos($$); }
2971 | SEND_TCP LPAREN ip RPAREN { $$=mk_action(SEND_TCP_T, 2, IP_ST, (void*)$3, NUMBER_ST, 0); set_cfg_pos($$); }
2972 | SEND_TCP LPAREN host COMMA NUMBER RPAREN { $$=mk_action( SEND_TCP_T, 2, STRING_ST, $3, NUMBER_ST, (void*)$5); set_cfg_pos($$);}
2973 | SEND_TCP LPAREN STRING COMMA NUMBER RPAREN {$$=mk_action(SEND_TCP_T, 2, STRING_ST, $3, NUMBER_ST, (void*)$5); set_cfg_pos($$); }
2974 | SEND_TCP LPAREN ip COMMA NUMBER RPAREN { $$=mk_action(SEND_TCP_T, 2, IP_ST, (void*)$3, NUMBER_ST, (void*)$5); set_cfg_pos($$); }
2975 | SEND_TCP error { $$=0; yyerror("missing '(' or ')' ?"); }
2976 | SEND_TCP LPAREN error RPAREN { $$=0; yyerror("bad send_tcp argument"); }
2977 | LOG_TOK LPAREN STRING RPAREN {$$=mk_action(LOG_T, 2, NUMBER_ST,
2978 (void*)(L_DBG+1), STRING_ST, $3);
2980 | LOG_TOK LPAREN NUMBER COMMA STRING RPAREN {$$=mk_action(LOG_T, 2, NUMBER_ST, (void*)$3, STRING_ST, $5); set_cfg_pos($$); }
2981 | LOG_TOK error { $$=0; yyerror("missing '(' or ')' ?"); }
2982 | LOG_TOK LPAREN error RPAREN { $$=0; yyerror("bad log argument"); }
2983 | SETFLAG LPAREN NUMBER RPAREN {
2984 if (check_flag($3)==-1)
2985 yyerror("bad flag value");
2986 $$=mk_action(SETFLAG_T, 1, NUMBER_ST,
2990 | SETFLAG LPAREN flag_name RPAREN {
2991 i_tmp=get_flag_no($3, strlen($3));
2992 if (i_tmp<0) yyerror("flag not declared");
2993 $$=mk_action(SETFLAG_T, 1, NUMBER_ST,
2994 (void*)(long)i_tmp);
2997 | SETFLAG error { $$=0; yyerror("missing '(' or ')'?"); }
2998 | RESETFLAG LPAREN NUMBER RPAREN {
2999 if (check_flag($3)==-1)
3000 yyerror("bad flag value");
3001 $$=mk_action(RESETFLAG_T, 1, NUMBER_ST, (void*)$3);
3004 | RESETFLAG LPAREN flag_name RPAREN {
3005 i_tmp=get_flag_no($3, strlen($3));
3006 if (i_tmp<0) yyerror("flag not declared");
3007 $$=mk_action(RESETFLAG_T, 1, NUMBER_ST,
3008 (void*)(long)i_tmp);
3011 | RESETFLAG error { $$=0; yyerror("missing '(' or ')'?"); }
3012 | ISFLAGSET LPAREN NUMBER RPAREN {
3013 if (check_flag($3)==-1)
3014 yyerror("bad flag value");
3015 $$=mk_action(ISFLAGSET_T, 1, NUMBER_ST, (void*)$3);
3018 | ISFLAGSET LPAREN flag_name RPAREN {
3019 i_tmp=get_flag_no($3, strlen($3));
3020 if (i_tmp<0) yyerror("flag not declared");
3021 $$=mk_action(ISFLAGSET_T, 1, NUMBER_ST,
3022 (void*)(long)i_tmp);
3025 | ISFLAGSET error { $$=0; yyerror("missing '(' or ')'?"); }
3026 | avpflag_oper LPAREN attr_id_any_str COMMA flag_name RPAREN {
3027 i_tmp=get_avpflag_no($5);
3028 if (i_tmp==0) yyerror("avpflag not declared");
3029 $$=mk_action(AVPFLAG_OPER_T, 3, AVP_ST, $3, NUMBER_ST, (void*)(long)i_tmp, NUMBER_ST, (void*)$1);
3032 | avpflag_oper LPAREN attr_id_any_str COMMA error RPAREN {
3033 $$=0; yyerror("error parsing flag name");
3035 | avpflag_oper LPAREN error COMMA flag_name RPAREN {
3036 $$=0; yyerror("error parsing first parameter (avp or string)");
3038 | avpflag_oper LPAREN error RPAREN { $$=0; yyerror("bad parameters"); }
3039 | avpflag_oper error { $$=0; yyerror("missing '(' or ')'?"); }
3040 | ERROR LPAREN STRING COMMA STRING RPAREN {$$=mk_action(ERROR_T, 2, STRING_ST, $3, STRING_ST, $5);
3043 | ERROR error { $$=0; yyerror("missing '(' or ')' ?"); }
3044 | ERROR LPAREN error RPAREN { $$=0; yyerror("bad error argument"); }
3045 | ROUTE LPAREN route_name RPAREN {
3046 i_tmp=route_get(&main_rt, $3);
3048 yyerror("internal error");
3051 $$=mk_action(ROUTE_T, 1, NUMBER_ST,(void*)(long)i_tmp);
3054 | ROUTE error { $$=0; yyerror("missing '(' or ')' ?"); }
3055 | ROUTE LPAREN error RPAREN { $$=0; yyerror("bad route argument"); }
3056 | EXEC LPAREN STRING RPAREN { $$=mk_action(EXEC_T, 1, STRING_ST, $3); set_cfg_pos($$); }
3057 | SET_HOST LPAREN STRING RPAREN { $$=mk_action(SET_HOST_T, 1, STRING_ST, $3); set_cfg_pos($$); }
3058 | SET_HOST error { $$=0; yyerror("missing '(' or ')' ?"); }
3059 | SET_HOST LPAREN error RPAREN { $$=0; yyerror("bad argument, string expected"); }
3060 | PREFIX LPAREN STRING RPAREN { $$=mk_action(PREFIX_T, 1, STRING_ST, $3); set_cfg_pos($$); }
3061 | PREFIX error { $$=0; yyerror("missing '(' or ')' ?"); }
3062 | PREFIX LPAREN error RPAREN { $$=0; yyerror("bad argument, string expected"); }
3063 | STRIP_TAIL LPAREN NUMBER RPAREN { $$=mk_action(STRIP_TAIL_T, 1, NUMBER_ST, (void*)$3); set_cfg_pos($$); }
3064 | STRIP_TAIL error { $$=0; yyerror("missing '(' or ')' ?"); }
3065 | STRIP_TAIL LPAREN error RPAREN { $$=0; yyerror("bad argument, number expected"); }
3066 | STRIP LPAREN NUMBER RPAREN { $$=mk_action(STRIP_T, 1, NUMBER_ST, (void*) $3); set_cfg_pos($$); }
3067 | STRIP error { $$=0; yyerror("missing '(' or ')' ?"); }
3068 | STRIP LPAREN error RPAREN { $$=0; yyerror("bad argument, number expected"); }
3069 | SET_USERPHONE LPAREN RPAREN { $$=mk_action(SET_USERPHONE_T, 0); set_cfg_pos($$); }
3070 | SET_USERPHONE error { $$=0; yyerror("missing '(' or ')' ?"); }
3071 | APPEND_BRANCH LPAREN STRING COMMA STRING RPAREN {
3073 if (str2q(&q, $5, strlen($5)) < 0) {
3074 yyerror("bad argument, q value expected");
3076 $$=mk_action(APPEND_BRANCH_T, 2, STRING_ST, $3, NUMBER_ST, (void *)(long)q);
3079 | APPEND_BRANCH LPAREN STRING RPAREN { $$=mk_action(APPEND_BRANCH_T, 2, STRING_ST, $3, NUMBER_ST, (void *)Q_UNSPECIFIED); set_cfg_pos($$); }
3080 | APPEND_BRANCH LPAREN RPAREN { $$=mk_action(APPEND_BRANCH_T, 2, STRING_ST, 0, NUMBER_ST, (void *)Q_UNSPECIFIED); set_cfg_pos($$); }
3081 | APPEND_BRANCH { $$=mk_action( APPEND_BRANCH_T, 1, STRING_ST, 0); set_cfg_pos($$); }
3082 | SET_HOSTPORT LPAREN STRING RPAREN { $$=mk_action(SET_HOSTPORT_T, 1, STRING_ST, $3); set_cfg_pos($$); }
3083 | SET_HOSTPORT error { $$=0; yyerror("missing '(' or ')' ?"); }
3084 | SET_HOSTPORT LPAREN error RPAREN { $$=0; yyerror("bad argument, string expected"); }
3085 | SET_HOSTPORTTRANS LPAREN STRING RPAREN { $$=mk_action(SET_HOSTPORTTRANS_T, 1, STRING_ST, $3); set_cfg_pos($$); }
3086 | SET_HOSTPORTTRANS error { $$=0; yyerror("missing '(' or ')' ?"); }
3087 | SET_HOSTPORTTRANS LPAREN error RPAREN { $$=0; yyerror("bad argument, string expected"); }
3088 | SET_PORT LPAREN STRING RPAREN { $$=mk_action(SET_PORT_T, 1, STRING_ST, $3); set_cfg_pos($$); }
3089 | SET_PORT error { $$=0; yyerror("missing '(' or ')' ?"); }
3090 | SET_PORT LPAREN error RPAREN { $$=0; yyerror("bad argument, string expected"); }
3091 | SET_USER LPAREN STRING RPAREN { $$=mk_action(SET_USER_T, 1, STRING_ST, $3); set_cfg_pos($$); }
3092 | SET_USER error { $$=0; yyerror("missing '(' or ')' ?"); }
3093 | SET_USER LPAREN error RPAREN { $$=0; yyerror("bad argument, string expected"); }
3094 | SET_USERPASS LPAREN STRING RPAREN { $$=mk_action(SET_USERPASS_T, 1, STRING_ST, $3); set_cfg_pos($$); }
3095 | SET_USERPASS error { $$=0; yyerror("missing '(' or ')' ?"); }
3096 | SET_USERPASS LPAREN error RPAREN { $$=0; yyerror("bad argument, string expected"); }
3097 | SET_URI LPAREN STRING RPAREN { $$=mk_action(SET_URI_T, 1, STRING_ST,$3); set_cfg_pos($$); }
3098 | SET_URI error { $$=0; yyerror("missing '(' or ')' ?"); }
3099 | SET_URI LPAREN error RPAREN { $$=0; yyerror("bad argument, string expected"); }
3100 | REVERT_URI LPAREN RPAREN { $$=mk_action(REVERT_URI_T, 0); set_cfg_pos($$); }
3101 | REVERT_URI { $$=mk_action(REVERT_URI_T, 0); set_cfg_pos($$); }
3102 | FORCE_RPORT LPAREN RPAREN { $$=mk_action(FORCE_RPORT_T, 0); set_cfg_pos($$); }
3103 | FORCE_RPORT {$$=mk_action(FORCE_RPORT_T, 0); set_cfg_pos($$); }
3104 | ADD_LOCAL_RPORT LPAREN RPAREN { $$=mk_action(ADD_LOCAL_RPORT_T, 0); set_cfg_pos($$); }
3105 | ADD_LOCAL_RPORT {$$=mk_action(ADD_LOCAL_RPORT_T, 0); set_cfg_pos($$); }
3106 | FORCE_TCP_ALIAS LPAREN NUMBER RPAREN {
3108 $$=mk_action(FORCE_TCP_ALIAS_T, 1, NUMBER_ST, (void*)$3);
3111 yyerror("tcp support not compiled in");
3114 | FORCE_TCP_ALIAS LPAREN RPAREN {
3116 $$=mk_action(FORCE_TCP_ALIAS_T, 0);
3119 yyerror("tcp support not compiled in");
3124 $$=mk_action(FORCE_TCP_ALIAS_T, 0);
3127 yyerror("tcp support not compiled in");
3130 | FORCE_TCP_ALIAS LPAREN error RPAREN {$$=0; yyerror("bad argument, number expected"); }
3131 | UDP_MTU_TRY_PROTO LPAREN proto RPAREN
3132 { $$=mk_action(UDP_MTU_TRY_PROTO_T, 1, NUMBER_ST, $3); set_cfg_pos($$); }
3133 | UDP_MTU_TRY_PROTO LPAREN error RPAREN
3134 { $$=0; yyerror("bad argument, UDP, TCP, TLS or SCTP expected"); }
3135 | SET_ADV_ADDRESS LPAREN listen_id RPAREN {
3137 if ((str_tmp=pkg_malloc(sizeof(str)))==0) {
3138 LOG(L_CRIT, "ERROR: cfg. parser: out of memory.\n");
3141 str_tmp->len=$3?strlen($3):0;
3142 $$=mk_action(SET_ADV_ADDR_T, 1, STR_ST, str_tmp);
3146 | SET_ADV_ADDRESS LPAREN error RPAREN { $$=0; yyerror("bad argument, string expected"); }
3147 | SET_ADV_ADDRESS error {$$=0; yyerror("missing '(' or ')' ?"); }
3148 | SET_ADV_PORT LPAREN NUMBER RPAREN {
3150 tmp=int2str($3, &i_tmp);
3151 if ((str_tmp=pkg_malloc(sizeof(str)))==0) {
3152 LOG(L_CRIT, "ERROR: cfg. parser: out of memory.\n");
3154 if ((str_tmp->s=pkg_malloc(i_tmp))==0) {
3155 LOG(L_CRIT, "ERROR: cfg. parser: out of memory.\n");
3157 memcpy(str_tmp->s, tmp, i_tmp);
3159 $$=mk_action(SET_ADV_PORT_T, 1, STR_ST, str_tmp);
3164 | SET_ADV_PORT LPAREN error RPAREN { $$=0; yyerror("bad argument, string expected"); }
3165 | SET_ADV_PORT error {$$=0; yyerror("missing '(' or ')' ?"); }
3166 | FORCE_SEND_SOCKET LPAREN phostport RPAREN {
3167 $$=mk_action(FORCE_SEND_SOCKET_T, 1, SOCKID_ST, $3);
3170 | FORCE_SEND_SOCKET LPAREN error RPAREN {
3171 $$=0; yyerror("bad argument, [proto:]host[:port] expected");
3173 | FORCE_SEND_SOCKET error {$$=0; yyerror("missing '(' or ')' ?"); }
3174 | SET_FWD_NO_CONNECT LPAREN RPAREN {
3175 $$=mk_action(SET_FWD_NO_CONNECT_T, 0); set_cfg_pos($$);
3177 | SET_FWD_NO_CONNECT {
3178 $$=mk_action(SET_FWD_NO_CONNECT_T, 0); set_cfg_pos($$);
3180 | SET_RPL_NO_CONNECT LPAREN RPAREN {
3181 $$=mk_action(SET_RPL_NO_CONNECT_T, 0); set_cfg_pos($$);
3183 | SET_RPL_NO_CONNECT {
3184 $$=mk_action(SET_RPL_NO_CONNECT_T, 0); set_cfg_pos($$);
3186 | SET_FWD_CLOSE LPAREN RPAREN {
3187 $$=mk_action(SET_FWD_CLOSE_T, 0); set_cfg_pos($$);
3190 $$=mk_action(SET_FWD_CLOSE_T, 0); set_cfg_pos($$);
3192 | SET_RPL_CLOSE LPAREN RPAREN {
3193 $$=mk_action(SET_RPL_CLOSE_T, 0); set_cfg_pos($$);
3196 $$=mk_action(SET_RPL_CLOSE_T, 0); set_cfg_pos($$);
3198 | ID {mod_func_action = mk_action(MODULE_T, 2, MODEXP_ST, NULL, NUMBER_ST,
3199 0); } LPAREN func_params RPAREN {
3200 mod_func_action->val[0].u.data =
3201 find_export_record($1, mod_func_action->val[1].u.number, rt,
3203 if (mod_func_action->val[0].u.data == 0) {
3204 if (find_export_record($1, mod_func_action->val[1].u.number, 0,
3206 yyerror("Command cannot be used in the block\n");
3208 yyerror("unknown command, missing loadmodule?\n");
3210 pkg_free(mod_func_action);
3213 switch( ((union cmd_export_u*)
3214 mod_func_action->val[0].u.data)->c.param_no){
3218 /* MODULE_T used for 0-2 params */
3221 mod_func_action->type=MODULE3_T;
3224 mod_func_action->type=MODULE4_T;
3227 mod_func_action->type=MODULE5_T;
3230 mod_func_action->type=MODULE6_T;
3233 mod_func_action->type=MODULEX_T;
3236 yyerror("too many parameters for function\n");
3240 $$ = mod_func_action;
3243 | ID error { yyerror("'('')' expected (function call)");}
3247 | func_params COMMA func_param { }
3249 | func_params error { yyerror("call params error\n"); }
3253 if (mod_func_action->val[1].u.number < MAX_ACTIONS-2) {
3254 mod_func_action->val[mod_func_action->val[1].u.number+2].type =
3256 mod_func_action->val[mod_func_action->val[1].u.number+2].u.number =
3258 mod_func_action->val[1].u.number++;
3260 yyerror("Too many arguments\n");
3264 if (mod_func_action->val[1].u.number < MAX_ACTIONS-2) {
3265 mod_func_action->val[mod_func_action->val[1].u.number+2].type = STRING_ST;
3266 mod_func_action->val[mod_func_action->val[1].u.number+2].u.string = $1;
3267 mod_func_action->val[1].u.number++;
3269 yyerror("Too many arguments\n");
3275 DROP LPAREN RPAREN {
3276 $$=mk_action(DROP_T, 2, NUMBER_ST, 0, NUMBER_ST,
3277 (void*)(DROP_R_F|EXIT_R_F)); set_cfg_pos($$);
3280 $$=mk_action(DROP_T, 2, RVE_ST, $2, NUMBER_ST,
3281 (void*)(DROP_R_F|EXIT_R_F)); set_cfg_pos($$);
3284 $$=mk_action(DROP_T, 2, NUMBER_ST, 0, NUMBER_ST,
3285 (void*)(DROP_R_F|EXIT_R_F)); set_cfg_pos($$);
3287 | EXIT LPAREN RPAREN {
3288 $$=mk_action(DROP_T, 2, NUMBER_ST, (void*)1, NUMBER_ST,
3293 $$=mk_action(DROP_T, 2, RVE_ST, $2, NUMBER_ST, (void*)EXIT_R_F);
3297 $$=mk_action(DROP_T, 2, NUMBER_ST, (void*)1, NUMBER_ST,
3302 $$=mk_action(DROP_T, 2, NUMBER_ST, (void*)1, NUMBER_ST,
3303 (void*)RETURN_R_F); set_cfg_pos($$);
3305 | RETURN LPAREN RPAREN {
3306 $$=mk_action(DROP_T, 2, NUMBER_ST, (void*)1, NUMBER_ST,
3307 (void*)RETURN_R_F); set_cfg_pos($$);
3309 | RETURN rval_expr {
3310 $$=mk_action(DROP_T, 2, RVE_ST, $2, NUMBER_ST, (void*)RETURN_R_F);
3314 $$=mk_action(DROP_T, 2, NUMBER_ST, 0, NUMBER_ST, (void*)BREAK_R_F);
3321 static void get_cpos(struct cfg_pos* pos)
3323 pos->s_line=startline;
3325 pos->s_col=startcolumn;
3326 pos->e_col=column-1;
3328 finame = (cfg_file!=0)?cfg_file:"default";
3333 static void warn_at(struct cfg_pos* p, char* format, ...)
3338 va_start(ap, format);
3339 vsnprintf(s, sizeof(s), format, ap);
3341 if (p->e_line!=p->s_line)
3342 LOG(L_WARN, "warning in config file %s, from line %d, column %d to"
3343 " line %d, column %d: %s\n",
3344 p->fname, p->s_line, p->s_col, p->e_line, p->e_col, s);
3345 else if (p->s_col!=p->e_col)
3346 LOG(L_WARN, "warning in config file %s, line %d, column %d-%d: %s\n",
3347 p->fname, p->s_line, p->s_col, p->e_col, s);
3349 LOG(L_WARN, "warning in config file %s, line %d, column %d: %s\n",
3350 p->fname, p->s_line, p->s_col, s);
3356 static void yyerror_at(struct cfg_pos* p, char* format, ...)
3361 va_start(ap, format);
3362 vsnprintf(s, sizeof(s), format, ap);
3364 if (p->e_line!=p->s_line)
3365 LOG(L_CRIT, "parse error in config file %s, from line %d, column %d"
3366 " to line %d, column %d: %s\n",
3367 p->fname, p->s_line, p->s_col, p->e_line, p->e_col, s);
3368 else if (p->s_col!=p->e_col)
3369 LOG(L_CRIT,"parse error in config file %s, line %d, column %d-%d: %s\n",
3370 p->fname, p->s_line, p->s_col, p->e_col, s);
3372 LOG(L_CRIT, "parse error in config file %s, line %d, column %d: %s\n",
3373 p->fname, p->s_line, p->s_col, s);
3379 static void warn(char* format, ...)
3386 va_start(ap, format);
3387 vsnprintf(s, sizeof(s), format, ap);
3394 static void yyerror(char* format, ...)
3401 va_start(ap, format);
3402 vsnprintf(s, sizeof(s), format, ap);
3404 yyerror_at(&pos, s);
3409 /** mk_rval_expr_v wrapper.
3410 * checks mk_rval_expr_v return value and sets the cfg. pos
3411 * (line and column numbers)
3412 * @return rval_expr* on success, 0 on error (@see mk_rval_expr_v)
3414 static struct rval_expr* mk_rve_rval(enum rval_type type, void* v)
3416 struct rval_expr* ret;
3420 ret=mk_rval_expr_v(type, v, &pos);
3422 yyerror("internal error: failed to create rval expr");
3429 /** mk_rval_expr1 wrapper.
3430 * checks mk_rval_expr1 return value (!=0 and type checking)
3431 * @return rval_expr* on success, 0 on error (@see mk_rval_expr1)
3433 static struct rval_expr* mk_rve1(enum rval_expr_op op, struct rval_expr* rve1)
3435 struct rval_expr* ret;
3436 struct rval_expr* bad_rve;
3437 enum rval_type type, bad_t, exp_t;
3441 ret=mk_rval_expr1(op, rve1, &rve1->fpos);
3442 if (ret && (rve_check_type(&type, ret, &bad_rve, &bad_t, &exp_t)!=1)){
3443 yyerror_at(&rve1->fpos, "bad expression: type mismatch"
3444 " (%s instead of %s)", rval_type_name(bad_t),
3445 rval_type_name(exp_t));
3453 /** mk_rval_expr2 wrapper.
3454 * checks mk_rval_expr2 return value (!=0 and type checking)
3455 * @return rval_expr* on success, 0 on error (@see mk_rval_expr2)
3457 static struct rval_expr* mk_rve2(enum rval_expr_op op, struct rval_expr* rve1,
3458 struct rval_expr* rve2)
3460 struct rval_expr* ret;
3461 struct rval_expr* bad_rve;
3462 enum rval_type type, bad_t, exp_t;
3465 if ((rve1==0) || (rve2==0))
3470 cfg_pos_join(&pos, &rve1->fpos, &rve2->fpos);
3471 ret=mk_rval_expr2(op, rve1, rve2, &pos);
3472 if (ret && (rve_check_type(&type, ret, &bad_rve, &bad_t, &exp_t)!=1)){
3474 yyerror_at(&pos, "bad expression: type mismatch:"
3475 " %s instead of %s at (%d,%d)",
3476 rval_type_name(bad_t), rval_type_name(exp_t),
3477 bad_rve->fpos.s_line, bad_rve->fpos.s_col);
3479 yyerror("BUG: unexpected null \"bad\" expression\n");
3487 /** check if the expression is an int.
3488 * if the expression does not evaluate to an int return -1 and
3490 * @return 0 success, no warnings; 1 success but warnings; -1 on error */
3491 static int rval_expr_int_check(struct rval_expr *rve)
3493 struct rval_expr* bad_rve;
3494 enum rval_type type, bad_t, exp_t;
3497 yyerror("invalid expression");
3499 }else if (!rve_check_type(&type, rve, &bad_rve, &bad_t ,&exp_t)){
3501 yyerror_at(&rve->fpos, "bad expression: type mismatch:"
3502 " %s instead of %s at (%d,%d)",
3503 rval_type_name(bad_t), rval_type_name(exp_t),
3504 bad_rve->fpos.s_line, bad_rve->fpos.s_col);
3506 yyerror("BUG: unexpected null \"bad\" expression\n");
3508 }else if (type!=RV_INT && type!=RV_NONE){
3509 warn_at(&rve->fpos, "non-int expression (you might want to use"
3517 /** warn if the expression is constant.
3518 * @return 0 on success (no warning), 1 when warning */
3519 static int warn_ct_rve(struct rval_expr *rve, char* name)
3521 if (rve && rve_is_constant(rve)){
3522 warn_at(&rve->fpos, "constant value in %s%s",
3523 name?name:"expression", name?"(...)":"");
3530 static struct name_lst* mk_name_lst(char* host, int flags)
3533 if (host==0) return 0;
3534 l=pkg_malloc(sizeof(struct name_lst));
3536 LOG(L_CRIT,"ERROR: cfg. parser: out of memory.\n");
3546 static struct socket_id* mk_listen_id(char* host, int proto, int port)
3548 struct socket_id* l;
3549 if (host==0) return 0;
3550 l=pkg_malloc(sizeof(struct socket_id));
3552 LOG(L_CRIT,"ERROR: cfg. parser: out of memory.\n");
3554 l->addr_lst=mk_name_lst(host, 0);
3555 if (l->addr_lst==0){