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 ADVERTISED_ADDRESS
390 %token ADVERTISED_PORT
393 %token SHM_FORCE_ALLOC
398 %token RT_TIMER1_PRIO
399 %token RT_TIMER1_POLICY
400 %token RT_TIMER2_PRIO
401 %token RT_TIMER2_POLICY
402 %token MCAST_LOOPBACK
405 %token PMTU_DISCOVERY
407 %token CFG_DESCRIPTION
421 %token ATTR_FROMDOMAIN
426 %token STUN_REFRESH_INTERVAL
427 %token STUN_ALLOW_STUN
448 %token <intval> NUMBER
450 %token <strval> STRING
451 %token <strval> IPV6ADDR
470 %type <expr> exp exp_elem /*, condition*/
471 %type <action> action actions cmd fcmd if_cmd stm exp_stm assign_action
472 %type <ipaddr> ipv4 ipv6 ipv6addr ip
475 %type <strval> listen_id
476 %type <name_l> listen_id_lst
477 %type <name_l> listen_id2
478 %type <sockid> id_lst
479 %type <sockid> phostport
480 %type <sockid> listen_phostport
481 %type <intval> proto port
482 %type <intval> equalop strop intop binop
483 %type <strval> host_sep
484 %type <intval> uri_type
486 %type <attr> attr_id_num_idx
487 %type <attr> attr_id_no_idx
488 %type <attr> attr_id_ass
489 %type <attr> attr_id_val
490 %type <attr> attr_id_any
491 %type <attr> attr_id_any_str
492 /* %type <intval> class_id */
493 %type <intval> assign_op
494 %type <select> select_id
495 %type <strval> flag_name;
496 %type <strval> route_name;
497 %type <intval> avpflag_oper
499 /*%type <route_el> rules;
500 %type <route_el> rule;
510 statements statement {}
512 | statements error { yyerror(""); YYABORT;}
519 | {rt=REQUEST_ROUTE;} route_stm
520 | {rt=FAILURE_ROUTE;} failure_route_stm
521 | {rt=ONREPLY_ROUTE;} onreply_route_stm
522 | {rt=BRANCH_ROUTE;} branch_route_stm
523 | {rt=ONSEND_ROUTE;} send_route_stm
524 | SEMICOLON /* null statement */
525 | CR /* null statement*/
531 LOG(L_CRIT, "ERROR: cfg. parser: bad ip "
535 $$=pkg_malloc(strlen(tmp)+1);
537 LOG(L_CRIT, "ERROR: cfg. parser: out of "
540 strncpy($$, tmp, strlen(tmp)+1);
545 $$=pkg_malloc(strlen($1)+1);
547 LOG(L_CRIT, "ERROR: cfg. parser: out of "
550 strncpy($$, $1, strlen($1)+1);
554 $$=pkg_malloc(strlen($1)+1);
556 LOG(L_CRIT, "ERROR: cfg. parser: out of "
559 strncpy($$, $1, strlen($1)+1);
566 listen_id { $$=mk_name_lst($1, SI_IS_MHOMED); }
567 | listen_id COMMA listen_id_lst { $$=mk_name_lst($1, SI_IS_MHOMED);
573 LPAREN listen_id_lst RPAREN { $$=$2; }
574 | listen_id { $$=mk_name_lst($1, 0); }
578 UDP { $$=PROTO_UDP; }
579 | TCP { $$=PROTO_TCP; }
580 | TLS { $$=PROTO_TLS; }
581 | SCTP { $$=PROTO_SCTP; }
589 listen_id { $$=mk_listen_id($1, 0, 0); }
590 | listen_id COLON port { $$=mk_listen_id($1, 0, $3); }
591 | proto COLON listen_id { $$=mk_listen_id($3, $1, 0); }
592 | proto COLON listen_id COLON port { $$=mk_listen_id($3, $1, $5);}
593 | listen_id COLON error { $$=0; yyerror(" port number expected"); }
597 listen_id2 { $$=mk_listen_id2($1, 0, 0); }
598 | listen_id2 COLON port { $$=mk_listen_id2($1, 0, $3); }
599 | proto COLON listen_id2 { $$=mk_listen_id2($3, $1, 0); }
600 | proto COLON listen_id2 COLON port { $$=mk_listen_id2($3, $1, $5);}
601 | listen_id2 COLON error { $$=0; yyerror(" port number expected"); }
605 listen_phostport { $$=$1 ; }
606 | listen_phostport id_lst { $$=$1; $$->next=$2; }
609 flags_decl: FLAGS_DECL flag_list
610 | FLAGS_DECL error { yyerror("flag list expected\n"); }
613 | flag_spec COMMA flag_list
616 flag_spec: flag_name { if (register_flag($1,-1)<0)
617 yyerror("register flag failed");
619 | flag_name COLON NUMBER {
620 if (register_flag($1, $3)<0)
621 yyerror("register flag failed");
625 flag_name: STRING { $$=$1; }
630 AVPFLAGS_DECL avpflag_list
631 | AVPFLAGS_DECL error { yyerror("avpflag list expected\n"); }
635 | avpflag_spec COMMA avpflag_list
639 if (register_avpflag($1)==0)
640 yyerror("cannot declare avpflag");
644 DEBUG_V EQUAL NUMBER { default_core_cfg.debug=$3; }
645 | DEBUG_V EQUAL error { yyerror("number expected"); }
646 | FORK EQUAL NUMBER { dont_fork= ! $3; }
647 | FORK EQUAL error { yyerror("boolean value expected"); }
648 | LOGSTDERROR EQUAL NUMBER { if (!config_check) log_stderr=$3; }
649 | LOGSTDERROR EQUAL error { yyerror("boolean value expected"); }
650 | LOGFACILITY EQUAL ID {
651 if ( (i_tmp=str2facility($3))==-1)
652 yyerror("bad facility (see syslog(3) man page)");
654 default_core_cfg.log_facility=i_tmp;
656 | LOGFACILITY EQUAL error { yyerror("ID expected"); }
657 | DNS EQUAL NUMBER { received_dns|= ($3)?DO_DNS:0; }
658 | DNS EQUAL error { yyerror("boolean value expected"); }
659 | REV_DNS EQUAL NUMBER { received_dns|= ($3)?DO_REV_DNS:0; }
660 | REV_DNS EQUAL error { yyerror("boolean value expected"); }
661 | DNS_TRY_IPV6 EQUAL NUMBER { default_core_cfg.dns_try_ipv6=$3; }
662 | DNS_TRY_IPV6 error { yyerror("boolean value expected"); }
663 | DNS_TRY_NAPTR EQUAL NUMBER { IF_NAPTR(default_core_cfg.dns_try_naptr=$3); }
664 | DNS_TRY_NAPTR error { yyerror("boolean value expected"); }
665 | DNS_SRV_LB EQUAL NUMBER { IF_DNS_FAILOVER(default_core_cfg.dns_srv_lb=$3); }
666 | DNS_SRV_LB error { yyerror("boolean value expected"); }
667 | DNS_UDP_PREF EQUAL NUMBER { IF_NAPTR(default_core_cfg.dns_udp_pref=$3);}
668 | DNS_UDP_PREF error { yyerror("number expected"); }
669 | DNS_TCP_PREF EQUAL NUMBER { IF_NAPTR(default_core_cfg.dns_tcp_pref=$3);}
670 | DNS_TCP_PREF error { yyerror("number expected"); }
671 | DNS_TLS_PREF EQUAL NUMBER { IF_NAPTR(default_core_cfg.dns_tls_pref=$3);}
672 | DNS_TLS_PREF error { yyerror("number expected"); }
673 | DNS_SCTP_PREF EQUAL NUMBER {
674 IF_NAPTR(default_core_cfg.dns_sctp_pref=$3); }
675 | DNS_SCTP_PREF error { yyerror("number expected"); }
676 | DNS_RETR_TIME EQUAL NUMBER { default_core_cfg.dns_retr_time=$3; }
677 | DNS_RETR_TIME error { yyerror("number expected"); }
678 | DNS_RETR_NO EQUAL NUMBER { default_core_cfg.dns_retr_no=$3; }
679 | DNS_RETR_NO error { yyerror("number expected"); }
680 | DNS_SERVERS_NO EQUAL NUMBER { default_core_cfg.dns_servers_no=$3; }
681 | DNS_SERVERS_NO error { yyerror("number expected"); }
682 | DNS_USE_SEARCH EQUAL NUMBER { default_core_cfg.dns_search_list=$3; }
683 | DNS_USE_SEARCH error { yyerror("boolean value expected"); }
684 | DNS_SEARCH_FMATCH EQUAL NUMBER { default_core_cfg.dns_search_fmatch=$3; }
685 | DNS_SEARCH_FMATCH error { yyerror("boolean value expected"); }
686 | DNS_CACHE_INIT EQUAL NUMBER { IF_DNS_CACHE(dns_cache_init=$3); }
687 | DNS_CACHE_INIT error { yyerror("boolean value expected"); }
688 | DNS_USE_CACHE EQUAL NUMBER { IF_DNS_CACHE(default_core_cfg.use_dns_cache=$3); }
689 | DNS_USE_CACHE error { yyerror("boolean value expected"); }
690 | DNS_USE_FAILOVER EQUAL NUMBER { IF_DNS_FAILOVER(default_core_cfg.use_dns_failover=$3);}
691 | DNS_USE_FAILOVER error { yyerror("boolean value expected"); }
692 | DNS_CACHE_FLAGS EQUAL NUMBER { IF_DNS_CACHE(default_core_cfg.dns_cache_flags=$3); }
693 | DNS_CACHE_FLAGS error { yyerror("boolean value expected"); }
694 | DNS_CACHE_NEG_TTL EQUAL NUMBER { IF_DNS_CACHE(default_core_cfg.dns_neg_cache_ttl=$3); }
695 | DNS_CACHE_NEG_TTL error { yyerror("boolean value expected"); }
696 | DNS_CACHE_MAX_TTL EQUAL NUMBER { IF_DNS_CACHE(default_core_cfg.dns_cache_max_ttl=$3); }
697 | DNS_CACHE_MAX_TTL error { yyerror("boolean value expected"); }
698 | DNS_CACHE_MIN_TTL EQUAL NUMBER { IF_DNS_CACHE(default_core_cfg.dns_cache_min_ttl=$3); }
699 | DNS_CACHE_MIN_TTL error { yyerror("boolean value expected"); }
700 | DNS_CACHE_MEM EQUAL NUMBER { IF_DNS_CACHE(default_core_cfg.dns_cache_max_mem=$3); }
701 | DNS_CACHE_MEM error { yyerror("boolean value expected"); }
702 | DNS_CACHE_GC_INT EQUAL NUMBER { IF_DNS_CACHE(dns_timer_interval=$3); }
703 | DNS_CACHE_GC_INT error { yyerror("boolean value expected"); }
704 | DNS_CACHE_DEL_NONEXP EQUAL NUMBER { IF_DNS_CACHE(default_core_cfg.dns_cache_del_nonexp=$3); }
705 | DNS_CACHE_DEL_NONEXP error { yyerror("boolean value expected"); }
706 | DST_BLST_INIT EQUAL NUMBER { IF_DST_BLACKLIST(dst_blacklist_init=$3); }
707 | DST_BLST_INIT error { yyerror("boolean value expected"); }
708 | USE_DST_BLST EQUAL NUMBER { IF_DST_BLACKLIST(default_core_cfg.use_dst_blacklist=$3); }
709 | USE_DST_BLST error { yyerror("boolean value expected"); }
710 | DST_BLST_MEM EQUAL NUMBER { IF_DST_BLACKLIST(default_core_cfg.blst_max_mem=$3); }
711 | DST_BLST_MEM error { yyerror("boolean value expected"); }
712 | DST_BLST_TTL EQUAL NUMBER { IF_DST_BLACKLIST(default_core_cfg.blst_timeout=$3); }
713 | DST_BLST_TTL error { yyerror("boolean value expected"); }
714 | DST_BLST_GC_INT EQUAL NUMBER { IF_DST_BLACKLIST(blst_timer_interval=$3);}
715 | DST_BLST_GC_INT error { yyerror("boolean value expected"); }
716 | PORT EQUAL NUMBER { port_no=$3; }
717 | STAT EQUAL STRING {
722 | MAXBUFFER EQUAL NUMBER { maxbuffer=$3; }
723 | MAXBUFFER EQUAL error { yyerror("number expected"); }
724 | PORT EQUAL error { yyerror("number expected"); }
725 | CHILDREN EQUAL NUMBER { children_no=$3; }
726 | CHILDREN EQUAL error { yyerror("number expected"); }
727 | CHECK_VIA EQUAL NUMBER { check_via=$3; }
728 | CHECK_VIA EQUAL error { yyerror("boolean value expected"); }
729 | PHONE2TEL EQUAL NUMBER { phone2tel=$3; }
730 | PHONE2TEL EQUAL error { yyerror("boolean value expected"); }
731 | SYN_BRANCH EQUAL NUMBER { syn_branch=$3; }
732 | SYN_BRANCH EQUAL error { yyerror("boolean value expected"); }
733 | MEMLOG EQUAL NUMBER { memlog=$3; }
734 | MEMLOG EQUAL error { yyerror("int value expected"); }
735 | MEMDBG EQUAL NUMBER { memdbg=$3; }
736 | MEMDBG EQUAL error { yyerror("int value expected"); }
737 | SIP_WARNING EQUAL NUMBER { sip_warning=$3; }
738 | SIP_WARNING EQUAL error { yyerror("boolean value expected"); }
739 | USER EQUAL STRING { user=$3; }
740 | USER EQUAL ID { user=$3; }
741 | USER EQUAL error { yyerror("string value expected"); }
742 | GROUP EQUAL STRING { group=$3; }
743 | GROUP EQUAL ID { group=$3; }
744 | GROUP EQUAL error { yyerror("string value expected"); }
745 | CHROOT EQUAL STRING { chroot_dir=$3; }
746 | CHROOT EQUAL ID { chroot_dir=$3; }
747 | CHROOT EQUAL error { yyerror("string value expected"); }
748 | WDIR EQUAL STRING { working_dir=$3; }
749 | WDIR EQUAL ID { working_dir=$3; }
750 | WDIR EQUAL error { yyerror("string value expected"); }
751 | MHOMED EQUAL NUMBER { mhomed=$3; }
752 | MHOMED EQUAL error { yyerror("boolean value expected"); }
753 | DISABLE_TCP EQUAL NUMBER {
757 warn("tcp support not compiled in");
760 | DISABLE_TCP EQUAL error { yyerror("boolean value expected"); }
761 | TCP_ACCEPT_ALIASES EQUAL NUMBER {
763 tcp_accept_aliases=$3;
765 warn("tcp support not compiled in");
768 | TCP_ACCEPT_ALIASES EQUAL error { yyerror("boolean value expected"); }
769 | TCP_CHILDREN EQUAL NUMBER {
773 warn("tcp support not compiled in");
776 | TCP_CHILDREN EQUAL error { yyerror("number expected"); }
777 | TCP_CONNECT_TIMEOUT EQUAL NUMBER {
779 tcp_connect_timeout=$3;
781 warn("tcp support not compiled in");
784 | TCP_CONNECT_TIMEOUT EQUAL error { yyerror("number expected"); }
785 | TCP_SEND_TIMEOUT EQUAL NUMBER {
789 warn("tcp support not compiled in");
792 | TCP_SEND_TIMEOUT EQUAL error { yyerror("number expected"); }
793 | TCP_CON_LIFETIME EQUAL NUMBER {
797 warn("tcp support not compiled in");
800 | TCP_CON_LIFETIME EQUAL error { yyerror("number expected"); }
801 | TCP_POLL_METHOD EQUAL ID {
803 tcp_poll_method=get_poll_type($3);
804 if (tcp_poll_method==POLL_NONE) {
805 LOG(L_CRIT, "bad poll method name:"
806 " %s\n, try one of %s.\n",
808 yyerror("bad tcp_poll_method "
812 warn("tcp support not compiled in");
815 | TCP_POLL_METHOD EQUAL STRING {
817 tcp_poll_method=get_poll_type($3);
818 if (tcp_poll_method==POLL_NONE) {
819 LOG(L_CRIT, "bad poll method name:"
820 " %s\n, try one of %s.\n",
822 yyerror("bad tcp_poll_method "
826 warn("tcp support not compiled in");
829 | TCP_POLL_METHOD EQUAL error { yyerror("poll method name expected"); }
830 | TCP_MAX_CONNECTIONS EQUAL NUMBER {
832 tcp_max_connections=$3;
834 warn("tcp support not compiled in");
837 | TCP_MAX_CONNECTIONS EQUAL error { yyerror("number expected"); }
838 | TCP_SOURCE_IPV4 EQUAL ipv4 {
840 if (tcp_set_src_addr($3)<0)
841 warn("tcp_source_ipv4 failed");
843 warn("tcp support not compiled in");
847 | TCP_SOURCE_IPV4 EQUAL error { yyerror("IPv4 address expected"); }
848 | TCP_SOURCE_IPV6 EQUAL ipv6 {
851 if (tcp_set_src_addr($3)<0)
852 warn("tcp_source_ipv6 failed");
854 warn("IPv6 support not compiled in");
857 warn("tcp support not compiled in");
861 | TCP_SOURCE_IPV6 EQUAL error { yyerror("IPv6 address expected"); }
862 | TCP_OPT_FD_CACHE EQUAL NUMBER {
864 tcp_options.fd_cache=$3;
866 warn("tcp support not compiled in");
869 | TCP_OPT_FD_CACHE EQUAL error { yyerror("boolean value expected"); }
870 | TCP_OPT_BUF_WRITE EQUAL NUMBER {
872 tcp_options.tcp_buf_write=$3;
874 warn("tcp support not compiled in");
877 | TCP_OPT_BUF_WRITE EQUAL error { yyerror("boolean value expected"); }
878 | TCP_OPT_CONN_WQ_MAX EQUAL NUMBER {
880 tcp_options.tcpconn_wq_max=$3;
882 warn("tcp support not compiled in");
885 | TCP_OPT_CONN_WQ_MAX error { yyerror("boolean value expected"); }
886 | TCP_OPT_WQ_MAX EQUAL NUMBER {
888 tcp_options.tcp_wq_max=$3;
890 warn("tcp support not compiled in");
893 | TCP_OPT_WQ_MAX error { yyerror("boolean value expected"); }
894 | TCP_OPT_DEFER_ACCEPT EQUAL NUMBER {
896 tcp_options.defer_accept=$3;
898 warn("tcp support not compiled in");
901 | TCP_OPT_DEFER_ACCEPT EQUAL error { yyerror("boolean value expected"); }
902 | TCP_OPT_DELAYED_ACK EQUAL NUMBER {
904 tcp_options.delayed_ack=$3;
906 warn("tcp support not compiled in");
909 | TCP_OPT_DELAYED_ACK EQUAL error { yyerror("boolean value expected"); }
910 | TCP_OPT_SYNCNT EQUAL NUMBER {
912 tcp_options.syncnt=$3;
914 warn("tcp support not compiled in");
917 | TCP_OPT_SYNCNT EQUAL error { yyerror("number expected"); }
918 | TCP_OPT_LINGER2 EQUAL NUMBER {
920 tcp_options.linger2=$3;
922 warn("tcp support not compiled in");
925 | TCP_OPT_LINGER2 EQUAL error { yyerror("number expected"); }
926 | TCP_OPT_KEEPALIVE EQUAL NUMBER {
928 tcp_options.keepalive=$3;
930 warn("tcp support not compiled in");
933 | TCP_OPT_KEEPALIVE EQUAL error { yyerror("boolean value expected");}
934 | TCP_OPT_KEEPIDLE EQUAL NUMBER {
936 tcp_options.keepidle=$3;
938 warn("tcp support not compiled in");
941 | TCP_OPT_KEEPIDLE EQUAL error { yyerror("number expected"); }
942 | TCP_OPT_KEEPINTVL EQUAL NUMBER {
944 tcp_options.keepintvl=$3;
946 warn("tcp support not compiled in");
949 | TCP_OPT_KEEPINTVL EQUAL error { yyerror("number expected"); }
950 | TCP_OPT_KEEPCNT EQUAL NUMBER {
952 tcp_options.keepcnt=$3;
954 warn("tcp support not compiled in");
957 | TCP_OPT_KEEPCNT EQUAL error { yyerror("number expected"); }
958 | TCP_OPT_CRLF_PING EQUAL NUMBER {
960 tcp_options.crlf_ping=$3;
962 warn("tcp support not compiled in");
965 | TCP_OPT_CRLF_PING EQUAL error { yyerror("boolean value expected"); }
966 | DISABLE_TLS EQUAL NUMBER {
970 warn("tls support not compiled in");
973 | DISABLE_TLS EQUAL error { yyerror("boolean value expected"); }
974 | ENABLE_TLS EQUAL NUMBER {
978 warn("tls support not compiled in");
981 | ENABLE_TLS EQUAL error { yyerror("boolean value expected"); }
982 | TLSLOG EQUAL NUMBER {
986 warn("tls-in-core support not compiled in");
989 | TLSLOG EQUAL error { yyerror("int value expected"); }
990 | TLS_PORT_NO EQUAL NUMBER {
994 warn("tls support not compiled in");
997 | TLS_PORT_NO EQUAL error { yyerror("number expected"); }
998 | TLS_METHOD EQUAL SSLv23 {
1000 tls_method=TLS_USE_SSLv23;
1002 warn("tls-in-core support not compiled in");
1005 | TLS_METHOD EQUAL SSLv2 {
1007 tls_method=TLS_USE_SSLv2;
1009 warn("tls-in-core support not compiled in");
1012 | TLS_METHOD EQUAL SSLv3 {
1014 tls_method=TLS_USE_SSLv3;
1016 warn("tls-in-core support not compiled in");
1019 | TLS_METHOD EQUAL TLSv1 {
1021 tls_method=TLS_USE_TLSv1;
1023 warn("tls-in-core support not compiled in");
1026 | TLS_METHOD EQUAL error {
1028 yyerror("SSLv23, SSLv2, SSLv3 or TLSv1 expected");
1030 warn("tls-in-core support not compiled in");
1033 | TLS_VERIFY EQUAL NUMBER {
1037 warn("tls-in-core support not compiled in");
1040 | TLS_VERIFY EQUAL error { yyerror("boolean value expected"); }
1041 | TLS_REQUIRE_CERTIFICATE EQUAL NUMBER {
1043 tls_require_cert=$3;
1045 warn( "tls-in-core support not compiled in");
1048 | TLS_REQUIRE_CERTIFICATE EQUAL error { yyerror("boolean value expected"); }
1049 | TLS_CERTIFICATE EQUAL STRING {
1053 warn("tls-in-core support not compiled in");
1056 | TLS_CERTIFICATE EQUAL error { yyerror("string value expected"); }
1057 | TLS_PRIVATE_KEY EQUAL STRING {
1061 warn("tls-in-core support not compiled in");
1064 | TLS_PRIVATE_KEY EQUAL error { yyerror("string value expected"); }
1065 | TLS_CA_LIST EQUAL STRING {
1069 warn("tls-in-core support not compiled in");
1072 | TLS_CA_LIST EQUAL error { yyerror("string value expected"); }
1073 | TLS_HANDSHAKE_TIMEOUT EQUAL NUMBER {
1075 tls_handshake_timeout=$3;
1077 warn("tls-in-core support not compiled in");
1080 | TLS_HANDSHAKE_TIMEOUT EQUAL error { yyerror("number expected"); }
1081 | TLS_SEND_TIMEOUT EQUAL NUMBER {
1083 tls_send_timeout=$3;
1085 warn("tls-in-core support not compiled in");
1088 | TLS_SEND_TIMEOUT EQUAL error { yyerror("number expected"); }
1089 | DISABLE_SCTP EQUAL NUMBER {
1093 warn("sctp support not compiled in");
1096 | DISABLE_SCTP EQUAL error { yyerror("boolean value expected"); }
1097 | ENABLE_SCTP EQUAL NUMBER {
1099 sctp_disable=($3<=1)?!$3:$3;
1101 warn("sctp support not compiled in");
1104 | ENABLE_SCTP EQUAL error { yyerror("boolean or number expected"); }
1105 | SCTP_CHILDREN EQUAL NUMBER {
1107 sctp_children_no=$3;
1109 warn("sctp support not compiled in");
1112 | SCTP_CHILDREN EQUAL error { yyerror("number expected"); }
1113 | SCTP_SOCKET_RCVBUF EQUAL NUMBER {
1115 sctp_options.sctp_so_rcvbuf=$3;
1117 warn("sctp support not compiled in");
1120 | SCTP_SOCKET_RCVBUF EQUAL error { yyerror("number expected"); }
1121 | SCTP_SOCKET_SNDBUF EQUAL NUMBER {
1123 sctp_options.sctp_so_sndbuf=$3;
1125 warn("sctp support not compiled in");
1128 | SCTP_SOCKET_SNDBUF EQUAL error { yyerror("number expected"); }
1129 | SCTP_AUTOCLOSE EQUAL NUMBER {
1131 sctp_options.sctp_autoclose=$3;
1133 warn("sctp support not compiled in");
1136 | SCTP_AUTOCLOSE EQUAL error { yyerror("number expected"); }
1137 | SCTP_SEND_TTL EQUAL NUMBER {
1139 sctp_options.sctp_send_ttl=$3;
1141 warn("sctp support not compiled in");
1144 | SCTP_SEND_TTL EQUAL error { yyerror("number expected"); }
1145 | SERVER_SIGNATURE EQUAL NUMBER { server_signature=$3; }
1146 | SERVER_SIGNATURE EQUAL error { yyerror("boolean value expected"); }
1147 | REPLY_TO_VIA EQUAL NUMBER { reply_to_via=$3; }
1148 | REPLY_TO_VIA EQUAL error { yyerror("boolean value expected"); }
1149 | LISTEN EQUAL id_lst {
1150 for(lst_tmp=$3; lst_tmp; lst_tmp=lst_tmp->next) {
1151 if (add_listen_iface( lst_tmp->addr_lst->name,
1152 lst_tmp->addr_lst->next,
1153 lst_tmp->port, lst_tmp->proto,
1154 lst_tmp->flags)!=0) {
1155 LOG(L_CRIT, "ERROR: cfg. parser: failed to add listen"
1160 free_socket_id_lst($3);
1162 | LISTEN EQUAL error { yyerror("ip address or hostname expected"); }
1163 | ALIAS EQUAL id_lst {
1164 for(lst_tmp=$3; lst_tmp; lst_tmp=lst_tmp->next){
1165 add_alias( lst_tmp->addr_lst->name,
1166 strlen(lst_tmp->addr_lst->name),
1167 lst_tmp->port, lst_tmp->proto);
1168 for (nl_tmp=lst_tmp->addr_lst->next; nl_tmp; nl_tmp=nl_tmp->next)
1169 add_alias(nl_tmp->name, strlen(nl_tmp->name),
1170 lst_tmp->port, lst_tmp->proto);
1172 free_socket_id_lst($3);
1174 | ALIAS EQUAL error { yyerror(" hostname expected"); }
1175 | ADVERTISED_ADDRESS EQUAL listen_id {
1176 default_global_address.s=$3;
1177 default_global_address.len=strlen($3);
1179 | ADVERTISED_ADDRESS EQUAL error {yyerror("ip address or hostname expected"); }
1180 | ADVERTISED_PORT EQUAL NUMBER {
1181 tmp=int2str($3, &i_tmp);
1182 if ((default_global_port.s=pkg_malloc(i_tmp))==0) {
1183 LOG(L_CRIT, "ERROR: cfg. parser: out of memory.\n");
1184 default_global_port.len=0;
1186 default_global_port.len=i_tmp;
1187 memcpy(default_global_port.s, tmp, default_global_port.len);
1190 |ADVERTISED_PORT EQUAL error {yyerror("ip address or hostname expected"); }
1191 | DISABLE_CORE EQUAL NUMBER { disable_core_dump=$3; }
1192 | DISABLE_CORE EQUAL error { yyerror("boolean value expected"); }
1193 | OPEN_FD_LIMIT EQUAL NUMBER { open_files_limit=$3; }
1194 | OPEN_FD_LIMIT EQUAL error { yyerror("number expected"); }
1195 | SHM_FORCE_ALLOC EQUAL NUMBER { shm_force_alloc=$3; }
1196 | SHM_FORCE_ALLOC EQUAL error { yyerror("boolean value expected"); }
1197 | MLOCK_PAGES EQUAL NUMBER { mlock_pages=$3; }
1198 | MLOCK_PAGES EQUAL error { yyerror("boolean value expected"); }
1199 | REAL_TIME EQUAL NUMBER { real_time=$3; }
1200 | REAL_TIME EQUAL error { yyerror("boolean value expected"); }
1201 | RT_PRIO EQUAL NUMBER { rt_prio=$3; }
1202 | RT_PRIO EQUAL error { yyerror("boolean value expected"); }
1203 | RT_POLICY EQUAL NUMBER { rt_policy=$3; }
1204 | RT_POLICY EQUAL error { yyerror("boolean value expected"); }
1205 | RT_TIMER1_PRIO EQUAL NUMBER { rt_timer1_prio=$3; }
1206 | RT_TIMER1_PRIO EQUAL error { yyerror("boolean value expected"); }
1207 | RT_TIMER1_POLICY EQUAL NUMBER { rt_timer1_policy=$3; }
1208 | RT_TIMER1_POLICY EQUAL error { yyerror("boolean value expected"); }
1209 | RT_TIMER2_PRIO EQUAL NUMBER { rt_timer2_prio=$3; }
1210 | RT_TIMER2_PRIO EQUAL error { yyerror("boolean value expected"); }
1211 | RT_TIMER2_POLICY EQUAL NUMBER { rt_timer2_policy=$3; }
1212 | RT_TIMER2_POLICY EQUAL error { yyerror("boolean value expected"); }
1213 | MCAST_LOOPBACK EQUAL NUMBER {
1217 warn("no multicast support compiled in");
1220 | MCAST_LOOPBACK EQUAL error { yyerror("boolean value expected"); }
1221 | MCAST_TTL EQUAL NUMBER {
1225 warn("no multicast support compiled in");
1228 | MCAST_TTL EQUAL error { yyerror("number expected"); }
1229 | TOS EQUAL NUMBER { tos=$3; }
1230 | TOS EQUAL error { yyerror("number expected"); }
1231 | PMTU_DISCOVERY EQUAL NUMBER { pmtu_discovery=$3; }
1232 | PMTU_DISCOVERY error { yyerror("number expected"); }
1233 | KILL_TIMEOUT EQUAL NUMBER { ser_kill_timeout=$3; }
1234 | KILL_TIMEOUT EQUAL error { yyerror("number expected"); }
1235 | STUN_REFRESH_INTERVAL EQUAL NUMBER { IF_STUN(stun_refresh_interval=$3); }
1236 | STUN_REFRESH_INTERVAL EQUAL error{ yyerror("number expected"); }
1237 | STUN_ALLOW_STUN EQUAL NUMBER { IF_STUN(stun_allow_stun=$3); }
1238 | STUN_ALLOW_STUN EQUAL error{ yyerror("number expected"); }
1239 | STUN_ALLOW_FP EQUAL NUMBER { IF_STUN(stun_allow_fp=$3) ; }
1240 | STUN_ALLOW_FP EQUAL error{ yyerror("number expected"); }
1241 | SERVER_ID EQUAL NUMBER { server_id=$3; }
1243 | error EQUAL { yyerror("unknown config variable"); }
1246 ID DOT ID EQUAL NUMBER {
1247 if (cfg_declare_int($1, $3, $5, 0, 0, NULL)) {
1248 yyerror("variable cannot be declared");
1251 | ID DOT ID EQUAL STRING {
1252 if (cfg_declare_str($1, $3, $5, NULL)) {
1253 yyerror("variable cannot be declared");
1256 | ID DOT ID EQUAL NUMBER CFG_DESCRIPTION STRING {
1257 if (cfg_declare_int($1, $3, $5, 0, 0, $7)) {
1258 yyerror("variable cannot be declared");
1261 | ID DOT ID EQUAL STRING CFG_DESCRIPTION STRING {
1262 if (cfg_declare_str($1, $3, $5, $7)) {
1263 yyerror("variable cannot be declared");
1266 | ID DOT ID EQUAL error { yyerror("number or string expected"); }
1270 DBG("loading module %s\n", $2);
1271 if (load_module($2)!=0) {
1272 yyerror("failed to load module");
1275 | LOADMODULE error { yyerror("string expected"); }
1277 DBG("loading modules under %s\n", $2);
1278 printf("loading modules under %s\n", $2);
1281 | LOADPATH error { yyerror("string expected"); }
1282 | MODPARAM LPAREN STRING COMMA STRING COMMA STRING RPAREN {
1283 if (set_mod_param_regex($3, $5, PARAM_STRING, $7) != 0) {
1284 yyerror("Can't set module parameter");
1287 | MODPARAM LPAREN STRING COMMA STRING COMMA NUMBER RPAREN {
1288 if (set_mod_param_regex($3, $5, PARAM_INT, (void*)$7) != 0) {
1289 yyerror("Can't set module parameter");
1292 | MODPARAM error { yyerror("Invalid arguments"); }
1299 NUMBER DOT NUMBER DOT NUMBER DOT NUMBER {
1300 $$=pkg_malloc(sizeof(struct ip_addr));
1302 LOG(L_CRIT, "ERROR: cfg. parser: out of memory.\n");
1304 memset($$, 0, sizeof(struct ip_addr));
1307 if (($1>255) || ($1<0) ||
1308 ($3>255) || ($3<0) ||
1309 ($5>255) || ($5<0) ||
1310 ($7>255) || ($7<0)) {
1311 yyerror("invalid ipv4 address");
1321 ($3<<16)| ($5<<8)|$7 );
1329 $$=pkg_malloc(sizeof(struct ip_addr));
1331 LOG(L_CRIT, "ERROR: cfg. parser: out of memory.\n");
1334 memset($$, 0, sizeof(struct ip_addr));
1337 if (inet_pton(AF_INET6, $1, $$->u.addr)<=0) {
1338 yyerror("bad ipv6 address");
1341 yyerror("ipv6 address & no ipv6 support compiled in");
1349 | LBRACK ipv6addr RBRACK {$$=$2; }
1353 route_name: NUMBER {
1354 tmp=int2str($1, &i_tmp);
1355 if (($$=pkg_malloc(i_tmp+1))==0) {
1356 yyerror("out of memory");
1359 memcpy($$, tmp, i_tmp);
1368 ROUTE LBRACE actions RBRACE { push($3, &main_rt.rlist[DEFAULT_RT]); }
1369 | ROUTE LBRACK route_name RBRACK LBRACE actions RBRACE {
1370 i_tmp=route_get(&main_rt, $3);
1372 yyerror("internal error");
1375 if (main_rt.rlist[i_tmp]){
1376 yyerror("duplicate route");
1379 push($6, &main_rt.rlist[i_tmp]);
1381 | ROUTE error { yyerror("invalid route statement"); }
1384 ROUTE_FAILURE LBRACE actions RBRACE {
1385 push($3, &failure_rt.rlist[DEFAULT_RT]);
1387 | ROUTE_FAILURE LBRACK route_name RBRACK LBRACE actions RBRACE {
1388 i_tmp=route_get(&failure_rt, $3);
1390 yyerror("internal error");
1393 if (failure_rt.rlist[i_tmp]){
1394 yyerror("duplicate route");
1397 push($6, &failure_rt.rlist[i_tmp]);
1399 | ROUTE_FAILURE error { yyerror("invalid failure_route statement"); }
1402 ROUTE_ONREPLY LBRACE actions RBRACE {
1403 push($3, &onreply_rt.rlist[DEFAULT_RT]);
1405 | ROUTE_ONREPLY LBRACK route_name RBRACK LBRACE actions RBRACE {
1406 i_tmp=route_get(&onreply_rt, $3);
1408 yyerror("internal error");
1411 if (onreply_rt.rlist[i_tmp]){
1412 yyerror("duplicate route");
1415 push($6, &onreply_rt.rlist[i_tmp]);
1417 | ROUTE_ONREPLY error { yyerror("invalid onreply_route statement"); }
1420 ROUTE_BRANCH LBRACE actions RBRACE {
1421 push($3, &branch_rt.rlist[DEFAULT_RT]);
1423 | ROUTE_BRANCH LBRACK route_name RBRACK LBRACE actions RBRACE {
1424 i_tmp=route_get(&branch_rt, $3);
1426 yyerror("internal error");
1429 if (branch_rt.rlist[i_tmp]){
1430 yyerror("duplicate route");
1433 push($6, &branch_rt.rlist[i_tmp]);
1435 | ROUTE_BRANCH error { yyerror("invalid branch_route statement"); }
1437 send_route_stm: ROUTE_SEND LBRACE actions RBRACE {
1438 push($3, &onsend_rt.rlist[DEFAULT_RT]);
1440 | ROUTE_SEND LBRACK route_name RBRACK LBRACE actions RBRACE {
1441 i_tmp=route_get(&onsend_rt, $3);
1443 yyerror("internal error");
1446 if (onsend_rt.rlist[i_tmp]){
1447 yyerror("duplicate route");
1450 push($6, &onsend_rt.rlist[i_tmp]);
1452 | ROUTE_SEND error { yyerror("invalid onsend_route statement"); }
1456 rules rule { push($2, &$1); $$=$1; }
1458 | rules error { $$=0; yyerror("invalid rule"); }
1461 condition actions CR {
1463 if (add_rule($1, $2, &$$)<0) {
1464 yyerror("error calling add_rule");
1469 | condition error { $$=0; yyerror("bad actions in rule"); }
1474 exp: exp LOG_AND exp { $$=mk_exp(LOGAND_OP, $1, $3); }
1475 | exp LOG_OR exp { $$=mk_exp(LOGOR_OP, $1, $3); }
1476 | NOT exp { $$=mk_exp(NOT_OP, $2, 0); }
1477 | LPAREN exp RPAREN { $$=$2; }
1478 | exp_elem { $$=$1; }
1481 EQUAL_T {$$=EQUAL_OP; }
1482 | DIFF {$$=DIFF_OP; }
1484 intop: equalop {$$=$1; }
1491 BIN_OR { $$= BINOR_OP; }
1492 | BIN_AND { $$ = BINAND_OP; }
1496 | MATCH {$$=MATCH_OP; }
1500 | FROM_URI {$$=FROM_URI_O;}
1501 | TO_URI {$$=TO_URI_O;}
1505 METHOD strop STRING {$$= mk_elem($2, METHOD_O, 0, STRING_ST, $3);}
1506 | METHOD strop attr_id_val {$$ = mk_elem($2, METHOD_O, 0, AVP_ST, $3); }
1507 | METHOD strop select_id {$$ = mk_elem($2, METHOD_O, 0, SELECT_ST, $3); }
1508 | METHOD strop ID {$$ = mk_elem($2, METHOD_O, 0, STRING_ST,$3); }
1509 | METHOD strop error { $$=0; yyerror("string expected"); }
1510 | METHOD error { $$=0; yyerror("invalid operator,== , !=, or =~ expected"); }
1511 | uri_type strop STRING {$$ = mk_elem($2, $1, 0, STRING_ST, $3); }
1512 | uri_type strop host {$$ = mk_elem($2, $1, 0, STRING_ST, $3); }
1513 | uri_type strop attr_id_val {$$ = mk_elem($2, $1, 0, AVP_ST, $3); }
1514 | uri_type strop select_id {$$ = mk_elem($2, $1, 0, SELECT_ST, $3); }
1515 | uri_type equalop MYSELF {$$=mk_elem($2, $1, 0, MYSELF_ST, 0); }
1516 | uri_type strop error { $$=0; yyerror("string or MYSELF expected"); }
1517 | uri_type error { $$=0; yyerror("invalid operator, == , != or =~ expected"); }
1519 | SRCPORT intop NUMBER { $$=mk_elem($2, SRCPORT_O, 0, NUMBER_ST, (void*)$3 ); }
1520 | SRCPORT intop attr_id_val { $$=mk_elem($2, SRCPORT_O, 0, AVP_ST, (void*)$3 ); }
1521 | SRCPORT intop error { $$=0; yyerror("number expected"); }
1522 | SRCPORT error { $$=0; yyerror("==, !=, <,>, >= or <= expected"); }
1524 | DSTPORT intop NUMBER { $$=mk_elem($2, DSTPORT_O, 0, NUMBER_ST, (void*)$3 ); }
1525 | DSTPORT intop attr_id_val { $$=mk_elem($2, DSTPORT_O, 0, AVP_ST, (void*)$3 ); }
1526 | DSTPORT intop error { $$=0; yyerror("number expected"); }
1527 | DSTPORT error { $$=0; yyerror("==, !=, <,>, >= or <= expected"); }
1529 | SNDPORT intop NUMBER {
1530 onsend_check("snd_port");
1531 $$=mk_elem($2, SNDPORT_O, 0, NUMBER_ST, (void*)$3 );
1533 | SNDPORT intop attr_id_val {
1534 onsend_check("snd_port");
1535 $$=mk_elem($2, SNDPORT_O, 0, AVP_ST, (void*)$3 );
1537 | SNDPORT intop error { $$=0; yyerror("number expected"); }
1538 | SNDPORT error { $$=0; yyerror("==, !=, <,>, >= or <= expected"); }
1540 | TOPORT intop NUMBER {
1541 onsend_check("to_port");
1542 $$=mk_elem($2, TOPORT_O, 0, NUMBER_ST, (void*)$3 );
1544 | TOPORT intop attr_id_val {
1545 onsend_check("to_port");
1546 $$=mk_elem($2, TOPORT_O, 0, AVP_ST, (void*)$3 );
1548 | TOPORT intop error { $$=0; yyerror("number expected"); }
1549 | TOPORT error { $$=0; yyerror("==, !=, <,>, >= or <= expected"); }
1551 | PROTO intop proto { $$=mk_elem($2, PROTO_O, 0, NUMBER_ST, (void*)$3 ); }
1552 | PROTO intop attr_id_val { $$=mk_elem($2, PROTO_O, 0, AVP_ST, (void*)$3 ); }
1553 | PROTO intop error { $$=0; yyerror("protocol expected (udp, tcp or tls)"); }
1555 | PROTO error { $$=0; yyerror("equal/!= operator expected"); }
1557 | SNDPROTO intop proto {
1558 onsend_check("snd_proto");
1559 $$=mk_elem($2, SNDPROTO_O, 0, NUMBER_ST, (void*)$3 );
1561 | SNDPROTO intop attr_id_val {
1562 onsend_check("snd_proto");
1563 $$=mk_elem($2, SNDPROTO_O, 0, AVP_ST, (void*)$3 );
1565 | SNDPROTO intop error { $$=0; yyerror("protocol expected (udp, tcp or tls)"); }
1566 | SNDPROTO error { $$=0; yyerror("equal/!= operator expected"); }
1568 | AF intop NUMBER { $$=mk_elem($2, AF_O, 0, NUMBER_ST,(void *) $3 ); }
1569 | AF intop attr_id_val { $$=mk_elem($2, AF_O, 0, AVP_ST,(void *) $3 ); }
1570 | AF intop error { $$=0; yyerror("number expected"); }
1571 | AF error { $$=0; yyerror("equal/!= operator expected"); }
1573 | SNDAF intop NUMBER {
1574 onsend_check("snd_af");
1575 $$=mk_elem($2, SNDAF_O, 0, NUMBER_ST, (void *) $3 ); }
1576 | SNDAF intop attr_id_val {
1577 onsend_check("snd_af");
1578 $$=mk_elem($2, SNDAF_O, 0, AVP_ST, (void *) $3 );
1580 | SNDAF intop error { $$=0; yyerror("number expected"); }
1581 | SNDAF error { $$=0; yyerror("equal/!= operator expected"); }
1583 | MSGLEN intop NUMBER { $$=mk_elem($2, MSGLEN_O, 0, NUMBER_ST, (void *) $3 ); }
1584 | MSGLEN intop attr_id_val { $$=mk_elem($2, MSGLEN_O, 0, AVP_ST, (void *) $3 ); }
1585 | MSGLEN intop MAX_LEN { $$=mk_elem($2, MSGLEN_O, 0, NUMBER_ST, (void *) BUF_SIZE); }
1586 | MSGLEN intop error { $$=0; yyerror("number expected"); }
1587 | MSGLEN error { $$=0; yyerror("equal/!= operator expected"); }
1589 | RETCODE intop NUMBER { $$=mk_elem($2, RETCODE_O, 0, NUMBER_ST, (void *) $3 ); }
1590 | RETCODE intop attr_id_val { $$=mk_elem($2, RETCODE_O, 0, AVP_ST, (void *) $3 ); }
1591 | RETCODE intop error { $$=0; yyerror("number expected"); }
1592 | RETCODE error { $$=0; yyerror("equal/!= operator expected"); }
1594 | SRCIP equalop ipnet { $$=mk_elem($2, SRCIP_O, 0, NET_ST, $3); }
1595 | SRCIP strop STRING {
1597 s_tmp.len=strlen($3);
1598 ip_tmp=str2ip(&s_tmp);
1601 ip_tmp=str2ip6(&s_tmp);
1604 $$=mk_elem($2, SRCIP_O, 0, NET_ST, mk_net_bitlen(ip_tmp, ip_tmp->len*8) );
1606 $$=mk_elem($2, SRCIP_O, 0, STRING_ST, $3);
1609 | SRCIP strop host { $$=mk_elem($2, SRCIP_O, 0, STRING_ST, $3); }
1610 | SRCIP equalop MYSELF { $$=mk_elem($2, SRCIP_O, 0, MYSELF_ST, 0);
1612 | SRCIP strop error { $$=0; yyerror( "ip address or hostname expected" ); }
1613 | SRCIP error { $$=0; yyerror("invalid operator, ==, != or =~ expected");}
1614 | DSTIP equalop ipnet { $$=mk_elem( $2, DSTIP_O, 0, NET_ST, (void*)$3); }
1615 | DSTIP strop STRING {
1617 s_tmp.len=strlen($3);
1618 ip_tmp=str2ip(&s_tmp);
1621 ip_tmp=str2ip6(&s_tmp);
1622 #endif /* USE_IPV6 */
1624 $$=mk_elem($2, DSTIP_O, 0, NET_ST, mk_net_bitlen(ip_tmp, ip_tmp->len*8) );
1626 $$=mk_elem($2, DSTIP_O, 0, STRING_ST, $3);
1629 | DSTIP strop host { $$=mk_elem( $2, DSTIP_O, 0, STRING_ST, $3); }
1630 | DSTIP equalop MYSELF { $$=mk_elem( $2, DSTIP_O, 0, MYSELF_ST, 0); }
1631 | DSTIP strop error { $$=0; yyerror( "ip address or hostname expected" ); }
1632 | DSTIP error { $$=0; yyerror("invalid operator, ==, != or =~ expected"); }
1633 | SNDIP equalop ipnet {
1634 onsend_check("snd_ip");
1635 $$=mk_elem($2, SNDIP_O, 0, NET_ST, $3);
1637 | SNDIP strop STRING {
1638 onsend_check("snd_ip");
1640 s_tmp.len=strlen($3);
1641 ip_tmp=str2ip(&s_tmp);
1644 ip_tmp=str2ip6(&s_tmp);
1645 #endif /* USE_IPV6 */
1647 $$=mk_elem($2, SNDIP_O, 0, NET_ST, mk_net_bitlen(ip_tmp, ip_tmp->len*8) );
1649 $$=mk_elem($2, SNDIP_O, 0, STRING_ST, $3);
1652 | SNDIP strop host {
1653 onsend_check("snd_ip");
1654 $$=mk_elem($2, SNDIP_O, 0, STRING_ST, $3);
1656 | SNDIP equalop attr_id_val {
1657 onsend_check("snd_ip");
1658 $$=mk_elem($2, SNDIP_O, 0, AVP_ST, (void*)$3 );
1660 | SNDIP equalop MYSELF {
1661 onsend_check("snd_ip");
1662 $$=mk_elem($2, SNDIP_O, 0, MYSELF_ST, 0);
1664 | SNDIP strop error { $$=0; yyerror( "ip address or hostname expected" ); }
1665 | SNDIP error { $$=0; yyerror("invalid operator, ==, != or =~ expected"); }
1666 | TOIP equalop ipnet {
1667 onsend_check("to_ip");
1668 $$=mk_elem($2, TOIP_O, 0, NET_ST, $3);
1670 | TOIP strop STRING {
1671 onsend_check("to_ip");
1673 s_tmp.len=strlen($3);
1674 ip_tmp=str2ip(&s_tmp);
1677 ip_tmp=str2ip6(&s_tmp);
1678 #endif /* USE_IPV6 */
1680 $$=mk_elem($2, TOIP_O, 0, NET_ST, mk_net_bitlen(ip_tmp, ip_tmp->len*8) );
1682 $$=mk_elem($2, TOIP_O, 0, STRING_ST, $3);
1686 onsend_check("to_ip");
1687 $$=mk_elem($2, TOIP_O, 0, STRING_ST, $3);
1689 | TOIP equalop attr_id_val {
1690 onsend_check("to_ip");
1691 $$=mk_elem($2, TOIP_O, 0, AVP_ST, (void*)$3 );
1693 | TOIP equalop MYSELF {
1694 onsend_check("to_ip");
1695 $$=mk_elem($2, TOIP_O, 0, MYSELF_ST, 0);
1697 | TOIP strop error { $$=0; yyerror( "ip address or hostname expected" ); }
1698 | TOIP error { $$=0; yyerror("invalid operator, ==, != or =~ expected"); }
1700 | MYSELF equalop uri_type { $$=mk_elem($2, $3, 0, MYSELF_ST, 0); }
1701 | MYSELF equalop SRCIP { $$=mk_elem($2, SRCIP_O, 0, MYSELF_ST, 0); }
1702 | MYSELF equalop DSTIP { $$=mk_elem($2, DSTIP_O, 0, MYSELF_ST, 0); }
1703 | MYSELF equalop SNDIP {
1704 onsend_check("snd_ip");
1705 $$=mk_elem($2, SNDIP_O, 0, MYSELF_ST, 0);
1707 | MYSELF equalop TOIP {
1708 onsend_check("to_ip");
1709 $$=mk_elem($2, TOIP_O, 0, MYSELF_ST, 0);
1711 | MYSELF equalop error { $$=0; yyerror(" URI, SRCIP or DSTIP expected"); }
1712 | MYSELF error { $$=0; yyerror ("invalid operator, == or != expected"); }
1713 | exp_stm { $$=mk_elem( NO_OP, ACTION_O, 0, ACTIONS_ST, $1); }
1714 | NUMBER { $$=mk_elem( NO_OP, NUMBER_O, 0, NUMBER_ST, (void*)$1 ); }
1716 | attr_id_any {$$=mk_elem( NO_OP, AVP_O, (void*)$1, 0, 0); }
1717 | attr_id_val strop STRING {$$=mk_elem( $2, AVP_O, (void*)$1, STRING_ST, $3); }
1718 | attr_id_val strop select_id {$$=mk_elem( $2, AVP_O, (void*)$1, SELECT_ST, $3); }
1719 | attr_id_val intop NUMBER {$$=mk_elem( $2, AVP_O, (void*)$1, NUMBER_ST, (void*)$3); }
1720 | attr_id_val binop NUMBER {$$=mk_elem( $2, AVP_O, (void*)$1, NUMBER_ST, (void*)$3); }
1721 | attr_id_val strop attr_id_val {$$=mk_elem( $2, AVP_O, (void*)$1, AVP_ST, (void*)$3); }
1722 | attr_id_val intop attr_id_val {$$=mk_elem( $2, AVP_O, (void*)$1, AVP_ST, (void*)$3); }
1724 | select_id { $$=mk_elem( NO_OP, SELECT_O, $1, 0, 0); }
1725 | select_id strop STRING { $$=mk_elem( $2, SELECT_O, $1, STRING_ST, $3); }
1726 | select_id strop attr_id_val { $$=mk_elem( $2, SELECT_O, $1, AVP_ST, (void*)$3); }
1727 | select_id strop select_id { $$=mk_elem( $2, SELECT_O, $1, SELECT_ST, $3); }
1730 ip SLASH ip { $$=mk_net($1, $3); }
1732 if (($3<0) || ($3>$1->len*8)) {
1733 yyerror("invalid bit number in netmask");
1736 $$=mk_net_bitlen($1, $3);
1738 $$=mk_net($1, htonl( ($3)?~( (1<<(32-$3))-1 ):0 ) );
1742 | ip { $$=mk_net_bitlen($1, $1->len*8); }
1743 | ip SLASH error { $$=0; yyerror("netmask (eg:255.0.0.0 or 8) expected"); }
1752 | host host_sep ID {
1753 $$=(char*)pkg_malloc(strlen($1)+1+strlen($3)+1);
1755 LOG(L_CRIT, "ERROR: cfg. parser: memory allocation failure while parsing host\n");
1757 memcpy($$, $1, strlen($1));
1759 memcpy($$+strlen($1)+1, $3, strlen($3));
1760 $$[strlen($1)+1+strlen($3)]=0;
1765 | host DOT error { $$=0; pkg_free($1); yyerror("invalid hostname"); }
1770 /* check if allowed */
1771 if ($1 && rt==ONSEND_ROUTE) {
1786 yyerror("command not allowed in onsend_route\n");
1796 | assign_action { $$ = $1; }
1797 | LBRACE actions RBRACE { $$=$2; }
1801 | LBRACE actions RBRACE { $$=$2; }
1804 actions action {$$=append_action($1, $2); }
1806 | actions error { $$=0; yyerror("bad command"); }
1809 fcmd SEMICOLON {$$=$1;}
1811 | assign_action SEMICOLON {$$=$1;}
1812 | SEMICOLON /* null action */ {$$=0;}
1813 | fcmd error { $$=0; yyerror("bad command: missing ';'?"); }
1816 IF exp stm { $$=mk_action( IF_T, 3, EXPR_ST, $2, ACTIONS_ST, $3, NOSUBTYPE, 0); }
1817 | IF exp stm ELSE stm { $$=mk_action( IF_T, 3, EXPR_ST, $2, ACTIONS_ST, $3, ACTIONS_ST, $5); }
1820 LBRACK ATTR_USER RBRACK { $$ = AVP_CLASS_USER; }
1821 | LBRACK ATTR_DOMAIN RBRACK { $$ = AVP_CLASS_DOMAIN; }
1822 | LBRACK ATTR_GLOBAL RBRACK { $$ = AVP_CLASS_GLOBAL; }
1827 if (sel.n >= MAX_SELECT_PARAMS-1) {
1828 yyerror("Select identifier too long\n");
1830 sel.params[sel.n].type = SEL_PARAM_STR;
1831 sel.params[sel.n].v.s.s = $1;
1832 sel.params[sel.n].v.s.len = strlen($1);
1835 | ID LBRACK NUMBER RBRACK {
1836 if (sel.n >= MAX_SELECT_PARAMS-2) {
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);
1843 sel.params[sel.n].type = SEL_PARAM_INT;
1844 sel.params[sel.n].v.i = $3;
1847 | ID LBRACK STRING RBRACK {
1848 if (sel.n >= MAX_SELECT_PARAMS-2) {
1849 yyerror("Select identifier too long\n");
1851 sel.params[sel.n].type = SEL_PARAM_STR;
1852 sel.params[sel.n].v.s.s = $1;
1853 sel.params[sel.n].v.s.len = strlen($1);
1855 sel.params[sel.n].type = SEL_PARAM_STR;
1856 sel.params[sel.n].v.s.s = $3;
1857 sel.params[sel.n].v.s.len = strlen($3);
1862 select_params DOT select_param
1866 SELECT_MARK { sel.n = 0; sel.f[0] = 0; } select_params {
1867 sel_ptr = (select_t*)pkg_malloc(sizeof(select_t));
1869 yyerror("No memory left to allocate select structure\n");
1871 memcpy(sel_ptr, &sel, sizeof(select_t));
1876 ATTR_FROM { s_attr->type |= AVP_TRACK_FROM; }
1877 | ATTR_TO { s_attr->type |= AVP_TRACK_TO; }
1878 | ATTR_FROMURI { s_attr->type |= AVP_TRACK_FROM | AVP_CLASS_URI; }
1879 | ATTR_TOURI { s_attr->type |= AVP_TRACK_TO | AVP_CLASS_URI; }
1880 | ATTR_FROMUSER { s_attr->type |= AVP_TRACK_FROM | AVP_CLASS_USER; }
1881 | ATTR_TOUSER { s_attr->type |= AVP_TRACK_TO | AVP_CLASS_USER; }
1882 | ATTR_FROMDOMAIN { s_attr->type |= AVP_TRACK_FROM | AVP_CLASS_DOMAIN; }
1883 | ATTR_TODOMAIN { s_attr->type |= AVP_TRACK_TO | AVP_CLASS_DOMAIN; }
1884 | ATTR_GLOBAL { s_attr->type |= AVP_TRACK_ALL | AVP_CLASS_GLOBAL; }
1887 ID { s_attr->type |= AVP_NAME_STR; s_attr->name.s.s = $1; s_attr->name.s.len = strlen ($1); }
1891 | attr_class_spec DOT attr_name_spec
1895 s_attr = (struct avp_spec*)pkg_malloc(sizeof(struct avp_spec));
1896 if (!s_attr) { yyerror("No memory left"); }
1901 attr_mark attr_spec { $$ = s_attr; }
1904 attr_mark attr_spec LBRACK NUMBER RBRACK {
1905 s_attr->type|= (AVP_NAME_STR | ($4<0?AVP_INDEX_BACKWARD:AVP_INDEX_FORWARD));
1906 s_attr->index = ($4<0?-$4:$4);
1911 attr_mark attr_spec LBRACK RBRACK {
1912 s_attr->type|= AVP_INDEX_ALL;
1932 avp_spec_t *avp_spec;
1935 avp_spec = pkg_malloc(sizeof(*avp_spec));
1937 yyerror("Not enough memory");
1943 s.len = strlen(s.s);
1944 if (parse_avp_name(&s, &type, &avp_spec->name, &idx)) {
1945 yyerror("error when parsing AVP");
1949 avp_spec->type = type;
1950 avp_spec->index = idx;
1956 ADDEQ { $$ = ADD_T; }
1957 | EQUAL { $$ = ASSIGN_T; }
1961 EQUAL { $$ = ASSIGN_T; }
1964 attr_id_ass assign_op STRING { $$=mk_action($2, 2, AVP_ST, $1, STRING_ST, $3); }
1965 | attr_id_ass assign_op NUMBER { $$=mk_action($2, 2, AVP_ST, $1, NUMBER_ST, (void*)$3); }
1966 | attr_id_ass assign_op fcmd { $$=mk_action($2, 2, AVP_ST, $1, ACTION_ST, $3); }
1967 | attr_id_ass assign_op attr_id_any { $$=mk_action($2, 2, AVP_ST, $1, AVP_ST, $3); }
1968 | attr_id_ass assign_op select_id { $$=mk_action($2, 2, AVP_ST, (void*)$1, SELECT_ST, (void*)$3); }
1969 | attr_id_ass assign_op LPAREN exp RPAREN { $$ = mk_action($2, 2, AVP_ST, $1, EXPR_ST, $4); }
1972 SETAVPFLAG { $$ = 1; }
1973 | RESETAVPFLAG { $$ = 0; }
1974 | ISAVPFLAGSET { $$ = -1; }
1977 FORWARD LPAREN host RPAREN { $$=mk_action( FORWARD_T, 2, STRING_ST, $3, NUMBER_ST, 0); }
1978 | FORWARD LPAREN STRING RPAREN { $$=mk_action( FORWARD_T, 2, STRING_ST, $3, NUMBER_ST, 0); }
1979 | FORWARD LPAREN ip RPAREN { $$=mk_action( FORWARD_T, 2, IP_ST, (void*)$3, NUMBER_ST, 0); }
1980 | FORWARD LPAREN host COMMA NUMBER RPAREN { $$=mk_action(FORWARD_T, 2, STRING_ST, $3, NUMBER_ST, (void*)$5); }
1981 | FORWARD LPAREN STRING COMMA NUMBER RPAREN {$$=mk_action(FORWARD_T, 2, STRING_ST, $3, NUMBER_ST, (void*)$5); }
1982 | FORWARD LPAREN ip COMMA NUMBER RPAREN { $$=mk_action(FORWARD_T, 2, IP_ST, (void*)$3, NUMBER_ST, (void*)$5); }
1983 | FORWARD LPAREN URIHOST COMMA URIPORT RPAREN { $$=mk_action(FORWARD_T, 2, URIHOST_ST, 0, URIPORT_ST, 0); }
1984 | FORWARD LPAREN URIHOST COMMA NUMBER RPAREN {$$=mk_action(FORWARD_T, 2, URIHOST_ST, 0, NUMBER_ST, (void*)$5); }
1985 | FORWARD LPAREN URIHOST RPAREN { $$=mk_action(FORWARD_T, 2, URIHOST_ST, 0, NUMBER_ST, 0); }
1986 | FORWARD error { $$=0; yyerror("missing '(' or ')' ?"); }
1987 | FORWARD LPAREN error RPAREN { $$=0; yyerror("bad forward argument"); }
1988 | FORWARD_UDP LPAREN host RPAREN { $$=mk_action(FORWARD_UDP_T, 2, STRING_ST, $3, NUMBER_ST, 0); }
1989 | FORWARD_UDP LPAREN STRING RPAREN { $$=mk_action(FORWARD_UDP_T, 2, STRING_ST, $3, NUMBER_ST, 0); }
1990 | FORWARD_UDP LPAREN ip RPAREN { $$=mk_action(FORWARD_UDP_T, 2, IP_ST, (void*)$3, NUMBER_ST, 0); }
1991 | FORWARD_UDP LPAREN host COMMA NUMBER RPAREN { $$=mk_action(FORWARD_UDP_T, 2, STRING_ST, $3, NUMBER_ST, (void*)$5); }
1992 | FORWARD_UDP LPAREN STRING COMMA NUMBER RPAREN {$$=mk_action(FORWARD_UDP_T, 2, STRING_ST, $3, NUMBER_ST, (void*)$5); }
1993 | FORWARD_UDP LPAREN ip COMMA NUMBER RPAREN { $$=mk_action(FORWARD_UDP_T, 2, IP_ST, (void*)$3, NUMBER_ST, (void*)$5); }
1994 | FORWARD_UDP LPAREN URIHOST COMMA URIPORT RPAREN {$$=mk_action(FORWARD_UDP_T, 2, URIHOST_ST, 0, URIPORT_ST, 0); }
1995 | FORWARD_UDP LPAREN URIHOST COMMA NUMBER RPAREN { $$=mk_action(FORWARD_UDP_T, 2, URIHOST_ST, 0, NUMBER_ST, (void*)$5); }
1996 | FORWARD_UDP LPAREN URIHOST RPAREN { $$=mk_action(FORWARD_UDP_T, 2, URIHOST_ST, 0, NUMBER_ST, 0); }
1997 | FORWARD_UDP error { $$=0; yyerror("missing '(' or ')' ?"); }
1998 | FORWARD_UDP LPAREN error RPAREN { $$=0; yyerror("bad forward_udp argument"); }
1999 | FORWARD_TCP LPAREN host RPAREN { $$=mk_action(FORWARD_TCP_T, 2, STRING_ST, $3, NUMBER_ST, 0); }
2000 | FORWARD_TCP LPAREN STRING RPAREN { $$=mk_action(FORWARD_TCP_T, 2, STRING_ST, $3, NUMBER_ST, 0); }
2001 | FORWARD_TCP LPAREN ip RPAREN { $$=mk_action(FORWARD_TCP_T, 2, IP_ST, (void*)$3, NUMBER_ST, 0); }
2002 | FORWARD_TCP LPAREN host COMMA NUMBER RPAREN { $$=mk_action(FORWARD_TCP_T, 2, STRING_ST, $3, NUMBER_ST, (void*)$5); }
2003 | FORWARD_TCP LPAREN STRING COMMA NUMBER RPAREN {$$=mk_action(FORWARD_TCP_T, 2, STRING_ST, $3, NUMBER_ST, (void*)$5); }
2004 | FORWARD_TCP LPAREN ip COMMA NUMBER RPAREN { $$=mk_action(FORWARD_TCP_T, 2, IP_ST, (void*)$3, NUMBER_ST, (void*)$5); }
2005 | FORWARD_TCP LPAREN URIHOST COMMA URIPORT RPAREN {$$=mk_action(FORWARD_TCP_T, 2, URIHOST_ST, 0, URIPORT_ST, 0); }
2006 | FORWARD_TCP LPAREN URIHOST COMMA NUMBER RPAREN { $$=mk_action(FORWARD_TCP_T, 2, URIHOST_ST, 0, NUMBER_ST, (void*)$5); }
2007 | FORWARD_TCP LPAREN URIHOST RPAREN { $$=mk_action(FORWARD_TCP_T, 2, URIHOST_ST, 0, NUMBER_ST, 0); }
2008 | FORWARD_TCP error { $$=0; yyerror("missing '(' or ')' ?"); }
2009 | FORWARD_TCP LPAREN error RPAREN { $$=0; yyerror("bad forward_tcp argument"); }
2010 | FORWARD_TLS LPAREN host RPAREN {
2012 $$=mk_action(FORWARD_TLS_T, 2, STRING_ST, $3, NUMBER_ST, 0);
2015 yyerror("tls support not compiled in");
2018 | FORWARD_TLS LPAREN STRING RPAREN {
2020 $$=mk_action(FORWARD_TLS_T, 2, STRING_ST, $3, NUMBER_ST, 0);
2023 yyerror("tls support not compiled in");
2026 | FORWARD_TLS LPAREN ip RPAREN {
2028 $$=mk_action(FORWARD_TLS_T, 2, IP_ST, (void*)$3, NUMBER_ST, 0);
2031 yyerror("tls support not compiled in");
2034 | FORWARD_TLS LPAREN host COMMA NUMBER RPAREN {
2036 $$=mk_action(FORWARD_TLS_T, 2, STRING_ST, $3, NUMBER_ST, (void*)$5);
2039 yyerror("tls support not compiled in");
2042 | FORWARD_TLS LPAREN STRING COMMA NUMBER RPAREN {
2044 $$=mk_action(FORWARD_TLS_T, 2, STRING_ST, $3, NUMBER_ST, (void*)$5);
2047 yyerror("tls support not compiled in");
2050 | FORWARD_TLS LPAREN ip COMMA NUMBER RPAREN {
2052 $$=mk_action(FORWARD_TLS_T, 2, IP_ST, (void*)$3, NUMBER_ST, (void*)$5);
2055 yyerror("tls support not compiled in");
2058 | FORWARD_TLS LPAREN URIHOST COMMA URIPORT RPAREN {
2060 $$=mk_action(FORWARD_TLS_T, 2, URIHOST_ST, 0, URIPORT_ST, 0);
2063 yyerror("tls support not compiled in");
2066 | FORWARD_TLS LPAREN URIHOST COMMA NUMBER RPAREN {
2068 $$=mk_action(FORWARD_TLS_T, 2, URIHOST_ST, 0, NUMBER_ST, (void*)$5);
2071 yyerror("tls support not compiled in");
2074 | FORWARD_TLS LPAREN URIHOST RPAREN {
2076 $$=mk_action(FORWARD_TLS_T, 2, URIHOST_ST, 0, NUMBER_ST, 0);
2079 yyerror("tls support not compiled in");
2082 | FORWARD_TLS error { $$=0; yyerror("missing '(' or ')' ?"); }
2083 | FORWARD_TLS LPAREN error RPAREN { $$=0;
2084 yyerror("bad forward_tls argument"); }
2085 | FORWARD_SCTP LPAREN host RPAREN {
2087 $$=mk_action(FORWARD_SCTP_T, 2, STRING_ST, $3, NUMBER_ST, 0);
2090 yyerror("sctp support not compiled in");
2093 | FORWARD_SCTP LPAREN STRING RPAREN {
2095 $$=mk_action(FORWARD_SCTP_T, 2, STRING_ST, $3, NUMBER_ST, 0);
2098 yyerror("sctp support not compiled in");
2101 | FORWARD_SCTP LPAREN ip RPAREN {
2103 $$=mk_action(FORWARD_SCTP_T, 2, IP_ST, (void*)$3, NUMBER_ST, 0);
2106 yyerror("sctp support not compiled in");
2109 | FORWARD_SCTP LPAREN host COMMA NUMBER RPAREN {
2111 $$=mk_action(FORWARD_SCTP_T, 2, STRING_ST, $3, NUMBER_ST,
2115 yyerror("sctp support not compiled in");
2118 | FORWARD_SCTP LPAREN STRING 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 ip COMMA NUMBER RPAREN {
2129 $$=mk_action(FORWARD_SCTP_T, 2, IP_ST, (void*)$3, NUMBER_ST,
2133 yyerror("sctp support not compiled in");
2136 | FORWARD_SCTP LPAREN URIHOST COMMA URIPORT RPAREN {
2138 $$=mk_action(FORWARD_SCTP_T, 2, URIHOST_ST, 0, URIPORT_ST, 0);
2141 yyerror("sctp support not compiled in");
2144 | FORWARD_SCTP LPAREN URIHOST COMMA NUMBER RPAREN {
2146 $$=mk_action(FORWARD_SCTP_T, 2, URIHOST_ST, 0, NUMBER_ST,
2150 yyerror("sctp support not compiled in");
2153 | FORWARD_SCTP LPAREN URIHOST RPAREN {
2155 $$=mk_action(FORWARD_SCTP_T, 2, URIHOST_ST, 0, NUMBER_ST, 0);
2158 yyerror("tls support not compiled in");
2161 | FORWARD_SCTP error { $$=0; yyerror("missing '(' or ')' ?"); }
2162 | FORWARD_SCTP LPAREN error RPAREN { $$=0;
2163 yyerror("bad forward_tls argument"); }
2164 | SEND LPAREN host RPAREN { $$=mk_action(SEND_T, 2, STRING_ST, $3, NUMBER_ST, 0); }
2165 | SEND LPAREN STRING RPAREN { $$=mk_action(SEND_T, 2, STRING_ST, $3, NUMBER_ST, 0); }
2166 | SEND LPAREN ip RPAREN { $$=mk_action(SEND_T, 2, IP_ST, (void*)$3, NUMBER_ST, 0); }
2167 | SEND LPAREN host COMMA NUMBER RPAREN { $$=mk_action(SEND_T, 2, STRING_ST, $3, NUMBER_ST, (void*)$5); }
2168 | SEND LPAREN STRING COMMA NUMBER RPAREN {$$=mk_action(SEND_T, 2, STRING_ST, $3, NUMBER_ST, (void*)$5); }
2169 | SEND LPAREN ip COMMA NUMBER RPAREN { $$=mk_action(SEND_T, 2, IP_ST, (void*)$3, NUMBER_ST, (void*)$5); }
2170 | SEND error { $$=0; yyerror("missing '(' or ')' ?"); }
2171 | SEND LPAREN error RPAREN { $$=0; yyerror("bad send argument"); }
2172 | SEND_TCP LPAREN host RPAREN { $$=mk_action(SEND_TCP_T, 2, STRING_ST, $3, NUMBER_ST, 0); }
2173 | SEND_TCP LPAREN STRING RPAREN { $$=mk_action(SEND_TCP_T, 2, STRING_ST, $3, NUMBER_ST, 0); }
2174 | SEND_TCP LPAREN ip RPAREN { $$=mk_action(SEND_TCP_T, 2, IP_ST, (void*)$3, NUMBER_ST, 0); }
2175 | SEND_TCP LPAREN host COMMA NUMBER RPAREN { $$=mk_action( SEND_TCP_T, 2, STRING_ST, $3, NUMBER_ST, (void*)$5);}
2176 | SEND_TCP LPAREN STRING COMMA NUMBER RPAREN {$$=mk_action(SEND_TCP_T, 2, STRING_ST, $3, NUMBER_ST, (void*)$5); }
2177 | SEND_TCP LPAREN ip COMMA NUMBER RPAREN { $$=mk_action(SEND_TCP_T, 2, IP_ST, (void*)$3, NUMBER_ST, (void*)$5); }
2178 | SEND_TCP error { $$=0; yyerror("missing '(' or ')' ?"); }
2179 | SEND_TCP LPAREN error RPAREN { $$=0; yyerror("bad send_tcp argument"); }
2180 | DROP LPAREN RPAREN {$$=mk_action(DROP_T, 2, NUMBER_ST, 0, NUMBER_ST, (void*)EXIT_R_F); }
2181 | DROP LPAREN NUMBER RPAREN {$$=mk_action(DROP_T, 2, NUMBER_ST, (void*)$3, NUMBER_ST, (void*)EXIT_R_F); }
2182 | DROP NUMBER {$$=mk_action(DROP_T, 2, NUMBER_ST, (void*)$2, NUMBER_ST, (void*)EXIT_R_F); }
2183 | DROP RETCODE {$$=mk_action(DROP_T, 2, RETCODE_ST, 0, NUMBER_ST, (void*)EXIT_R_F); }
2184 | DROP {$$=mk_action(DROP_T, 2, NUMBER_ST, 0, NUMBER_ST, (void*)EXIT_R_F); }
2185 | RETURN {$$=mk_action(DROP_T, 2, NUMBER_ST, (void*)1, NUMBER_ST, (void*)RETURN_R_F); }
2186 | RETURN NUMBER {$$=mk_action(DROP_T, 2, NUMBER_ST, (void*)$2, NUMBER_ST, (void*)RETURN_R_F);}
2187 | RETURN RETCODE {$$=mk_action(DROP_T, 2, RETCODE_ST, 0, NUMBER_ST, (void*)RETURN_R_F);}
2188 | BREAK {$$=mk_action(DROP_T, 2, NUMBER_ST, 0, NUMBER_ST, (void*)RETURN_R_F); }
2189 | LOG_TOK LPAREN STRING RPAREN {$$=mk_action(LOG_T, 2, NUMBER_ST, (void*)4, STRING_ST, $3); }
2190 | LOG_TOK LPAREN NUMBER COMMA STRING RPAREN {$$=mk_action(LOG_T, 2, NUMBER_ST, (void*)$3, STRING_ST, $5); }
2191 | LOG_TOK error { $$=0; yyerror("missing '(' or ')' ?"); }
2192 | LOG_TOK LPAREN error RPAREN { $$=0; yyerror("bad log argument"); }
2193 | SETFLAG LPAREN NUMBER RPAREN {
2194 if (check_flag($3)==-1)
2195 yyerror("bad flag value");
2196 $$=mk_action(SETFLAG_T, 1, NUMBER_ST,
2199 | SETFLAG LPAREN flag_name RPAREN {
2200 i_tmp=get_flag_no($3, strlen($3));
2201 if (i_tmp<0) yyerror("flag not declared");
2202 $$=mk_action(SETFLAG_T, 1, NUMBER_ST,
2203 (void*)(long)i_tmp);
2205 | SETFLAG error { $$=0; yyerror("missing '(' or ')'?"); }
2206 | RESETFLAG LPAREN NUMBER RPAREN {
2207 if (check_flag($3)==-1)
2208 yyerror("bad flag value");
2209 $$=mk_action(RESETFLAG_T, 1, NUMBER_ST, (void*)$3);
2211 | RESETFLAG LPAREN flag_name RPAREN {
2212 i_tmp=get_flag_no($3, strlen($3));
2213 if (i_tmp<0) yyerror("flag not declared");
2214 $$=mk_action(RESETFLAG_T, 1, NUMBER_ST,
2215 (void*)(long)i_tmp);
2217 | RESETFLAG error { $$=0; yyerror("missing '(' or ')'?"); }
2218 | ISFLAGSET LPAREN NUMBER RPAREN {
2219 if (check_flag($3)==-1)
2220 yyerror("bad flag value");
2221 $$=mk_action(ISFLAGSET_T, 1, NUMBER_ST, (void*)$3);
2223 | ISFLAGSET LPAREN flag_name RPAREN {
2224 i_tmp=get_flag_no($3, strlen($3));
2225 if (i_tmp<0) yyerror("flag not declared");
2226 $$=mk_action(ISFLAGSET_T, 1, NUMBER_ST,
2227 (void*)(long)i_tmp);
2229 | ISFLAGSET error { $$=0; yyerror("missing '(' or ')'?"); }
2230 | avpflag_oper LPAREN attr_id_any_str COMMA flag_name RPAREN {
2231 i_tmp=get_avpflag_no($5);
2232 if (i_tmp==0) yyerror("avpflag not declared");
2233 $$=mk_action(AVPFLAG_OPER_T, 3, AVP_ST, $3, NUMBER_ST, (void*)(long)i_tmp, NUMBER_ST, (void*)$1);
2235 | avpflag_oper error { $$=0; yyerror("missing '(' or ')'?"); }
2236 | ERROR LPAREN STRING COMMA STRING RPAREN {$$=mk_action(ERROR_T, 2, STRING_ST, $3, STRING_ST, $5); }
2237 | ERROR error { $$=0; yyerror("missing '(' or ')' ?"); }
2238 | ERROR LPAREN error RPAREN { $$=0; yyerror("bad error argument"); }
2239 | ROUTE LPAREN route_name RPAREN {
2240 i_tmp=route_get(&main_rt, $3);
2242 yyerror("internal error");
2245 $$=mk_action(ROUTE_T, 1, NUMBER_ST,(void*)(long)i_tmp);
2247 | ROUTE error { $$=0; yyerror("missing '(' or ')' ?"); }
2248 | ROUTE LPAREN error RPAREN { $$=0; yyerror("bad route argument"); }
2249 | EXEC LPAREN STRING RPAREN { $$=mk_action(EXEC_T, 1, STRING_ST, $3); }
2250 | SET_HOST LPAREN STRING RPAREN { $$=mk_action(SET_HOST_T, 1, STRING_ST, $3); }
2251 | SET_HOST error { $$=0; yyerror("missing '(' or ')' ?"); }
2252 | SET_HOST LPAREN error RPAREN { $$=0; yyerror("bad argument, string expected"); }
2253 | PREFIX LPAREN STRING RPAREN { $$=mk_action(PREFIX_T, 1, STRING_ST, $3); }
2254 | PREFIX error { $$=0; yyerror("missing '(' or ')' ?"); }
2255 | PREFIX LPAREN error RPAREN { $$=0; yyerror("bad argument, string expected"); }
2256 | STRIP_TAIL LPAREN NUMBER RPAREN { $$=mk_action(STRIP_TAIL_T, 1, NUMBER_ST, (void*)$3); }
2257 | STRIP_TAIL error { $$=0; yyerror("missing '(' or ')' ?"); }
2258 | STRIP_TAIL LPAREN error RPAREN { $$=0; yyerror("bad argument, number expected"); }
2259 | STRIP LPAREN NUMBER RPAREN { $$=mk_action(STRIP_T, 1, NUMBER_ST, (void*) $3); }
2260 | STRIP error { $$=0; yyerror("missing '(' or ')' ?"); }
2261 | STRIP LPAREN error RPAREN { $$=0; yyerror("bad argument, number expected"); }
2262 | APPEND_BRANCH LPAREN STRING COMMA STRING RPAREN {
2264 if (str2q(&q, $5, strlen($5)) < 0) {
2265 yyerror("bad argument, q value expected");
2267 $$=mk_action(APPEND_BRANCH_T, 2, STRING_ST, $3, NUMBER_ST, (void *)(long)q);
2269 | APPEND_BRANCH LPAREN STRING RPAREN { $$=mk_action(APPEND_BRANCH_T, 2, STRING_ST, $3, NUMBER_ST, (void *)Q_UNSPECIFIED); }
2270 | APPEND_BRANCH LPAREN RPAREN { $$=mk_action(APPEND_BRANCH_T, 2, STRING_ST, 0, NUMBER_ST, (void *)Q_UNSPECIFIED); }
2271 | APPEND_BRANCH { $$=mk_action( APPEND_BRANCH_T, 1, STRING_ST, 0); }
2272 | SET_HOSTPORT LPAREN STRING RPAREN { $$=mk_action(SET_HOSTPORT_T, 1, STRING_ST, $3); }
2273 | SET_HOSTPORT error { $$=0; yyerror("missing '(' or ')' ?"); }
2274 | SET_HOSTPORT LPAREN error RPAREN { $$=0; yyerror("bad argument, string expected"); }
2275 | SET_HOSTPORTTRANS LPAREN STRING RPAREN { $$=mk_action(SET_HOSTPORTTRANS_T, 1, STRING_ST, $3); }
2276 | SET_HOSTPORTTRANS error { $$=0; yyerror("missing '(' or ')' ?"); }
2277 | SET_HOSTPORTTRANS LPAREN error RPAREN { $$=0; yyerror("bad argument, string expected"); }
2278 | SET_PORT LPAREN STRING RPAREN { $$=mk_action(SET_PORT_T, 1, STRING_ST, $3); }
2279 | SET_PORT error { $$=0; yyerror("missing '(' or ')' ?"); }
2280 | SET_PORT LPAREN error RPAREN { $$=0; yyerror("bad argument, string expected"); }
2281 | SET_USER LPAREN STRING RPAREN { $$=mk_action(SET_USER_T, 1, STRING_ST, $3); }
2282 | SET_USER error { $$=0; yyerror("missing '(' or ')' ?"); }
2283 | SET_USER LPAREN error RPAREN { $$=0; yyerror("bad argument, string expected"); }
2284 | SET_USERPASS LPAREN STRING RPAREN { $$=mk_action(SET_USERPASS_T, 1, STRING_ST, $3); }
2285 | SET_USERPASS error { $$=0; yyerror("missing '(' or ')' ?"); }
2286 | SET_USERPASS LPAREN error RPAREN { $$=0; yyerror("bad argument, string expected"); }
2287 | SET_URI LPAREN STRING RPAREN { $$=mk_action(SET_URI_T, 1, STRING_ST,$3); }
2288 | SET_URI error { $$=0; yyerror("missing '(' or ')' ?"); }
2289 | SET_URI LPAREN error RPAREN { $$=0; yyerror("bad argument, string expected"); }
2290 | REVERT_URI LPAREN RPAREN { $$=mk_action(REVERT_URI_T, 0); }
2291 | REVERT_URI { $$=mk_action(REVERT_URI_T, 0); }
2292 | FORCE_RPORT LPAREN RPAREN { $$=mk_action(FORCE_RPORT_T, 0); }
2293 | FORCE_RPORT {$$=mk_action(FORCE_RPORT_T, 0); }
2294 | FORCE_TCP_ALIAS LPAREN NUMBER RPAREN {
2296 $$=mk_action(FORCE_TCP_ALIAS_T, 1, NUMBER_ST, (void*)$3);
2298 yyerror("tcp support not compiled in");
2301 | FORCE_TCP_ALIAS LPAREN RPAREN {
2303 $$=mk_action(FORCE_TCP_ALIAS_T, 0);
2305 yyerror("tcp support not compiled in");
2310 $$=mk_action(FORCE_TCP_ALIAS_T, 0);
2312 yyerror("tcp support not compiled in");
2315 | FORCE_TCP_ALIAS LPAREN error RPAREN {$$=0; yyerror("bad argument, number expected"); }
2316 | SET_ADV_ADDRESS LPAREN listen_id RPAREN {
2318 if ((str_tmp=pkg_malloc(sizeof(str)))==0) {
2319 LOG(L_CRIT, "ERROR: cfg. parser: out of memory.\n");
2322 str_tmp->len=strlen($3);
2323 $$=mk_action(SET_ADV_ADDR_T, 1, STR_ST, str_tmp);
2326 | SET_ADV_ADDRESS LPAREN error RPAREN { $$=0; yyerror("bad argument, string expected"); }
2327 | SET_ADV_ADDRESS error {$$=0; yyerror("missing '(' or ')' ?"); }
2328 | SET_ADV_PORT LPAREN NUMBER RPAREN {
2330 tmp=int2str($3, &i_tmp);
2331 if ((str_tmp=pkg_malloc(sizeof(str)))==0) {
2332 LOG(L_CRIT, "ERROR: cfg. parser: out of memory.\n");
2334 if ((str_tmp->s=pkg_malloc(i_tmp))==0) {
2335 LOG(L_CRIT, "ERROR: cfg. parser: out of memory.\n");
2337 memcpy(str_tmp->s, tmp, i_tmp);
2339 $$=mk_action(SET_ADV_PORT_T, 1, STR_ST, str_tmp);
2343 | SET_ADV_PORT LPAREN error RPAREN { $$=0; yyerror("bad argument, string expected"); }
2344 | SET_ADV_PORT error {$$=0; yyerror("missing '(' or ')' ?"); }
2345 | FORCE_SEND_SOCKET LPAREN phostport RPAREN {
2346 $$=mk_action(FORCE_SEND_SOCKET_T, 1, SOCKID_ST, $3);
2348 | FORCE_SEND_SOCKET LPAREN error RPAREN {
2349 $$=0; yyerror("bad argument, [proto:]host[:port] expected");
2351 | FORCE_SEND_SOCKET error {$$=0; yyerror("missing '(' or ')' ?"); }
2352 | ID {mod_func_action = mk_action(MODULE_T, 2, MODEXP_ST, NULL, NUMBER_ST, 0); } LPAREN func_params RPAREN {
2353 mod_func_action->val[0].u.data = find_export_record($1, mod_func_action->val[1].u.number, rt);
2354 if (mod_func_action->val[0].u.data == 0) {
2355 if (find_export_record($1, mod_func_action->val[1].u.number, 0) ) {
2356 yyerror("Command cannot be used in the block\n");
2358 yyerror("unknown command, missing loadmodule?\n");
2360 pkg_free(mod_func_action);
2363 $$ = mod_func_action;
2368 | func_params COMMA func_param { }
2370 | func_params error { yyerror("call params error\n"); YYABORT; }
2374 if (mod_func_action->val[1].u.number < MAX_ACTIONS-2) {
2375 mod_func_action->val[mod_func_action->val[1].u.number+2].type = NUMBER_ST;
2376 mod_func_action->val[mod_func_action->val[1].u.number+2].u.number = $1;
2377 mod_func_action->val[1].u.number++;
2379 yyerror("Too many arguments\n");
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 = STRING_ST;
2385 mod_func_action->val[mod_func_action->val[1].u.number+2].u.string = $1;
2386 mod_func_action->val[1].u.number++;
2388 yyerror("Too many arguments\n");
2396 extern int startcolumn;
2397 static void warn(char* s)
2399 LOG(L_WARN, "cfg. warning: (%d,%d-%d): %s\n", line, startcolumn,
2404 static void yyerror(char* s)
2406 LOG(L_CRIT, "*** PARSE ERROR *** (%d,%d-%d): %s\n", line, startcolumn,
2412 static struct name_lst* mk_name_lst(char* host, int flags)
2415 l=pkg_malloc(sizeof(struct name_lst));
2417 LOG(L_CRIT,"ERROR: cfg. parser: out of memory.\n");
2427 static struct socket_id* mk_listen_id(char* host, int proto, int port)
2429 struct socket_id* l;
2430 l=pkg_malloc(sizeof(struct socket_id));
2432 LOG(L_CRIT,"ERROR: cfg. parser: out of memory.\n");
2434 l->addr_lst=mk_name_lst(host, 0);
2435 if (l->addr_lst==0){
2448 static void free_name_lst(struct name_lst* lst)
2450 struct name_lst* tmp;
2460 static struct socket_id* mk_listen_id2(struct name_lst* addr_l, int proto,
2463 struct socket_id* l;
2464 l=pkg_malloc(sizeof(struct socket_id));
2466 LOG(L_CRIT,"ERROR: cfg. parser: out of memory.\n");
2468 l->flags=addr_l->flags;
2478 static void free_socket_id(struct socket_id* i)
2480 free_name_lst(i->addr_lst);
2485 static void free_socket_id_lst(struct socket_id* lst)
2487 struct socket_id* tmp;
2492 free_socket_id(tmp);
2497 int main(int argc, char ** argv)
2500 fprintf(stderr, "parsing error\n");