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 int rt; /* Type of route block for find_export */
181 static struct ip_addr* ip_tmp;
182 static struct avp_spec* s_attr;
184 static select_t* sel_ptr;
185 static struct action *mod_func_action;
187 static void warn(char* s);
188 static struct socket_id* mk_listen_id(char*, int, int);
197 struct action* action;
199 struct ip_addr* ipaddr;
200 struct socket_id* sockid;
201 struct avp_spec* attr;
229 %token SET_HOSTPORTTRANS
240 %token FORCE_TCP_ALIAS
243 %token SET_ADV_ADDRESS
245 %token FORCE_SEND_SOCKET
295 %token DNS_SERVERS_NO
296 %token DNS_USE_SEARCH
297 %token DNS_SEARCH_FMATCH
298 %token DNS_CACHE_INIT
300 %token DNS_USE_FAILOVER
301 %token DNS_CACHE_FLAGS
302 %token DNS_CACHE_NEG_TTL
303 %token DNS_CACHE_MIN_TTL
304 %token DNS_CACHE_MAX_TTL
306 %token DNS_CACHE_GC_INT
307 %token DNS_CACHE_DEL_NONEXP
313 %token DST_BLST_GC_INT
324 %token SERVER_SIGNATURE
336 %token TCP_ACCEPT_ALIASES
338 %token TCP_CONNECT_TIMEOUT
339 %token TCP_SEND_TIMEOUT
340 %token TCP_CON_LIFETIME
341 %token TCP_POLL_METHOD
342 %token TCP_MAX_CONNECTIONS
343 %token TCP_SOURCE_IPV4
344 %token TCP_SOURCE_IPV6
345 %token TCP_OPT_FD_CACHE
346 %token TCP_OPT_BUF_WRITE
347 %token TCP_OPT_CONN_WQ_MAX
348 %token TCP_OPT_WQ_MAX
349 %token TCP_OPT_DEFER_ACCEPT
350 %token TCP_OPT_DELAYED_ACK
351 %token TCP_OPT_SYNCNT
352 %token TCP_OPT_LINGER2
353 %token TCP_OPT_KEEPALIVE
354 %token TCP_OPT_KEEPIDLE
355 %token TCP_OPT_KEEPINTVL
356 %token TCP_OPT_KEEPCNT
357 %token TCP_OPT_CRLF_PING
363 %token TLS_HANDSHAKE_TIMEOUT
364 %token TLS_SEND_TIMEOUT
370 %token TLS_REQUIRE_CERTIFICATE
371 %token TLS_CERTIFICATE
372 %token TLS_PRIVATE_KEY
376 %token SCTP_SOCKET_RCVBUF
377 %token SCTP_SOCKET_SNDBUF
378 %token SCTP_AUTOCLOSE
380 %token ADVERTISED_ADDRESS
381 %token ADVERTISED_PORT
384 %token SHM_FORCE_ALLOC
389 %token RT_TIMER1_PRIO
390 %token RT_TIMER1_POLICY
391 %token RT_TIMER2_PRIO
392 %token RT_TIMER2_POLICY
393 %token MCAST_LOOPBACK
396 %token PMTU_DISCOVERY
398 %token CFG_DESCRIPTION
412 %token ATTR_FROMDOMAIN
417 %token STUN_REFRESH_INTERVAL
418 %token STUN_ALLOW_STUN
439 %token <intval> NUMBER
441 %token <strval> STRING
442 %token <strval> IPV6ADDR
461 %type <expr> exp exp_elem /*, condition*/
462 %type <action> action actions cmd fcmd if_cmd stm exp_stm assign_action
463 %type <ipaddr> ipv4 ipv6 ipv6addr ip
466 %type <strval> listen_id
467 %type <sockid> id_lst
468 %type <sockid> phostport
469 %type <intval> proto port
470 %type <intval> equalop strop intop binop
471 %type <strval> host_sep
472 %type <intval> uri_type
474 %type <attr> attr_id_num_idx
475 %type <attr> attr_id_no_idx
476 %type <attr> attr_id_ass
477 %type <attr> attr_id_val
478 %type <attr> attr_id_any
479 %type <attr> attr_id_any_str
480 /* %type <intval> class_id */
481 %type <intval> assign_op
482 %type <select> select_id
483 %type <strval> flag_name;
484 %type <strval> route_name;
485 %type <intval> avpflag_oper
487 /*%type <route_el> rules;
488 %type <route_el> rule;
498 statements statement {}
500 | statements error { yyerror(""); YYABORT;}
507 | {rt=REQUEST_ROUTE;} route_stm
508 | {rt=FAILURE_ROUTE;} failure_route_stm
509 | {rt=ONREPLY_ROUTE;} onreply_route_stm
510 | {rt=BRANCH_ROUTE;} branch_route_stm
511 | {rt=ONSEND_ROUTE;} send_route_stm
512 | SEMICOLON /* null statement */
513 | CR /* null statement*/
519 LOG(L_CRIT, "ERROR: cfg. parser: bad ip "
523 $$=pkg_malloc(strlen(tmp)+1);
525 LOG(L_CRIT, "ERROR: cfg. parser: out of "
528 strncpy($$, tmp, strlen(tmp)+1);
533 $$=pkg_malloc(strlen($1)+1);
535 LOG(L_CRIT, "ERROR: cfg. parser: out of "
538 strncpy($$, $1, strlen($1)+1);
542 $$=pkg_malloc(strlen($1)+1);
544 LOG(L_CRIT, "ERROR: cfg. parser: out of "
547 strncpy($$, $1, strlen($1)+1);
552 UDP { $$=PROTO_UDP; }
553 | TCP { $$=PROTO_TCP; }
554 | TLS { $$=PROTO_TLS; }
562 listen_id { $$=mk_listen_id($1, 0, 0); }
563 | listen_id COLON port { $$=mk_listen_id($1, 0, $3); }
564 | proto COLON listen_id { $$=mk_listen_id($3, $1, 0); }
565 | proto COLON listen_id COLON port { $$=mk_listen_id($3, $1, $5);}
566 | listen_id COLON error { $$=0; yyerror(" port number expected"); }
569 phostport { $$=$1 ; }
570 | phostport id_lst { $$=$1; $$->next=$2; }
573 flags_decl: FLAGS_DECL flag_list
574 | FLAGS_DECL error { yyerror("flag list expected\n"); }
577 | flag_spec COMMA flag_list
580 flag_spec: flag_name { if (register_flag($1,-1)<0)
581 yyerror("register flag failed");
583 | flag_name COLON NUMBER {
584 if (register_flag($1, $3)<0)
585 yyerror("register flag failed");
589 flag_name: STRING { $$=$1; }
594 AVPFLAGS_DECL avpflag_list
595 | AVPFLAGS_DECL error { yyerror("avpflag list expected\n"); }
599 | avpflag_spec COMMA avpflag_list
603 if (register_avpflag($1)==0)
604 yyerror("cannot declare avpflag");
608 DEBUG_V EQUAL NUMBER { default_core_cfg.debug=$3; }
609 | DEBUG_V EQUAL error { yyerror("number expected"); }
610 | FORK EQUAL NUMBER { dont_fork= ! $3; }
611 | FORK EQUAL error { yyerror("boolean value expected"); }
612 | LOGSTDERROR EQUAL NUMBER { if (!config_check) log_stderr=$3; }
613 | LOGSTDERROR EQUAL error { yyerror("boolean value expected"); }
614 | LOGFACILITY EQUAL ID {
615 if ( (i_tmp=str2facility($3))==-1)
616 yyerror("bad facility (see syslog(3) man page)");
618 default_core_cfg.log_facility=i_tmp;
620 | LOGFACILITY EQUAL error { yyerror("ID expected"); }
621 | DNS EQUAL NUMBER { received_dns|= ($3)?DO_DNS:0; }
622 | DNS EQUAL error { yyerror("boolean value expected"); }
623 | REV_DNS EQUAL NUMBER { received_dns|= ($3)?DO_REV_DNS:0; }
624 | REV_DNS EQUAL error { yyerror("boolean value expected"); }
625 | DNS_TRY_IPV6 EQUAL NUMBER { default_core_cfg.dns_try_ipv6=$3; }
626 | DNS_TRY_IPV6 error { yyerror("boolean value expected"); }
627 | DNS_TRY_NAPTR EQUAL NUMBER { IF_NAPTR(default_core_cfg.dns_try_naptr=$3); }
628 | DNS_TRY_NAPTR error { yyerror("boolean value expected"); }
629 | DNS_SRV_LB EQUAL NUMBER { IF_DNS_FAILOVER(default_core_cfg.dns_srv_lb=$3); }
630 | DNS_SRV_LB error { yyerror("boolean value expected"); }
631 | DNS_UDP_PREF EQUAL NUMBER { IF_NAPTR(default_core_cfg.dns_udp_pref=$3); }
632 | DNS_UDP_PREF error { yyerror("number expected"); }
633 | DNS_TCP_PREF EQUAL NUMBER { IF_NAPTR(default_core_cfg.dns_tcp_pref=$3); }
634 | DNS_TCP_PREF error { yyerror("number expected"); }
635 | DNS_TLS_PREF EQUAL NUMBER { IF_NAPTR(default_core_cfg.dns_tls_pref=$3); }
636 | DNS_TLS_PREF error { yyerror("number expected"); }
637 | DNS_RETR_TIME EQUAL NUMBER { default_core_cfg.dns_retr_time=$3; }
638 | DNS_RETR_TIME error { yyerror("number expected"); }
639 | DNS_RETR_NO EQUAL NUMBER { default_core_cfg.dns_retr_no=$3; }
640 | DNS_RETR_NO error { yyerror("number expected"); }
641 | DNS_SERVERS_NO EQUAL NUMBER { default_core_cfg.dns_servers_no=$3; }
642 | DNS_SERVERS_NO error { yyerror("number expected"); }
643 | DNS_USE_SEARCH EQUAL NUMBER { default_core_cfg.dns_search_list=$3; }
644 | DNS_USE_SEARCH error { yyerror("boolean value expected"); }
645 | DNS_SEARCH_FMATCH EQUAL NUMBER { default_core_cfg.dns_search_fmatch=$3; }
646 | DNS_SEARCH_FMATCH error { yyerror("boolean value expected"); }
647 | DNS_CACHE_INIT EQUAL NUMBER { IF_DNS_CACHE(dns_cache_init=$3); }
648 | DNS_CACHE_INIT error { yyerror("boolean value expected"); }
649 | DNS_USE_CACHE EQUAL NUMBER { IF_DNS_CACHE(default_core_cfg.use_dns_cache=$3); }
650 | DNS_USE_CACHE error { yyerror("boolean value expected"); }
651 | DNS_USE_FAILOVER EQUAL NUMBER { IF_DNS_FAILOVER(default_core_cfg.use_dns_failover=$3);}
652 | DNS_USE_FAILOVER error { yyerror("boolean value expected"); }
653 | DNS_CACHE_FLAGS EQUAL NUMBER { IF_DNS_CACHE(default_core_cfg.dns_cache_flags=$3); }
654 | DNS_CACHE_FLAGS error { yyerror("boolean value expected"); }
655 | DNS_CACHE_NEG_TTL EQUAL NUMBER { IF_DNS_CACHE(default_core_cfg.dns_neg_cache_ttl=$3); }
656 | DNS_CACHE_NEG_TTL error { yyerror("boolean value expected"); }
657 | DNS_CACHE_MAX_TTL EQUAL NUMBER { IF_DNS_CACHE(default_core_cfg.dns_cache_max_ttl=$3); }
658 | DNS_CACHE_MAX_TTL error { yyerror("boolean value expected"); }
659 | DNS_CACHE_MIN_TTL EQUAL NUMBER { IF_DNS_CACHE(default_core_cfg.dns_cache_min_ttl=$3); }
660 | DNS_CACHE_MIN_TTL error { yyerror("boolean value expected"); }
661 | DNS_CACHE_MEM EQUAL NUMBER { IF_DNS_CACHE(default_core_cfg.dns_cache_max_mem=$3); }
662 | DNS_CACHE_MEM error { yyerror("boolean value expected"); }
663 | DNS_CACHE_GC_INT EQUAL NUMBER { IF_DNS_CACHE(dns_timer_interval=$3); }
664 | DNS_CACHE_GC_INT error { yyerror("boolean value expected"); }
665 | DNS_CACHE_DEL_NONEXP EQUAL NUMBER { IF_DNS_CACHE(default_core_cfg.dns_cache_del_nonexp=$3); }
666 | DNS_CACHE_DEL_NONEXP error { yyerror("boolean value expected"); }
667 | DST_BLST_INIT EQUAL NUMBER { IF_DST_BLACKLIST(dst_blacklist_init=$3); }
668 | DST_BLST_INIT error { yyerror("boolean value expected"); }
669 | USE_DST_BLST EQUAL NUMBER { IF_DST_BLACKLIST(default_core_cfg.use_dst_blacklist=$3); }
670 | USE_DST_BLST error { yyerror("boolean value expected"); }
671 | DST_BLST_MEM EQUAL NUMBER { IF_DST_BLACKLIST(default_core_cfg.blst_max_mem=$3); }
672 | DST_BLST_MEM error { yyerror("boolean value expected"); }
673 | DST_BLST_TTL EQUAL NUMBER { IF_DST_BLACKLIST(default_core_cfg.blst_timeout=$3); }
674 | DST_BLST_TTL error { yyerror("boolean value expected"); }
675 | DST_BLST_GC_INT EQUAL NUMBER { IF_DST_BLACKLIST(blst_timer_interval=$3);}
676 | DST_BLST_GC_INT error { yyerror("boolean value expected"); }
677 | PORT EQUAL NUMBER { port_no=$3; }
678 | STAT EQUAL STRING {
683 | MAXBUFFER EQUAL NUMBER { maxbuffer=$3; }
684 | MAXBUFFER EQUAL error { yyerror("number expected"); }
685 | PORT EQUAL error { yyerror("number expected"); }
686 | CHILDREN EQUAL NUMBER { children_no=$3; }
687 | CHILDREN EQUAL error { yyerror("number expected"); }
688 | CHECK_VIA EQUAL NUMBER { check_via=$3; }
689 | CHECK_VIA EQUAL error { yyerror("boolean value expected"); }
690 | PHONE2TEL EQUAL NUMBER { phone2tel=$3; }
691 | PHONE2TEL EQUAL error { yyerror("boolean value expected"); }
692 | SYN_BRANCH EQUAL NUMBER { syn_branch=$3; }
693 | SYN_BRANCH EQUAL error { yyerror("boolean value expected"); }
694 | MEMLOG EQUAL NUMBER { memlog=$3; }
695 | MEMLOG EQUAL error { yyerror("int value expected"); }
696 | MEMDBG EQUAL NUMBER { memdbg=$3; }
697 | MEMDBG EQUAL error { yyerror("int value expected"); }
698 | SIP_WARNING EQUAL NUMBER { sip_warning=$3; }
699 | SIP_WARNING EQUAL error { yyerror("boolean value expected"); }
700 | USER EQUAL STRING { user=$3; }
701 | USER EQUAL ID { user=$3; }
702 | USER EQUAL error { yyerror("string value expected"); }
703 | GROUP EQUAL STRING { group=$3; }
704 | GROUP EQUAL ID { group=$3; }
705 | GROUP EQUAL error { yyerror("string value expected"); }
706 | CHROOT EQUAL STRING { chroot_dir=$3; }
707 | CHROOT EQUAL ID { chroot_dir=$3; }
708 | CHROOT EQUAL error { yyerror("string value expected"); }
709 | WDIR EQUAL STRING { working_dir=$3; }
710 | WDIR EQUAL ID { working_dir=$3; }
711 | WDIR EQUAL error { yyerror("string value expected"); }
712 | MHOMED EQUAL NUMBER { mhomed=$3; }
713 | MHOMED EQUAL error { yyerror("boolean value expected"); }
714 | DISABLE_TCP EQUAL NUMBER {
718 warn("tcp support not compiled in");
721 | DISABLE_TCP EQUAL error { yyerror("boolean value expected"); }
722 | TCP_ACCEPT_ALIASES EQUAL NUMBER {
724 tcp_accept_aliases=$3;
726 warn("tcp support not compiled in");
729 | TCP_ACCEPT_ALIASES EQUAL error { yyerror("boolean value expected"); }
730 | TCP_CHILDREN EQUAL NUMBER {
734 warn("tcp support not compiled in");
737 | TCP_CHILDREN EQUAL error { yyerror("number expected"); }
738 | TCP_CONNECT_TIMEOUT EQUAL NUMBER {
740 tcp_connect_timeout=$3;
742 warn("tcp support not compiled in");
745 | TCP_CONNECT_TIMEOUT EQUAL error { yyerror("number expected"); }
746 | TCP_SEND_TIMEOUT EQUAL NUMBER {
750 warn("tcp support not compiled in");
753 | TCP_SEND_TIMEOUT EQUAL error { yyerror("number expected"); }
754 | TCP_CON_LIFETIME EQUAL NUMBER {
758 warn("tcp support not compiled in");
761 | TCP_CON_LIFETIME EQUAL error { yyerror("number expected"); }
762 | TCP_POLL_METHOD EQUAL ID {
764 tcp_poll_method=get_poll_type($3);
765 if (tcp_poll_method==POLL_NONE) {
766 LOG(L_CRIT, "bad poll method name:"
767 " %s\n, try one of %s.\n",
769 yyerror("bad tcp_poll_method "
773 warn("tcp support not compiled in");
776 | TCP_POLL_METHOD EQUAL STRING {
778 tcp_poll_method=get_poll_type($3);
779 if (tcp_poll_method==POLL_NONE) {
780 LOG(L_CRIT, "bad poll method name:"
781 " %s\n, try one of %s.\n",
783 yyerror("bad tcp_poll_method "
787 warn("tcp support not compiled in");
790 | TCP_POLL_METHOD EQUAL error { yyerror("poll method name expected"); }
791 | TCP_MAX_CONNECTIONS EQUAL NUMBER {
793 tcp_max_connections=$3;
795 warn("tcp support not compiled in");
798 | TCP_MAX_CONNECTIONS EQUAL error { yyerror("number expected"); }
799 | TCP_SOURCE_IPV4 EQUAL ipv4 {
801 if (tcp_set_src_addr($3)<0)
802 warn("tcp_source_ipv4 failed");
804 warn("tcp support not compiled in");
808 | TCP_SOURCE_IPV4 EQUAL error { yyerror("IPv4 address expected"); }
809 | TCP_SOURCE_IPV6 EQUAL ipv6 {
812 if (tcp_set_src_addr($3)<0)
813 warn("tcp_source_ipv6 failed");
815 warn("IPv6 support not compiled in");
818 warn("tcp support not compiled in");
822 | TCP_SOURCE_IPV6 EQUAL error { yyerror("IPv6 address expected"); }
823 | TCP_OPT_FD_CACHE EQUAL NUMBER {
825 tcp_options.fd_cache=$3;
827 warn("tcp support not compiled in");
830 | TCP_OPT_FD_CACHE EQUAL error { yyerror("boolean value expected"); }
831 | TCP_OPT_BUF_WRITE EQUAL NUMBER {
833 tcp_options.tcp_buf_write=$3;
835 warn("tcp support not compiled in");
838 | TCP_OPT_BUF_WRITE EQUAL error { yyerror("boolean value expected"); }
839 | TCP_OPT_CONN_WQ_MAX EQUAL NUMBER {
841 tcp_options.tcpconn_wq_max=$3;
843 warn("tcp support not compiled in");
846 | TCP_OPT_CONN_WQ_MAX error { yyerror("boolean value expected"); }
847 | TCP_OPT_WQ_MAX EQUAL NUMBER {
849 tcp_options.tcp_wq_max=$3;
851 warn("tcp support not compiled in");
854 | TCP_OPT_WQ_MAX error { yyerror("boolean value expected"); }
855 | TCP_OPT_DEFER_ACCEPT EQUAL NUMBER {
857 tcp_options.defer_accept=$3;
859 warn("tcp support not compiled in");
862 | TCP_OPT_DEFER_ACCEPT EQUAL error { yyerror("boolean value expected"); }
863 | TCP_OPT_DELAYED_ACK EQUAL NUMBER {
865 tcp_options.delayed_ack=$3;
867 warn("tcp support not compiled in");
870 | TCP_OPT_DELAYED_ACK EQUAL error { yyerror("boolean value expected"); }
871 | TCP_OPT_SYNCNT EQUAL NUMBER {
873 tcp_options.syncnt=$3;
875 warn("tcp support not compiled in");
878 | TCP_OPT_SYNCNT EQUAL error { yyerror("number expected"); }
879 | TCP_OPT_LINGER2 EQUAL NUMBER {
881 tcp_options.linger2=$3;
883 warn("tcp support not compiled in");
886 | TCP_OPT_LINGER2 EQUAL error { yyerror("number expected"); }
887 | TCP_OPT_KEEPALIVE EQUAL NUMBER {
889 tcp_options.keepalive=$3;
891 warn("tcp support not compiled in");
894 | TCP_OPT_KEEPALIVE EQUAL error { yyerror("boolean value expected");}
895 | TCP_OPT_KEEPIDLE EQUAL NUMBER {
897 tcp_options.keepidle=$3;
899 warn("tcp support not compiled in");
902 | TCP_OPT_KEEPIDLE EQUAL error { yyerror("number expected"); }
903 | TCP_OPT_KEEPINTVL EQUAL NUMBER {
905 tcp_options.keepintvl=$3;
907 warn("tcp support not compiled in");
910 | TCP_OPT_KEEPINTVL EQUAL error { yyerror("number expected"); }
911 | TCP_OPT_KEEPCNT EQUAL NUMBER {
913 tcp_options.keepcnt=$3;
915 warn("tcp support not compiled in");
918 | TCP_OPT_KEEPCNT EQUAL error { yyerror("number expected"); }
919 | TCP_OPT_CRLF_PING EQUAL NUMBER {
921 tcp_options.crlf_ping=$3;
923 warn("tcp support not compiled in");
926 | TCP_OPT_CRLF_PING EQUAL error { yyerror("boolean value expected"); }
927 | DISABLE_TLS EQUAL NUMBER {
931 warn("tls support not compiled in");
934 | DISABLE_TLS EQUAL error { yyerror("boolean value expected"); }
935 | ENABLE_TLS EQUAL NUMBER {
939 warn("tls support not compiled in");
942 | ENABLE_TLS EQUAL error { yyerror("boolean value expected"); }
943 | TLSLOG EQUAL NUMBER {
947 warn("tls-in-core support not compiled in");
950 | TLSLOG EQUAL error { yyerror("int value expected"); }
951 | TLS_PORT_NO EQUAL NUMBER {
955 warn("tls support not compiled in");
958 | TLS_PORT_NO EQUAL error { yyerror("number expected"); }
959 | TLS_METHOD EQUAL SSLv23 {
961 tls_method=TLS_USE_SSLv23;
963 warn("tls-in-core support not compiled in");
966 | TLS_METHOD EQUAL SSLv2 {
968 tls_method=TLS_USE_SSLv2;
970 warn("tls-in-core support not compiled in");
973 | TLS_METHOD EQUAL SSLv3 {
975 tls_method=TLS_USE_SSLv3;
977 warn("tls-in-core support not compiled in");
980 | TLS_METHOD EQUAL TLSv1 {
982 tls_method=TLS_USE_TLSv1;
984 warn("tls-in-core support not compiled in");
987 | TLS_METHOD EQUAL error {
989 yyerror("SSLv23, SSLv2, SSLv3 or TLSv1 expected");
991 warn("tls-in-core support not compiled in");
994 | TLS_VERIFY EQUAL NUMBER {
998 warn("tls-in-core support not compiled in");
1001 | TLS_VERIFY EQUAL error { yyerror("boolean value expected"); }
1002 | TLS_REQUIRE_CERTIFICATE EQUAL NUMBER {
1004 tls_require_cert=$3;
1006 warn( "tls-in-core support not compiled in");
1009 | TLS_REQUIRE_CERTIFICATE EQUAL error { yyerror("boolean value expected"); }
1010 | TLS_CERTIFICATE EQUAL STRING {
1014 warn("tls-in-core support not compiled in");
1017 | TLS_CERTIFICATE EQUAL error { yyerror("string value expected"); }
1018 | TLS_PRIVATE_KEY EQUAL STRING {
1022 warn("tls-in-core support not compiled in");
1025 | TLS_PRIVATE_KEY EQUAL error { yyerror("string value expected"); }
1026 | TLS_CA_LIST EQUAL STRING {
1030 warn("tls-in-core support not compiled in");
1033 | TLS_CA_LIST EQUAL error { yyerror("string value expected"); }
1034 | TLS_HANDSHAKE_TIMEOUT EQUAL NUMBER {
1036 tls_handshake_timeout=$3;
1038 warn("tls-in-core support not compiled in");
1041 | TLS_HANDSHAKE_TIMEOUT EQUAL error { yyerror("number expected"); }
1042 | TLS_SEND_TIMEOUT EQUAL NUMBER {
1044 tls_send_timeout=$3;
1046 warn("tls-in-core support not compiled in");
1049 | TLS_SEND_TIMEOUT EQUAL error { yyerror("number expected"); }
1050 | DISABLE_SCTP EQUAL NUMBER {
1054 warn("sctp support not compiled in");
1057 | DISABLE_SCTP EQUAL error { yyerror("boolean value expected"); }
1058 | SCTP_CHILDREN EQUAL NUMBER {
1060 sctp_children_no=$3;
1062 warn("sctp support not compiled in");
1065 | SCTP_CHILDREN EQUAL error { yyerror("number expected"); }
1066 | SCTP_SOCKET_RCVBUF EQUAL NUMBER {
1068 sctp_options.sctp_so_rcvbuf=$3;
1070 warn("sctp support not compiled in");
1073 | SCTP_SOCKET_RCVBUF EQUAL error { yyerror("number expected"); }
1074 | SCTP_SOCKET_SNDBUF EQUAL NUMBER {
1076 sctp_options.sctp_so_sndbuf=$3;
1078 warn("sctp support not compiled in");
1081 | SCTP_SOCKET_SNDBUF EQUAL error { yyerror("number expected"); }
1082 | SCTP_AUTOCLOSE EQUAL NUMBER {
1084 sctp_options.sctp_autoclose=$3;
1086 warn("sctp support not compiled in");
1089 | SCTP_AUTOCLOSE EQUAL error { yyerror("number expected"); }
1090 | SCTP_SEND_TTL EQUAL NUMBER {
1092 sctp_options.sctp_send_ttl=$3;
1094 warn("sctp support not compiled in");
1097 | SCTP_SEND_TTL EQUAL error { yyerror("number expected"); }
1098 | SERVER_SIGNATURE EQUAL NUMBER { server_signature=$3; }
1099 | SERVER_SIGNATURE EQUAL error { yyerror("boolean value expected"); }
1100 | REPLY_TO_VIA EQUAL NUMBER { reply_to_via=$3; }
1101 | REPLY_TO_VIA EQUAL error { yyerror("boolean value expected"); }
1102 | LISTEN EQUAL id_lst {
1103 for(lst_tmp=$3; lst_tmp; lst_tmp=lst_tmp->next) {
1104 if (add_listen_iface(lst_tmp->name, lst_tmp->port, lst_tmp->proto, 0)!=0) {
1105 LOG(L_CRIT, "ERROR: cfg. parser: failed to add listen address\n");
1110 | LISTEN EQUAL error { yyerror("ip address or hostname expected"); }
1111 | ALIAS EQUAL id_lst {
1112 for(lst_tmp=$3; lst_tmp; lst_tmp=lst_tmp->next)
1113 add_alias(lst_tmp->name, strlen(lst_tmp->name), lst_tmp->port, lst_tmp->proto);
1115 | ALIAS EQUAL error { yyerror(" hostname expected"); }
1116 | ADVERTISED_ADDRESS EQUAL listen_id {
1117 default_global_address.s=$3;
1118 default_global_address.len=strlen($3);
1120 | ADVERTISED_ADDRESS EQUAL error {yyerror("ip address or hostname expected"); }
1121 | ADVERTISED_PORT EQUAL NUMBER {
1122 tmp=int2str($3, &i_tmp);
1123 if ((default_global_port.s=pkg_malloc(i_tmp))==0) {
1124 LOG(L_CRIT, "ERROR: cfg. parser: out of memory.\n");
1125 default_global_port.len=0;
1127 default_global_port.len=i_tmp;
1128 memcpy(default_global_port.s, tmp, default_global_port.len);
1131 |ADVERTISED_PORT EQUAL error {yyerror("ip address or hostname expected"); }
1132 | DISABLE_CORE EQUAL NUMBER { disable_core_dump=$3; }
1133 | DISABLE_CORE EQUAL error { yyerror("boolean value expected"); }
1134 | OPEN_FD_LIMIT EQUAL NUMBER { open_files_limit=$3; }
1135 | OPEN_FD_LIMIT EQUAL error { yyerror("number expected"); }
1136 | SHM_FORCE_ALLOC EQUAL NUMBER { shm_force_alloc=$3; }
1137 | SHM_FORCE_ALLOC EQUAL error { yyerror("boolean value expected"); }
1138 | MLOCK_PAGES EQUAL NUMBER { mlock_pages=$3; }
1139 | MLOCK_PAGES EQUAL error { yyerror("boolean value expected"); }
1140 | REAL_TIME EQUAL NUMBER { real_time=$3; }
1141 | REAL_TIME EQUAL error { yyerror("boolean value expected"); }
1142 | RT_PRIO EQUAL NUMBER { rt_prio=$3; }
1143 | RT_PRIO EQUAL error { yyerror("boolean value expected"); }
1144 | RT_POLICY EQUAL NUMBER { rt_policy=$3; }
1145 | RT_POLICY EQUAL error { yyerror("boolean value expected"); }
1146 | RT_TIMER1_PRIO EQUAL NUMBER { rt_timer1_prio=$3; }
1147 | RT_TIMER1_PRIO EQUAL error { yyerror("boolean value expected"); }
1148 | RT_TIMER1_POLICY EQUAL NUMBER { rt_timer1_policy=$3; }
1149 | RT_TIMER1_POLICY EQUAL error { yyerror("boolean value expected"); }
1150 | RT_TIMER2_PRIO EQUAL NUMBER { rt_timer2_prio=$3; }
1151 | RT_TIMER2_PRIO EQUAL error { yyerror("boolean value expected"); }
1152 | RT_TIMER2_POLICY EQUAL NUMBER { rt_timer2_policy=$3; }
1153 | RT_TIMER2_POLICY EQUAL error { yyerror("boolean value expected"); }
1154 | MCAST_LOOPBACK EQUAL NUMBER {
1158 warn("no multicast support compiled in");
1161 | MCAST_LOOPBACK EQUAL error { yyerror("boolean value expected"); }
1162 | MCAST_TTL EQUAL NUMBER {
1166 warn("no multicast support compiled in");
1169 | MCAST_TTL EQUAL error { yyerror("number expected"); }
1170 | TOS EQUAL NUMBER { tos=$3; }
1171 | TOS EQUAL error { yyerror("number expected"); }
1172 | PMTU_DISCOVERY EQUAL NUMBER { pmtu_discovery=$3; }
1173 | PMTU_DISCOVERY error { yyerror("number expected"); }
1174 | KILL_TIMEOUT EQUAL NUMBER { ser_kill_timeout=$3; }
1175 | KILL_TIMEOUT EQUAL error { yyerror("number expected"); }
1176 | STUN_REFRESH_INTERVAL EQUAL NUMBER { IF_STUN(stun_refresh_interval=$3); }
1177 | STUN_REFRESH_INTERVAL EQUAL error{ yyerror("number expected"); }
1178 | STUN_ALLOW_STUN EQUAL NUMBER { IF_STUN(stun_allow_stun=$3); }
1179 | STUN_ALLOW_STUN EQUAL error{ yyerror("number expected"); }
1180 | STUN_ALLOW_FP EQUAL NUMBER { IF_STUN(stun_allow_fp=$3) ; }
1181 | STUN_ALLOW_FP EQUAL error{ yyerror("number expected"); }
1182 | SERVER_ID EQUAL NUMBER { server_id=$3; }
1184 | error EQUAL { yyerror("unknown config variable"); }
1187 ID DOT ID EQUAL NUMBER {
1188 if (cfg_declare_int($1, $3, $5, 0, 0, NULL)) {
1189 yyerror("variable cannot be declared");
1192 | ID DOT ID EQUAL STRING {
1193 if (cfg_declare_str($1, $3, $5, NULL)) {
1194 yyerror("variable cannot be declared");
1197 | ID DOT ID EQUAL NUMBER CFG_DESCRIPTION STRING {
1198 if (cfg_declare_int($1, $3, $5, 0, 0, $7)) {
1199 yyerror("variable cannot be declared");
1202 | ID DOT ID EQUAL STRING CFG_DESCRIPTION STRING {
1203 if (cfg_declare_str($1, $3, $5, $7)) {
1204 yyerror("variable cannot be declared");
1207 | ID DOT ID EQUAL error { yyerror("number or string expected"); }
1211 DBG("loading module %s\n", $2);
1212 if (load_module($2)!=0) {
1213 yyerror("failed to load module");
1216 | LOADMODULE error { yyerror("string expected"); }
1218 DBG("loading modules under %s\n", $2);
1219 printf("loading modules under %s\n", $2);
1222 | LOADPATH error { yyerror("string expected"); }
1223 | MODPARAM LPAREN STRING COMMA STRING COMMA STRING RPAREN {
1224 if (set_mod_param_regex($3, $5, PARAM_STRING, $7) != 0) {
1225 yyerror("Can't set module parameter");
1228 | MODPARAM LPAREN STRING COMMA STRING COMMA NUMBER RPAREN {
1229 if (set_mod_param_regex($3, $5, PARAM_INT, (void*)$7) != 0) {
1230 yyerror("Can't set module parameter");
1233 | MODPARAM error { yyerror("Invalid arguments"); }
1240 NUMBER DOT NUMBER DOT NUMBER DOT NUMBER {
1241 $$=pkg_malloc(sizeof(struct ip_addr));
1243 LOG(L_CRIT, "ERROR: cfg. parser: out of memory.\n");
1245 memset($$, 0, sizeof(struct ip_addr));
1248 if (($1>255) || ($1<0) ||
1249 ($3>255) || ($3<0) ||
1250 ($5>255) || ($5<0) ||
1251 ($7>255) || ($7<0)) {
1252 yyerror("invalid ipv4 address");
1262 ($3<<16)| ($5<<8)|$7 );
1270 $$=pkg_malloc(sizeof(struct ip_addr));
1272 LOG(L_CRIT, "ERROR: cfg. parser: out of memory.\n");
1275 memset($$, 0, sizeof(struct ip_addr));
1278 if (inet_pton(AF_INET6, $1, $$->u.addr)<=0) {
1279 yyerror("bad ipv6 address");
1282 yyerror("ipv6 address & no ipv6 support compiled in");
1290 | LBRACK ipv6addr RBRACK {$$=$2; }
1294 route_name: NUMBER {
1295 tmp=int2str($1, &i_tmp);
1296 if (($$=pkg_malloc(i_tmp+1))==0) {
1297 yyerror("out of memory");
1300 memcpy($$, tmp, i_tmp);
1309 ROUTE LBRACE actions RBRACE { push($3, &main_rt.rlist[DEFAULT_RT]); }
1310 | ROUTE LBRACK route_name RBRACK LBRACE actions RBRACE {
1311 i_tmp=route_get(&main_rt, $3);
1313 yyerror("internal error");
1316 if (main_rt.rlist[i_tmp]){
1317 yyerror("duplicate route");
1320 push($6, &main_rt.rlist[i_tmp]);
1322 | ROUTE error { yyerror("invalid route statement"); }
1325 ROUTE_FAILURE LBRACE actions RBRACE {
1326 push($3, &failure_rt.rlist[DEFAULT_RT]);
1328 | ROUTE_FAILURE LBRACK route_name RBRACK LBRACE actions RBRACE {
1329 i_tmp=route_get(&failure_rt, $3);
1331 yyerror("internal error");
1334 if (failure_rt.rlist[i_tmp]){
1335 yyerror("duplicate route");
1338 push($6, &failure_rt.rlist[i_tmp]);
1340 | ROUTE_FAILURE error { yyerror("invalid failure_route statement"); }
1343 ROUTE_ONREPLY LBRACE actions RBRACE {
1344 push($3, &onreply_rt.rlist[DEFAULT_RT]);
1346 | ROUTE_ONREPLY LBRACK route_name RBRACK LBRACE actions RBRACE {
1347 i_tmp=route_get(&onreply_rt, $3);
1349 yyerror("internal error");
1352 if (onreply_rt.rlist[i_tmp]){
1353 yyerror("duplicate route");
1356 push($6, &onreply_rt.rlist[i_tmp]);
1358 | ROUTE_ONREPLY error { yyerror("invalid onreply_route statement"); }
1361 ROUTE_BRANCH LBRACE actions RBRACE {
1362 push($3, &branch_rt.rlist[DEFAULT_RT]);
1364 | ROUTE_BRANCH LBRACK route_name RBRACK LBRACE actions RBRACE {
1365 i_tmp=route_get(&branch_rt, $3);
1367 yyerror("internal error");
1370 if (branch_rt.rlist[i_tmp]){
1371 yyerror("duplicate route");
1374 push($6, &branch_rt.rlist[i_tmp]);
1376 | ROUTE_BRANCH error { yyerror("invalid branch_route statement"); }
1378 send_route_stm: ROUTE_SEND LBRACE actions RBRACE {
1379 push($3, &onsend_rt.rlist[DEFAULT_RT]);
1381 | ROUTE_SEND LBRACK route_name RBRACK LBRACE actions RBRACE {
1382 i_tmp=route_get(&onsend_rt, $3);
1384 yyerror("internal error");
1387 if (onsend_rt.rlist[i_tmp]){
1388 yyerror("duplicate route");
1391 push($6, &onsend_rt.rlist[i_tmp]);
1393 | ROUTE_SEND error { yyerror("invalid onsend_route statement"); }
1397 rules rule { push($2, &$1); $$=$1; }
1399 | rules error { $$=0; yyerror("invalid rule"); }
1402 condition actions CR {
1404 if (add_rule($1, $2, &$$)<0) {
1405 yyerror("error calling add_rule");
1410 | condition error { $$=0; yyerror("bad actions in rule"); }
1415 exp: exp LOG_AND exp { $$=mk_exp(LOGAND_OP, $1, $3); }
1416 | exp LOG_OR exp { $$=mk_exp(LOGOR_OP, $1, $3); }
1417 | NOT exp { $$=mk_exp(NOT_OP, $2, 0); }
1418 | LPAREN exp RPAREN { $$=$2; }
1419 | exp_elem { $$=$1; }
1422 EQUAL_T {$$=EQUAL_OP; }
1423 | DIFF {$$=DIFF_OP; }
1425 intop: equalop {$$=$1; }
1432 BIN_OR { $$= BINOR_OP; }
1433 | BIN_AND { $$ = BINAND_OP; }
1437 | MATCH {$$=MATCH_OP; }
1441 | FROM_URI {$$=FROM_URI_O;}
1442 | TO_URI {$$=TO_URI_O;}
1446 METHOD strop STRING {$$= mk_elem($2, METHOD_O, 0, STRING_ST, $3);}
1447 | METHOD strop attr_id_val {$$ = mk_elem($2, METHOD_O, 0, AVP_ST, $3); }
1448 | METHOD strop select_id {$$ = mk_elem($2, METHOD_O, 0, SELECT_ST, $3); }
1449 | METHOD strop ID {$$ = mk_elem($2, METHOD_O, 0, STRING_ST,$3); }
1450 | METHOD strop error { $$=0; yyerror("string expected"); }
1451 | METHOD error { $$=0; yyerror("invalid operator,== , !=, or =~ expected"); }
1452 | uri_type strop STRING {$$ = mk_elem($2, $1, 0, STRING_ST, $3); }
1453 | uri_type strop host {$$ = mk_elem($2, $1, 0, STRING_ST, $3); }
1454 | uri_type strop attr_id_val {$$ = mk_elem($2, $1, 0, AVP_ST, $3); }
1455 | uri_type strop select_id {$$ = mk_elem($2, $1, 0, SELECT_ST, $3); }
1456 | uri_type equalop MYSELF {$$=mk_elem($2, $1, 0, MYSELF_ST, 0); }
1457 | uri_type strop error { $$=0; yyerror("string or MYSELF expected"); }
1458 | uri_type error { $$=0; yyerror("invalid operator, == , != or =~ expected"); }
1460 | SRCPORT intop NUMBER { $$=mk_elem($2, SRCPORT_O, 0, NUMBER_ST, (void*)$3 ); }
1461 | SRCPORT intop attr_id_val { $$=mk_elem($2, SRCPORT_O, 0, AVP_ST, (void*)$3 ); }
1462 | SRCPORT intop error { $$=0; yyerror("number expected"); }
1463 | SRCPORT error { $$=0; yyerror("==, !=, <,>, >= or <= expected"); }
1465 | DSTPORT intop NUMBER { $$=mk_elem($2, DSTPORT_O, 0, NUMBER_ST, (void*)$3 ); }
1466 | DSTPORT intop attr_id_val { $$=mk_elem($2, DSTPORT_O, 0, AVP_ST, (void*)$3 ); }
1467 | DSTPORT intop error { $$=0; yyerror("number expected"); }
1468 | DSTPORT error { $$=0; yyerror("==, !=, <,>, >= or <= expected"); }
1470 | SNDPORT intop NUMBER {
1471 onsend_check("snd_port");
1472 $$=mk_elem($2, SNDPORT_O, 0, NUMBER_ST, (void*)$3 );
1474 | SNDPORT intop attr_id_val {
1475 onsend_check("snd_port");
1476 $$=mk_elem($2, SNDPORT_O, 0, AVP_ST, (void*)$3 );
1478 | SNDPORT intop error { $$=0; yyerror("number expected"); }
1479 | SNDPORT error { $$=0; yyerror("==, !=, <,>, >= or <= expected"); }
1481 | TOPORT intop NUMBER {
1482 onsend_check("to_port");
1483 $$=mk_elem($2, TOPORT_O, 0, NUMBER_ST, (void*)$3 );
1485 | TOPORT intop attr_id_val {
1486 onsend_check("to_port");
1487 $$=mk_elem($2, TOPORT_O, 0, AVP_ST, (void*)$3 );
1489 | TOPORT intop error { $$=0; yyerror("number expected"); }
1490 | TOPORT error { $$=0; yyerror("==, !=, <,>, >= or <= expected"); }
1492 | PROTO intop proto { $$=mk_elem($2, PROTO_O, 0, NUMBER_ST, (void*)$3 ); }
1493 | PROTO intop attr_id_val { $$=mk_elem($2, PROTO_O, 0, AVP_ST, (void*)$3 ); }
1494 | PROTO intop error { $$=0; yyerror("protocol expected (udp, tcp or tls)"); }
1496 | PROTO error { $$=0; yyerror("equal/!= operator expected"); }
1498 | SNDPROTO intop proto {
1499 onsend_check("snd_proto");
1500 $$=mk_elem($2, SNDPROTO_O, 0, NUMBER_ST, (void*)$3 );
1502 | SNDPROTO intop attr_id_val {
1503 onsend_check("snd_proto");
1504 $$=mk_elem($2, SNDPROTO_O, 0, AVP_ST, (void*)$3 );
1506 | SNDPROTO intop error { $$=0; yyerror("protocol expected (udp, tcp or tls)"); }
1507 | SNDPROTO error { $$=0; yyerror("equal/!= operator expected"); }
1509 | AF intop NUMBER { $$=mk_elem($2, AF_O, 0, NUMBER_ST,(void *) $3 ); }
1510 | AF intop attr_id_val { $$=mk_elem($2, AF_O, 0, AVP_ST,(void *) $3 ); }
1511 | AF intop error { $$=0; yyerror("number expected"); }
1512 | AF error { $$=0; yyerror("equal/!= operator expected"); }
1514 | SNDAF intop NUMBER {
1515 onsend_check("snd_af");
1516 $$=mk_elem($2, SNDAF_O, 0, NUMBER_ST, (void *) $3 ); }
1517 | SNDAF intop attr_id_val {
1518 onsend_check("snd_af");
1519 $$=mk_elem($2, SNDAF_O, 0, AVP_ST, (void *) $3 );
1521 | SNDAF intop error { $$=0; yyerror("number expected"); }
1522 | SNDAF error { $$=0; yyerror("equal/!= operator expected"); }
1524 | MSGLEN intop NUMBER { $$=mk_elem($2, MSGLEN_O, 0, NUMBER_ST, (void *) $3 ); }
1525 | MSGLEN intop attr_id_val { $$=mk_elem($2, MSGLEN_O, 0, AVP_ST, (void *) $3 ); }
1526 | MSGLEN intop MAX_LEN { $$=mk_elem($2, MSGLEN_O, 0, NUMBER_ST, (void *) BUF_SIZE); }
1527 | MSGLEN intop error { $$=0; yyerror("number expected"); }
1528 | MSGLEN error { $$=0; yyerror("equal/!= operator expected"); }
1530 | RETCODE intop NUMBER { $$=mk_elem($2, RETCODE_O, 0, NUMBER_ST, (void *) $3 ); }
1531 | RETCODE intop attr_id_val { $$=mk_elem($2, RETCODE_O, 0, AVP_ST, (void *) $3 ); }
1532 | RETCODE intop error { $$=0; yyerror("number expected"); }
1533 | RETCODE error { $$=0; yyerror("equal/!= operator expected"); }
1535 | SRCIP equalop ipnet { $$=mk_elem($2, SRCIP_O, 0, NET_ST, $3); }
1536 | SRCIP strop STRING {
1538 s_tmp.len=strlen($3);
1539 ip_tmp=str2ip(&s_tmp);
1542 ip_tmp=str2ip6(&s_tmp);
1545 $$=mk_elem($2, SRCIP_O, 0, NET_ST, mk_net_bitlen(ip_tmp, ip_tmp->len*8) );
1547 $$=mk_elem($2, SRCIP_O, 0, STRING_ST, $3);
1550 | SRCIP strop host { $$=mk_elem($2, SRCIP_O, 0, STRING_ST, $3); }
1551 | SRCIP equalop MYSELF { $$=mk_elem($2, SRCIP_O, 0, MYSELF_ST, 0);
1553 | SRCIP strop error { $$=0; yyerror( "ip address or hostname expected" ); }
1554 | SRCIP error { $$=0; yyerror("invalid operator, ==, != or =~ expected");}
1555 | DSTIP equalop ipnet { $$=mk_elem( $2, DSTIP_O, 0, NET_ST, (void*)$3); }
1556 | DSTIP strop STRING {
1558 s_tmp.len=strlen($3);
1559 ip_tmp=str2ip(&s_tmp);
1562 ip_tmp=str2ip6(&s_tmp);
1563 #endif /* USE_IPV6 */
1565 $$=mk_elem($2, DSTIP_O, 0, NET_ST, mk_net_bitlen(ip_tmp, ip_tmp->len*8) );
1567 $$=mk_elem($2, DSTIP_O, 0, STRING_ST, $3);
1570 | DSTIP strop host { $$=mk_elem( $2, DSTIP_O, 0, STRING_ST, $3); }
1571 | DSTIP equalop MYSELF { $$=mk_elem( $2, DSTIP_O, 0, MYSELF_ST, 0); }
1572 | DSTIP strop error { $$=0; yyerror( "ip address or hostname expected" ); }
1573 | DSTIP error { $$=0; yyerror("invalid operator, ==, != or =~ expected"); }
1574 | SNDIP equalop ipnet {
1575 onsend_check("snd_ip");
1576 $$=mk_elem($2, SNDIP_O, 0, NET_ST, $3);
1578 | SNDIP strop STRING {
1579 onsend_check("snd_ip");
1581 s_tmp.len=strlen($3);
1582 ip_tmp=str2ip(&s_tmp);
1585 ip_tmp=str2ip6(&s_tmp);
1586 #endif /* USE_IPV6 */
1588 $$=mk_elem($2, SNDIP_O, 0, NET_ST, mk_net_bitlen(ip_tmp, ip_tmp->len*8) );
1590 $$=mk_elem($2, SNDIP_O, 0, STRING_ST, $3);
1593 | SNDIP strop host {
1594 onsend_check("snd_ip");
1595 $$=mk_elem($2, SNDIP_O, 0, STRING_ST, $3);
1597 | SNDIP equalop attr_id_val {
1598 onsend_check("snd_ip");
1599 $$=mk_elem($2, SNDIP_O, 0, AVP_ST, (void*)$3 );
1601 | SNDIP equalop MYSELF {
1602 onsend_check("snd_ip");
1603 $$=mk_elem($2, SNDIP_O, 0, MYSELF_ST, 0);
1605 | SNDIP strop error { $$=0; yyerror( "ip address or hostname expected" ); }
1606 | SNDIP error { $$=0; yyerror("invalid operator, ==, != or =~ expected"); }
1607 | TOIP equalop ipnet {
1608 onsend_check("to_ip");
1609 $$=mk_elem($2, TOIP_O, 0, NET_ST, $3);
1611 | TOIP strop STRING {
1612 onsend_check("to_ip");
1614 s_tmp.len=strlen($3);
1615 ip_tmp=str2ip(&s_tmp);
1618 ip_tmp=str2ip6(&s_tmp);
1619 #endif /* USE_IPV6 */
1621 $$=mk_elem($2, TOIP_O, 0, NET_ST, mk_net_bitlen(ip_tmp, ip_tmp->len*8) );
1623 $$=mk_elem($2, TOIP_O, 0, STRING_ST, $3);
1627 onsend_check("to_ip");
1628 $$=mk_elem($2, TOIP_O, 0, STRING_ST, $3);
1630 | TOIP equalop attr_id_val {
1631 onsend_check("to_ip");
1632 $$=mk_elem($2, TOIP_O, 0, AVP_ST, (void*)$3 );
1634 | TOIP equalop MYSELF {
1635 onsend_check("to_ip");
1636 $$=mk_elem($2, TOIP_O, 0, MYSELF_ST, 0);
1638 | TOIP strop error { $$=0; yyerror( "ip address or hostname expected" ); }
1639 | TOIP error { $$=0; yyerror("invalid operator, ==, != or =~ expected"); }
1641 | MYSELF equalop uri_type { $$=mk_elem($2, $3, 0, MYSELF_ST, 0); }
1642 | MYSELF equalop SRCIP { $$=mk_elem($2, SRCIP_O, 0, MYSELF_ST, 0); }
1643 | MYSELF equalop DSTIP { $$=mk_elem($2, DSTIP_O, 0, MYSELF_ST, 0); }
1644 | MYSELF equalop SNDIP {
1645 onsend_check("snd_ip");
1646 $$=mk_elem($2, SNDIP_O, 0, MYSELF_ST, 0);
1648 | MYSELF equalop TOIP {
1649 onsend_check("to_ip");
1650 $$=mk_elem($2, TOIP_O, 0, MYSELF_ST, 0);
1652 | MYSELF equalop error { $$=0; yyerror(" URI, SRCIP or DSTIP expected"); }
1653 | MYSELF error { $$=0; yyerror ("invalid operator, == or != expected"); }
1654 | exp_stm { $$=mk_elem( NO_OP, ACTION_O, 0, ACTIONS_ST, $1); }
1655 | NUMBER { $$=mk_elem( NO_OP, NUMBER_O, 0, NUMBER_ST, (void*)$1 ); }
1657 | attr_id_any {$$=mk_elem( NO_OP, AVP_O, (void*)$1, 0, 0); }
1658 | attr_id_val strop STRING {$$=mk_elem( $2, AVP_O, (void*)$1, STRING_ST, $3); }
1659 | attr_id_val strop select_id {$$=mk_elem( $2, AVP_O, (void*)$1, SELECT_ST, $3); }
1660 | attr_id_val intop NUMBER {$$=mk_elem( $2, AVP_O, (void*)$1, NUMBER_ST, (void*)$3); }
1661 | attr_id_val binop NUMBER {$$=mk_elem( $2, AVP_O, (void*)$1, NUMBER_ST, (void*)$3); }
1662 | attr_id_val strop attr_id_val {$$=mk_elem( $2, AVP_O, (void*)$1, AVP_ST, (void*)$3); }
1663 | attr_id_val intop attr_id_val {$$=mk_elem( $2, AVP_O, (void*)$1, AVP_ST, (void*)$3); }
1665 | select_id { $$=mk_elem( NO_OP, SELECT_O, $1, 0, 0); }
1666 | select_id strop STRING { $$=mk_elem( $2, SELECT_O, $1, STRING_ST, $3); }
1667 | select_id strop attr_id_val { $$=mk_elem( $2, SELECT_O, $1, AVP_ST, (void*)$3); }
1668 | select_id strop select_id { $$=mk_elem( $2, SELECT_O, $1, SELECT_ST, $3); }
1671 ip SLASH ip { $$=mk_net($1, $3); }
1673 if (($3<0) || ($3>$1->len*8)) {
1674 yyerror("invalid bit number in netmask");
1677 $$=mk_net_bitlen($1, $3);
1679 $$=mk_net($1, htonl( ($3)?~( (1<<(32-$3))-1 ):0 ) );
1683 | ip { $$=mk_net_bitlen($1, $1->len*8); }
1684 | ip SLASH error { $$=0; yyerror("netmask (eg:255.0.0.0 or 8) expected"); }
1693 | host host_sep ID {
1694 $$=(char*)pkg_malloc(strlen($1)+1+strlen($3)+1);
1696 LOG(L_CRIT, "ERROR: cfg. parser: memory allocation failure while parsing host\n");
1698 memcpy($$, $1, strlen($1));
1700 memcpy($$+strlen($1)+1, $3, strlen($3));
1701 $$[strlen($1)+1+strlen($3)]=0;
1706 | host DOT error { $$=0; pkg_free($1); yyerror("invalid hostname"); }
1711 /* check if allowed */
1712 if ($1 && rt==ONSEND_ROUTE) {
1727 yyerror("command not allowed in onsend_route\n");
1737 | assign_action { $$ = $1; }
1738 | LBRACE actions RBRACE { $$=$2; }
1742 | LBRACE actions RBRACE { $$=$2; }
1745 actions action {$$=append_action($1, $2); }
1747 | actions error { $$=0; yyerror("bad command"); }
1750 fcmd SEMICOLON {$$=$1;}
1752 | assign_action SEMICOLON {$$=$1;}
1753 | SEMICOLON /* null action */ {$$=0;}
1754 | fcmd error { $$=0; yyerror("bad command: missing ';'?"); }
1757 IF exp stm { $$=mk_action( IF_T, 3, EXPR_ST, $2, ACTIONS_ST, $3, NOSUBTYPE, 0); }
1758 | IF exp stm ELSE stm { $$=mk_action( IF_T, 3, EXPR_ST, $2, ACTIONS_ST, $3, ACTIONS_ST, $5); }
1761 LBRACK ATTR_USER RBRACK { $$ = AVP_CLASS_USER; }
1762 | LBRACK ATTR_DOMAIN RBRACK { $$ = AVP_CLASS_DOMAIN; }
1763 | LBRACK ATTR_GLOBAL RBRACK { $$ = AVP_CLASS_GLOBAL; }
1768 if (sel.n >= MAX_SELECT_PARAMS-1) {
1769 yyerror("Select identifier too long\n");
1771 sel.params[sel.n].type = SEL_PARAM_STR;
1772 sel.params[sel.n].v.s.s = $1;
1773 sel.params[sel.n].v.s.len = strlen($1);
1776 | ID LBRACK NUMBER RBRACK {
1777 if (sel.n >= MAX_SELECT_PARAMS-2) {
1778 yyerror("Select identifier too long\n");
1780 sel.params[sel.n].type = SEL_PARAM_STR;
1781 sel.params[sel.n].v.s.s = $1;
1782 sel.params[sel.n].v.s.len = strlen($1);
1784 sel.params[sel.n].type = SEL_PARAM_INT;
1785 sel.params[sel.n].v.i = $3;
1788 | ID LBRACK STRING RBRACK {
1789 if (sel.n >= MAX_SELECT_PARAMS-2) {
1790 yyerror("Select identifier too long\n");
1792 sel.params[sel.n].type = SEL_PARAM_STR;
1793 sel.params[sel.n].v.s.s = $1;
1794 sel.params[sel.n].v.s.len = strlen($1);
1796 sel.params[sel.n].type = SEL_PARAM_STR;
1797 sel.params[sel.n].v.s.s = $3;
1798 sel.params[sel.n].v.s.len = strlen($3);
1803 select_params DOT select_param
1807 SELECT_MARK { sel.n = 0; sel.f[0] = 0; } select_params {
1808 sel_ptr = (select_t*)pkg_malloc(sizeof(select_t));
1810 yyerror("No memory left to allocate select structure\n");
1812 memcpy(sel_ptr, &sel, sizeof(select_t));
1817 ATTR_FROM { s_attr->type |= AVP_TRACK_FROM; }
1818 | ATTR_TO { s_attr->type |= AVP_TRACK_TO; }
1819 | ATTR_FROMURI { s_attr->type |= AVP_TRACK_FROM | AVP_CLASS_URI; }
1820 | ATTR_TOURI { s_attr->type |= AVP_TRACK_TO | AVP_CLASS_URI; }
1821 | ATTR_FROMUSER { s_attr->type |= AVP_TRACK_FROM | AVP_CLASS_USER; }
1822 | ATTR_TOUSER { s_attr->type |= AVP_TRACK_TO | AVP_CLASS_USER; }
1823 | ATTR_FROMDOMAIN { s_attr->type |= AVP_TRACK_FROM | AVP_CLASS_DOMAIN; }
1824 | ATTR_TODOMAIN { s_attr->type |= AVP_TRACK_TO | AVP_CLASS_DOMAIN; }
1825 | ATTR_GLOBAL { s_attr->type |= AVP_TRACK_ALL | AVP_CLASS_GLOBAL; }
1828 ID { s_attr->type |= AVP_NAME_STR; s_attr->name.s.s = $1; s_attr->name.s.len = strlen ($1); }
1832 | attr_class_spec DOT attr_name_spec
1836 s_attr = (struct avp_spec*)pkg_malloc(sizeof(struct avp_spec));
1837 if (!s_attr) { yyerror("No memory left"); }
1842 attr_mark attr_spec { $$ = s_attr; }
1845 attr_mark attr_spec LBRACK NUMBER RBRACK {
1846 s_attr->type|= (AVP_NAME_STR | ($4<0?AVP_INDEX_BACKWARD:AVP_INDEX_FORWARD));
1847 s_attr->index = ($4<0?-$4:$4);
1852 attr_mark attr_spec LBRACK RBRACK {
1853 s_attr->type|= AVP_INDEX_ALL;
1873 avp_spec_t *avp_spec;
1876 avp_spec = pkg_malloc(sizeof(*avp_spec));
1878 yyerror("Not enough memory");
1884 s.len = strlen(s.s);
1885 if (parse_avp_name(&s, &type, &avp_spec->name, &idx)) {
1886 yyerror("error when parsing AVP");
1890 avp_spec->type = type;
1891 avp_spec->index = idx;
1897 ADDEQ { $$ = ADD_T; }
1898 | EQUAL { $$ = ASSIGN_T; }
1902 EQUAL { $$ = ASSIGN_T; }
1905 attr_id_ass assign_op STRING { $$=mk_action($2, 2, AVP_ST, $1, STRING_ST, $3); }
1906 | attr_id_ass assign_op NUMBER { $$=mk_action($2, 2, AVP_ST, $1, NUMBER_ST, (void*)$3); }
1907 | attr_id_ass assign_op fcmd { $$=mk_action($2, 2, AVP_ST, $1, ACTION_ST, $3); }
1908 | attr_id_ass assign_op attr_id_any { $$=mk_action($2, 2, AVP_ST, $1, AVP_ST, $3); }
1909 | attr_id_ass assign_op select_id { $$=mk_action($2, 2, AVP_ST, (void*)$1, SELECT_ST, (void*)$3); }
1910 | attr_id_ass assign_op LPAREN exp RPAREN { $$ = mk_action($2, 2, AVP_ST, $1, EXPR_ST, $4); }
1913 SETAVPFLAG { $$ = 1; }
1914 | RESETAVPFLAG { $$ = 0; }
1915 | ISAVPFLAGSET { $$ = -1; }
1918 FORWARD LPAREN host RPAREN { $$=mk_action( FORWARD_T, 2, STRING_ST, $3, NUMBER_ST, 0); }
1919 | FORWARD LPAREN STRING RPAREN { $$=mk_action( FORWARD_T, 2, STRING_ST, $3, NUMBER_ST, 0); }
1920 | FORWARD LPAREN ip RPAREN { $$=mk_action( FORWARD_T, 2, IP_ST, (void*)$3, NUMBER_ST, 0); }
1921 | FORWARD LPAREN host COMMA NUMBER RPAREN { $$=mk_action(FORWARD_T, 2, STRING_ST, $3, NUMBER_ST, (void*)$5); }
1922 | FORWARD LPAREN STRING COMMA NUMBER RPAREN {$$=mk_action(FORWARD_T, 2, STRING_ST, $3, NUMBER_ST, (void*)$5); }
1923 | FORWARD LPAREN ip COMMA NUMBER RPAREN { $$=mk_action(FORWARD_T, 2, IP_ST, (void*)$3, NUMBER_ST, (void*)$5); }
1924 | FORWARD LPAREN URIHOST COMMA URIPORT RPAREN { $$=mk_action(FORWARD_T, 2, URIHOST_ST, 0, URIPORT_ST, 0); }
1925 | FORWARD LPAREN URIHOST COMMA NUMBER RPAREN {$$=mk_action(FORWARD_T, 2, URIHOST_ST, 0, NUMBER_ST, (void*)$5); }
1926 | FORWARD LPAREN URIHOST RPAREN { $$=mk_action(FORWARD_T, 2, URIHOST_ST, 0, NUMBER_ST, 0); }
1927 | FORWARD error { $$=0; yyerror("missing '(' or ')' ?"); }
1928 | FORWARD LPAREN error RPAREN { $$=0; yyerror("bad forward argument"); }
1929 | FORWARD_UDP LPAREN host RPAREN { $$=mk_action(FORWARD_UDP_T, 2, STRING_ST, $3, NUMBER_ST, 0); }
1930 | FORWARD_UDP LPAREN STRING RPAREN { $$=mk_action(FORWARD_UDP_T, 2, STRING_ST, $3, NUMBER_ST, 0); }
1931 | FORWARD_UDP LPAREN ip RPAREN { $$=mk_action(FORWARD_UDP_T, 2, IP_ST, (void*)$3, NUMBER_ST, 0); }
1932 | FORWARD_UDP LPAREN host COMMA NUMBER RPAREN { $$=mk_action(FORWARD_UDP_T, 2, STRING_ST, $3, NUMBER_ST, (void*)$5); }
1933 | FORWARD_UDP LPAREN STRING COMMA NUMBER RPAREN {$$=mk_action(FORWARD_UDP_T, 2, STRING_ST, $3, NUMBER_ST, (void*)$5); }
1934 | FORWARD_UDP LPAREN ip COMMA NUMBER RPAREN { $$=mk_action(FORWARD_UDP_T, 2, IP_ST, (void*)$3, NUMBER_ST, (void*)$5); }
1935 | FORWARD_UDP LPAREN URIHOST COMMA URIPORT RPAREN {$$=mk_action(FORWARD_UDP_T, 2, URIHOST_ST, 0, URIPORT_ST, 0); }
1936 | FORWARD_UDP LPAREN URIHOST COMMA NUMBER RPAREN { $$=mk_action(FORWARD_UDP_T, 2, URIHOST_ST, 0, NUMBER_ST, (void*)$5); }
1937 | FORWARD_UDP LPAREN URIHOST RPAREN { $$=mk_action(FORWARD_UDP_T, 2, URIHOST_ST, 0, NUMBER_ST, 0); }
1938 | FORWARD_UDP error { $$=0; yyerror("missing '(' or ')' ?"); }
1939 | FORWARD_UDP LPAREN error RPAREN { $$=0; yyerror("bad forward_udp argument"); }
1940 | FORWARD_TCP LPAREN host RPAREN { $$=mk_action(FORWARD_TCP_T, 2, STRING_ST, $3, NUMBER_ST, 0); }
1941 | FORWARD_TCP LPAREN STRING RPAREN { $$=mk_action(FORWARD_TCP_T, 2, STRING_ST, $3, NUMBER_ST, 0); }
1942 | FORWARD_TCP LPAREN ip RPAREN { $$=mk_action(FORWARD_TCP_T, 2, IP_ST, (void*)$3, NUMBER_ST, 0); }
1943 | FORWARD_TCP LPAREN host COMMA NUMBER RPAREN { $$=mk_action(FORWARD_TCP_T, 2, STRING_ST, $3, NUMBER_ST, (void*)$5); }
1944 | FORWARD_TCP LPAREN STRING COMMA NUMBER RPAREN {$$=mk_action(FORWARD_TCP_T, 2, STRING_ST, $3, NUMBER_ST, (void*)$5); }
1945 | FORWARD_TCP LPAREN ip COMMA NUMBER RPAREN { $$=mk_action(FORWARD_TCP_T, 2, IP_ST, (void*)$3, NUMBER_ST, (void*)$5); }
1946 | FORWARD_TCP LPAREN URIHOST COMMA URIPORT RPAREN {$$=mk_action(FORWARD_TCP_T, 2, URIHOST_ST, 0, URIPORT_ST, 0); }
1947 | FORWARD_TCP LPAREN URIHOST COMMA NUMBER RPAREN { $$=mk_action(FORWARD_TCP_T, 2, URIHOST_ST, 0, NUMBER_ST, (void*)$5); }
1948 | FORWARD_TCP LPAREN URIHOST RPAREN { $$=mk_action(FORWARD_TCP_T, 2, URIHOST_ST, 0, NUMBER_ST, 0); }
1949 | FORWARD_TCP error { $$=0; yyerror("missing '(' or ')' ?"); }
1950 | FORWARD_TCP LPAREN error RPAREN { $$=0; yyerror("bad forward_tcp argument"); }
1951 | FORWARD_TLS LPAREN host RPAREN {
1953 $$=mk_action(FORWARD_TLS_T, 2, STRING_ST, $3, NUMBER_ST, 0);
1956 yyerror("tls support not compiled in");
1959 | FORWARD_TLS LPAREN STRING RPAREN {
1961 $$=mk_action(FORWARD_TLS_T, 2, STRING_ST, $3, NUMBER_ST, 0);
1964 yyerror("tls support not compiled in");
1967 | FORWARD_TLS LPAREN ip RPAREN {
1969 $$=mk_action(FORWARD_TLS_T, 2, IP_ST, (void*)$3, NUMBER_ST, 0);
1972 yyerror("tls support not compiled in");
1975 | FORWARD_TLS LPAREN host COMMA NUMBER RPAREN {
1977 $$=mk_action(FORWARD_TLS_T, 2, STRING_ST, $3, NUMBER_ST, (void*)$5);
1980 yyerror("tls support not compiled in");
1983 | FORWARD_TLS LPAREN STRING COMMA NUMBER RPAREN {
1985 $$=mk_action(FORWARD_TLS_T, 2, STRING_ST, $3, NUMBER_ST, (void*)$5);
1988 yyerror("tls support not compiled in");
1991 | FORWARD_TLS LPAREN ip COMMA NUMBER RPAREN {
1993 $$=mk_action(FORWARD_TLS_T, 2, IP_ST, (void*)$3, NUMBER_ST, (void*)$5);
1996 yyerror("tls support not compiled in");
1999 | FORWARD_TLS LPAREN URIHOST COMMA URIPORT RPAREN {
2001 $$=mk_action(FORWARD_TLS_T, 2, URIHOST_ST, 0, URIPORT_ST, 0);
2004 yyerror("tls support not compiled in");
2007 | FORWARD_TLS LPAREN URIHOST COMMA NUMBER RPAREN {
2009 $$=mk_action(FORWARD_TLS_T, 2, URIHOST_ST, 0, NUMBER_ST, (void*)$5);
2012 yyerror("tls support not compiled in");
2015 | FORWARD_TLS LPAREN URIHOST RPAREN {
2017 $$=mk_action(FORWARD_TLS_T, 2, URIHOST_ST, 0, NUMBER_ST, 0);
2020 yyerror("tls support not compiled in");
2023 | FORWARD_TLS error { $$=0; yyerror("missing '(' or ')' ?"); }
2024 | FORWARD_TLS LPAREN error RPAREN { $$=0;
2025 yyerror("bad forward_tls argument"); }
2026 | FORWARD_SCTP LPAREN host RPAREN {
2028 $$=mk_action(FORWARD_SCTP_T, 2, STRING_ST, $3, NUMBER_ST, 0);
2031 yyerror("sctp support not compiled in");
2034 | FORWARD_SCTP LPAREN STRING RPAREN {
2036 $$=mk_action(FORWARD_SCTP_T, 2, STRING_ST, $3, NUMBER_ST, 0);
2039 yyerror("sctp support not compiled in");
2042 | FORWARD_SCTP LPAREN ip RPAREN {
2044 $$=mk_action(FORWARD_SCTP_T, 2, IP_ST, (void*)$3, NUMBER_ST, 0);
2047 yyerror("sctp support not compiled in");
2050 | FORWARD_SCTP LPAREN host COMMA NUMBER RPAREN {
2052 $$=mk_action(FORWARD_SCTP_T, 2, STRING_ST, $3, NUMBER_ST,
2056 yyerror("sctp support not compiled in");
2059 | FORWARD_SCTP LPAREN STRING COMMA NUMBER RPAREN {
2061 $$=mk_action(FORWARD_SCTP_T, 2, STRING_ST, $3, NUMBER_ST,
2065 yyerror("sctp support not compiled in");
2068 | FORWARD_SCTP LPAREN ip COMMA NUMBER RPAREN {
2070 $$=mk_action(FORWARD_SCTP_T, 2, IP_ST, (void*)$3, NUMBER_ST,
2074 yyerror("sctp support not compiled in");
2077 | FORWARD_SCTP LPAREN URIHOST COMMA URIPORT RPAREN {
2079 $$=mk_action(FORWARD_SCTP_T, 2, URIHOST_ST, 0, URIPORT_ST, 0);
2082 yyerror("sctp support not compiled in");
2085 | FORWARD_SCTP LPAREN URIHOST COMMA NUMBER RPAREN {
2087 $$=mk_action(FORWARD_SCTP_T, 2, URIHOST_ST, 0, NUMBER_ST,
2091 yyerror("sctp support not compiled in");
2094 | FORWARD_SCTP LPAREN URIHOST RPAREN {
2096 $$=mk_action(FORWARD_SCTP_T, 2, URIHOST_ST, 0, NUMBER_ST, 0);
2099 yyerror("tls support not compiled in");
2102 | FORWARD_SCTP error { $$=0; yyerror("missing '(' or ')' ?"); }
2103 | FORWARD_SCTP LPAREN error RPAREN { $$=0;
2104 yyerror("bad forward_tls argument"); }
2105 | SEND LPAREN host RPAREN { $$=mk_action(SEND_T, 2, STRING_ST, $3, NUMBER_ST, 0); }
2106 | SEND LPAREN STRING RPAREN { $$=mk_action(SEND_T, 2, STRING_ST, $3, NUMBER_ST, 0); }
2107 | SEND LPAREN ip RPAREN { $$=mk_action(SEND_T, 2, IP_ST, (void*)$3, NUMBER_ST, 0); }
2108 | SEND LPAREN host COMMA NUMBER RPAREN { $$=mk_action(SEND_T, 2, STRING_ST, $3, NUMBER_ST, (void*)$5); }
2109 | SEND LPAREN STRING COMMA NUMBER RPAREN {$$=mk_action(SEND_T, 2, STRING_ST, $3, NUMBER_ST, (void*)$5); }
2110 | SEND LPAREN ip COMMA NUMBER RPAREN { $$=mk_action(SEND_T, 2, IP_ST, (void*)$3, NUMBER_ST, (void*)$5); }
2111 | SEND error { $$=0; yyerror("missing '(' or ')' ?"); }
2112 | SEND LPAREN error RPAREN { $$=0; yyerror("bad send argument"); }
2113 | SEND_TCP LPAREN host RPAREN { $$=mk_action(SEND_TCP_T, 2, STRING_ST, $3, NUMBER_ST, 0); }
2114 | SEND_TCP LPAREN STRING RPAREN { $$=mk_action(SEND_TCP_T, 2, STRING_ST, $3, NUMBER_ST, 0); }
2115 | SEND_TCP LPAREN ip RPAREN { $$=mk_action(SEND_TCP_T, 2, IP_ST, (void*)$3, NUMBER_ST, 0); }
2116 | SEND_TCP LPAREN host COMMA NUMBER RPAREN { $$=mk_action( SEND_TCP_T, 2, STRING_ST, $3, NUMBER_ST, (void*)$5);}
2117 | SEND_TCP LPAREN STRING COMMA NUMBER RPAREN {$$=mk_action(SEND_TCP_T, 2, STRING_ST, $3, NUMBER_ST, (void*)$5); }
2118 | SEND_TCP LPAREN ip COMMA NUMBER RPAREN { $$=mk_action(SEND_TCP_T, 2, IP_ST, (void*)$3, NUMBER_ST, (void*)$5); }
2119 | SEND_TCP error { $$=0; yyerror("missing '(' or ')' ?"); }
2120 | SEND_TCP LPAREN error RPAREN { $$=0; yyerror("bad send_tcp argument"); }
2121 | DROP LPAREN RPAREN {$$=mk_action(DROP_T, 2, NUMBER_ST, 0, NUMBER_ST, (void*)EXIT_R_F); }
2122 | DROP LPAREN NUMBER RPAREN {$$=mk_action(DROP_T, 2, NUMBER_ST, (void*)$3, NUMBER_ST, (void*)EXIT_R_F); }
2123 | DROP NUMBER {$$=mk_action(DROP_T, 2, NUMBER_ST, (void*)$2, NUMBER_ST, (void*)EXIT_R_F); }
2124 | DROP RETCODE {$$=mk_action(DROP_T, 2, RETCODE_ST, 0, NUMBER_ST, (void*)EXIT_R_F); }
2125 | DROP {$$=mk_action(DROP_T, 2, NUMBER_ST, 0, NUMBER_ST, (void*)EXIT_R_F); }
2126 | RETURN {$$=mk_action(DROP_T, 2, NUMBER_ST, (void*)1, NUMBER_ST, (void*)RETURN_R_F); }
2127 | RETURN NUMBER {$$=mk_action(DROP_T, 2, NUMBER_ST, (void*)$2, NUMBER_ST, (void*)RETURN_R_F);}
2128 | RETURN RETCODE {$$=mk_action(DROP_T, 2, RETCODE_ST, 0, NUMBER_ST, (void*)RETURN_R_F);}
2129 | BREAK {$$=mk_action(DROP_T, 2, NUMBER_ST, 0, NUMBER_ST, (void*)RETURN_R_F); }
2130 | LOG_TOK LPAREN STRING RPAREN {$$=mk_action(LOG_T, 2, NUMBER_ST, (void*)4, STRING_ST, $3); }
2131 | LOG_TOK LPAREN NUMBER COMMA STRING RPAREN {$$=mk_action(LOG_T, 2, NUMBER_ST, (void*)$3, STRING_ST, $5); }
2132 | LOG_TOK error { $$=0; yyerror("missing '(' or ')' ?"); }
2133 | LOG_TOK LPAREN error RPAREN { $$=0; yyerror("bad log argument"); }
2134 | SETFLAG LPAREN NUMBER RPAREN {
2135 if (check_flag($3)==-1)
2136 yyerror("bad flag value");
2137 $$=mk_action(SETFLAG_T, 1, NUMBER_ST,
2140 | SETFLAG LPAREN flag_name RPAREN {
2141 i_tmp=get_flag_no($3, strlen($3));
2142 if (i_tmp<0) yyerror("flag not declared");
2143 $$=mk_action(SETFLAG_T, 1, NUMBER_ST,
2144 (void*)(long)i_tmp);
2146 | SETFLAG error { $$=0; yyerror("missing '(' or ')'?"); }
2147 | RESETFLAG LPAREN NUMBER RPAREN {
2148 if (check_flag($3)==-1)
2149 yyerror("bad flag value");
2150 $$=mk_action(RESETFLAG_T, 1, NUMBER_ST, (void*)$3);
2152 | RESETFLAG LPAREN flag_name RPAREN {
2153 i_tmp=get_flag_no($3, strlen($3));
2154 if (i_tmp<0) yyerror("flag not declared");
2155 $$=mk_action(RESETFLAG_T, 1, NUMBER_ST,
2156 (void*)(long)i_tmp);
2158 | RESETFLAG error { $$=0; yyerror("missing '(' or ')'?"); }
2159 | ISFLAGSET LPAREN NUMBER RPAREN {
2160 if (check_flag($3)==-1)
2161 yyerror("bad flag value");
2162 $$=mk_action(ISFLAGSET_T, 1, NUMBER_ST, (void*)$3);
2164 | ISFLAGSET LPAREN flag_name RPAREN {
2165 i_tmp=get_flag_no($3, strlen($3));
2166 if (i_tmp<0) yyerror("flag not declared");
2167 $$=mk_action(ISFLAGSET_T, 1, NUMBER_ST,
2168 (void*)(long)i_tmp);
2170 | ISFLAGSET error { $$=0; yyerror("missing '(' or ')'?"); }
2171 | avpflag_oper LPAREN attr_id_any_str COMMA flag_name RPAREN {
2172 i_tmp=get_avpflag_no($5);
2173 if (i_tmp==0) yyerror("avpflag not declared");
2174 $$=mk_action(AVPFLAG_OPER_T, 3, AVP_ST, $3, NUMBER_ST, (void*)(long)i_tmp, NUMBER_ST, (void*)$1);
2176 | avpflag_oper error { $$=0; yyerror("missing '(' or ')'?"); }
2177 | ERROR LPAREN STRING COMMA STRING RPAREN {$$=mk_action(ERROR_T, 2, STRING_ST, $3, STRING_ST, $5); }
2178 | ERROR error { $$=0; yyerror("missing '(' or ')' ?"); }
2179 | ERROR LPAREN error RPAREN { $$=0; yyerror("bad error argument"); }
2180 | ROUTE LPAREN route_name RPAREN {
2181 i_tmp=route_get(&main_rt, $3);
2183 yyerror("internal error");
2186 $$=mk_action(ROUTE_T, 1, NUMBER_ST,(void*)(long)i_tmp);
2188 | ROUTE error { $$=0; yyerror("missing '(' or ')' ?"); }
2189 | ROUTE LPAREN error RPAREN { $$=0; yyerror("bad route argument"); }
2190 | EXEC LPAREN STRING RPAREN { $$=mk_action(EXEC_T, 1, STRING_ST, $3); }
2191 | SET_HOST LPAREN STRING RPAREN { $$=mk_action(SET_HOST_T, 1, STRING_ST, $3); }
2192 | SET_HOST error { $$=0; yyerror("missing '(' or ')' ?"); }
2193 | SET_HOST LPAREN error RPAREN { $$=0; yyerror("bad argument, string expected"); }
2194 | PREFIX LPAREN STRING RPAREN { $$=mk_action(PREFIX_T, 1, STRING_ST, $3); }
2195 | PREFIX error { $$=0; yyerror("missing '(' or ')' ?"); }
2196 | PREFIX LPAREN error RPAREN { $$=0; yyerror("bad argument, string expected"); }
2197 | STRIP_TAIL LPAREN NUMBER RPAREN { $$=mk_action(STRIP_TAIL_T, 1, NUMBER_ST, (void*)$3); }
2198 | STRIP_TAIL error { $$=0; yyerror("missing '(' or ')' ?"); }
2199 | STRIP_TAIL LPAREN error RPAREN { $$=0; yyerror("bad argument, number expected"); }
2200 | STRIP LPAREN NUMBER RPAREN { $$=mk_action(STRIP_T, 1, NUMBER_ST, (void*) $3); }
2201 | STRIP error { $$=0; yyerror("missing '(' or ')' ?"); }
2202 | STRIP LPAREN error RPAREN { $$=0; yyerror("bad argument, number expected"); }
2203 | APPEND_BRANCH LPAREN STRING COMMA STRING RPAREN {
2205 if (str2q(&q, $5, strlen($5)) < 0) {
2206 yyerror("bad argument, q value expected");
2208 $$=mk_action(APPEND_BRANCH_T, 2, STRING_ST, $3, NUMBER_ST, (void *)(long)q);
2210 | APPEND_BRANCH LPAREN STRING RPAREN { $$=mk_action(APPEND_BRANCH_T, 2, STRING_ST, $3, NUMBER_ST, (void *)Q_UNSPECIFIED); }
2211 | APPEND_BRANCH LPAREN RPAREN { $$=mk_action(APPEND_BRANCH_T, 2, STRING_ST, 0, NUMBER_ST, (void *)Q_UNSPECIFIED); }
2212 | APPEND_BRANCH { $$=mk_action( APPEND_BRANCH_T, 1, STRING_ST, 0); }
2213 | SET_HOSTPORT LPAREN STRING RPAREN { $$=mk_action(SET_HOSTPORT_T, 1, STRING_ST, $3); }
2214 | SET_HOSTPORT error { $$=0; yyerror("missing '(' or ')' ?"); }
2215 | SET_HOSTPORT LPAREN error RPAREN { $$=0; yyerror("bad argument, string expected"); }
2216 | SET_HOSTPORTTRANS LPAREN STRING RPAREN { $$=mk_action(SET_HOSTPORTTRANS_T, 1, STRING_ST, $3); }
2217 | SET_HOSTPORTTRANS error { $$=0; yyerror("missing '(' or ')' ?"); }
2218 | SET_HOSTPORTTRANS LPAREN error RPAREN { $$=0; yyerror("bad argument, string expected"); }
2219 | SET_PORT LPAREN STRING RPAREN { $$=mk_action(SET_PORT_T, 1, STRING_ST, $3); }
2220 | SET_PORT error { $$=0; yyerror("missing '(' or ')' ?"); }
2221 | SET_PORT LPAREN error RPAREN { $$=0; yyerror("bad argument, string expected"); }
2222 | SET_USER LPAREN STRING RPAREN { $$=mk_action(SET_USER_T, 1, STRING_ST, $3); }
2223 | SET_USER error { $$=0; yyerror("missing '(' or ')' ?"); }
2224 | SET_USER LPAREN error RPAREN { $$=0; yyerror("bad argument, string expected"); }
2225 | SET_USERPASS LPAREN STRING RPAREN { $$=mk_action(SET_USERPASS_T, 1, STRING_ST, $3); }
2226 | SET_USERPASS error { $$=0; yyerror("missing '(' or ')' ?"); }
2227 | SET_USERPASS LPAREN error RPAREN { $$=0; yyerror("bad argument, string expected"); }
2228 | SET_URI LPAREN STRING RPAREN { $$=mk_action(SET_URI_T, 1, STRING_ST,$3); }
2229 | SET_URI error { $$=0; yyerror("missing '(' or ')' ?"); }
2230 | SET_URI LPAREN error RPAREN { $$=0; yyerror("bad argument, string expected"); }
2231 | REVERT_URI LPAREN RPAREN { $$=mk_action(REVERT_URI_T, 0); }
2232 | REVERT_URI { $$=mk_action(REVERT_URI_T, 0); }
2233 | FORCE_RPORT LPAREN RPAREN { $$=mk_action(FORCE_RPORT_T, 0); }
2234 | FORCE_RPORT {$$=mk_action(FORCE_RPORT_T, 0); }
2235 | FORCE_TCP_ALIAS LPAREN NUMBER RPAREN {
2237 $$=mk_action(FORCE_TCP_ALIAS_T, 1, NUMBER_ST, (void*)$3);
2239 yyerror("tcp support not compiled in");
2242 | FORCE_TCP_ALIAS LPAREN RPAREN {
2244 $$=mk_action(FORCE_TCP_ALIAS_T, 0);
2246 yyerror("tcp support not compiled in");
2251 $$=mk_action(FORCE_TCP_ALIAS_T, 0);
2253 yyerror("tcp support not compiled in");
2256 | FORCE_TCP_ALIAS LPAREN error RPAREN {$$=0; yyerror("bad argument, number expected"); }
2257 | SET_ADV_ADDRESS LPAREN listen_id RPAREN {
2259 if ((str_tmp=pkg_malloc(sizeof(str)))==0) {
2260 LOG(L_CRIT, "ERROR: cfg. parser: out of memory.\n");
2263 str_tmp->len=strlen($3);
2264 $$=mk_action(SET_ADV_ADDR_T, 1, STR_ST, str_tmp);
2267 | SET_ADV_ADDRESS LPAREN error RPAREN { $$=0; yyerror("bad argument, string expected"); }
2268 | SET_ADV_ADDRESS error {$$=0; yyerror("missing '(' or ')' ?"); }
2269 | SET_ADV_PORT LPAREN NUMBER RPAREN {
2271 tmp=int2str($3, &i_tmp);
2272 if ((str_tmp=pkg_malloc(sizeof(str)))==0) {
2273 LOG(L_CRIT, "ERROR: cfg. parser: out of memory.\n");
2275 if ((str_tmp->s=pkg_malloc(i_tmp))==0) {
2276 LOG(L_CRIT, "ERROR: cfg. parser: out of memory.\n");
2278 memcpy(str_tmp->s, tmp, i_tmp);
2280 $$=mk_action(SET_ADV_PORT_T, 1, STR_ST, str_tmp);
2284 | SET_ADV_PORT LPAREN error RPAREN { $$=0; yyerror("bad argument, string expected"); }
2285 | SET_ADV_PORT error {$$=0; yyerror("missing '(' or ')' ?"); }
2286 | FORCE_SEND_SOCKET LPAREN phostport RPAREN { $$=mk_action(FORCE_SEND_SOCKET_T, 1, SOCKID_ST, $3); }
2287 | FORCE_SEND_SOCKET LPAREN error RPAREN { $$=0; yyerror("bad argument, [proto:]host[:port] expected"); }
2288 | FORCE_SEND_SOCKET error {$$=0; yyerror("missing '(' or ')' ?"); }
2289 | ID {mod_func_action = mk_action(MODULE_T, 2, MODEXP_ST, NULL, NUMBER_ST, 0); } LPAREN func_params RPAREN {
2290 mod_func_action->val[0].u.data = find_export_record($1, mod_func_action->val[1].u.number, rt);
2291 if (mod_func_action->val[0].u.data == 0) {
2292 if (find_export_record($1, mod_func_action->val[1].u.number, 0) ) {
2293 yyerror("Command cannot be used in the block\n");
2295 yyerror("unknown command, missing loadmodule?\n");
2297 pkg_free(mod_func_action);
2300 $$ = mod_func_action;
2305 | func_params COMMA func_param { }
2307 | func_params error { yyerror("call params error\n"); YYABORT; }
2311 if (mod_func_action->val[1].u.number < MAX_ACTIONS-2) {
2312 mod_func_action->val[mod_func_action->val[1].u.number+2].type = NUMBER_ST;
2313 mod_func_action->val[mod_func_action->val[1].u.number+2].u.number = $1;
2314 mod_func_action->val[1].u.number++;
2316 yyerror("Too many arguments\n");
2320 if (mod_func_action->val[1].u.number < MAX_ACTIONS-2) {
2321 mod_func_action->val[mod_func_action->val[1].u.number+2].type = STRING_ST;
2322 mod_func_action->val[mod_func_action->val[1].u.number+2].u.string = $1;
2323 mod_func_action->val[1].u.number++;
2325 yyerror("Too many arguments\n");
2333 extern int startcolumn;
2334 static void warn(char* s)
2336 LOG(L_WARN, "cfg. warning: (%d,%d-%d): %s\n", line, startcolumn,
2341 static void yyerror(char* s)
2343 LOG(L_CRIT, "*** PARSE ERROR *** (%d,%d-%d): %s\n", line, startcolumn,
2349 static struct socket_id* mk_listen_id(char* host, int proto, int port)
2351 struct socket_id* l;
2352 l=pkg_malloc(sizeof(struct socket_id));
2354 LOG(L_CRIT,"ERROR: cfg. parser: out of memory.\n");
2366 int main(int argc, char ** argv)
2369 fprintf(stderr, "parsing error\n");