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)
97 #include <sys/types.h>
98 #include <sys/socket.h>
99 #include <netinet/in.h>
100 #include <arpa/inet.h>
103 #include "route_struct.h"
107 #include "sr_module.h"
108 #include "modparam.h"
111 #include "socket_info.h"
112 #include "name_alias.h"
117 #include "tcp_init.h"
118 #include "tcp_options.h"
119 #include "sctp_options.h"
122 #include "cfg_core.h"
125 #include "tls/tls_config.h"
132 /* hack to avoid alloca usage in the generated C file (needed for compiler
133 with no built in alloca, like icc*/
136 #define onsend_check(s) \
138 if (rt!=ONSEND_ROUTE) yyerror( s " allowed only in onsend_routes");\
143 #define IF_DNS_CACHE(x) x
145 #define IF_DNS_CACHE(x) warn("dns cache support not compiled in")
148 #ifdef USE_DNS_FAILOVER
149 #define IF_DNS_FAILOVER(x) x
151 #define IF_DNS_FAILOVER(x) warn("dns failover support not compiled in")
155 #define IF_NAPTR(x) x
157 #define IF_NAPTR(x) warn("dns naptr support not compiled in")
160 #ifdef USE_DST_BLACKLIST
161 #define IF_DST_BLACKLIST(x) x
163 #define IF_DST_BLACKLIST(x) warn("dst blacklist support not compiled in")
169 #define IF_STUN(x) warn("stun support not compiled in")
174 static void yyerror(char* s);
177 static struct socket_id* lst_tmp;
178 static struct name_lst* nl_tmp;
179 static int rt; /* Type of route block for find_export */
182 static struct ip_addr* ip_tmp;
183 static struct avp_spec* s_attr;
185 static select_t* sel_ptr;
186 static struct action *mod_func_action;
188 static void warn(char* s);
189 static struct socket_id* mk_listen_id(char*, int, int);
190 static struct name_lst* mk_name_lst(char* name, int flags);
191 static struct socket_id* mk_listen_id2(struct name_lst*, int, int);
192 static void free_name_lst(struct name_lst* lst);
193 static void free_socket_id_lst(struct socket_id* i);
202 struct action* action;
204 struct ip_addr* ipaddr;
205 struct socket_id* sockid;
206 struct name_lst* name_l;
207 struct avp_spec* attr;
235 %token SET_HOSTPORTTRANS
246 %token FORCE_TCP_ALIAS
249 %token SET_ADV_ADDRESS
251 %token FORCE_SEND_SOCKET
303 %token DNS_SERVERS_NO
304 %token DNS_USE_SEARCH
305 %token DNS_SEARCH_FMATCH
306 %token DNS_CACHE_INIT
308 %token DNS_USE_FAILOVER
309 %token DNS_CACHE_FLAGS
310 %token DNS_CACHE_NEG_TTL
311 %token DNS_CACHE_MIN_TTL
312 %token DNS_CACHE_MAX_TTL
314 %token DNS_CACHE_GC_INT
315 %token DNS_CACHE_DEL_NONEXP
321 %token DST_BLST_GC_INT
332 %token SERVER_SIGNATURE
344 %token TCP_ACCEPT_ALIASES
346 %token TCP_CONNECT_TIMEOUT
347 %token TCP_SEND_TIMEOUT
348 %token TCP_CON_LIFETIME
349 %token TCP_POLL_METHOD
350 %token TCP_MAX_CONNECTIONS
351 %token TCP_SOURCE_IPV4
352 %token TCP_SOURCE_IPV6
353 %token TCP_OPT_FD_CACHE
354 %token TCP_OPT_BUF_WRITE
355 %token TCP_OPT_CONN_WQ_MAX
356 %token TCP_OPT_WQ_MAX
357 %token TCP_OPT_DEFER_ACCEPT
358 %token TCP_OPT_DELAYED_ACK
359 %token TCP_OPT_SYNCNT
360 %token TCP_OPT_LINGER2
361 %token TCP_OPT_KEEPALIVE
362 %token TCP_OPT_KEEPIDLE
363 %token TCP_OPT_KEEPINTVL
364 %token TCP_OPT_KEEPCNT
365 %token TCP_OPT_CRLF_PING
371 %token TLS_HANDSHAKE_TIMEOUT
372 %token TLS_SEND_TIMEOUT
378 %token TLS_REQUIRE_CERTIFICATE
379 %token TLS_CERTIFICATE
380 %token TLS_PRIVATE_KEY
385 %token SCTP_SOCKET_RCVBUF
386 %token SCTP_SOCKET_SNDBUF
387 %token SCTP_AUTOCLOSE
389 %token SCTP_SEND_RETRIES
390 %token ADVERTISED_ADDRESS
391 %token ADVERTISED_PORT
394 %token SHM_FORCE_ALLOC
399 %token RT_TIMER1_PRIO
400 %token RT_TIMER1_POLICY
401 %token RT_TIMER2_PRIO
402 %token RT_TIMER2_POLICY
403 %token MCAST_LOOPBACK
406 %token PMTU_DISCOVERY
408 %token CFG_DESCRIPTION
422 %token ATTR_FROMDOMAIN
427 %token STUN_REFRESH_INTERVAL
428 %token STUN_ALLOW_STUN
449 %token <intval> NUMBER
451 %token <strval> STRING
452 %token <strval> IPV6ADDR
471 %type <expr> exp exp_elem /*, condition*/
472 %type <action> action actions cmd fcmd if_cmd stm exp_stm assign_action
473 %type <ipaddr> ipv4 ipv6 ipv6addr ip
476 %type <strval> listen_id
477 %type <name_l> listen_id_lst
478 %type <name_l> listen_id2
479 %type <sockid> id_lst
480 %type <sockid> phostport
481 %type <sockid> listen_phostport
482 %type <intval> proto port
483 %type <intval> equalop strop intop binop
484 %type <strval> host_sep
485 %type <intval> uri_type
487 %type <attr> attr_id_num_idx
488 %type <attr> attr_id_no_idx
489 %type <attr> attr_id_ass
490 %type <attr> attr_id_val
491 %type <attr> attr_id_any
492 %type <attr> attr_id_any_str
493 /* %type <intval> class_id */
494 %type <intval> assign_op
495 %type <select> select_id
496 %type <strval> flag_name;
497 %type <strval> route_name;
498 %type <intval> avpflag_oper
500 /*%type <route_el> rules;
501 %type <route_el> rule;
511 statements statement {}
513 | statements error { yyerror(""); YYABORT;}
520 | {rt=REQUEST_ROUTE;} route_stm
521 | {rt=FAILURE_ROUTE;} failure_route_stm
522 | {rt=ONREPLY_ROUTE;} onreply_route_stm
523 | {rt=BRANCH_ROUTE;} branch_route_stm
524 | {rt=ONSEND_ROUTE;} send_route_stm
525 | SEMICOLON /* null statement */
526 | CR /* null statement*/
532 LOG(L_CRIT, "ERROR: cfg. parser: bad ip "
536 $$=pkg_malloc(strlen(tmp)+1);
538 LOG(L_CRIT, "ERROR: cfg. parser: out of "
541 strncpy($$, tmp, strlen(tmp)+1);
546 $$=pkg_malloc(strlen($1)+1);
548 LOG(L_CRIT, "ERROR: cfg. parser: out of "
551 strncpy($$, $1, strlen($1)+1);
555 $$=pkg_malloc(strlen($1)+1);
557 LOG(L_CRIT, "ERROR: cfg. parser: out of "
560 strncpy($$, $1, strlen($1)+1);
567 listen_id { $$=mk_name_lst($1, SI_IS_MHOMED); }
568 | listen_id COMMA listen_id_lst { $$=mk_name_lst($1, SI_IS_MHOMED);
574 LPAREN listen_id_lst RPAREN { $$=$2; }
575 | listen_id { $$=mk_name_lst($1, 0); }
579 UDP { $$=PROTO_UDP; }
580 | TCP { $$=PROTO_TCP; }
581 | TLS { $$=PROTO_TLS; }
582 | SCTP { $$=PROTO_SCTP; }
590 listen_id { $$=mk_listen_id($1, 0, 0); }
591 | listen_id COLON port { $$=mk_listen_id($1, 0, $3); }
592 | proto COLON listen_id { $$=mk_listen_id($3, $1, 0); }
593 | proto COLON listen_id COLON port { $$=mk_listen_id($3, $1, $5);}
594 | listen_id COLON error { $$=0; yyerror(" port number expected"); }
598 listen_id2 { $$=mk_listen_id2($1, 0, 0); }
599 | listen_id2 COLON port { $$=mk_listen_id2($1, 0, $3); }
600 | proto COLON listen_id2 { $$=mk_listen_id2($3, $1, 0); }
601 | proto COLON listen_id2 COLON port { $$=mk_listen_id2($3, $1, $5);}
602 | listen_id2 COLON error { $$=0; yyerror(" port number expected"); }
606 listen_phostport { $$=$1 ; }
607 | listen_phostport id_lst { $$=$1; $$->next=$2; }
610 flags_decl: FLAGS_DECL flag_list
611 | FLAGS_DECL error { yyerror("flag list expected\n"); }
614 | flag_spec COMMA flag_list
617 flag_spec: flag_name { if (register_flag($1,-1)<0)
618 yyerror("register flag failed");
620 | flag_name COLON NUMBER {
621 if (register_flag($1, $3)<0)
622 yyerror("register flag failed");
626 flag_name: STRING { $$=$1; }
631 AVPFLAGS_DECL avpflag_list
632 | AVPFLAGS_DECL error { yyerror("avpflag list expected\n"); }
636 | avpflag_spec COMMA avpflag_list
640 if (register_avpflag($1)==0)
641 yyerror("cannot declare avpflag");
645 DEBUG_V EQUAL NUMBER { default_core_cfg.debug=$3; }
646 | DEBUG_V EQUAL error { yyerror("number expected"); }
647 | FORK EQUAL NUMBER { dont_fork= ! $3; }
648 | FORK EQUAL error { yyerror("boolean value expected"); }
649 | LOGSTDERROR EQUAL NUMBER { if (!config_check) log_stderr=$3; }
650 | LOGSTDERROR EQUAL error { yyerror("boolean value expected"); }
651 | LOGFACILITY EQUAL ID {
652 if ( (i_tmp=str2facility($3))==-1)
653 yyerror("bad facility (see syslog(3) man page)");
655 default_core_cfg.log_facility=i_tmp;
657 | LOGFACILITY EQUAL error { yyerror("ID expected"); }
658 | DNS EQUAL NUMBER { received_dns|= ($3)?DO_DNS:0; }
659 | DNS EQUAL error { yyerror("boolean value expected"); }
660 | REV_DNS EQUAL NUMBER { received_dns|= ($3)?DO_REV_DNS:0; }
661 | REV_DNS EQUAL error { yyerror("boolean value expected"); }
662 | DNS_TRY_IPV6 EQUAL NUMBER { default_core_cfg.dns_try_ipv6=$3; }
663 | DNS_TRY_IPV6 error { yyerror("boolean value expected"); }
664 | DNS_TRY_NAPTR EQUAL NUMBER { IF_NAPTR(default_core_cfg.dns_try_naptr=$3); }
665 | DNS_TRY_NAPTR error { yyerror("boolean value expected"); }
666 | DNS_SRV_LB EQUAL NUMBER { IF_DNS_FAILOVER(default_core_cfg.dns_srv_lb=$3); }
667 | DNS_SRV_LB error { yyerror("boolean value expected"); }
668 | DNS_UDP_PREF EQUAL NUMBER { IF_NAPTR(default_core_cfg.dns_udp_pref=$3);}
669 | DNS_UDP_PREF error { yyerror("number expected"); }
670 | DNS_TCP_PREF EQUAL NUMBER { IF_NAPTR(default_core_cfg.dns_tcp_pref=$3);}
671 | DNS_TCP_PREF error { yyerror("number expected"); }
672 | DNS_TLS_PREF EQUAL NUMBER { IF_NAPTR(default_core_cfg.dns_tls_pref=$3);}
673 | DNS_TLS_PREF error { yyerror("number expected"); }
674 | DNS_SCTP_PREF EQUAL NUMBER {
675 IF_NAPTR(default_core_cfg.dns_sctp_pref=$3); }
676 | DNS_SCTP_PREF error { yyerror("number expected"); }
677 | DNS_RETR_TIME EQUAL NUMBER { default_core_cfg.dns_retr_time=$3; }
678 | DNS_RETR_TIME error { yyerror("number expected"); }
679 | DNS_RETR_NO EQUAL NUMBER { default_core_cfg.dns_retr_no=$3; }
680 | DNS_RETR_NO error { yyerror("number expected"); }
681 | DNS_SERVERS_NO EQUAL NUMBER { default_core_cfg.dns_servers_no=$3; }
682 | DNS_SERVERS_NO error { yyerror("number expected"); }
683 | DNS_USE_SEARCH EQUAL NUMBER { default_core_cfg.dns_search_list=$3; }
684 | DNS_USE_SEARCH error { yyerror("boolean value expected"); }
685 | DNS_SEARCH_FMATCH EQUAL NUMBER { default_core_cfg.dns_search_fmatch=$3; }
686 | DNS_SEARCH_FMATCH error { yyerror("boolean value expected"); }
687 | DNS_CACHE_INIT EQUAL NUMBER { IF_DNS_CACHE(dns_cache_init=$3); }
688 | DNS_CACHE_INIT error { yyerror("boolean value expected"); }
689 | DNS_USE_CACHE EQUAL NUMBER { IF_DNS_CACHE(default_core_cfg.use_dns_cache=$3); }
690 | DNS_USE_CACHE error { yyerror("boolean value expected"); }
691 | DNS_USE_FAILOVER EQUAL NUMBER { IF_DNS_FAILOVER(default_core_cfg.use_dns_failover=$3);}
692 | DNS_USE_FAILOVER error { yyerror("boolean value expected"); }
693 | DNS_CACHE_FLAGS EQUAL NUMBER { IF_DNS_CACHE(default_core_cfg.dns_cache_flags=$3); }
694 | DNS_CACHE_FLAGS error { yyerror("boolean value expected"); }
695 | DNS_CACHE_NEG_TTL EQUAL NUMBER { IF_DNS_CACHE(default_core_cfg.dns_neg_cache_ttl=$3); }
696 | DNS_CACHE_NEG_TTL error { yyerror("boolean value expected"); }
697 | DNS_CACHE_MAX_TTL EQUAL NUMBER { IF_DNS_CACHE(default_core_cfg.dns_cache_max_ttl=$3); }
698 | DNS_CACHE_MAX_TTL error { yyerror("boolean value expected"); }
699 | DNS_CACHE_MIN_TTL EQUAL NUMBER { IF_DNS_CACHE(default_core_cfg.dns_cache_min_ttl=$3); }
700 | DNS_CACHE_MIN_TTL error { yyerror("boolean value expected"); }
701 | DNS_CACHE_MEM EQUAL NUMBER { IF_DNS_CACHE(default_core_cfg.dns_cache_max_mem=$3); }
702 | DNS_CACHE_MEM error { yyerror("boolean value expected"); }
703 | DNS_CACHE_GC_INT EQUAL NUMBER { IF_DNS_CACHE(dns_timer_interval=$3); }
704 | DNS_CACHE_GC_INT error { yyerror("boolean value expected"); }
705 | DNS_CACHE_DEL_NONEXP EQUAL NUMBER { IF_DNS_CACHE(default_core_cfg.dns_cache_del_nonexp=$3); }
706 | DNS_CACHE_DEL_NONEXP error { yyerror("boolean value expected"); }
707 | DST_BLST_INIT EQUAL NUMBER { IF_DST_BLACKLIST(dst_blacklist_init=$3); }
708 | DST_BLST_INIT error { yyerror("boolean value expected"); }
709 | USE_DST_BLST EQUAL NUMBER { IF_DST_BLACKLIST(default_core_cfg.use_dst_blacklist=$3); }
710 | USE_DST_BLST error { yyerror("boolean value expected"); }
711 | DST_BLST_MEM EQUAL NUMBER { IF_DST_BLACKLIST(default_core_cfg.blst_max_mem=$3); }
712 | DST_BLST_MEM error { yyerror("boolean value expected"); }
713 | DST_BLST_TTL EQUAL NUMBER { IF_DST_BLACKLIST(default_core_cfg.blst_timeout=$3); }
714 | DST_BLST_TTL error { yyerror("boolean value expected"); }
715 | DST_BLST_GC_INT EQUAL NUMBER { IF_DST_BLACKLIST(blst_timer_interval=$3);}
716 | DST_BLST_GC_INT error { yyerror("boolean value expected"); }
717 | PORT EQUAL NUMBER { port_no=$3; }
718 | STAT EQUAL STRING {
723 | MAXBUFFER EQUAL NUMBER { maxbuffer=$3; }
724 | MAXBUFFER EQUAL error { yyerror("number expected"); }
725 | PORT EQUAL error { yyerror("number expected"); }
726 | CHILDREN EQUAL NUMBER { children_no=$3; }
727 | CHILDREN EQUAL error { yyerror("number expected"); }
728 | CHECK_VIA EQUAL NUMBER { check_via=$3; }
729 | CHECK_VIA EQUAL error { yyerror("boolean value expected"); }
730 | PHONE2TEL EQUAL NUMBER { phone2tel=$3; }
731 | PHONE2TEL EQUAL error { yyerror("boolean value expected"); }
732 | SYN_BRANCH EQUAL NUMBER { syn_branch=$3; }
733 | SYN_BRANCH EQUAL error { yyerror("boolean value expected"); }
734 | MEMLOG EQUAL NUMBER { memlog=$3; }
735 | MEMLOG EQUAL error { yyerror("int value expected"); }
736 | MEMDBG EQUAL NUMBER { memdbg=$3; }
737 | MEMDBG EQUAL error { yyerror("int value expected"); }
738 | SIP_WARNING EQUAL NUMBER { sip_warning=$3; }
739 | SIP_WARNING EQUAL error { yyerror("boolean value expected"); }
740 | USER EQUAL STRING { user=$3; }
741 | USER EQUAL ID { user=$3; }
742 | USER EQUAL error { yyerror("string value expected"); }
743 | GROUP EQUAL STRING { group=$3; }
744 | GROUP EQUAL ID { group=$3; }
745 | GROUP EQUAL error { yyerror("string value expected"); }
746 | CHROOT EQUAL STRING { chroot_dir=$3; }
747 | CHROOT EQUAL ID { chroot_dir=$3; }
748 | CHROOT EQUAL error { yyerror("string value expected"); }
749 | WDIR EQUAL STRING { working_dir=$3; }
750 | WDIR EQUAL ID { working_dir=$3; }
751 | WDIR EQUAL error { yyerror("string value expected"); }
752 | MHOMED EQUAL NUMBER { mhomed=$3; }
753 | MHOMED EQUAL error { yyerror("boolean value expected"); }
754 | DISABLE_TCP EQUAL NUMBER {
758 warn("tcp support not compiled in");
761 | DISABLE_TCP EQUAL error { yyerror("boolean value expected"); }
762 | TCP_ACCEPT_ALIASES EQUAL NUMBER {
764 tcp_accept_aliases=$3;
766 warn("tcp support not compiled in");
769 | TCP_ACCEPT_ALIASES EQUAL error { yyerror("boolean value expected"); }
770 | TCP_CHILDREN EQUAL NUMBER {
774 warn("tcp support not compiled in");
777 | TCP_CHILDREN EQUAL error { yyerror("number expected"); }
778 | TCP_CONNECT_TIMEOUT EQUAL NUMBER {
780 tcp_connect_timeout=$3;
782 warn("tcp support not compiled in");
785 | TCP_CONNECT_TIMEOUT EQUAL error { yyerror("number expected"); }
786 | TCP_SEND_TIMEOUT EQUAL NUMBER {
790 warn("tcp support not compiled in");
793 | TCP_SEND_TIMEOUT EQUAL error { yyerror("number expected"); }
794 | TCP_CON_LIFETIME EQUAL NUMBER {
798 warn("tcp support not compiled in");
801 | TCP_CON_LIFETIME EQUAL error { yyerror("number expected"); }
802 | TCP_POLL_METHOD EQUAL ID {
804 tcp_poll_method=get_poll_type($3);
805 if (tcp_poll_method==POLL_NONE) {
806 LOG(L_CRIT, "bad poll method name:"
807 " %s\n, try one of %s.\n",
809 yyerror("bad tcp_poll_method "
813 warn("tcp support not compiled in");
816 | TCP_POLL_METHOD EQUAL STRING {
818 tcp_poll_method=get_poll_type($3);
819 if (tcp_poll_method==POLL_NONE) {
820 LOG(L_CRIT, "bad poll method name:"
821 " %s\n, try one of %s.\n",
823 yyerror("bad tcp_poll_method "
827 warn("tcp support not compiled in");
830 | TCP_POLL_METHOD EQUAL error { yyerror("poll method name expected"); }
831 | TCP_MAX_CONNECTIONS EQUAL NUMBER {
833 tcp_max_connections=$3;
835 warn("tcp support not compiled in");
838 | TCP_MAX_CONNECTIONS EQUAL error { yyerror("number expected"); }
839 | TCP_SOURCE_IPV4 EQUAL ipv4 {
841 if (tcp_set_src_addr($3)<0)
842 warn("tcp_source_ipv4 failed");
844 warn("tcp support not compiled in");
848 | TCP_SOURCE_IPV4 EQUAL error { yyerror("IPv4 address expected"); }
849 | TCP_SOURCE_IPV6 EQUAL ipv6 {
852 if (tcp_set_src_addr($3)<0)
853 warn("tcp_source_ipv6 failed");
855 warn("IPv6 support not compiled in");
858 warn("tcp support not compiled in");
862 | TCP_SOURCE_IPV6 EQUAL error { yyerror("IPv6 address expected"); }
863 | TCP_OPT_FD_CACHE EQUAL NUMBER {
865 tcp_options.fd_cache=$3;
867 warn("tcp support not compiled in");
870 | TCP_OPT_FD_CACHE EQUAL error { yyerror("boolean value expected"); }
871 | TCP_OPT_BUF_WRITE EQUAL NUMBER {
873 tcp_options.tcp_buf_write=$3;
875 warn("tcp support not compiled in");
878 | TCP_OPT_BUF_WRITE EQUAL error { yyerror("boolean value expected"); }
879 | TCP_OPT_CONN_WQ_MAX EQUAL NUMBER {
881 tcp_options.tcpconn_wq_max=$3;
883 warn("tcp support not compiled in");
886 | TCP_OPT_CONN_WQ_MAX error { yyerror("boolean value expected"); }
887 | TCP_OPT_WQ_MAX EQUAL NUMBER {
889 tcp_options.tcp_wq_max=$3;
891 warn("tcp support not compiled in");
894 | TCP_OPT_WQ_MAX error { yyerror("boolean value expected"); }
895 | TCP_OPT_DEFER_ACCEPT EQUAL NUMBER {
897 tcp_options.defer_accept=$3;
899 warn("tcp support not compiled in");
902 | TCP_OPT_DEFER_ACCEPT EQUAL error { yyerror("boolean value expected"); }
903 | TCP_OPT_DELAYED_ACK EQUAL NUMBER {
905 tcp_options.delayed_ack=$3;
907 warn("tcp support not compiled in");
910 | TCP_OPT_DELAYED_ACK EQUAL error { yyerror("boolean value expected"); }
911 | TCP_OPT_SYNCNT EQUAL NUMBER {
913 tcp_options.syncnt=$3;
915 warn("tcp support not compiled in");
918 | TCP_OPT_SYNCNT EQUAL error { yyerror("number expected"); }
919 | TCP_OPT_LINGER2 EQUAL NUMBER {
921 tcp_options.linger2=$3;
923 warn("tcp support not compiled in");
926 | TCP_OPT_LINGER2 EQUAL error { yyerror("number expected"); }
927 | TCP_OPT_KEEPALIVE EQUAL NUMBER {
929 tcp_options.keepalive=$3;
931 warn("tcp support not compiled in");
934 | TCP_OPT_KEEPALIVE EQUAL error { yyerror("boolean value expected");}
935 | TCP_OPT_KEEPIDLE EQUAL NUMBER {
937 tcp_options.keepidle=$3;
939 warn("tcp support not compiled in");
942 | TCP_OPT_KEEPIDLE EQUAL error { yyerror("number expected"); }
943 | TCP_OPT_KEEPINTVL EQUAL NUMBER {
945 tcp_options.keepintvl=$3;
947 warn("tcp support not compiled in");
950 | TCP_OPT_KEEPINTVL EQUAL error { yyerror("number expected"); }
951 | TCP_OPT_KEEPCNT EQUAL NUMBER {
953 tcp_options.keepcnt=$3;
955 warn("tcp support not compiled in");
958 | TCP_OPT_KEEPCNT EQUAL error { yyerror("number expected"); }
959 | TCP_OPT_CRLF_PING EQUAL NUMBER {
961 tcp_options.crlf_ping=$3;
963 warn("tcp support not compiled in");
966 | TCP_OPT_CRLF_PING EQUAL error { yyerror("boolean value expected"); }
967 | DISABLE_TLS EQUAL NUMBER {
971 warn("tls support not compiled in");
974 | DISABLE_TLS EQUAL error { yyerror("boolean value expected"); }
975 | ENABLE_TLS EQUAL NUMBER {
979 warn("tls support not compiled in");
982 | ENABLE_TLS EQUAL error { yyerror("boolean value expected"); }
983 | TLSLOG EQUAL NUMBER {
987 warn("tls-in-core support not compiled in");
990 | TLSLOG EQUAL error { yyerror("int value expected"); }
991 | TLS_PORT_NO EQUAL NUMBER {
995 warn("tls support not compiled in");
998 | TLS_PORT_NO EQUAL error { yyerror("number expected"); }
999 | TLS_METHOD EQUAL SSLv23 {
1001 tls_method=TLS_USE_SSLv23;
1003 warn("tls-in-core support not compiled in");
1006 | TLS_METHOD EQUAL SSLv2 {
1008 tls_method=TLS_USE_SSLv2;
1010 warn("tls-in-core support not compiled in");
1013 | TLS_METHOD EQUAL SSLv3 {
1015 tls_method=TLS_USE_SSLv3;
1017 warn("tls-in-core support not compiled in");
1020 | TLS_METHOD EQUAL TLSv1 {
1022 tls_method=TLS_USE_TLSv1;
1024 warn("tls-in-core support not compiled in");
1027 | TLS_METHOD EQUAL error {
1029 yyerror("SSLv23, SSLv2, SSLv3 or TLSv1 expected");
1031 warn("tls-in-core support not compiled in");
1034 | TLS_VERIFY EQUAL NUMBER {
1038 warn("tls-in-core support not compiled in");
1041 | TLS_VERIFY EQUAL error { yyerror("boolean value expected"); }
1042 | TLS_REQUIRE_CERTIFICATE EQUAL NUMBER {
1044 tls_require_cert=$3;
1046 warn( "tls-in-core support not compiled in");
1049 | TLS_REQUIRE_CERTIFICATE EQUAL error { yyerror("boolean value expected"); }
1050 | TLS_CERTIFICATE EQUAL STRING {
1054 warn("tls-in-core support not compiled in");
1057 | TLS_CERTIFICATE EQUAL error { yyerror("string value expected"); }
1058 | TLS_PRIVATE_KEY EQUAL STRING {
1062 warn("tls-in-core support not compiled in");
1065 | TLS_PRIVATE_KEY EQUAL error { yyerror("string value expected"); }
1066 | TLS_CA_LIST EQUAL STRING {
1070 warn("tls-in-core support not compiled in");
1073 | TLS_CA_LIST EQUAL error { yyerror("string value expected"); }
1074 | TLS_HANDSHAKE_TIMEOUT EQUAL NUMBER {
1076 tls_handshake_timeout=$3;
1078 warn("tls-in-core support not compiled in");
1081 | TLS_HANDSHAKE_TIMEOUT EQUAL error { yyerror("number expected"); }
1082 | TLS_SEND_TIMEOUT EQUAL NUMBER {
1084 tls_send_timeout=$3;
1086 warn("tls-in-core support not compiled in");
1089 | TLS_SEND_TIMEOUT EQUAL error { yyerror("number expected"); }
1090 | DISABLE_SCTP EQUAL NUMBER {
1094 warn("sctp support not compiled in");
1097 | DISABLE_SCTP EQUAL error { yyerror("boolean value expected"); }
1098 | ENABLE_SCTP EQUAL NUMBER {
1100 sctp_disable=($3<=1)?!$3:$3;
1102 warn("sctp support not compiled in");
1105 | ENABLE_SCTP EQUAL error { yyerror("boolean or number expected"); }
1106 | SCTP_CHILDREN EQUAL NUMBER {
1108 sctp_children_no=$3;
1110 warn("sctp support not compiled in");
1113 | SCTP_CHILDREN EQUAL error { yyerror("number expected"); }
1114 | SCTP_SOCKET_RCVBUF EQUAL NUMBER {
1116 sctp_options.sctp_so_rcvbuf=$3;
1118 warn("sctp support not compiled in");
1121 | SCTP_SOCKET_RCVBUF EQUAL error { yyerror("number expected"); }
1122 | SCTP_SOCKET_SNDBUF EQUAL NUMBER {
1124 sctp_options.sctp_so_sndbuf=$3;
1126 warn("sctp support not compiled in");
1129 | SCTP_SOCKET_SNDBUF EQUAL error { yyerror("number expected"); }
1130 | SCTP_AUTOCLOSE EQUAL NUMBER {
1132 sctp_options.sctp_autoclose=$3;
1134 warn("sctp support not compiled in");
1137 | SCTP_AUTOCLOSE EQUAL error { yyerror("number expected"); }
1138 | SCTP_SEND_TTL EQUAL NUMBER {
1140 sctp_options.sctp_send_ttl=$3;
1142 warn("sctp support not compiled in");
1145 | SCTP_SEND_TTL EQUAL error { yyerror("number expected"); }
1146 | SCTP_SEND_RETRIES EQUAL NUMBER {
1148 sctp_options.sctp_send_retries=$3;
1150 warn("sctp support not compiled in");
1153 | SCTP_SEND_RETRIES EQUAL error { yyerror("number expected"); }
1154 | SERVER_SIGNATURE EQUAL NUMBER { server_signature=$3; }
1155 | SERVER_SIGNATURE EQUAL error { yyerror("boolean value expected"); }
1156 | REPLY_TO_VIA EQUAL NUMBER { reply_to_via=$3; }
1157 | REPLY_TO_VIA EQUAL error { yyerror("boolean value expected"); }
1158 | LISTEN EQUAL id_lst {
1159 for(lst_tmp=$3; lst_tmp; lst_tmp=lst_tmp->next) {
1160 if (add_listen_iface( lst_tmp->addr_lst->name,
1161 lst_tmp->addr_lst->next,
1162 lst_tmp->port, lst_tmp->proto,
1163 lst_tmp->flags)!=0) {
1164 LOG(L_CRIT, "ERROR: cfg. parser: failed to add listen"
1169 free_socket_id_lst($3);
1171 | LISTEN EQUAL error { yyerror("ip address or hostname expected"); }
1172 | ALIAS EQUAL id_lst {
1173 for(lst_tmp=$3; lst_tmp; lst_tmp=lst_tmp->next){
1174 add_alias( lst_tmp->addr_lst->name,
1175 strlen(lst_tmp->addr_lst->name),
1176 lst_tmp->port, lst_tmp->proto);
1177 for (nl_tmp=lst_tmp->addr_lst->next; nl_tmp; nl_tmp=nl_tmp->next)
1178 add_alias(nl_tmp->name, strlen(nl_tmp->name),
1179 lst_tmp->port, lst_tmp->proto);
1181 free_socket_id_lst($3);
1183 | ALIAS EQUAL error { yyerror(" hostname expected"); }
1184 | ADVERTISED_ADDRESS EQUAL listen_id {
1185 default_global_address.s=$3;
1186 default_global_address.len=strlen($3);
1188 | ADVERTISED_ADDRESS EQUAL error {yyerror("ip address or hostname expected"); }
1189 | ADVERTISED_PORT EQUAL NUMBER {
1190 tmp=int2str($3, &i_tmp);
1191 if ((default_global_port.s=pkg_malloc(i_tmp))==0) {
1192 LOG(L_CRIT, "ERROR: cfg. parser: out of memory.\n");
1193 default_global_port.len=0;
1195 default_global_port.len=i_tmp;
1196 memcpy(default_global_port.s, tmp, default_global_port.len);
1199 |ADVERTISED_PORT EQUAL error {yyerror("ip address or hostname expected"); }
1200 | DISABLE_CORE EQUAL NUMBER { disable_core_dump=$3; }
1201 | DISABLE_CORE EQUAL error { yyerror("boolean value expected"); }
1202 | OPEN_FD_LIMIT EQUAL NUMBER { open_files_limit=$3; }
1203 | OPEN_FD_LIMIT EQUAL error { yyerror("number expected"); }
1204 | SHM_FORCE_ALLOC EQUAL NUMBER { shm_force_alloc=$3; }
1205 | SHM_FORCE_ALLOC EQUAL error { yyerror("boolean value expected"); }
1206 | MLOCK_PAGES EQUAL NUMBER { mlock_pages=$3; }
1207 | MLOCK_PAGES EQUAL error { yyerror("boolean value expected"); }
1208 | REAL_TIME EQUAL NUMBER { real_time=$3; }
1209 | REAL_TIME EQUAL error { yyerror("boolean value expected"); }
1210 | RT_PRIO EQUAL NUMBER { rt_prio=$3; }
1211 | RT_PRIO EQUAL error { yyerror("boolean value expected"); }
1212 | RT_POLICY EQUAL NUMBER { rt_policy=$3; }
1213 | RT_POLICY EQUAL error { yyerror("boolean value expected"); }
1214 | RT_TIMER1_PRIO EQUAL NUMBER { rt_timer1_prio=$3; }
1215 | RT_TIMER1_PRIO EQUAL error { yyerror("boolean value expected"); }
1216 | RT_TIMER1_POLICY EQUAL NUMBER { rt_timer1_policy=$3; }
1217 | RT_TIMER1_POLICY EQUAL error { yyerror("boolean value expected"); }
1218 | RT_TIMER2_PRIO EQUAL NUMBER { rt_timer2_prio=$3; }
1219 | RT_TIMER2_PRIO EQUAL error { yyerror("boolean value expected"); }
1220 | RT_TIMER2_POLICY EQUAL NUMBER { rt_timer2_policy=$3; }
1221 | RT_TIMER2_POLICY EQUAL error { yyerror("boolean value expected"); }
1222 | MCAST_LOOPBACK EQUAL NUMBER {
1226 warn("no multicast support compiled in");
1229 | MCAST_LOOPBACK EQUAL error { yyerror("boolean value expected"); }
1230 | MCAST_TTL EQUAL NUMBER {
1234 warn("no multicast support compiled in");
1237 | MCAST_TTL EQUAL error { yyerror("number expected"); }
1238 | TOS EQUAL NUMBER { tos=$3; }
1239 | TOS EQUAL error { yyerror("number expected"); }
1240 | PMTU_DISCOVERY EQUAL NUMBER { pmtu_discovery=$3; }
1241 | PMTU_DISCOVERY error { yyerror("number expected"); }
1242 | KILL_TIMEOUT EQUAL NUMBER { ser_kill_timeout=$3; }
1243 | KILL_TIMEOUT EQUAL error { yyerror("number expected"); }
1244 | STUN_REFRESH_INTERVAL EQUAL NUMBER { IF_STUN(stun_refresh_interval=$3); }
1245 | STUN_REFRESH_INTERVAL EQUAL error{ yyerror("number expected"); }
1246 | STUN_ALLOW_STUN EQUAL NUMBER { IF_STUN(stun_allow_stun=$3); }
1247 | STUN_ALLOW_STUN EQUAL error{ yyerror("number expected"); }
1248 | STUN_ALLOW_FP EQUAL NUMBER { IF_STUN(stun_allow_fp=$3) ; }
1249 | STUN_ALLOW_FP EQUAL error{ yyerror("number expected"); }
1250 | SERVER_ID EQUAL NUMBER { server_id=$3; }
1252 | error EQUAL { yyerror("unknown config variable"); }
1255 ID DOT ID EQUAL NUMBER {
1256 if (cfg_declare_int($1, $3, $5, 0, 0, NULL)) {
1257 yyerror("variable cannot be declared");
1260 | ID DOT ID EQUAL STRING {
1261 if (cfg_declare_str($1, $3, $5, NULL)) {
1262 yyerror("variable cannot be declared");
1265 | ID DOT ID EQUAL NUMBER CFG_DESCRIPTION STRING {
1266 if (cfg_declare_int($1, $3, $5, 0, 0, $7)) {
1267 yyerror("variable cannot be declared");
1270 | ID DOT ID EQUAL STRING CFG_DESCRIPTION STRING {
1271 if (cfg_declare_str($1, $3, $5, $7)) {
1272 yyerror("variable cannot be declared");
1275 | ID DOT ID EQUAL error { yyerror("number or string expected"); }
1279 DBG("loading module %s\n", $2);
1280 if (load_module($2)!=0) {
1281 yyerror("failed to load module");
1284 | LOADMODULE error { yyerror("string expected"); }
1286 DBG("loading modules under %s\n", $2);
1287 printf("loading modules under %s\n", $2);
1290 | LOADPATH error { yyerror("string expected"); }
1291 | MODPARAM LPAREN STRING COMMA STRING COMMA STRING RPAREN {
1292 if (set_mod_param_regex($3, $5, PARAM_STRING, $7) != 0) {
1293 yyerror("Can't set module parameter");
1296 | MODPARAM LPAREN STRING COMMA STRING COMMA NUMBER RPAREN {
1297 if (set_mod_param_regex($3, $5, PARAM_INT, (void*)$7) != 0) {
1298 yyerror("Can't set module parameter");
1301 | MODPARAM error { yyerror("Invalid arguments"); }
1308 NUMBER DOT NUMBER DOT NUMBER DOT NUMBER {
1309 $$=pkg_malloc(sizeof(struct ip_addr));
1311 LOG(L_CRIT, "ERROR: cfg. parser: out of memory.\n");
1313 memset($$, 0, sizeof(struct ip_addr));
1316 if (($1>255) || ($1<0) ||
1317 ($3>255) || ($3<0) ||
1318 ($5>255) || ($5<0) ||
1319 ($7>255) || ($7<0)) {
1320 yyerror("invalid ipv4 address");
1330 ($3<<16)| ($5<<8)|$7 );
1338 $$=pkg_malloc(sizeof(struct ip_addr));
1340 LOG(L_CRIT, "ERROR: cfg. parser: out of memory.\n");
1343 memset($$, 0, sizeof(struct ip_addr));
1346 if (inet_pton(AF_INET6, $1, $$->u.addr)<=0) {
1347 yyerror("bad ipv6 address");
1350 yyerror("ipv6 address & no ipv6 support compiled in");
1358 | LBRACK ipv6addr RBRACK {$$=$2; }
1362 route_name: NUMBER {
1363 tmp=int2str($1, &i_tmp);
1364 if (($$=pkg_malloc(i_tmp+1))==0) {
1365 yyerror("out of memory");
1368 memcpy($$, tmp, i_tmp);
1377 ROUTE LBRACE actions RBRACE { push($3, &main_rt.rlist[DEFAULT_RT]); }
1378 | ROUTE LBRACK route_name RBRACK LBRACE actions RBRACE {
1379 i_tmp=route_get(&main_rt, $3);
1381 yyerror("internal error");
1384 if (main_rt.rlist[i_tmp]){
1385 yyerror("duplicate route");
1388 push($6, &main_rt.rlist[i_tmp]);
1390 | ROUTE error { yyerror("invalid route statement"); }
1393 ROUTE_FAILURE LBRACE actions RBRACE {
1394 push($3, &failure_rt.rlist[DEFAULT_RT]);
1396 | ROUTE_FAILURE LBRACK route_name RBRACK LBRACE actions RBRACE {
1397 i_tmp=route_get(&failure_rt, $3);
1399 yyerror("internal error");
1402 if (failure_rt.rlist[i_tmp]){
1403 yyerror("duplicate route");
1406 push($6, &failure_rt.rlist[i_tmp]);
1408 | ROUTE_FAILURE error { yyerror("invalid failure_route statement"); }
1411 ROUTE_ONREPLY LBRACE actions RBRACE {
1412 push($3, &onreply_rt.rlist[DEFAULT_RT]);
1414 | ROUTE_ONREPLY LBRACK route_name RBRACK LBRACE actions RBRACE {
1415 i_tmp=route_get(&onreply_rt, $3);
1417 yyerror("internal error");
1420 if (onreply_rt.rlist[i_tmp]){
1421 yyerror("duplicate route");
1424 push($6, &onreply_rt.rlist[i_tmp]);
1426 | ROUTE_ONREPLY error { yyerror("invalid onreply_route statement"); }
1429 ROUTE_BRANCH LBRACE actions RBRACE {
1430 push($3, &branch_rt.rlist[DEFAULT_RT]);
1432 | ROUTE_BRANCH LBRACK route_name RBRACK LBRACE actions RBRACE {
1433 i_tmp=route_get(&branch_rt, $3);
1435 yyerror("internal error");
1438 if (branch_rt.rlist[i_tmp]){
1439 yyerror("duplicate route");
1442 push($6, &branch_rt.rlist[i_tmp]);
1444 | ROUTE_BRANCH error { yyerror("invalid branch_route statement"); }
1446 send_route_stm: ROUTE_SEND LBRACE actions RBRACE {
1447 push($3, &onsend_rt.rlist[DEFAULT_RT]);
1449 | ROUTE_SEND LBRACK route_name RBRACK LBRACE actions RBRACE {
1450 i_tmp=route_get(&onsend_rt, $3);
1452 yyerror("internal error");
1455 if (onsend_rt.rlist[i_tmp]){
1456 yyerror("duplicate route");
1459 push($6, &onsend_rt.rlist[i_tmp]);
1461 | ROUTE_SEND error { yyerror("invalid onsend_route statement"); }
1465 rules rule { push($2, &$1); $$=$1; }
1467 | rules error { $$=0; yyerror("invalid rule"); }
1470 condition actions CR {
1472 if (add_rule($1, $2, &$$)<0) {
1473 yyerror("error calling add_rule");
1478 | condition error { $$=0; yyerror("bad actions in rule"); }
1483 exp: exp LOG_AND exp { $$=mk_exp(LOGAND_OP, $1, $3); }
1484 | exp LOG_OR exp { $$=mk_exp(LOGOR_OP, $1, $3); }
1485 | NOT exp { $$=mk_exp(NOT_OP, $2, 0); }
1486 | LPAREN exp RPAREN { $$=$2; }
1487 | exp_elem { $$=$1; }
1490 EQUAL_T {$$=EQUAL_OP; }
1491 | DIFF {$$=DIFF_OP; }
1493 intop: equalop {$$=$1; }
1500 BIN_OR { $$= BINOR_OP; }
1501 | BIN_AND { $$ = BINAND_OP; }
1505 | MATCH {$$=MATCH_OP; }
1509 | FROM_URI {$$=FROM_URI_O;}
1510 | TO_URI {$$=TO_URI_O;}
1514 METHOD strop STRING {$$= mk_elem($2, METHOD_O, 0, STRING_ST, $3);}
1515 | METHOD strop attr_id_val {$$ = mk_elem($2, METHOD_O, 0, AVP_ST, $3); }
1516 | METHOD strop select_id {$$ = mk_elem($2, METHOD_O, 0, SELECT_ST, $3); }
1517 | METHOD strop ID {$$ = mk_elem($2, METHOD_O, 0, STRING_ST,$3); }
1518 | METHOD strop error { $$=0; yyerror("string expected"); }
1519 | METHOD error { $$=0; yyerror("invalid operator,== , !=, or =~ expected"); }
1520 | uri_type strop STRING {$$ = mk_elem($2, $1, 0, STRING_ST, $3); }
1521 | uri_type strop host {$$ = mk_elem($2, $1, 0, STRING_ST, $3); }
1522 | uri_type strop attr_id_val {$$ = mk_elem($2, $1, 0, AVP_ST, $3); }
1523 | uri_type strop select_id {$$ = mk_elem($2, $1, 0, SELECT_ST, $3); }
1524 | uri_type equalop MYSELF {$$=mk_elem($2, $1, 0, MYSELF_ST, 0); }
1525 | uri_type strop error { $$=0; yyerror("string or MYSELF expected"); }
1526 | uri_type error { $$=0; yyerror("invalid operator, == , != or =~ expected"); }
1528 | SRCPORT intop NUMBER { $$=mk_elem($2, SRCPORT_O, 0, NUMBER_ST, (void*)$3 ); }
1529 | SRCPORT intop attr_id_val { $$=mk_elem($2, SRCPORT_O, 0, AVP_ST, (void*)$3 ); }
1530 | SRCPORT intop error { $$=0; yyerror("number expected"); }
1531 | SRCPORT error { $$=0; yyerror("==, !=, <,>, >= or <= expected"); }
1533 | DSTPORT intop NUMBER { $$=mk_elem($2, DSTPORT_O, 0, NUMBER_ST, (void*)$3 ); }
1534 | DSTPORT intop attr_id_val { $$=mk_elem($2, DSTPORT_O, 0, AVP_ST, (void*)$3 ); }
1535 | DSTPORT intop error { $$=0; yyerror("number expected"); }
1536 | DSTPORT error { $$=0; yyerror("==, !=, <,>, >= or <= expected"); }
1538 | SNDPORT intop NUMBER {
1539 onsend_check("snd_port");
1540 $$=mk_elem($2, SNDPORT_O, 0, NUMBER_ST, (void*)$3 );
1542 | SNDPORT intop attr_id_val {
1543 onsend_check("snd_port");
1544 $$=mk_elem($2, SNDPORT_O, 0, AVP_ST, (void*)$3 );
1546 | SNDPORT intop error { $$=0; yyerror("number expected"); }
1547 | SNDPORT error { $$=0; yyerror("==, !=, <,>, >= or <= expected"); }
1549 | TOPORT intop NUMBER {
1550 onsend_check("to_port");
1551 $$=mk_elem($2, TOPORT_O, 0, NUMBER_ST, (void*)$3 );
1553 | TOPORT intop attr_id_val {
1554 onsend_check("to_port");
1555 $$=mk_elem($2, TOPORT_O, 0, AVP_ST, (void*)$3 );
1557 | TOPORT intop error { $$=0; yyerror("number expected"); }
1558 | TOPORT error { $$=0; yyerror("==, !=, <,>, >= or <= expected"); }
1560 | PROTO intop proto { $$=mk_elem($2, PROTO_O, 0, NUMBER_ST, (void*)$3 ); }
1561 | PROTO intop attr_id_val { $$=mk_elem($2, PROTO_O, 0, AVP_ST, (void*)$3 ); }
1562 | PROTO intop error { $$=0; yyerror("protocol expected (udp, tcp or tls)"); }
1564 | PROTO error { $$=0; yyerror("equal/!= operator expected"); }
1566 | SNDPROTO intop proto {
1567 onsend_check("snd_proto");
1568 $$=mk_elem($2, SNDPROTO_O, 0, NUMBER_ST, (void*)$3 );
1570 | SNDPROTO intop attr_id_val {
1571 onsend_check("snd_proto");
1572 $$=mk_elem($2, SNDPROTO_O, 0, AVP_ST, (void*)$3 );
1574 | SNDPROTO intop error { $$=0; yyerror("protocol expected (udp, tcp or tls)"); }
1575 | SNDPROTO error { $$=0; yyerror("equal/!= operator expected"); }
1577 | AF intop NUMBER { $$=mk_elem($2, AF_O, 0, NUMBER_ST,(void *) $3 ); }
1578 | AF intop attr_id_val { $$=mk_elem($2, AF_O, 0, AVP_ST,(void *) $3 ); }
1579 | AF intop error { $$=0; yyerror("number expected"); }
1580 | AF error { $$=0; yyerror("equal/!= operator expected"); }
1582 | SNDAF intop NUMBER {
1583 onsend_check("snd_af");
1584 $$=mk_elem($2, SNDAF_O, 0, NUMBER_ST, (void *) $3 ); }
1585 | SNDAF intop attr_id_val {
1586 onsend_check("snd_af");
1587 $$=mk_elem($2, SNDAF_O, 0, AVP_ST, (void *) $3 );
1589 | SNDAF intop error { $$=0; yyerror("number expected"); }
1590 | SNDAF error { $$=0; yyerror("equal/!= operator expected"); }
1592 | MSGLEN intop NUMBER { $$=mk_elem($2, MSGLEN_O, 0, NUMBER_ST, (void *) $3 ); }
1593 | MSGLEN intop attr_id_val { $$=mk_elem($2, MSGLEN_O, 0, AVP_ST, (void *) $3 ); }
1594 | MSGLEN intop MAX_LEN { $$=mk_elem($2, MSGLEN_O, 0, NUMBER_ST, (void *) BUF_SIZE); }
1595 | MSGLEN intop error { $$=0; yyerror("number expected"); }
1596 | MSGLEN error { $$=0; yyerror("equal/!= operator expected"); }
1598 | RETCODE intop NUMBER { $$=mk_elem($2, RETCODE_O, 0, NUMBER_ST, (void *) $3 ); }
1599 | RETCODE intop attr_id_val { $$=mk_elem($2, RETCODE_O, 0, AVP_ST, (void *) $3 ); }
1600 | RETCODE intop error { $$=0; yyerror("number expected"); }
1601 | RETCODE error { $$=0; yyerror("equal/!= operator expected"); }
1603 | SRCIP equalop ipnet { $$=mk_elem($2, SRCIP_O, 0, NET_ST, $3); }
1604 | SRCIP strop STRING {
1606 s_tmp.len=strlen($3);
1607 ip_tmp=str2ip(&s_tmp);
1610 ip_tmp=str2ip6(&s_tmp);
1613 $$=mk_elem($2, SRCIP_O, 0, NET_ST, mk_net_bitlen(ip_tmp, ip_tmp->len*8) );
1615 $$=mk_elem($2, SRCIP_O, 0, STRING_ST, $3);
1618 | SRCIP strop host { $$=mk_elem($2, SRCIP_O, 0, STRING_ST, $3); }
1619 | SRCIP equalop MYSELF { $$=mk_elem($2, SRCIP_O, 0, MYSELF_ST, 0);
1621 | SRCIP strop error { $$=0; yyerror( "ip address or hostname expected" ); }
1622 | SRCIP error { $$=0; yyerror("invalid operator, ==, != or =~ expected");}
1623 | DSTIP equalop ipnet { $$=mk_elem( $2, DSTIP_O, 0, NET_ST, (void*)$3); }
1624 | DSTIP strop STRING {
1626 s_tmp.len=strlen($3);
1627 ip_tmp=str2ip(&s_tmp);
1630 ip_tmp=str2ip6(&s_tmp);
1631 #endif /* USE_IPV6 */
1633 $$=mk_elem($2, DSTIP_O, 0, NET_ST, mk_net_bitlen(ip_tmp, ip_tmp->len*8) );
1635 $$=mk_elem($2, DSTIP_O, 0, STRING_ST, $3);
1638 | DSTIP strop host { $$=mk_elem( $2, DSTIP_O, 0, STRING_ST, $3); }
1639 | DSTIP equalop MYSELF { $$=mk_elem( $2, DSTIP_O, 0, MYSELF_ST, 0); }
1640 | DSTIP strop error { $$=0; yyerror( "ip address or hostname expected" ); }
1641 | DSTIP error { $$=0; yyerror("invalid operator, ==, != or =~ expected"); }
1642 | SNDIP equalop ipnet {
1643 onsend_check("snd_ip");
1644 $$=mk_elem($2, SNDIP_O, 0, NET_ST, $3);
1646 | SNDIP strop STRING {
1647 onsend_check("snd_ip");
1649 s_tmp.len=strlen($3);
1650 ip_tmp=str2ip(&s_tmp);
1653 ip_tmp=str2ip6(&s_tmp);
1654 #endif /* USE_IPV6 */
1656 $$=mk_elem($2, SNDIP_O, 0, NET_ST, mk_net_bitlen(ip_tmp, ip_tmp->len*8) );
1658 $$=mk_elem($2, SNDIP_O, 0, STRING_ST, $3);
1661 | SNDIP strop host {
1662 onsend_check("snd_ip");
1663 $$=mk_elem($2, SNDIP_O, 0, STRING_ST, $3);
1665 | SNDIP equalop attr_id_val {
1666 onsend_check("snd_ip");
1667 $$=mk_elem($2, SNDIP_O, 0, AVP_ST, (void*)$3 );
1669 | SNDIP equalop MYSELF {
1670 onsend_check("snd_ip");
1671 $$=mk_elem($2, SNDIP_O, 0, MYSELF_ST, 0);
1673 | SNDIP strop error { $$=0; yyerror( "ip address or hostname expected" ); }
1674 | SNDIP error { $$=0; yyerror("invalid operator, ==, != or =~ expected"); }
1675 | TOIP equalop ipnet {
1676 onsend_check("to_ip");
1677 $$=mk_elem($2, TOIP_O, 0, NET_ST, $3);
1679 | TOIP strop STRING {
1680 onsend_check("to_ip");
1682 s_tmp.len=strlen($3);
1683 ip_tmp=str2ip(&s_tmp);
1686 ip_tmp=str2ip6(&s_tmp);
1687 #endif /* USE_IPV6 */
1689 $$=mk_elem($2, TOIP_O, 0, NET_ST, mk_net_bitlen(ip_tmp, ip_tmp->len*8) );
1691 $$=mk_elem($2, TOIP_O, 0, STRING_ST, $3);
1695 onsend_check("to_ip");
1696 $$=mk_elem($2, TOIP_O, 0, STRING_ST, $3);
1698 | TOIP equalop attr_id_val {
1699 onsend_check("to_ip");
1700 $$=mk_elem($2, TOIP_O, 0, AVP_ST, (void*)$3 );
1702 | TOIP equalop MYSELF {
1703 onsend_check("to_ip");
1704 $$=mk_elem($2, TOIP_O, 0, MYSELF_ST, 0);
1706 | TOIP strop error { $$=0; yyerror( "ip address or hostname expected" ); }
1707 | TOIP error { $$=0; yyerror("invalid operator, ==, != or =~ expected"); }
1709 | MYSELF equalop uri_type { $$=mk_elem($2, $3, 0, MYSELF_ST, 0); }
1710 | MYSELF equalop SRCIP { $$=mk_elem($2, SRCIP_O, 0, MYSELF_ST, 0); }
1711 | MYSELF equalop DSTIP { $$=mk_elem($2, DSTIP_O, 0, MYSELF_ST, 0); }
1712 | MYSELF equalop SNDIP {
1713 onsend_check("snd_ip");
1714 $$=mk_elem($2, SNDIP_O, 0, MYSELF_ST, 0);
1716 | MYSELF equalop TOIP {
1717 onsend_check("to_ip");
1718 $$=mk_elem($2, TOIP_O, 0, MYSELF_ST, 0);
1720 | MYSELF equalop error { $$=0; yyerror(" URI, SRCIP or DSTIP expected"); }
1721 | MYSELF error { $$=0; yyerror ("invalid operator, == or != expected"); }
1722 | exp_stm { $$=mk_elem( NO_OP, ACTION_O, 0, ACTIONS_ST, $1); }
1723 | NUMBER { $$=mk_elem( NO_OP, NUMBER_O, 0, NUMBER_ST, (void*)$1 ); }
1725 | attr_id_any {$$=mk_elem( NO_OP, AVP_O, (void*)$1, 0, 0); }
1726 | attr_id_val strop STRING {$$=mk_elem( $2, AVP_O, (void*)$1, STRING_ST, $3); }
1727 | attr_id_val strop select_id {$$=mk_elem( $2, AVP_O, (void*)$1, SELECT_ST, $3); }
1728 | attr_id_val intop NUMBER {$$=mk_elem( $2, AVP_O, (void*)$1, NUMBER_ST, (void*)$3); }
1729 | attr_id_val binop NUMBER {$$=mk_elem( $2, AVP_O, (void*)$1, NUMBER_ST, (void*)$3); }
1730 | attr_id_val strop attr_id_val {$$=mk_elem( $2, AVP_O, (void*)$1, AVP_ST, (void*)$3); }
1731 | attr_id_val intop attr_id_val {$$=mk_elem( $2, AVP_O, (void*)$1, AVP_ST, (void*)$3); }
1733 | select_id { $$=mk_elem( NO_OP, SELECT_O, $1, 0, 0); }
1734 | select_id strop STRING { $$=mk_elem( $2, SELECT_O, $1, STRING_ST, $3); }
1735 | select_id strop attr_id_val { $$=mk_elem( $2, SELECT_O, $1, AVP_ST, (void*)$3); }
1736 | select_id strop select_id { $$=mk_elem( $2, SELECT_O, $1, SELECT_ST, $3); }
1739 ip SLASH ip { $$=mk_net($1, $3); }
1741 if (($3<0) || ($3>$1->len*8)) {
1742 yyerror("invalid bit number in netmask");
1745 $$=mk_net_bitlen($1, $3);
1747 $$=mk_net($1, htonl( ($3)?~( (1<<(32-$3))-1 ):0 ) );
1751 | ip { $$=mk_net_bitlen($1, $1->len*8); }
1752 | ip SLASH error { $$=0; yyerror("netmask (eg:255.0.0.0 or 8) expected"); }
1761 | host host_sep ID {
1762 $$=(char*)pkg_malloc(strlen($1)+1+strlen($3)+1);
1764 LOG(L_CRIT, "ERROR: cfg. parser: memory allocation failure while parsing host\n");
1766 memcpy($$, $1, strlen($1));
1768 memcpy($$+strlen($1)+1, $3, strlen($3));
1769 $$[strlen($1)+1+strlen($3)]=0;
1774 | host DOT error { $$=0; pkg_free($1); yyerror("invalid hostname"); }
1779 /* check if allowed */
1780 if ($1 && rt==ONSEND_ROUTE) {
1795 yyerror("command not allowed in onsend_route\n");
1805 | assign_action { $$ = $1; }
1806 | LBRACE actions RBRACE { $$=$2; }
1810 | LBRACE actions RBRACE { $$=$2; }
1813 actions action {$$=append_action($1, $2); }
1815 | actions error { $$=0; yyerror("bad command"); }
1818 fcmd SEMICOLON {$$=$1;}
1820 | assign_action SEMICOLON {$$=$1;}
1821 | SEMICOLON /* null action */ {$$=0;}
1822 | fcmd error { $$=0; yyerror("bad command: missing ';'?"); }
1825 IF exp stm { $$=mk_action( IF_T, 3, EXPR_ST, $2, ACTIONS_ST, $3, NOSUBTYPE, 0); }
1826 | IF exp stm ELSE stm { $$=mk_action( IF_T, 3, EXPR_ST, $2, ACTIONS_ST, $3, ACTIONS_ST, $5); }
1829 LBRACK ATTR_USER RBRACK { $$ = AVP_CLASS_USER; }
1830 | LBRACK ATTR_DOMAIN RBRACK { $$ = AVP_CLASS_DOMAIN; }
1831 | LBRACK ATTR_GLOBAL RBRACK { $$ = AVP_CLASS_GLOBAL; }
1836 if (sel.n >= MAX_SELECT_PARAMS-1) {
1837 yyerror("Select identifier too long\n");
1839 sel.params[sel.n].type = SEL_PARAM_STR;
1840 sel.params[sel.n].v.s.s = $1;
1841 sel.params[sel.n].v.s.len = strlen($1);
1844 | ID LBRACK NUMBER RBRACK {
1845 if (sel.n >= MAX_SELECT_PARAMS-2) {
1846 yyerror("Select identifier too long\n");
1848 sel.params[sel.n].type = SEL_PARAM_STR;
1849 sel.params[sel.n].v.s.s = $1;
1850 sel.params[sel.n].v.s.len = strlen($1);
1852 sel.params[sel.n].type = SEL_PARAM_INT;
1853 sel.params[sel.n].v.i = $3;
1856 | ID LBRACK STRING RBRACK {
1857 if (sel.n >= MAX_SELECT_PARAMS-2) {
1858 yyerror("Select identifier too long\n");
1860 sel.params[sel.n].type = SEL_PARAM_STR;
1861 sel.params[sel.n].v.s.s = $1;
1862 sel.params[sel.n].v.s.len = strlen($1);
1864 sel.params[sel.n].type = SEL_PARAM_STR;
1865 sel.params[sel.n].v.s.s = $3;
1866 sel.params[sel.n].v.s.len = strlen($3);
1871 select_params DOT select_param
1875 SELECT_MARK { sel.n = 0; sel.f[0] = 0; } select_params {
1876 sel_ptr = (select_t*)pkg_malloc(sizeof(select_t));
1878 yyerror("No memory left to allocate select structure\n");
1880 memcpy(sel_ptr, &sel, sizeof(select_t));
1885 ATTR_FROM { s_attr->type |= AVP_TRACK_FROM; }
1886 | ATTR_TO { s_attr->type |= AVP_TRACK_TO; }
1887 | ATTR_FROMURI { s_attr->type |= AVP_TRACK_FROM | AVP_CLASS_URI; }
1888 | ATTR_TOURI { s_attr->type |= AVP_TRACK_TO | AVP_CLASS_URI; }
1889 | ATTR_FROMUSER { s_attr->type |= AVP_TRACK_FROM | AVP_CLASS_USER; }
1890 | ATTR_TOUSER { s_attr->type |= AVP_TRACK_TO | AVP_CLASS_USER; }
1891 | ATTR_FROMDOMAIN { s_attr->type |= AVP_TRACK_FROM | AVP_CLASS_DOMAIN; }
1892 | ATTR_TODOMAIN { s_attr->type |= AVP_TRACK_TO | AVP_CLASS_DOMAIN; }
1893 | ATTR_GLOBAL { s_attr->type |= AVP_TRACK_ALL | AVP_CLASS_GLOBAL; }
1896 ID { s_attr->type |= AVP_NAME_STR; s_attr->name.s.s = $1; s_attr->name.s.len = strlen ($1); }
1900 | attr_class_spec DOT attr_name_spec
1904 s_attr = (struct avp_spec*)pkg_malloc(sizeof(struct avp_spec));
1905 if (!s_attr) { yyerror("No memory left"); }
1910 attr_mark attr_spec { $$ = s_attr; }
1913 attr_mark attr_spec LBRACK NUMBER RBRACK {
1914 s_attr->type|= (AVP_NAME_STR | ($4<0?AVP_INDEX_BACKWARD:AVP_INDEX_FORWARD));
1915 s_attr->index = ($4<0?-$4:$4);
1920 attr_mark attr_spec LBRACK RBRACK {
1921 s_attr->type|= AVP_INDEX_ALL;
1941 avp_spec_t *avp_spec;
1944 avp_spec = pkg_malloc(sizeof(*avp_spec));
1946 yyerror("Not enough memory");
1952 s.len = strlen(s.s);
1953 if (parse_avp_name(&s, &type, &avp_spec->name, &idx)) {
1954 yyerror("error when parsing AVP");
1958 avp_spec->type = type;
1959 avp_spec->index = idx;
1965 ADDEQ { $$ = ADD_T; }
1966 | EQUAL { $$ = ASSIGN_T; }
1970 EQUAL { $$ = ASSIGN_T; }
1973 attr_id_ass assign_op STRING { $$=mk_action($2, 2, AVP_ST, $1, STRING_ST, $3); }
1974 | attr_id_ass assign_op NUMBER { $$=mk_action($2, 2, AVP_ST, $1, NUMBER_ST, (void*)$3); }
1975 | attr_id_ass assign_op fcmd { $$=mk_action($2, 2, AVP_ST, $1, ACTION_ST, $3); }
1976 | attr_id_ass assign_op attr_id_any { $$=mk_action($2, 2, AVP_ST, $1, AVP_ST, $3); }
1977 | attr_id_ass assign_op select_id { $$=mk_action($2, 2, AVP_ST, (void*)$1, SELECT_ST, (void*)$3); }
1978 | attr_id_ass assign_op LPAREN exp RPAREN { $$ = mk_action($2, 2, AVP_ST, $1, EXPR_ST, $4); }
1981 SETAVPFLAG { $$ = 1; }
1982 | RESETAVPFLAG { $$ = 0; }
1983 | ISAVPFLAGSET { $$ = -1; }
1986 FORWARD LPAREN host RPAREN { $$=mk_action( FORWARD_T, 2, STRING_ST, $3, NUMBER_ST, 0); }
1987 | FORWARD LPAREN STRING RPAREN { $$=mk_action( FORWARD_T, 2, STRING_ST, $3, NUMBER_ST, 0); }
1988 | FORWARD LPAREN ip RPAREN { $$=mk_action( FORWARD_T, 2, IP_ST, (void*)$3, NUMBER_ST, 0); }
1989 | FORWARD LPAREN host COMMA NUMBER RPAREN { $$=mk_action(FORWARD_T, 2, STRING_ST, $3, NUMBER_ST, (void*)$5); }
1990 | FORWARD LPAREN STRING COMMA NUMBER RPAREN {$$=mk_action(FORWARD_T, 2, STRING_ST, $3, NUMBER_ST, (void*)$5); }
1991 | FORWARD LPAREN ip COMMA NUMBER RPAREN { $$=mk_action(FORWARD_T, 2, IP_ST, (void*)$3, NUMBER_ST, (void*)$5); }
1992 | FORWARD LPAREN URIHOST COMMA URIPORT RPAREN { $$=mk_action(FORWARD_T, 2, URIHOST_ST, 0, URIPORT_ST, 0); }
1993 | FORWARD LPAREN URIHOST COMMA NUMBER RPAREN {$$=mk_action(FORWARD_T, 2, URIHOST_ST, 0, NUMBER_ST, (void*)$5); }
1994 | FORWARD LPAREN URIHOST RPAREN { $$=mk_action(FORWARD_T, 2, URIHOST_ST, 0, NUMBER_ST, 0); }
1995 | FORWARD error { $$=0; yyerror("missing '(' or ')' ?"); }
1996 | FORWARD LPAREN error RPAREN { $$=0; yyerror("bad forward argument"); }
1997 | FORWARD_UDP LPAREN host RPAREN { $$=mk_action(FORWARD_UDP_T, 2, STRING_ST, $3, NUMBER_ST, 0); }
1998 | FORWARD_UDP LPAREN STRING RPAREN { $$=mk_action(FORWARD_UDP_T, 2, STRING_ST, $3, NUMBER_ST, 0); }
1999 | FORWARD_UDP LPAREN ip RPAREN { $$=mk_action(FORWARD_UDP_T, 2, IP_ST, (void*)$3, NUMBER_ST, 0); }
2000 | FORWARD_UDP LPAREN host COMMA NUMBER RPAREN { $$=mk_action(FORWARD_UDP_T, 2, STRING_ST, $3, NUMBER_ST, (void*)$5); }
2001 | FORWARD_UDP LPAREN STRING COMMA NUMBER RPAREN {$$=mk_action(FORWARD_UDP_T, 2, STRING_ST, $3, NUMBER_ST, (void*)$5); }
2002 | FORWARD_UDP LPAREN ip COMMA NUMBER RPAREN { $$=mk_action(FORWARD_UDP_T, 2, IP_ST, (void*)$3, NUMBER_ST, (void*)$5); }
2003 | FORWARD_UDP LPAREN URIHOST COMMA URIPORT RPAREN {$$=mk_action(FORWARD_UDP_T, 2, URIHOST_ST, 0, URIPORT_ST, 0); }
2004 | FORWARD_UDP LPAREN URIHOST COMMA NUMBER RPAREN { $$=mk_action(FORWARD_UDP_T, 2, URIHOST_ST, 0, NUMBER_ST, (void*)$5); }
2005 | FORWARD_UDP LPAREN URIHOST RPAREN { $$=mk_action(FORWARD_UDP_T, 2, URIHOST_ST, 0, NUMBER_ST, 0); }
2006 | FORWARD_UDP error { $$=0; yyerror("missing '(' or ')' ?"); }
2007 | FORWARD_UDP LPAREN error RPAREN { $$=0; yyerror("bad forward_udp argument"); }
2008 | FORWARD_TCP LPAREN host RPAREN { $$=mk_action(FORWARD_TCP_T, 2, STRING_ST, $3, NUMBER_ST, 0); }
2009 | FORWARD_TCP LPAREN STRING RPAREN { $$=mk_action(FORWARD_TCP_T, 2, STRING_ST, $3, NUMBER_ST, 0); }
2010 | FORWARD_TCP LPAREN ip RPAREN { $$=mk_action(FORWARD_TCP_T, 2, IP_ST, (void*)$3, NUMBER_ST, 0); }
2011 | FORWARD_TCP LPAREN host COMMA NUMBER RPAREN { $$=mk_action(FORWARD_TCP_T, 2, STRING_ST, $3, NUMBER_ST, (void*)$5); }
2012 | FORWARD_TCP LPAREN STRING COMMA NUMBER RPAREN {$$=mk_action(FORWARD_TCP_T, 2, STRING_ST, $3, NUMBER_ST, (void*)$5); }
2013 | FORWARD_TCP LPAREN ip COMMA NUMBER RPAREN { $$=mk_action(FORWARD_TCP_T, 2, IP_ST, (void*)$3, NUMBER_ST, (void*)$5); }
2014 | FORWARD_TCP LPAREN URIHOST COMMA URIPORT RPAREN {$$=mk_action(FORWARD_TCP_T, 2, URIHOST_ST, 0, URIPORT_ST, 0); }
2015 | FORWARD_TCP LPAREN URIHOST COMMA NUMBER RPAREN { $$=mk_action(FORWARD_TCP_T, 2, URIHOST_ST, 0, NUMBER_ST, (void*)$5); }
2016 | FORWARD_TCP LPAREN URIHOST RPAREN { $$=mk_action(FORWARD_TCP_T, 2, URIHOST_ST, 0, NUMBER_ST, 0); }
2017 | FORWARD_TCP error { $$=0; yyerror("missing '(' or ')' ?"); }
2018 | FORWARD_TCP LPAREN error RPAREN { $$=0; yyerror("bad forward_tcp argument"); }
2019 | FORWARD_TLS LPAREN host RPAREN {
2021 $$=mk_action(FORWARD_TLS_T, 2, STRING_ST, $3, NUMBER_ST, 0);
2024 yyerror("tls support not compiled in");
2027 | FORWARD_TLS LPAREN STRING RPAREN {
2029 $$=mk_action(FORWARD_TLS_T, 2, STRING_ST, $3, NUMBER_ST, 0);
2032 yyerror("tls support not compiled in");
2035 | FORWARD_TLS LPAREN ip RPAREN {
2037 $$=mk_action(FORWARD_TLS_T, 2, IP_ST, (void*)$3, NUMBER_ST, 0);
2040 yyerror("tls support not compiled in");
2043 | FORWARD_TLS LPAREN host COMMA NUMBER RPAREN {
2045 $$=mk_action(FORWARD_TLS_T, 2, STRING_ST, $3, NUMBER_ST, (void*)$5);
2048 yyerror("tls support not compiled in");
2051 | FORWARD_TLS LPAREN STRING COMMA NUMBER RPAREN {
2053 $$=mk_action(FORWARD_TLS_T, 2, STRING_ST, $3, NUMBER_ST, (void*)$5);
2056 yyerror("tls support not compiled in");
2059 | FORWARD_TLS LPAREN ip COMMA NUMBER RPAREN {
2061 $$=mk_action(FORWARD_TLS_T, 2, IP_ST, (void*)$3, NUMBER_ST, (void*)$5);
2064 yyerror("tls support not compiled in");
2067 | FORWARD_TLS LPAREN URIHOST COMMA URIPORT RPAREN {
2069 $$=mk_action(FORWARD_TLS_T, 2, URIHOST_ST, 0, URIPORT_ST, 0);
2072 yyerror("tls support not compiled in");
2075 | FORWARD_TLS LPAREN URIHOST COMMA NUMBER RPAREN {
2077 $$=mk_action(FORWARD_TLS_T, 2, URIHOST_ST, 0, NUMBER_ST, (void*)$5);
2080 yyerror("tls support not compiled in");
2083 | FORWARD_TLS LPAREN URIHOST RPAREN {
2085 $$=mk_action(FORWARD_TLS_T, 2, URIHOST_ST, 0, NUMBER_ST, 0);
2088 yyerror("tls support not compiled in");
2091 | FORWARD_TLS error { $$=0; yyerror("missing '(' or ')' ?"); }
2092 | FORWARD_TLS LPAREN error RPAREN { $$=0;
2093 yyerror("bad forward_tls argument"); }
2094 | FORWARD_SCTP LPAREN host RPAREN {
2096 $$=mk_action(FORWARD_SCTP_T, 2, STRING_ST, $3, NUMBER_ST, 0);
2099 yyerror("sctp support not compiled in");
2102 | FORWARD_SCTP LPAREN STRING RPAREN {
2104 $$=mk_action(FORWARD_SCTP_T, 2, STRING_ST, $3, NUMBER_ST, 0);
2107 yyerror("sctp support not compiled in");
2110 | FORWARD_SCTP LPAREN ip RPAREN {
2112 $$=mk_action(FORWARD_SCTP_T, 2, IP_ST, (void*)$3, NUMBER_ST, 0);
2115 yyerror("sctp support not compiled in");
2118 | FORWARD_SCTP LPAREN host COMMA NUMBER RPAREN {
2120 $$=mk_action(FORWARD_SCTP_T, 2, STRING_ST, $3, NUMBER_ST,
2124 yyerror("sctp support not compiled in");
2127 | FORWARD_SCTP LPAREN STRING COMMA NUMBER RPAREN {
2129 $$=mk_action(FORWARD_SCTP_T, 2, STRING_ST, $3, NUMBER_ST,
2133 yyerror("sctp support not compiled in");
2136 | FORWARD_SCTP LPAREN ip COMMA NUMBER RPAREN {
2138 $$=mk_action(FORWARD_SCTP_T, 2, IP_ST, (void*)$3, NUMBER_ST,
2142 yyerror("sctp support not compiled in");
2145 | FORWARD_SCTP LPAREN URIHOST COMMA URIPORT RPAREN {
2147 $$=mk_action(FORWARD_SCTP_T, 2, URIHOST_ST, 0, URIPORT_ST, 0);
2150 yyerror("sctp support not compiled in");
2153 | FORWARD_SCTP LPAREN URIHOST COMMA NUMBER RPAREN {
2155 $$=mk_action(FORWARD_SCTP_T, 2, URIHOST_ST, 0, NUMBER_ST,
2159 yyerror("sctp support not compiled in");
2162 | FORWARD_SCTP LPAREN URIHOST RPAREN {
2164 $$=mk_action(FORWARD_SCTP_T, 2, URIHOST_ST, 0, NUMBER_ST, 0);
2167 yyerror("tls support not compiled in");
2170 | FORWARD_SCTP error { $$=0; yyerror("missing '(' or ')' ?"); }
2171 | FORWARD_SCTP LPAREN error RPAREN { $$=0;
2172 yyerror("bad forward_tls argument"); }
2173 | SEND LPAREN host RPAREN { $$=mk_action(SEND_T, 2, STRING_ST, $3, NUMBER_ST, 0); }
2174 | SEND LPAREN STRING RPAREN { $$=mk_action(SEND_T, 2, STRING_ST, $3, NUMBER_ST, 0); }
2175 | SEND LPAREN ip RPAREN { $$=mk_action(SEND_T, 2, IP_ST, (void*)$3, NUMBER_ST, 0); }
2176 | SEND LPAREN host COMMA NUMBER RPAREN { $$=mk_action(SEND_T, 2, STRING_ST, $3, NUMBER_ST, (void*)$5); }
2177 | SEND LPAREN STRING COMMA NUMBER RPAREN {$$=mk_action(SEND_T, 2, STRING_ST, $3, NUMBER_ST, (void*)$5); }
2178 | SEND LPAREN ip COMMA NUMBER RPAREN { $$=mk_action(SEND_T, 2, IP_ST, (void*)$3, NUMBER_ST, (void*)$5); }
2179 | SEND error { $$=0; yyerror("missing '(' or ')' ?"); }
2180 | SEND LPAREN error RPAREN { $$=0; yyerror("bad send argument"); }
2181 | SEND_TCP LPAREN host RPAREN { $$=mk_action(SEND_TCP_T, 2, STRING_ST, $3, NUMBER_ST, 0); }
2182 | SEND_TCP LPAREN STRING RPAREN { $$=mk_action(SEND_TCP_T, 2, STRING_ST, $3, NUMBER_ST, 0); }
2183 | SEND_TCP LPAREN ip RPAREN { $$=mk_action(SEND_TCP_T, 2, IP_ST, (void*)$3, NUMBER_ST, 0); }
2184 | SEND_TCP LPAREN host COMMA NUMBER RPAREN { $$=mk_action( SEND_TCP_T, 2, STRING_ST, $3, NUMBER_ST, (void*)$5);}
2185 | SEND_TCP LPAREN STRING COMMA NUMBER RPAREN {$$=mk_action(SEND_TCP_T, 2, STRING_ST, $3, NUMBER_ST, (void*)$5); }
2186 | SEND_TCP LPAREN ip COMMA NUMBER RPAREN { $$=mk_action(SEND_TCP_T, 2, IP_ST, (void*)$3, NUMBER_ST, (void*)$5); }
2187 | SEND_TCP error { $$=0; yyerror("missing '(' or ')' ?"); }
2188 | SEND_TCP LPAREN error RPAREN { $$=0; yyerror("bad send_tcp argument"); }
2189 | DROP LPAREN RPAREN {$$=mk_action(DROP_T, 2, NUMBER_ST, 0, NUMBER_ST, (void*)EXIT_R_F); }
2190 | DROP LPAREN NUMBER RPAREN {$$=mk_action(DROP_T, 2, NUMBER_ST, (void*)$3, NUMBER_ST, (void*)EXIT_R_F); }
2191 | DROP NUMBER {$$=mk_action(DROP_T, 2, NUMBER_ST, (void*)$2, NUMBER_ST, (void*)EXIT_R_F); }
2192 | DROP RETCODE {$$=mk_action(DROP_T, 2, RETCODE_ST, 0, NUMBER_ST, (void*)EXIT_R_F); }
2193 | DROP {$$=mk_action(DROP_T, 2, NUMBER_ST, 0, NUMBER_ST, (void*)EXIT_R_F); }
2194 | RETURN {$$=mk_action(DROP_T, 2, NUMBER_ST, (void*)1, NUMBER_ST, (void*)RETURN_R_F); }
2195 | RETURN NUMBER {$$=mk_action(DROP_T, 2, NUMBER_ST, (void*)$2, NUMBER_ST, (void*)RETURN_R_F);}
2196 | RETURN RETCODE {$$=mk_action(DROP_T, 2, RETCODE_ST, 0, NUMBER_ST, (void*)RETURN_R_F);}
2197 | BREAK {$$=mk_action(DROP_T, 2, NUMBER_ST, 0, NUMBER_ST, (void*)RETURN_R_F); }
2198 | LOG_TOK LPAREN STRING RPAREN {$$=mk_action(LOG_T, 2, NUMBER_ST, (void*)4, STRING_ST, $3); }
2199 | LOG_TOK LPAREN NUMBER COMMA STRING RPAREN {$$=mk_action(LOG_T, 2, NUMBER_ST, (void*)$3, STRING_ST, $5); }
2200 | LOG_TOK error { $$=0; yyerror("missing '(' or ')' ?"); }
2201 | LOG_TOK LPAREN error RPAREN { $$=0; yyerror("bad log argument"); }
2202 | SETFLAG LPAREN NUMBER RPAREN {
2203 if (check_flag($3)==-1)
2204 yyerror("bad flag value");
2205 $$=mk_action(SETFLAG_T, 1, NUMBER_ST,
2208 | SETFLAG LPAREN flag_name RPAREN {
2209 i_tmp=get_flag_no($3, strlen($3));
2210 if (i_tmp<0) yyerror("flag not declared");
2211 $$=mk_action(SETFLAG_T, 1, NUMBER_ST,
2212 (void*)(long)i_tmp);
2214 | SETFLAG error { $$=0; yyerror("missing '(' or ')'?"); }
2215 | RESETFLAG LPAREN NUMBER RPAREN {
2216 if (check_flag($3)==-1)
2217 yyerror("bad flag value");
2218 $$=mk_action(RESETFLAG_T, 1, NUMBER_ST, (void*)$3);
2220 | RESETFLAG LPAREN flag_name RPAREN {
2221 i_tmp=get_flag_no($3, strlen($3));
2222 if (i_tmp<0) yyerror("flag not declared");
2223 $$=mk_action(RESETFLAG_T, 1, NUMBER_ST,
2224 (void*)(long)i_tmp);
2226 | RESETFLAG error { $$=0; yyerror("missing '(' or ')'?"); }
2227 | ISFLAGSET LPAREN NUMBER RPAREN {
2228 if (check_flag($3)==-1)
2229 yyerror("bad flag value");
2230 $$=mk_action(ISFLAGSET_T, 1, NUMBER_ST, (void*)$3);
2232 | ISFLAGSET LPAREN flag_name RPAREN {
2233 i_tmp=get_flag_no($3, strlen($3));
2234 if (i_tmp<0) yyerror("flag not declared");
2235 $$=mk_action(ISFLAGSET_T, 1, NUMBER_ST,
2236 (void*)(long)i_tmp);
2238 | ISFLAGSET error { $$=0; yyerror("missing '(' or ')'?"); }
2239 | avpflag_oper LPAREN attr_id_any_str COMMA flag_name RPAREN {
2240 i_tmp=get_avpflag_no($5);
2241 if (i_tmp==0) yyerror("avpflag not declared");
2242 $$=mk_action(AVPFLAG_OPER_T, 3, AVP_ST, $3, NUMBER_ST, (void*)(long)i_tmp, NUMBER_ST, (void*)$1);
2244 | avpflag_oper error { $$=0; yyerror("missing '(' or ')'?"); }
2245 | ERROR LPAREN STRING COMMA STRING RPAREN {$$=mk_action(ERROR_T, 2, STRING_ST, $3, STRING_ST, $5); }
2246 | ERROR error { $$=0; yyerror("missing '(' or ')' ?"); }
2247 | ERROR LPAREN error RPAREN { $$=0; yyerror("bad error argument"); }
2248 | ROUTE LPAREN route_name RPAREN {
2249 i_tmp=route_get(&main_rt, $3);
2251 yyerror("internal error");
2254 $$=mk_action(ROUTE_T, 1, NUMBER_ST,(void*)(long)i_tmp);
2256 | ROUTE error { $$=0; yyerror("missing '(' or ')' ?"); }
2257 | ROUTE LPAREN error RPAREN { $$=0; yyerror("bad route argument"); }
2258 | EXEC LPAREN STRING RPAREN { $$=mk_action(EXEC_T, 1, STRING_ST, $3); }
2259 | SET_HOST LPAREN STRING RPAREN { $$=mk_action(SET_HOST_T, 1, STRING_ST, $3); }
2260 | SET_HOST error { $$=0; yyerror("missing '(' or ')' ?"); }
2261 | SET_HOST LPAREN error RPAREN { $$=0; yyerror("bad argument, string expected"); }
2262 | PREFIX LPAREN STRING RPAREN { $$=mk_action(PREFIX_T, 1, STRING_ST, $3); }
2263 | PREFIX error { $$=0; yyerror("missing '(' or ')' ?"); }
2264 | PREFIX LPAREN error RPAREN { $$=0; yyerror("bad argument, string expected"); }
2265 | STRIP_TAIL LPAREN NUMBER RPAREN { $$=mk_action(STRIP_TAIL_T, 1, NUMBER_ST, (void*)$3); }
2266 | STRIP_TAIL error { $$=0; yyerror("missing '(' or ')' ?"); }
2267 | STRIP_TAIL LPAREN error RPAREN { $$=0; yyerror("bad argument, number expected"); }
2268 | STRIP LPAREN NUMBER RPAREN { $$=mk_action(STRIP_T, 1, NUMBER_ST, (void*) $3); }
2269 | STRIP error { $$=0; yyerror("missing '(' or ')' ?"); }
2270 | STRIP LPAREN error RPAREN { $$=0; yyerror("bad argument, number expected"); }
2271 | APPEND_BRANCH LPAREN STRING COMMA STRING RPAREN {
2273 if (str2q(&q, $5, strlen($5)) < 0) {
2274 yyerror("bad argument, q value expected");
2276 $$=mk_action(APPEND_BRANCH_T, 2, STRING_ST, $3, NUMBER_ST, (void *)(long)q);
2278 | APPEND_BRANCH LPAREN STRING RPAREN { $$=mk_action(APPEND_BRANCH_T, 2, STRING_ST, $3, NUMBER_ST, (void *)Q_UNSPECIFIED); }
2279 | APPEND_BRANCH LPAREN RPAREN { $$=mk_action(APPEND_BRANCH_T, 2, STRING_ST, 0, NUMBER_ST, (void *)Q_UNSPECIFIED); }
2280 | APPEND_BRANCH { $$=mk_action( APPEND_BRANCH_T, 1, STRING_ST, 0); }
2281 | SET_HOSTPORT LPAREN STRING RPAREN { $$=mk_action(SET_HOSTPORT_T, 1, STRING_ST, $3); }
2282 | SET_HOSTPORT error { $$=0; yyerror("missing '(' or ')' ?"); }
2283 | SET_HOSTPORT LPAREN error RPAREN { $$=0; yyerror("bad argument, string expected"); }
2284 | SET_HOSTPORTTRANS LPAREN STRING RPAREN { $$=mk_action(SET_HOSTPORTTRANS_T, 1, STRING_ST, $3); }
2285 | SET_HOSTPORTTRANS error { $$=0; yyerror("missing '(' or ')' ?"); }
2286 | SET_HOSTPORTTRANS LPAREN error RPAREN { $$=0; yyerror("bad argument, string expected"); }
2287 | SET_PORT LPAREN STRING RPAREN { $$=mk_action(SET_PORT_T, 1, STRING_ST, $3); }
2288 | SET_PORT error { $$=0; yyerror("missing '(' or ')' ?"); }
2289 | SET_PORT LPAREN error RPAREN { $$=0; yyerror("bad argument, string expected"); }
2290 | SET_USER LPAREN STRING RPAREN { $$=mk_action(SET_USER_T, 1, STRING_ST, $3); }
2291 | SET_USER error { $$=0; yyerror("missing '(' or ')' ?"); }
2292 | SET_USER LPAREN error RPAREN { $$=0; yyerror("bad argument, string expected"); }
2293 | SET_USERPASS LPAREN STRING RPAREN { $$=mk_action(SET_USERPASS_T, 1, STRING_ST, $3); }
2294 | SET_USERPASS error { $$=0; yyerror("missing '(' or ')' ?"); }
2295 | SET_USERPASS LPAREN error RPAREN { $$=0; yyerror("bad argument, string expected"); }
2296 | SET_URI LPAREN STRING RPAREN { $$=mk_action(SET_URI_T, 1, STRING_ST,$3); }
2297 | SET_URI error { $$=0; yyerror("missing '(' or ')' ?"); }
2298 | SET_URI LPAREN error RPAREN { $$=0; yyerror("bad argument, string expected"); }
2299 | REVERT_URI LPAREN RPAREN { $$=mk_action(REVERT_URI_T, 0); }
2300 | REVERT_URI { $$=mk_action(REVERT_URI_T, 0); }
2301 | FORCE_RPORT LPAREN RPAREN { $$=mk_action(FORCE_RPORT_T, 0); }
2302 | FORCE_RPORT {$$=mk_action(FORCE_RPORT_T, 0); }
2303 | FORCE_TCP_ALIAS LPAREN NUMBER RPAREN {
2305 $$=mk_action(FORCE_TCP_ALIAS_T, 1, NUMBER_ST, (void*)$3);
2307 yyerror("tcp support not compiled in");
2310 | FORCE_TCP_ALIAS LPAREN RPAREN {
2312 $$=mk_action(FORCE_TCP_ALIAS_T, 0);
2314 yyerror("tcp support not compiled in");
2319 $$=mk_action(FORCE_TCP_ALIAS_T, 0);
2321 yyerror("tcp support not compiled in");
2324 | FORCE_TCP_ALIAS LPAREN error RPAREN {$$=0; yyerror("bad argument, number expected"); }
2325 | SET_ADV_ADDRESS LPAREN listen_id RPAREN {
2327 if ((str_tmp=pkg_malloc(sizeof(str)))==0) {
2328 LOG(L_CRIT, "ERROR: cfg. parser: out of memory.\n");
2331 str_tmp->len=strlen($3);
2332 $$=mk_action(SET_ADV_ADDR_T, 1, STR_ST, str_tmp);
2335 | SET_ADV_ADDRESS LPAREN error RPAREN { $$=0; yyerror("bad argument, string expected"); }
2336 | SET_ADV_ADDRESS error {$$=0; yyerror("missing '(' or ')' ?"); }
2337 | SET_ADV_PORT LPAREN NUMBER RPAREN {
2339 tmp=int2str($3, &i_tmp);
2340 if ((str_tmp=pkg_malloc(sizeof(str)))==0) {
2341 LOG(L_CRIT, "ERROR: cfg. parser: out of memory.\n");
2343 if ((str_tmp->s=pkg_malloc(i_tmp))==0) {
2344 LOG(L_CRIT, "ERROR: cfg. parser: out of memory.\n");
2346 memcpy(str_tmp->s, tmp, i_tmp);
2348 $$=mk_action(SET_ADV_PORT_T, 1, STR_ST, str_tmp);
2352 | SET_ADV_PORT LPAREN error RPAREN { $$=0; yyerror("bad argument, string expected"); }
2353 | SET_ADV_PORT error {$$=0; yyerror("missing '(' or ')' ?"); }
2354 | FORCE_SEND_SOCKET LPAREN phostport RPAREN {
2355 $$=mk_action(FORCE_SEND_SOCKET_T, 1, SOCKID_ST, $3);
2357 | FORCE_SEND_SOCKET LPAREN error RPAREN {
2358 $$=0; yyerror("bad argument, [proto:]host[:port] expected");
2360 | FORCE_SEND_SOCKET error {$$=0; yyerror("missing '(' or ')' ?"); }
2361 | ID {mod_func_action = mk_action(MODULE_T, 2, MODEXP_ST, NULL, NUMBER_ST, 0); } LPAREN func_params RPAREN {
2362 mod_func_action->val[0].u.data = find_export_record($1, mod_func_action->val[1].u.number, rt);
2363 if (mod_func_action->val[0].u.data == 0) {
2364 if (find_export_record($1, mod_func_action->val[1].u.number, 0) ) {
2365 yyerror("Command cannot be used in the block\n");
2367 yyerror("unknown command, missing loadmodule?\n");
2369 pkg_free(mod_func_action);
2372 $$ = mod_func_action;
2377 | func_params COMMA func_param { }
2379 | func_params error { yyerror("call params error\n"); YYABORT; }
2383 if (mod_func_action->val[1].u.number < MAX_ACTIONS-2) {
2384 mod_func_action->val[mod_func_action->val[1].u.number+2].type = NUMBER_ST;
2385 mod_func_action->val[mod_func_action->val[1].u.number+2].u.number = $1;
2386 mod_func_action->val[1].u.number++;
2388 yyerror("Too many arguments\n");
2392 if (mod_func_action->val[1].u.number < MAX_ACTIONS-2) {
2393 mod_func_action->val[mod_func_action->val[1].u.number+2].type = STRING_ST;
2394 mod_func_action->val[mod_func_action->val[1].u.number+2].u.string = $1;
2395 mod_func_action->val[1].u.number++;
2397 yyerror("Too many arguments\n");
2405 extern int startcolumn;
2406 static void warn(char* s)
2408 LOG(L_WARN, "cfg. warning: (%d,%d-%d): %s\n", line, startcolumn,
2413 static void yyerror(char* s)
2415 LOG(L_CRIT, "*** PARSE ERROR *** (%d,%d-%d): %s\n", line, startcolumn,
2421 static struct name_lst* mk_name_lst(char* host, int flags)
2424 l=pkg_malloc(sizeof(struct name_lst));
2426 LOG(L_CRIT,"ERROR: cfg. parser: out of memory.\n");
2436 static struct socket_id* mk_listen_id(char* host, int proto, int port)
2438 struct socket_id* l;
2439 l=pkg_malloc(sizeof(struct socket_id));
2441 LOG(L_CRIT,"ERROR: cfg. parser: out of memory.\n");
2443 l->addr_lst=mk_name_lst(host, 0);
2444 if (l->addr_lst==0){
2457 static void free_name_lst(struct name_lst* lst)
2459 struct name_lst* tmp;
2469 static struct socket_id* mk_listen_id2(struct name_lst* addr_l, int proto,
2472 struct socket_id* l;
2473 l=pkg_malloc(sizeof(struct socket_id));
2475 LOG(L_CRIT,"ERROR: cfg. parser: out of memory.\n");
2477 l->flags=addr_l->flags;
2487 static void free_socket_id(struct socket_id* i)
2489 free_name_lst(i->addr_lst);
2494 static void free_socket_id_lst(struct socket_id* lst)
2496 struct socket_id* tmp;
2501 free_socket_id(tmp);
2506 int main(int argc, char ** argv)
2509 fprintf(stderr, "parsing error\n");