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)
96 #include <sys/types.h>
97 #include <sys/socket.h>
98 #include <netinet/in.h>
99 #include <arpa/inet.h>
102 #include "route_struct.h"
106 #include "sr_module.h"
107 #include "modparam.h"
110 #include "socket_info.h"
111 #include "name_alias.h"
116 #include "tcp_init.h"
117 #include "tcp_options.h"
120 #include "cfg_core.h"
122 #include "tls/tls_config.h"
129 /* hack to avoid alloca usage in the generated C file (needed for compiler
130 with no built in alloca, like icc*/
133 #define onsend_check(s) \
135 if (rt!=ONSEND_ROUTE) yyerror( s " allowed only in onsend_routes");\
140 #define IF_DNS_CACHE(x) x
142 #define IF_DNS_CACHE(x) warn("dns cache support not compiled in")
145 #ifdef USE_DNS_FAILOVER
146 #define IF_DNS_FAILOVER(x) x
148 #define IF_DNS_FAILOVER(x) warn("dns failover support not compiled in")
152 #define IF_NAPTR(x) x
154 #define IF_NAPTR(x) warn("dns naptr support not compiled in")
157 #ifdef USE_DST_BLACKLIST
158 #define IF_DST_BLACKLIST(x) x
160 #define IF_DST_BLACKLIST(x) warn("dst blacklist support not compiled in")
166 #define IF_STUN(x) warn("stun support not compiled in")
171 static void yyerror(char* s);
174 static struct socket_id* lst_tmp;
175 static int rt; /* Type of route block for find_export */
178 static struct ip_addr* ip_tmp;
179 static struct avp_spec* s_attr;
181 static select_t* sel_ptr;
182 static struct action *mod_func_action;
184 static void warn(char* s);
185 static struct socket_id* mk_listen_id(char*, int, int);
194 struct action* action;
196 struct ip_addr* ipaddr;
197 struct socket_id* sockid;
198 struct avp_spec* attr;
235 %token FORCE_TCP_ALIAS
238 %token SET_ADV_ADDRESS
240 %token FORCE_SEND_SOCKET
290 %token DNS_SERVERS_NO
291 %token DNS_USE_SEARCH
292 %token DNS_SEARCH_FMATCH
294 %token DNS_USE_FAILOVER
295 %token DNS_CACHE_FLAGS
296 %token DNS_CACHE_NEG_TTL
297 %token DNS_CACHE_MIN_TTL
298 %token DNS_CACHE_MAX_TTL
300 %token DNS_CACHE_GC_INT
301 %token DNS_CACHE_DEL_NONEXP
306 %token DST_BLST_GC_INT
317 %token SERVER_SIGNATURE
328 %token TCP_ACCEPT_ALIASES
330 %token TCP_CONNECT_TIMEOUT
331 %token TCP_SEND_TIMEOUT
332 %token TCP_CON_LIFETIME
333 %token TCP_POLL_METHOD
334 %token TCP_MAX_CONNECTIONS
335 %token TCP_SOURCE_IPV4
336 %token TCP_SOURCE_IPV6
337 %token TCP_OPT_FD_CACHE
338 %token TCP_OPT_BUF_WRITE
339 %token TCP_OPT_CONN_WQ_MAX
340 %token TCP_OPT_WQ_MAX
341 %token TCP_OPT_DEFER_ACCEPT
342 %token TCP_OPT_DELAYED_ACK
343 %token TCP_OPT_SYNCNT
344 %token TCP_OPT_LINGER2
345 %token TCP_OPT_KEEPALIVE
346 %token TCP_OPT_KEEPIDLE
347 %token TCP_OPT_KEEPINTVL
348 %token TCP_OPT_KEEPCNT
354 %token TLS_HANDSHAKE_TIMEOUT
355 %token TLS_SEND_TIMEOUT
361 %token TLS_REQUIRE_CERTIFICATE
362 %token TLS_CERTIFICATE
363 %token TLS_PRIVATE_KEY
365 %token ADVERTISED_ADDRESS
366 %token ADVERTISED_PORT
369 %token SHM_FORCE_ALLOC
374 %token RT_TIMER1_PRIO
375 %token RT_TIMER1_POLICY
376 %token RT_TIMER2_PRIO
377 %token RT_TIMER2_POLICY
378 %token MCAST_LOOPBACK
381 %token PMTU_DISCOVERY
395 %token ATTR_FROMDOMAIN
400 %token STUN_REFRESH_INTERVAL
401 %token STUN_ALLOW_STUN
422 %token <intval> NUMBER
424 %token <strval> STRING
425 %token <strval> IPV6ADDR
444 %type <expr> exp exp_elem /*, condition*/
445 %type <action> action actions cmd fcmd if_cmd stm exp_stm assign_action
446 %type <ipaddr> ipv4 ipv6 ipv6addr ip
449 %type <strval> listen_id
450 %type <sockid> id_lst
451 %type <sockid> phostport
452 %type <intval> proto port
453 %type <intval> equalop strop intop binop
454 %type <strval> host_sep
455 %type <intval> uri_type
457 %type <attr> attr_id_num_idx
458 %type <attr> attr_id_no_idx
459 %type <attr> attr_id_ass
460 %type <attr> attr_id_val
461 %type <attr> attr_id_any
462 %type <attr> attr_id_any_str
463 /* %type <intval> class_id */
464 %type <intval> assign_op
465 %type <select> select_id
466 %type <strval> flag_name;
467 %type <strval> route_name;
468 %type <intval> avpflag_oper
470 /*%type <route_el> rules;
471 %type <route_el> rule;
481 statements statement {}
483 | statements error { yyerror(""); YYABORT;}
490 | {rt=REQUEST_ROUTE;} route_stm
491 | {rt=FAILURE_ROUTE;} failure_route_stm
492 | {rt=ONREPLY_ROUTE;} onreply_route_stm
493 | {rt=BRANCH_ROUTE;} branch_route_stm
494 | {rt=ONSEND_ROUTE;} send_route_stm
495 | SEMICOLON /* null statement */
496 | CR /* null statement*/
502 LOG(L_CRIT, "ERROR: cfg. parser: bad ip "
506 $$=pkg_malloc(strlen(tmp)+1);
508 LOG(L_CRIT, "ERROR: cfg. parser: out of "
511 strncpy($$, tmp, strlen(tmp)+1);
516 $$=pkg_malloc(strlen($1)+1);
518 LOG(L_CRIT, "ERROR: cfg. parser: out of "
521 strncpy($$, $1, strlen($1)+1);
525 $$=pkg_malloc(strlen($1)+1);
527 LOG(L_CRIT, "ERROR: cfg. parser: out of "
530 strncpy($$, $1, strlen($1)+1);
535 UDP { $$=PROTO_UDP; }
536 | TCP { $$=PROTO_TCP; }
537 | TLS { $$=PROTO_TLS; }
545 listen_id { $$=mk_listen_id($1, 0, 0); }
546 | listen_id COLON port { $$=mk_listen_id($1, 0, $3); }
547 | proto COLON listen_id { $$=mk_listen_id($3, $1, 0); }
548 | proto COLON listen_id COLON port { $$=mk_listen_id($3, $1, $5);}
549 | listen_id COLON error { $$=0; yyerror(" port number expected"); }
552 phostport { $$=$1 ; }
553 | phostport id_lst { $$=$1; $$->next=$2; }
556 flags_decl: FLAGS_DECL flag_list
557 | FLAGS_DECL error { yyerror("flag list expected\n"); }
560 | flag_spec COMMA flag_list
563 flag_spec: flag_name { if (register_flag($1,-1)<0)
564 yyerror("register flag failed");
566 | flag_name COLON NUMBER {
567 if (register_flag($1, $3)<0)
568 yyerror("register flag failed");
572 flag_name: STRING { $$=$1; }
577 AVPFLAGS_DECL avpflag_list
578 | AVPFLAGS_DECL error { yyerror("avpflag list expected\n"); }
582 | avpflag_spec COMMA avpflag_list
586 if (register_avpflag($1)==0)
587 yyerror("cannot declare avpflag");
591 DEBUG_V EQUAL NUMBER { default_core_cfg.debug=$3; }
592 | DEBUG_V EQUAL error { yyerror("number expected"); }
593 | FORK EQUAL NUMBER { dont_fork= ! $3; }
594 | FORK EQUAL error { yyerror("boolean value expected"); }
595 | LOGSTDERROR EQUAL NUMBER { if (!config_check) log_stderr=$3; }
596 | LOGSTDERROR EQUAL error { yyerror("boolean value expected"); }
597 | LOGFACILITY EQUAL ID {
598 if ( (i_tmp=str2facility($3))==-1)
599 yyerror("bad facility (see syslog(3) man page)");
603 | LOGFACILITY EQUAL error { yyerror("ID expected"); }
604 | DNS EQUAL NUMBER { received_dns|= ($3)?DO_DNS:0; }
605 | DNS EQUAL error { yyerror("boolean value expected"); }
606 | REV_DNS EQUAL NUMBER { received_dns|= ($3)?DO_REV_DNS:0; }
607 | REV_DNS EQUAL error { yyerror("boolean value expected"); }
608 | DNS_TRY_IPV6 EQUAL NUMBER { dns_try_ipv6=$3; }
609 | DNS_TRY_IPV6 error { yyerror("boolean value expected"); }
610 | DNS_TRY_NAPTR EQUAL NUMBER { IF_NAPTR(dns_try_naptr=$3); }
611 | DNS_TRY_NAPTR error { yyerror("boolean value expected"); }
612 | DNS_SRV_LB EQUAL NUMBER { IF_DNS_FAILOVER(dns_srv_lb=$3); }
613 | DNS_SRV_LB error { yyerror("boolean value expected"); }
614 | DNS_UDP_PREF EQUAL NUMBER { IF_NAPTR(dns_udp_pref=$3); }
615 | DNS_UDP_PREF error { yyerror("number expected"); }
616 | DNS_TCP_PREF EQUAL NUMBER { IF_NAPTR(dns_tcp_pref=$3); }
617 | DNS_TCP_PREF error { yyerror("number expected"); }
618 | DNS_TLS_PREF EQUAL NUMBER { IF_NAPTR(dns_tls_pref=$3); }
619 | DNS_TLS_PREF error { yyerror("number expected"); }
620 | DNS_RETR_TIME EQUAL NUMBER { dns_retr_time=$3; }
621 | DNS_RETR_TIME error { yyerror("number expected"); }
622 | DNS_RETR_NO EQUAL NUMBER { dns_retr_no=$3; }
623 | DNS_RETR_NO error { yyerror("number expected"); }
624 | DNS_SERVERS_NO EQUAL NUMBER { dns_servers_no=$3; }
625 | DNS_SERVERS_NO error { yyerror("number expected"); }
626 | DNS_USE_SEARCH EQUAL NUMBER { dns_search_list=$3; }
627 | DNS_USE_SEARCH error { yyerror("boolean value expected"); }
628 | DNS_SEARCH_FMATCH EQUAL NUMBER { dns_search_fmatch=$3; }
629 | DNS_SEARCH_FMATCH error { yyerror("boolean value expected"); }
630 | DNS_USE_CACHE EQUAL NUMBER { IF_DNS_CACHE(use_dns_cache=$3); }
631 | DNS_USE_CACHE error { yyerror("boolean value expected"); }
632 | DNS_USE_FAILOVER EQUAL NUMBER { IF_DNS_FAILOVER(use_dns_failover=$3);}
633 | DNS_USE_FAILOVER error { yyerror("boolean value expected"); }
634 | DNS_CACHE_FLAGS EQUAL NUMBER { IF_DNS_CACHE(dns_flags=$3); }
635 | DNS_CACHE_FLAGS error { yyerror("boolean value expected"); }
636 | DNS_CACHE_NEG_TTL EQUAL NUMBER { IF_DNS_CACHE(dns_neg_cache_ttl=$3); }
637 | DNS_CACHE_NEG_TTL error { yyerror("boolean value expected"); }
638 | DNS_CACHE_MAX_TTL EQUAL NUMBER { IF_DNS_CACHE(dns_cache_max_ttl=$3); }
639 | DNS_CACHE_MAX_TTL error { yyerror("boolean value expected"); }
640 | DNS_CACHE_MIN_TTL EQUAL NUMBER { IF_DNS_CACHE(dns_cache_min_ttl=$3); }
641 | DNS_CACHE_MIN_TTL error { yyerror("boolean value expected"); }
642 | DNS_CACHE_MEM EQUAL NUMBER { IF_DNS_CACHE(dns_cache_max_mem=$3); }
643 | DNS_CACHE_MEM error { yyerror("boolean value expected"); }
644 | DNS_CACHE_GC_INT EQUAL NUMBER { IF_DNS_CACHE(dns_timer_interval=$3); }
645 | DNS_CACHE_GC_INT error { yyerror("boolean value expected"); }
646 | DNS_CACHE_DEL_NONEXP EQUAL NUMBER { IF_DNS_CACHE(dns_cache_del_nonexp=$3); }
647 | DNS_CACHE_DEL_NONEXP error { yyerror("boolean value expected"); }
648 | USE_DST_BLST EQUAL NUMBER { IF_DST_BLACKLIST(use_dst_blacklist=$3); }
649 | USE_DST_BLST error { yyerror("boolean value expected"); }
650 | DST_BLST_MEM EQUAL NUMBER { IF_DST_BLACKLIST(blst_max_mem=$3); }
651 | DST_BLST_MEM error { yyerror("boolean value expected"); }
652 | DST_BLST_TTL EQUAL NUMBER { IF_DST_BLACKLIST(blst_timeout=$3); }
653 | DST_BLST_TTL error { yyerror("boolean value expected"); }
654 | DST_BLST_GC_INT EQUAL NUMBER { IF_DST_BLACKLIST(blst_timer_interval=$3);}
655 | DST_BLST_GC_INT error { yyerror("boolean value expected"); }
656 | PORT EQUAL NUMBER { port_no=$3; }
657 | STAT EQUAL STRING {
662 | MAXBUFFER EQUAL NUMBER { maxbuffer=$3; }
663 | MAXBUFFER EQUAL error { yyerror("number expected"); }
664 | PORT EQUAL error { yyerror("number expected"); }
665 | CHILDREN EQUAL NUMBER { children_no=$3; }
666 | CHILDREN EQUAL error { yyerror("number expected"); }
667 | CHECK_VIA EQUAL NUMBER { check_via=$3; }
668 | CHECK_VIA EQUAL error { yyerror("boolean value expected"); }
669 | PHONE2TEL EQUAL NUMBER { phone2tel=$3; }
670 | PHONE2TEL EQUAL error { yyerror("boolean value expected"); }
671 | SYN_BRANCH EQUAL NUMBER { syn_branch=$3; }
672 | SYN_BRANCH EQUAL error { yyerror("boolean value expected"); }
673 | MEMLOG EQUAL NUMBER { memlog=$3; }
674 | MEMLOG EQUAL error { yyerror("int value expected"); }
675 | MEMDBG EQUAL NUMBER { memdbg=$3; }
676 | MEMDBG EQUAL error { yyerror("int value expected"); }
677 | SIP_WARNING EQUAL NUMBER { sip_warning=$3; }
678 | SIP_WARNING EQUAL error { yyerror("boolean value expected"); }
679 | USER EQUAL STRING { user=$3; }
680 | USER EQUAL ID { user=$3; }
681 | USER EQUAL error { yyerror("string value expected"); }
682 | GROUP EQUAL STRING { group=$3; }
683 | GROUP EQUAL ID { group=$3; }
684 | GROUP EQUAL error { yyerror("string value expected"); }
685 | CHROOT EQUAL STRING { chroot_dir=$3; }
686 | CHROOT EQUAL ID { chroot_dir=$3; }
687 | CHROOT EQUAL error { yyerror("string value expected"); }
688 | WDIR EQUAL STRING { working_dir=$3; }
689 | WDIR EQUAL ID { working_dir=$3; }
690 | WDIR EQUAL error { yyerror("string value expected"); }
691 | MHOMED EQUAL NUMBER { mhomed=$3; }
692 | MHOMED EQUAL error { yyerror("boolean value expected"); }
693 | DISABLE_TCP EQUAL NUMBER {
697 warn("tcp support not compiled in");
700 | DISABLE_TCP EQUAL error { yyerror("boolean value expected"); }
701 | TCP_ACCEPT_ALIASES EQUAL NUMBER {
703 tcp_accept_aliases=$3;
705 warn("tcp support not compiled in");
708 | TCP_ACCEPT_ALIASES EQUAL error { yyerror("boolean value expected"); }
709 | TCP_CHILDREN EQUAL NUMBER {
713 warn("tcp support not compiled in");
716 | TCP_CHILDREN EQUAL error { yyerror("number expected"); }
717 | TCP_CONNECT_TIMEOUT EQUAL NUMBER {
719 tcp_connect_timeout=$3;
721 warn("tcp support not compiled in");
724 | TCP_CONNECT_TIMEOUT EQUAL error { yyerror("number expected"); }
725 | TCP_SEND_TIMEOUT EQUAL NUMBER {
729 warn("tcp support not compiled in");
732 | TCP_SEND_TIMEOUT EQUAL error { yyerror("number expected"); }
733 | TCP_CON_LIFETIME EQUAL NUMBER {
737 warn("tcp support not compiled in");
740 | TCP_CON_LIFETIME EQUAL error { yyerror("number expected"); }
741 | TCP_POLL_METHOD EQUAL ID {
743 tcp_poll_method=get_poll_type($3);
744 if (tcp_poll_method==POLL_NONE) {
745 LOG(L_CRIT, "bad poll method name:"
746 " %s\n, try one of %s.\n",
748 yyerror("bad tcp_poll_method "
752 warn("tcp support not compiled in");
755 | TCP_POLL_METHOD EQUAL STRING {
757 tcp_poll_method=get_poll_type($3);
758 if (tcp_poll_method==POLL_NONE) {
759 LOG(L_CRIT, "bad poll method name:"
760 " %s\n, try one of %s.\n",
762 yyerror("bad tcp_poll_method "
766 warn("tcp support not compiled in");
769 | TCP_POLL_METHOD EQUAL error { yyerror("poll method name expected"); }
770 | TCP_MAX_CONNECTIONS EQUAL NUMBER {
772 tcp_max_connections=$3;
774 warn("tcp support not compiled in");
777 | TCP_MAX_CONNECTIONS EQUAL error { yyerror("number expected"); }
778 | TCP_SOURCE_IPV4 EQUAL ipv4 {
780 if (tcp_set_src_addr($3)<0)
781 warn("tcp_source_ipv4 failed");
783 warn("tcp support not compiled in");
787 | TCP_SOURCE_IPV4 EQUAL error { yyerror("IPv4 address expected"); }
788 | TCP_SOURCE_IPV6 EQUAL ipv6 {
791 if (tcp_set_src_addr($3)<0)
792 warn("tcp_source_ipv6 failed");
794 warn("IPv6 support not compiled in");
797 warn("tcp support not compiled in");
801 | TCP_SOURCE_IPV6 EQUAL error { yyerror("IPv6 address expected"); }
802 | TCP_OPT_FD_CACHE EQUAL NUMBER {
804 tcp_options.fd_cache=$3;
806 warn("tcp support not compiled in");
809 | TCP_OPT_FD_CACHE EQUAL error { yyerror("boolean value expected"); }
810 | TCP_OPT_BUF_WRITE EQUAL NUMBER {
812 tcp_options.tcp_buf_write=$3;
814 warn("tcp support not compiled in");
817 | TCP_OPT_BUF_WRITE EQUAL error { yyerror("boolean value expected"); }
818 | TCP_OPT_CONN_WQ_MAX EQUAL NUMBER {
820 tcp_options.tcpconn_wq_max=$3;
822 warn("tcp support not compiled in");
825 | TCP_OPT_CONN_WQ_MAX error { yyerror("boolean value expected"); }
826 | TCP_OPT_WQ_MAX EQUAL NUMBER {
828 tcp_options.tcp_wq_max=$3;
830 warn("tcp support not compiled in");
833 | TCP_OPT_WQ_MAX error { yyerror("boolean value expected"); }
834 | TCP_OPT_DEFER_ACCEPT EQUAL NUMBER {
836 tcp_options.defer_accept=$3;
838 warn("tcp support not compiled in");
841 | TCP_OPT_DEFER_ACCEPT EQUAL error { yyerror("boolean value expected"); }
842 | TCP_OPT_DELAYED_ACK EQUAL NUMBER {
844 tcp_options.delayed_ack=$3;
846 warn("tcp support not compiled in");
849 | TCP_OPT_DELAYED_ACK EQUAL error { yyerror("boolean value expected"); }
850 | TCP_OPT_SYNCNT EQUAL NUMBER {
852 tcp_options.syncnt=$3;
854 warn("tcp support not compiled in");
857 | TCP_OPT_SYNCNT EQUAL error { yyerror("number expected"); }
858 | TCP_OPT_LINGER2 EQUAL NUMBER {
860 tcp_options.linger2=$3;
862 warn("tcp support not compiled in");
865 | TCP_OPT_LINGER2 EQUAL error { yyerror("number expected"); }
866 | TCP_OPT_KEEPALIVE EQUAL NUMBER {
868 tcp_options.keepalive=$3;
870 warn("tcp support not compiled in");
873 | TCP_OPT_KEEPALIVE EQUAL error { yyerror("boolean value expected");}
874 | TCP_OPT_KEEPIDLE EQUAL NUMBER {
876 tcp_options.keepidle=$3;
878 warn("tcp support not compiled in");
881 | TCP_OPT_KEEPIDLE EQUAL error { yyerror("number expected"); }
882 | TCP_OPT_KEEPINTVL EQUAL NUMBER {
884 tcp_options.keepintvl=$3;
886 warn("tcp support not compiled in");
889 | TCP_OPT_KEEPINTVL EQUAL error { yyerror("number expected"); }
890 | TCP_OPT_KEEPCNT EQUAL NUMBER {
892 tcp_options.keepcnt=$3;
894 warn("tcp support not compiled in");
897 | TCP_OPT_KEEPCNT EQUAL error { yyerror("number expected"); }
898 | DISABLE_TLS EQUAL NUMBER {
902 warn("tls support not compiled in");
905 | DISABLE_TLS EQUAL error { yyerror("boolean value expected"); }
906 | ENABLE_TLS EQUAL NUMBER {
910 warn("tls support not compiled in");
913 | ENABLE_TLS EQUAL error { yyerror("boolean value expected"); }
914 | TLSLOG EQUAL NUMBER {
918 warn("tls-in-core support not compiled in");
921 | TLSLOG EQUAL error { yyerror("int value expected"); }
922 | TLS_PORT_NO EQUAL NUMBER {
926 warn("tls support not compiled in");
929 | TLS_PORT_NO EQUAL error { yyerror("number expected"); }
930 | TLS_METHOD EQUAL SSLv23 {
932 tls_method=TLS_USE_SSLv23;
934 warn("tls-in-core support not compiled in");
937 | TLS_METHOD EQUAL SSLv2 {
939 tls_method=TLS_USE_SSLv2;
941 warn("tls-in-core support not compiled in");
944 | TLS_METHOD EQUAL SSLv3 {
946 tls_method=TLS_USE_SSLv3;
948 warn("tls-in-core support not compiled in");
951 | TLS_METHOD EQUAL TLSv1 {
953 tls_method=TLS_USE_TLSv1;
955 warn("tls-in-core support not compiled in");
958 | TLS_METHOD EQUAL error {
960 yyerror("SSLv23, SSLv2, SSLv3 or TLSv1 expected");
962 warn("tls-in-core support not compiled in");
965 | TLS_VERIFY EQUAL NUMBER {
969 warn("tls-in-core support not compiled in");
972 | TLS_VERIFY EQUAL error { yyerror("boolean value expected"); }
973 | TLS_REQUIRE_CERTIFICATE EQUAL NUMBER {
977 warn( "tls-in-core support not compiled in");
980 | TLS_REQUIRE_CERTIFICATE EQUAL error { yyerror("boolean value expected"); }
981 | TLS_CERTIFICATE EQUAL STRING {
985 warn("tls-in-core support not compiled in");
988 | TLS_CERTIFICATE EQUAL error { yyerror("string value expected"); }
989 | TLS_PRIVATE_KEY EQUAL STRING {
993 warn("tls-in-core support not compiled in");
996 | TLS_PRIVATE_KEY EQUAL error { yyerror("string value expected"); }
997 | TLS_CA_LIST EQUAL STRING {
1001 warn("tls-in-core support not compiled in");
1004 | TLS_CA_LIST EQUAL error { yyerror("string value expected"); }
1005 | TLS_HANDSHAKE_TIMEOUT EQUAL NUMBER {
1007 tls_handshake_timeout=$3;
1009 warn("tls-in-core support not compiled in");
1012 | TLS_HANDSHAKE_TIMEOUT EQUAL error { yyerror("number expected"); }
1013 | TLS_SEND_TIMEOUT EQUAL NUMBER {
1015 tls_send_timeout=$3;
1017 warn("tls-in-core support not compiled in");
1020 | TLS_SEND_TIMEOUT EQUAL error { yyerror("number expected"); }
1021 | SERVER_SIGNATURE EQUAL NUMBER { server_signature=$3; }
1022 | SERVER_SIGNATURE EQUAL error { yyerror("boolean value expected"); }
1023 | REPLY_TO_VIA EQUAL NUMBER { reply_to_via=$3; }
1024 | REPLY_TO_VIA EQUAL error { yyerror("boolean value expected"); }
1025 | LISTEN EQUAL id_lst {
1026 for(lst_tmp=$3; lst_tmp; lst_tmp=lst_tmp->next) {
1027 if (add_listen_iface(lst_tmp->name, lst_tmp->port, lst_tmp->proto, 0)!=0) {
1028 LOG(L_CRIT, "ERROR: cfg. parser: failed to add listen address\n");
1033 | LISTEN EQUAL error { yyerror("ip address or hostname expected"); }
1034 | ALIAS EQUAL id_lst {
1035 for(lst_tmp=$3; lst_tmp; lst_tmp=lst_tmp->next)
1036 add_alias(lst_tmp->name, strlen(lst_tmp->name), lst_tmp->port, lst_tmp->proto);
1038 | ALIAS EQUAL error { yyerror(" hostname expected"); }
1039 | ADVERTISED_ADDRESS EQUAL listen_id {
1040 default_global_address.s=$3;
1041 default_global_address.len=strlen($3);
1043 | ADVERTISED_ADDRESS EQUAL error {yyerror("ip address or hostname expected"); }
1044 | ADVERTISED_PORT EQUAL NUMBER {
1045 tmp=int2str($3, &i_tmp);
1046 if ((default_global_port.s=pkg_malloc(i_tmp))==0) {
1047 LOG(L_CRIT, "ERROR: cfg. parser: out of memory.\n");
1048 default_global_port.len=0;
1050 default_global_port.len=i_tmp;
1051 memcpy(default_global_port.s, tmp, default_global_port.len);
1054 |ADVERTISED_PORT EQUAL error {yyerror("ip address or hostname expected"); }
1055 | DISABLE_CORE EQUAL NUMBER { disable_core_dump=$3; }
1056 | DISABLE_CORE EQUAL error { yyerror("boolean value expected"); }
1057 | OPEN_FD_LIMIT EQUAL NUMBER { open_files_limit=$3; }
1058 | OPEN_FD_LIMIT EQUAL error { yyerror("number expected"); }
1059 | SHM_FORCE_ALLOC EQUAL NUMBER { shm_force_alloc=$3; }
1060 | SHM_FORCE_ALLOC EQUAL error { yyerror("boolean value expected"); }
1061 | MLOCK_PAGES EQUAL NUMBER { mlock_pages=$3; }
1062 | MLOCK_PAGES EQUAL error { yyerror("boolean value expected"); }
1063 | REAL_TIME EQUAL NUMBER { real_time=$3; }
1064 | REAL_TIME EQUAL error { yyerror("boolean value expected"); }
1065 | RT_PRIO EQUAL NUMBER { rt_prio=$3; }
1066 | RT_PRIO EQUAL error { yyerror("boolean value expected"); }
1067 | RT_POLICY EQUAL NUMBER { rt_policy=$3; }
1068 | RT_POLICY EQUAL error { yyerror("boolean value expected"); }
1069 | RT_TIMER1_PRIO EQUAL NUMBER { rt_timer1_prio=$3; }
1070 | RT_TIMER1_PRIO EQUAL error { yyerror("boolean value expected"); }
1071 | RT_TIMER1_POLICY EQUAL NUMBER { rt_timer1_policy=$3; }
1072 | RT_TIMER1_POLICY EQUAL error { yyerror("boolean value expected"); }
1073 | RT_TIMER2_PRIO EQUAL NUMBER { rt_timer2_prio=$3; }
1074 | RT_TIMER2_PRIO EQUAL error { yyerror("boolean value expected"); }
1075 | RT_TIMER2_POLICY EQUAL NUMBER { rt_timer2_policy=$3; }
1076 | RT_TIMER2_POLICY EQUAL error { yyerror("boolean value expected"); }
1077 | MCAST_LOOPBACK EQUAL NUMBER {
1081 warn("no multicast support compiled in");
1084 | MCAST_LOOPBACK EQUAL error { yyerror("boolean value expected"); }
1085 | MCAST_TTL EQUAL NUMBER {
1089 warn("no multicast support compiled in");
1092 | MCAST_TTL EQUAL error { yyerror("number expected"); }
1093 | TOS EQUAL NUMBER { tos=$3; }
1094 | TOS EQUAL error { yyerror("number expected"); }
1095 | PMTU_DISCOVERY EQUAL NUMBER { pmtu_discovery=$3; }
1096 | PMTU_DISCOVERY error { yyerror("number expected"); }
1097 | KILL_TIMEOUT EQUAL NUMBER { ser_kill_timeout=$3; }
1098 | KILL_TIMEOUT EQUAL error { yyerror("number expected"); }
1099 | STUN_REFRESH_INTERVAL EQUAL NUMBER { IF_STUN(stun_refresh_interval=$3); }
1100 | STUN_REFRESH_INTERVAL EQUAL error{ yyerror("number expected"); }
1101 | STUN_ALLOW_STUN EQUAL NUMBER { IF_STUN(stun_allow_stun=$3); }
1102 | STUN_ALLOW_STUN EQUAL error{ yyerror("number expected"); }
1103 | STUN_ALLOW_FP EQUAL NUMBER { IF_STUN(stun_allow_fp=$3) ; }
1104 | STUN_ALLOW_FP EQUAL error{ yyerror("number expected"); }
1105 | error EQUAL { yyerror("unknown config variable"); }
1109 DBG("loading module %s\n", $2);
1110 if (load_module($2)!=0) {
1111 yyerror("failed to load module");
1114 | LOADMODULE error { yyerror("string expected"); }
1115 | MODPARAM LPAREN STRING COMMA STRING COMMA STRING RPAREN {
1116 if (set_mod_param_regex($3, $5, PARAM_STRING, $7) != 0) {
1117 yyerror("Can't set module parameter");
1120 | MODPARAM LPAREN STRING COMMA STRING COMMA NUMBER RPAREN {
1121 if (set_mod_param_regex($3, $5, PARAM_INT, (void*)$7) != 0) {
1122 yyerror("Can't set module parameter");
1125 | MODPARAM error { yyerror("Invalid arguments"); }
1132 NUMBER DOT NUMBER DOT NUMBER DOT NUMBER {
1133 $$=pkg_malloc(sizeof(struct ip_addr));
1135 LOG(L_CRIT, "ERROR: cfg. parser: out of memory.\n");
1137 memset($$, 0, sizeof(struct ip_addr));
1140 if (($1>255) || ($1<0) ||
1141 ($3>255) || ($3<0) ||
1142 ($5>255) || ($5<0) ||
1143 ($7>255) || ($7<0)) {
1144 yyerror("invalid ipv4 address");
1154 ($3<<16)| ($5<<8)|$7 );
1162 $$=pkg_malloc(sizeof(struct ip_addr));
1164 LOG(L_CRIT, "ERROR: cfg. parser: out of memory.\n");
1166 memset($$, 0, sizeof(struct ip_addr));
1170 if (inet_pton(AF_INET6, $1, $$->u.addr)<=0) {
1171 yyerror("bad ipv6 address");
1174 yyerror("ipv6 address & no ipv6 support compiled in");
1182 | LBRACK ipv6addr RBRACK {$$=$2; }
1186 route_name: NUMBER {
1187 tmp=int2str($1, &i_tmp);
1188 if (($$=pkg_malloc(i_tmp+1))==0) {
1189 yyerror("out of memory");
1192 memcpy($$, tmp, i_tmp);
1201 ROUTE LBRACE actions RBRACE { push($3, &main_rt.rlist[DEFAULT_RT]); }
1202 | ROUTE LBRACK route_name RBRACK LBRACE actions RBRACE {
1203 i_tmp=route_get(&main_rt, $3);
1205 yyerror("internal error");
1208 if (main_rt.rlist[i_tmp]){
1209 yyerror("duplicate route");
1212 push($6, &main_rt.rlist[i_tmp]);
1214 | ROUTE error { yyerror("invalid route statement"); }
1217 ROUTE_FAILURE LBRACE actions RBRACE {
1218 push($3, &failure_rt.rlist[DEFAULT_RT]);
1220 | ROUTE_FAILURE LBRACK route_name RBRACK LBRACE actions RBRACE {
1221 i_tmp=route_get(&failure_rt, $3);
1223 yyerror("internal error");
1226 if (failure_rt.rlist[i_tmp]){
1227 yyerror("duplicate route");
1230 push($6, &failure_rt.rlist[i_tmp]);
1232 | ROUTE_FAILURE error { yyerror("invalid failure_route statement"); }
1235 ROUTE_ONREPLY LBRACE actions RBRACE {
1236 push($3, &onreply_rt.rlist[DEFAULT_RT]);
1238 | ROUTE_ONREPLY LBRACK route_name RBRACK LBRACE actions RBRACE {
1239 i_tmp=route_get(&onreply_rt, $3);
1241 yyerror("internal error");
1244 if (onreply_rt.rlist[i_tmp]){
1245 yyerror("duplicate route");
1248 push($6, &onreply_rt.rlist[i_tmp]);
1250 | ROUTE_ONREPLY error { yyerror("invalid onreply_route statement"); }
1253 ROUTE_BRANCH LBRACE actions RBRACE {
1254 push($3, &branch_rt.rlist[DEFAULT_RT]);
1256 | ROUTE_BRANCH LBRACK route_name RBRACK LBRACE actions RBRACE {
1257 i_tmp=route_get(&branch_rt, $3);
1259 yyerror("internal error");
1262 if (branch_rt.rlist[i_tmp]){
1263 yyerror("duplicate route");
1266 push($6, &branch_rt.rlist[i_tmp]);
1268 | ROUTE_BRANCH error { yyerror("invalid branch_route statement"); }
1270 send_route_stm: ROUTE_SEND LBRACE actions RBRACE {
1271 push($3, &onsend_rt.rlist[DEFAULT_RT]);
1273 | ROUTE_SEND LBRACK route_name RBRACK LBRACE actions RBRACE {
1274 i_tmp=route_get(&onsend_rt, $3);
1276 yyerror("internal error");
1279 if (onsend_rt.rlist[i_tmp]){
1280 yyerror("duplicate route");
1283 push($6, &onsend_rt.rlist[i_tmp]);
1285 | ROUTE_SEND error { yyerror("invalid onsend_route statement"); }
1289 rules rule { push($2, &$1); $$=$1; }
1291 | rules error { $$=0; yyerror("invalid rule"); }
1294 condition actions CR {
1296 if (add_rule($1, $2, &$$)<0) {
1297 yyerror("error calling add_rule");
1302 | condition error { $$=0; yyerror("bad actions in rule"); }
1307 exp: exp LOG_AND exp { $$=mk_exp(LOGAND_OP, $1, $3); }
1308 | exp LOG_OR exp { $$=mk_exp(LOGOR_OP, $1, $3); }
1309 | NOT exp { $$=mk_exp(NOT_OP, $2, 0); }
1310 | LPAREN exp RPAREN { $$=$2; }
1311 | exp_elem { $$=$1; }
1314 EQUAL_T {$$=EQUAL_OP; }
1315 | DIFF {$$=DIFF_OP; }
1317 intop: equalop {$$=$1; }
1324 BIN_OR { $$= BINOR_OP; }
1325 | BIN_AND { $$ = BINAND_OP; }
1329 | MATCH {$$=MATCH_OP; }
1333 | FROM_URI {$$=FROM_URI_O;}
1334 | TO_URI {$$=TO_URI_O;}
1338 METHOD strop STRING {$$= mk_elem($2, METHOD_O, 0, STRING_ST, $3);}
1339 | METHOD strop attr_id_val {$$ = mk_elem($2, METHOD_O, 0, AVP_ST, $3); }
1340 | METHOD strop select_id {$$ = mk_elem($2, METHOD_O, 0, SELECT_ST, $3); }
1341 | METHOD strop ID {$$ = mk_elem($2, METHOD_O, 0, STRING_ST,$3); }
1342 | METHOD strop error { $$=0; yyerror("string expected"); }
1343 | METHOD error { $$=0; yyerror("invalid operator,== , !=, or =~ expected"); }
1344 | uri_type strop STRING {$$ = mk_elem($2, $1, 0, STRING_ST, $3); }
1345 | uri_type strop host {$$ = mk_elem($2, $1, 0, STRING_ST, $3); }
1346 | uri_type strop attr_id_val {$$ = mk_elem($2, $1, 0, AVP_ST, $3); }
1347 | uri_type strop select_id {$$ = mk_elem($2, $1, 0, SELECT_ST, $3); }
1348 | uri_type equalop MYSELF {$$=mk_elem($2, $1, 0, MYSELF_ST, 0); }
1349 | uri_type strop error { $$=0; yyerror("string or MYSELF expected"); }
1350 | uri_type error { $$=0; yyerror("invalid operator, == , != or =~ expected"); }
1352 | SRCPORT intop NUMBER { $$=mk_elem($2, SRCPORT_O, 0, NUMBER_ST, (void*)$3 ); }
1353 | SRCPORT intop attr_id_val { $$=mk_elem($2, SRCPORT_O, 0, AVP_ST, (void*)$3 ); }
1354 | SRCPORT intop error { $$=0; yyerror("number expected"); }
1355 | SRCPORT error { $$=0; yyerror("==, !=, <,>, >= or <= expected"); }
1357 | DSTPORT intop NUMBER { $$=mk_elem($2, DSTPORT_O, 0, NUMBER_ST, (void*)$3 ); }
1358 | DSTPORT intop attr_id_val { $$=mk_elem($2, DSTPORT_O, 0, AVP_ST, (void*)$3 ); }
1359 | DSTPORT intop error { $$=0; yyerror("number expected"); }
1360 | DSTPORT error { $$=0; yyerror("==, !=, <,>, >= or <= expected"); }
1362 | SNDPORT intop NUMBER {
1363 onsend_check("snd_port");
1364 $$=mk_elem($2, SNDPORT_O, 0, NUMBER_ST, (void*)$3 );
1366 | SNDPORT intop attr_id_val {
1367 onsend_check("snd_port");
1368 $$=mk_elem($2, SNDPORT_O, 0, AVP_ST, (void*)$3 );
1370 | SNDPORT intop error { $$=0; yyerror("number expected"); }
1371 | SNDPORT error { $$=0; yyerror("==, !=, <,>, >= or <= expected"); }
1373 | TOPORT intop NUMBER {
1374 onsend_check("to_port");
1375 $$=mk_elem($2, TOPORT_O, 0, NUMBER_ST, (void*)$3 );
1377 | TOPORT intop attr_id_val {
1378 onsend_check("to_port");
1379 $$=mk_elem($2, TOPORT_O, 0, AVP_ST, (void*)$3 );
1381 | TOPORT intop error { $$=0; yyerror("number expected"); }
1382 | TOPORT error { $$=0; yyerror("==, !=, <,>, >= or <= expected"); }
1384 | PROTO intop proto { $$=mk_elem($2, PROTO_O, 0, NUMBER_ST, (void*)$3 ); }
1385 | PROTO intop attr_id_val { $$=mk_elem($2, PROTO_O, 0, AVP_ST, (void*)$3 ); }
1386 | PROTO intop error { $$=0; yyerror("protocol expected (udp, tcp or tls)"); }
1388 | PROTO error { $$=0; yyerror("equal/!= operator expected"); }
1390 | SNDPROTO intop proto {
1391 onsend_check("snd_proto");
1392 $$=mk_elem($2, SNDPROTO_O, 0, NUMBER_ST, (void*)$3 );
1394 | SNDPROTO intop attr_id_val {
1395 onsend_check("snd_proto");
1396 $$=mk_elem($2, SNDPROTO_O, 0, AVP_ST, (void*)$3 );
1398 | SNDPROTO intop error { $$=0; yyerror("protocol expected (udp, tcp or tls)"); }
1399 | SNDPROTO error { $$=0; yyerror("equal/!= operator expected"); }
1401 | AF intop NUMBER { $$=mk_elem($2, AF_O, 0, NUMBER_ST,(void *) $3 ); }
1402 | AF intop attr_id_val { $$=mk_elem($2, AF_O, 0, AVP_ST,(void *) $3 ); }
1403 | AF intop error { $$=0; yyerror("number expected"); }
1404 | AF error { $$=0; yyerror("equal/!= operator expected"); }
1406 | SNDAF intop NUMBER {
1407 onsend_check("snd_af");
1408 $$=mk_elem($2, SNDAF_O, 0, NUMBER_ST, (void *) $3 ); }
1409 | SNDAF intop attr_id_val {
1410 onsend_check("snd_af");
1411 $$=mk_elem($2, SNDAF_O, 0, AVP_ST, (void *) $3 );
1413 | SNDAF intop error { $$=0; yyerror("number expected"); }
1414 | SNDAF error { $$=0; yyerror("equal/!= operator expected"); }
1416 | MSGLEN intop NUMBER { $$=mk_elem($2, MSGLEN_O, 0, NUMBER_ST, (void *) $3 ); }
1417 | MSGLEN intop attr_id_val { $$=mk_elem($2, MSGLEN_O, 0, AVP_ST, (void *) $3 ); }
1418 | MSGLEN intop MAX_LEN { $$=mk_elem($2, MSGLEN_O, 0, NUMBER_ST, (void *) BUF_SIZE); }
1419 | MSGLEN intop error { $$=0; yyerror("number expected"); }
1420 | MSGLEN error { $$=0; yyerror("equal/!= operator expected"); }
1422 | RETCODE intop NUMBER { $$=mk_elem($2, RETCODE_O, 0, NUMBER_ST, (void *) $3 ); }
1423 | RETCODE intop attr_id_val { $$=mk_elem($2, RETCODE_O, 0, AVP_ST, (void *) $3 ); }
1424 | RETCODE intop error { $$=0; yyerror("number expected"); }
1425 | RETCODE error { $$=0; yyerror("equal/!= operator expected"); }
1427 | SRCIP equalop ipnet { $$=mk_elem($2, SRCIP_O, 0, NET_ST, $3); }
1428 | SRCIP strop STRING {
1430 s_tmp.len=strlen($3);
1431 ip_tmp=str2ip(&s_tmp);
1433 ip_tmp=str2ip6(&s_tmp);
1435 $$=mk_elem($2, SRCIP_O, 0, NET_ST, mk_net_bitlen(ip_tmp, ip_tmp->len*8) );
1437 $$=mk_elem($2, SRCIP_O, 0, STRING_ST, $3);
1440 | SRCIP strop host { $$=mk_elem($2, SRCIP_O, 0, STRING_ST, $3); }
1441 | SRCIP equalop MYSELF { $$=mk_elem($2, SRCIP_O, 0, MYSELF_ST, 0);
1443 | SRCIP strop error { $$=0; yyerror( "ip address or hostname expected" ); }
1444 | SRCIP error { $$=0; yyerror("invalid operator, ==, != or =~ expected");}
1445 | DSTIP equalop ipnet { $$=mk_elem( $2, DSTIP_O, 0, NET_ST, (void*)$3); }
1446 | DSTIP strop STRING {
1448 s_tmp.len=strlen($3);
1449 ip_tmp=str2ip(&s_tmp);
1451 ip_tmp=str2ip6(&s_tmp);
1453 $$=mk_elem($2, DSTIP_O, 0, NET_ST, mk_net_bitlen(ip_tmp, ip_tmp->len*8) );
1455 $$=mk_elem($2, DSTIP_O, 0, STRING_ST, $3);
1458 | DSTIP strop host { $$=mk_elem( $2, DSTIP_O, 0, STRING_ST, $3); }
1459 | DSTIP equalop MYSELF { $$=mk_elem( $2, DSTIP_O, 0, MYSELF_ST, 0); }
1460 | DSTIP strop error { $$=0; yyerror( "ip address or hostname expected" ); }
1461 | DSTIP error { $$=0; yyerror("invalid operator, ==, != or =~ expected"); }
1462 | SNDIP equalop ipnet {
1463 onsend_check("snd_ip");
1464 $$=mk_elem($2, SNDIP_O, 0, NET_ST, $3);
1466 | SNDIP strop STRING {
1467 onsend_check("snd_ip");
1469 s_tmp.len=strlen($3);
1470 ip_tmp=str2ip(&s_tmp);
1472 ip_tmp=str2ip6(&s_tmp);
1474 $$=mk_elem($2, SNDIP_O, 0, NET_ST, mk_net_bitlen(ip_tmp, ip_tmp->len*8) );
1476 $$=mk_elem($2, SNDIP_O, 0, STRING_ST, $3);
1479 | SNDIP strop host {
1480 onsend_check("snd_ip");
1481 $$=mk_elem($2, SNDIP_O, 0, STRING_ST, $3);
1483 | SNDIP equalop attr_id_val {
1484 onsend_check("snd_ip");
1485 $$=mk_elem($2, SNDIP_O, 0, AVP_ST, (void*)$3 );
1487 | SNDIP equalop MYSELF {
1488 onsend_check("snd_ip");
1489 $$=mk_elem($2, SNDIP_O, 0, MYSELF_ST, 0);
1491 | SNDIP strop error { $$=0; yyerror( "ip address or hostname expected" ); }
1492 | SNDIP error { $$=0; yyerror("invalid operator, ==, != or =~ expected"); }
1493 | TOIP equalop ipnet {
1494 onsend_check("to_ip");
1495 $$=mk_elem($2, TOIP_O, 0, NET_ST, $3);
1497 | TOIP strop STRING {
1498 onsend_check("to_ip");
1500 s_tmp.len=strlen($3);
1501 ip_tmp=str2ip(&s_tmp);
1503 ip_tmp=str2ip6(&s_tmp);
1505 $$=mk_elem($2, TOIP_O, 0, NET_ST, mk_net_bitlen(ip_tmp, ip_tmp->len*8) );
1507 $$=mk_elem($2, TOIP_O, 0, STRING_ST, $3);
1511 onsend_check("to_ip");
1512 $$=mk_elem($2, TOIP_O, 0, STRING_ST, $3);
1514 | TOIP equalop attr_id_val {
1515 onsend_check("to_ip");
1516 $$=mk_elem($2, TOIP_O, 0, AVP_ST, (void*)$3 );
1518 | TOIP equalop MYSELF {
1519 onsend_check("to_ip");
1520 $$=mk_elem($2, TOIP_O, 0, MYSELF_ST, 0);
1522 | TOIP strop error { $$=0; yyerror( "ip address or hostname expected" ); }
1523 | TOIP error { $$=0; yyerror("invalid operator, ==, != or =~ expected"); }
1525 | MYSELF equalop uri_type { $$=mk_elem($2, $3, 0, MYSELF_ST, 0); }
1526 | MYSELF equalop SRCIP { $$=mk_elem($2, SRCIP_O, 0, MYSELF_ST, 0); }
1527 | MYSELF equalop DSTIP { $$=mk_elem($2, DSTIP_O, 0, MYSELF_ST, 0); }
1528 | MYSELF equalop SNDIP {
1529 onsend_check("snd_ip");
1530 $$=mk_elem($2, SNDIP_O, 0, MYSELF_ST, 0);
1532 | MYSELF equalop TOIP {
1533 onsend_check("to_ip");
1534 $$=mk_elem($2, TOIP_O, 0, MYSELF_ST, 0);
1536 | MYSELF equalop error { $$=0; yyerror(" URI, SRCIP or DSTIP expected"); }
1537 | MYSELF error { $$=0; yyerror ("invalid operator, == or != expected"); }
1538 | exp_stm { $$=mk_elem( NO_OP, ACTION_O, 0, ACTIONS_ST, $1); }
1539 | NUMBER { $$=mk_elem( NO_OP, NUMBER_O, 0, NUMBER_ST, (void*)$1 ); }
1541 | attr_id_any {$$=mk_elem( NO_OP, AVP_O, (void*)$1, 0, 0); }
1542 | attr_id_val strop STRING {$$=mk_elem( $2, AVP_O, (void*)$1, STRING_ST, $3); }
1543 | attr_id_val strop select_id {$$=mk_elem( $2, AVP_O, (void*)$1, SELECT_ST, $3); }
1544 | attr_id_val intop NUMBER {$$=mk_elem( $2, AVP_O, (void*)$1, NUMBER_ST, (void*)$3); }
1545 | attr_id_val binop NUMBER {$$=mk_elem( $2, AVP_O, (void*)$1, NUMBER_ST, (void*)$3); }
1546 | attr_id_val strop attr_id_val {$$=mk_elem( $2, AVP_O, (void*)$1, AVP_ST, (void*)$3); }
1548 | select_id { $$=mk_elem( NO_OP, SELECT_O, $1, 0, 0); }
1549 | select_id strop STRING { $$=mk_elem( $2, SELECT_O, $1, STRING_ST, $3); }
1550 | select_id strop attr_id_val { $$=mk_elem( $2, SELECT_O, $1, AVP_ST, (void*)$3); }
1551 | select_id strop select_id { $$=mk_elem( $2, SELECT_O, $1, SELECT_ST, $3); }
1554 ip SLASH ip { $$=mk_net($1, $3); }
1556 if (($3<0) || ($3>$1->len*8)) {
1557 yyerror("invalid bit number in netmask");
1560 $$=mk_net_bitlen($1, $3);
1562 $$=mk_net($1, htonl( ($3)?~( (1<<(32-$3))-1 ):0 ) );
1566 | ip { $$=mk_net_bitlen($1, $1->len*8); }
1567 | ip SLASH error { $$=0; yyerror("netmask (eg:255.0.0.0 or 8) expected"); }
1576 | host host_sep ID {
1577 $$=(char*)pkg_malloc(strlen($1)+1+strlen($3)+1);
1579 LOG(L_CRIT, "ERROR: cfg. parser: memory allocation failure while parsing host\n");
1581 memcpy($$, $1, strlen($1));
1583 memcpy($$+strlen($1)+1, $3, strlen($3));
1584 $$[strlen($1)+1+strlen($3)]=0;
1589 | host DOT error { $$=0; pkg_free($1); yyerror("invalid hostname"); }
1594 /* check if allowed */
1595 if ($1 && rt==ONSEND_ROUTE) {
1610 yyerror("command not allowed in onsend_route\n");
1620 | assign_action { $$ = $1; }
1621 | LBRACE actions RBRACE { $$=$2; }
1625 | LBRACE actions RBRACE { $$=$2; }
1628 actions action {$$=append_action($1, $2); }
1630 | actions error { $$=0; yyerror("bad command"); }
1633 fcmd SEMICOLON {$$=$1;}
1635 | assign_action SEMICOLON {$$=$1;}
1636 | SEMICOLON /* null action */ {$$=0;}
1637 | fcmd error { $$=0; yyerror("bad command: missing ';'?"); }
1640 IF exp stm { $$=mk_action( IF_T, 3, EXPR_ST, $2, ACTIONS_ST, $3, NOSUBTYPE, 0); }
1641 | IF exp stm ELSE stm { $$=mk_action( IF_T, 3, EXPR_ST, $2, ACTIONS_ST, $3, ACTIONS_ST, $5); }
1644 LBRACK ATTR_USER RBRACK { $$ = AVP_CLASS_USER; }
1645 | LBRACK ATTR_DOMAIN RBRACK { $$ = AVP_CLASS_DOMAIN; }
1646 | LBRACK ATTR_GLOBAL RBRACK { $$ = AVP_CLASS_GLOBAL; }
1651 if (sel.n >= MAX_SELECT_PARAMS-1) {
1652 yyerror("Select identifier too long\n");
1654 sel.params[sel.n].type = SEL_PARAM_STR;
1655 sel.params[sel.n].v.s.s = $1;
1656 sel.params[sel.n].v.s.len = strlen($1);
1659 | ID LBRACK NUMBER RBRACK {
1660 if (sel.n >= MAX_SELECT_PARAMS-2) {
1661 yyerror("Select identifier too long\n");
1663 sel.params[sel.n].type = SEL_PARAM_STR;
1664 sel.params[sel.n].v.s.s = $1;
1665 sel.params[sel.n].v.s.len = strlen($1);
1667 sel.params[sel.n].type = SEL_PARAM_INT;
1668 sel.params[sel.n].v.i = $3;
1671 | ID LBRACK STRING RBRACK {
1672 if (sel.n >= MAX_SELECT_PARAMS-2) {
1673 yyerror("Select identifier too long\n");
1675 sel.params[sel.n].type = SEL_PARAM_STR;
1676 sel.params[sel.n].v.s.s = $1;
1677 sel.params[sel.n].v.s.len = strlen($1);
1679 sel.params[sel.n].type = SEL_PARAM_STR;
1680 sel.params[sel.n].v.s.s = $3;
1681 sel.params[sel.n].v.s.len = strlen($3);
1686 select_params DOT select_param
1690 SELECT_MARK { sel.n = 0; sel.f[0] = 0; } select_params {
1691 sel_ptr = (select_t*)pkg_malloc(sizeof(select_t));
1693 yyerror("No memory left to allocate select structure\n");
1695 memcpy(sel_ptr, &sel, sizeof(select_t));
1700 ATTR_FROM { s_attr->type |= AVP_TRACK_FROM; }
1701 | ATTR_TO { s_attr->type |= AVP_TRACK_TO; }
1702 | ATTR_FROMURI { s_attr->type |= AVP_TRACK_FROM | AVP_CLASS_URI; }
1703 | ATTR_TOURI { s_attr->type |= AVP_TRACK_TO | AVP_CLASS_URI; }
1704 | ATTR_FROMUSER { s_attr->type |= AVP_TRACK_FROM | AVP_CLASS_USER; }
1705 | ATTR_TOUSER { s_attr->type |= AVP_TRACK_TO | AVP_CLASS_USER; }
1706 | ATTR_FROMDOMAIN { s_attr->type |= AVP_TRACK_FROM | AVP_CLASS_DOMAIN; }
1707 | ATTR_TODOMAIN { s_attr->type |= AVP_TRACK_TO | AVP_CLASS_DOMAIN; }
1708 | ATTR_GLOBAL { s_attr->type |= AVP_TRACK_ALL | AVP_CLASS_GLOBAL; }
1711 ID { s_attr->type |= AVP_NAME_STR; s_attr->name.s.s = $1; s_attr->name.s.len = strlen ($1); }
1715 | attr_class_spec DOT attr_name_spec
1719 s_attr = (struct avp_spec*)pkg_malloc(sizeof(struct avp_spec));
1720 if (!s_attr) { yyerror("No memory left"); }
1725 attr_mark attr_spec { $$ = s_attr; }
1728 attr_mark attr_spec LBRACK NUMBER RBRACK {
1729 s_attr->type|= (AVP_NAME_STR | ($4<0?AVP_INDEX_BACKWARD:AVP_INDEX_FORWARD));
1730 s_attr->index = ($4<0?-$4:$4);
1735 attr_mark attr_spec LBRACK RBRACK {
1736 s_attr->type|= AVP_INDEX_ALL;
1756 avp_spec_t *avp_spec;
1759 avp_spec = pkg_malloc(sizeof(*avp_spec));
1761 yyerror("Not enough memory");
1767 s.len = strlen(s.s);
1768 if (parse_avp_name(&s, &type, &avp_spec->name, &idx)) {
1769 yyerror("error when parsing AVP");
1773 avp_spec->type = type;
1774 avp_spec->index = idx;
1780 ADDEQ { $$ = ADD_T; }
1781 | EQUAL { $$ = ASSIGN_T; }
1785 EQUAL { $$ = ASSIGN_T; }
1788 attr_id_ass assign_op STRING { $$=mk_action($2, 2, AVP_ST, $1, STRING_ST, $3); }
1789 | attr_id_ass assign_op NUMBER { $$=mk_action($2, 2, AVP_ST, $1, NUMBER_ST, (void*)$3); }
1790 | attr_id_ass assign_op fcmd { $$=mk_action($2, 2, AVP_ST, $1, ACTION_ST, $3); }
1791 | attr_id_ass assign_op attr_id_any { $$=mk_action($2, 2, AVP_ST, $1, AVP_ST, $3); }
1792 | attr_id_ass assign_op select_id { $$=mk_action($2, 2, AVP_ST, (void*)$1, SELECT_ST, (void*)$3); }
1793 | attr_id_ass assign_op LPAREN exp RPAREN { $$ = mk_action($2, 2, AVP_ST, $1, EXPR_ST, $4); }
1796 SETAVPFLAG { $$ = 1; }
1797 | RESETAVPFLAG { $$ = 0; }
1798 | ISAVPFLAGSET { $$ = -1; }
1801 FORWARD LPAREN host RPAREN { $$=mk_action( FORWARD_T, 2, STRING_ST, $3, NUMBER_ST, 0); }
1802 | FORWARD LPAREN STRING RPAREN { $$=mk_action( FORWARD_T, 2, STRING_ST, $3, NUMBER_ST, 0); }
1803 | FORWARD LPAREN ip RPAREN { $$=mk_action( FORWARD_T, 2, IP_ST, (void*)$3, NUMBER_ST, 0); }
1804 | FORWARD LPAREN host COMMA NUMBER RPAREN { $$=mk_action(FORWARD_T, 2, STRING_ST, $3, NUMBER_ST, (void*)$5); }
1805 | FORWARD LPAREN STRING COMMA NUMBER RPAREN {$$=mk_action(FORWARD_T, 2, STRING_ST, $3, NUMBER_ST, (void*)$5); }
1806 | FORWARD LPAREN ip COMMA NUMBER RPAREN { $$=mk_action(FORWARD_T, 2, IP_ST, (void*)$3, NUMBER_ST, (void*)$5); }
1807 | FORWARD LPAREN URIHOST COMMA URIPORT RPAREN { $$=mk_action(FORWARD_T, 2, URIHOST_ST, 0, URIPORT_ST, 0); }
1808 | FORWARD LPAREN URIHOST COMMA NUMBER RPAREN {$$=mk_action(FORWARD_T, 2, URIHOST_ST, 0, NUMBER_ST, (void*)$5); }
1809 | FORWARD LPAREN URIHOST RPAREN { $$=mk_action(FORWARD_T, 2, URIHOST_ST, 0, NUMBER_ST, 0); }
1810 | FORWARD error { $$=0; yyerror("missing '(' or ')' ?"); }
1811 | FORWARD LPAREN error RPAREN { $$=0; yyerror("bad forward argument"); }
1812 | FORWARD_UDP LPAREN host RPAREN { $$=mk_action(FORWARD_UDP_T, 2, STRING_ST, $3, NUMBER_ST, 0); }
1813 | FORWARD_UDP LPAREN STRING RPAREN { $$=mk_action(FORWARD_UDP_T, 2, STRING_ST, $3, NUMBER_ST, 0); }
1814 | FORWARD_UDP LPAREN ip RPAREN { $$=mk_action(FORWARD_UDP_T, 2, IP_ST, (void*)$3, NUMBER_ST, 0); }
1815 | FORWARD_UDP LPAREN host COMMA NUMBER RPAREN { $$=mk_action(FORWARD_UDP_T, 2, STRING_ST, $3, NUMBER_ST, (void*)$5); }
1816 | FORWARD_UDP LPAREN STRING COMMA NUMBER RPAREN {$$=mk_action(FORWARD_UDP_T, 2, STRING_ST, $3, NUMBER_ST, (void*)$5); }
1817 | FORWARD_UDP LPAREN ip COMMA NUMBER RPAREN { $$=mk_action(FORWARD_UDP_T, 2, IP_ST, (void*)$3, NUMBER_ST, (void*)$5); }
1818 | FORWARD_UDP LPAREN URIHOST COMMA URIPORT RPAREN {$$=mk_action(FORWARD_UDP_T, 2, URIHOST_ST, 0, URIPORT_ST, 0); }
1819 | FORWARD_UDP LPAREN URIHOST COMMA NUMBER RPAREN { $$=mk_action(FORWARD_UDP_T, 2, URIHOST_ST, 0, NUMBER_ST, (void*)$5); }
1820 | FORWARD_UDP LPAREN URIHOST RPAREN { $$=mk_action(FORWARD_UDP_T, 2, URIHOST_ST, 0, NUMBER_ST, 0); }
1821 | FORWARD_UDP error { $$=0; yyerror("missing '(' or ')' ?"); }
1822 | FORWARD_UDP LPAREN error RPAREN { $$=0; yyerror("bad forward_udp argument"); }
1823 | FORWARD_TCP LPAREN host RPAREN { $$=mk_action(FORWARD_TCP_T, 2, STRING_ST, $3, NUMBER_ST, 0); }
1824 | FORWARD_TCP LPAREN STRING RPAREN { $$=mk_action(FORWARD_TCP_T, 2, STRING_ST, $3, NUMBER_ST, 0); }
1825 | FORWARD_TCP LPAREN ip RPAREN { $$=mk_action(FORWARD_TCP_T, 2, IP_ST, (void*)$3, NUMBER_ST, 0); }
1826 | FORWARD_TCP LPAREN host COMMA NUMBER RPAREN { $$=mk_action(FORWARD_TCP_T, 2, STRING_ST, $3, NUMBER_ST, (void*)$5); }
1827 | FORWARD_TCP LPAREN STRING COMMA NUMBER RPAREN {$$=mk_action(FORWARD_TCP_T, 2, STRING_ST, $3, NUMBER_ST, (void*)$5); }
1828 | FORWARD_TCP LPAREN ip COMMA NUMBER RPAREN { $$=mk_action(FORWARD_TCP_T, 2, IP_ST, (void*)$3, NUMBER_ST, (void*)$5); }
1829 | FORWARD_TCP LPAREN URIHOST COMMA URIPORT RPAREN {$$=mk_action(FORWARD_TCP_T, 2, URIHOST_ST, 0, URIPORT_ST, 0); }
1830 | FORWARD_TCP LPAREN URIHOST COMMA NUMBER RPAREN { $$=mk_action(FORWARD_TCP_T, 2, URIHOST_ST, 0, NUMBER_ST, (void*)$5); }
1831 | FORWARD_TCP LPAREN URIHOST RPAREN { $$=mk_action(FORWARD_TCP_T, 2, URIHOST_ST, 0, NUMBER_ST, 0); }
1832 | FORWARD_TCP error { $$=0; yyerror("missing '(' or ')' ?"); }
1833 | FORWARD_TCP LPAREN error RPAREN { $$=0; yyerror("bad forward_tcp argument"); }
1834 | FORWARD_TLS LPAREN host RPAREN {
1836 $$=mk_action(FORWARD_TLS_T, 2, STRING_ST, $3, NUMBER_ST, 0);
1839 yyerror("tls support not compiled in");
1842 | FORWARD_TLS LPAREN STRING RPAREN {
1844 $$=mk_action(FORWARD_TLS_T, 2, STRING_ST, $3, NUMBER_ST, 0);
1847 yyerror("tls support not compiled in");
1850 | FORWARD_TLS LPAREN ip RPAREN {
1852 $$=mk_action(FORWARD_TLS_T, 2, IP_ST, (void*)$3, NUMBER_ST, 0);
1855 yyerror("tls support not compiled in");
1858 | FORWARD_TLS LPAREN host COMMA NUMBER RPAREN {
1860 $$=mk_action(FORWARD_TLS_T, 2, STRING_ST, $3, NUMBER_ST, (void*)$5);
1863 yyerror("tls support not compiled in");
1866 | FORWARD_TLS LPAREN STRING COMMA NUMBER RPAREN {
1868 $$=mk_action(FORWARD_TLS_T, 2, STRING_ST, $3, NUMBER_ST, (void*)$5);
1871 yyerror("tls support not compiled in");
1874 | FORWARD_TLS LPAREN ip COMMA NUMBER RPAREN {
1876 $$=mk_action(FORWARD_TLS_T, 2, IP_ST, (void*)$3, NUMBER_ST, (void*)$5);
1879 yyerror("tls support not compiled in");
1882 | FORWARD_TLS LPAREN URIHOST COMMA URIPORT RPAREN {
1884 $$=mk_action(FORWARD_TLS_T, 2, URIHOST_ST, 0, URIPORT_ST, 0);
1887 yyerror("tls support not compiled in");
1890 | FORWARD_TLS LPAREN URIHOST COMMA NUMBER RPAREN {
1892 $$=mk_action(FORWARD_TLS_T, 2, URIHOST_ST, 0, NUMBER_ST, (void*)$5);
1895 yyerror("tls support not compiled in");
1898 | FORWARD_TLS LPAREN URIHOST RPAREN {
1900 $$=mk_action(FORWARD_TLS_T, 2, URIHOST_ST, 0, NUMBER_ST, 0);
1903 yyerror("tls support not compiled in");
1906 | FORWARD_TLS error { $$=0; yyerror("missing '(' or ')' ?"); }
1907 | FORWARD_TLS LPAREN error RPAREN { $$=0; yyerror("bad forward_tls argument"); }
1908 | SEND LPAREN host RPAREN { $$=mk_action(SEND_T, 2, STRING_ST, $3, NUMBER_ST, 0); }
1909 | SEND LPAREN STRING RPAREN { $$=mk_action(SEND_T, 2, STRING_ST, $3, NUMBER_ST, 0); }
1910 | SEND LPAREN ip RPAREN { $$=mk_action(SEND_T, 2, IP_ST, (void*)$3, NUMBER_ST, 0); }
1911 | SEND LPAREN host COMMA NUMBER RPAREN { $$=mk_action(SEND_T, 2, STRING_ST, $3, NUMBER_ST, (void*)$5); }
1912 | SEND LPAREN STRING COMMA NUMBER RPAREN {$$=mk_action(SEND_T, 2, STRING_ST, $3, NUMBER_ST, (void*)$5); }
1913 | SEND LPAREN ip COMMA NUMBER RPAREN { $$=mk_action(SEND_T, 2, IP_ST, (void*)$3, NUMBER_ST, (void*)$5); }
1914 | SEND error { $$=0; yyerror("missing '(' or ')' ?"); }
1915 | SEND LPAREN error RPAREN { $$=0; yyerror("bad send argument"); }
1916 | SEND_TCP LPAREN host RPAREN { $$=mk_action(SEND_TCP_T, 2, STRING_ST, $3, NUMBER_ST, 0); }
1917 | SEND_TCP LPAREN STRING RPAREN { $$=mk_action(SEND_TCP_T, 2, STRING_ST, $3, NUMBER_ST, 0); }
1918 | SEND_TCP LPAREN ip RPAREN { $$=mk_action(SEND_TCP_T, 2, IP_ST, (void*)$3, NUMBER_ST, 0); }
1919 | SEND_TCP LPAREN host COMMA NUMBER RPAREN { $$=mk_action( SEND_TCP_T, 2, STRING_ST, $3, NUMBER_ST, (void*)$5);}
1920 | SEND_TCP LPAREN STRING COMMA NUMBER RPAREN {$$=mk_action(SEND_TCP_T, 2, STRING_ST, $3, NUMBER_ST, (void*)$5); }
1921 | SEND_TCP LPAREN ip COMMA NUMBER RPAREN { $$=mk_action(SEND_TCP_T, 2, IP_ST, (void*)$3, NUMBER_ST, (void*)$5); }
1922 | SEND_TCP error { $$=0; yyerror("missing '(' or ')' ?"); }
1923 | SEND_TCP LPAREN error RPAREN { $$=0; yyerror("bad send_tcp argument"); }
1924 | DROP LPAREN RPAREN {$$=mk_action(DROP_T, 2, NUMBER_ST, 0, NUMBER_ST, (void*)EXIT_R_F); }
1925 | DROP LPAREN NUMBER RPAREN {$$=mk_action(DROP_T, 2, NUMBER_ST, (void*)$3, NUMBER_ST, (void*)EXIT_R_F); }
1926 | DROP NUMBER {$$=mk_action(DROP_T, 2, NUMBER_ST, (void*)$2, NUMBER_ST, (void*)EXIT_R_F); }
1927 | DROP RETCODE {$$=mk_action(DROP_T, 2, RETCODE_ST, 0, NUMBER_ST, (void*)EXIT_R_F); }
1928 | DROP {$$=mk_action(DROP_T, 2, NUMBER_ST, 0, NUMBER_ST, (void*)EXIT_R_F); }
1929 | RETURN {$$=mk_action(DROP_T, 2, NUMBER_ST, (void*)1, NUMBER_ST, (void*)RETURN_R_F); }
1930 | RETURN NUMBER {$$=mk_action(DROP_T, 2, NUMBER_ST, (void*)$2, NUMBER_ST, (void*)RETURN_R_F);}
1931 | RETURN RETCODE {$$=mk_action(DROP_T, 2, RETCODE_ST, 0, NUMBER_ST, (void*)RETURN_R_F);}
1932 | BREAK {$$=mk_action(DROP_T, 2, NUMBER_ST, 0, NUMBER_ST, (void*)RETURN_R_F); }
1933 | LOG_TOK LPAREN STRING RPAREN {$$=mk_action(LOG_T, 2, NUMBER_ST, (void*)4, STRING_ST, $3); }
1934 | LOG_TOK LPAREN NUMBER COMMA STRING RPAREN {$$=mk_action(LOG_T, 2, NUMBER_ST, (void*)$3, STRING_ST, $5); }
1935 | LOG_TOK error { $$=0; yyerror("missing '(' or ')' ?"); }
1936 | LOG_TOK LPAREN error RPAREN { $$=0; yyerror("bad log argument"); }
1937 | SETFLAG LPAREN NUMBER RPAREN {
1938 if (check_flag($3)==-1)
1939 yyerror("bad flag value");
1940 $$=mk_action(SETFLAG_T, 1, NUMBER_ST,
1943 | SETFLAG LPAREN flag_name RPAREN {
1944 i_tmp=get_flag_no($3, strlen($3));
1945 if (i_tmp<0) yyerror("flag not declared");
1946 $$=mk_action(SETFLAG_T, 1, NUMBER_ST,
1947 (void*)(long)i_tmp);
1949 | SETFLAG error { $$=0; yyerror("missing '(' or ')'?"); }
1950 | RESETFLAG LPAREN NUMBER RPAREN {
1951 if (check_flag($3)==-1)
1952 yyerror("bad flag value");
1953 $$=mk_action(RESETFLAG_T, 1, NUMBER_ST, (void*)$3);
1955 | RESETFLAG LPAREN flag_name RPAREN {
1956 i_tmp=get_flag_no($3, strlen($3));
1957 if (i_tmp<0) yyerror("flag not declared");
1958 $$=mk_action(RESETFLAG_T, 1, NUMBER_ST,
1959 (void*)(long)i_tmp);
1961 | RESETFLAG error { $$=0; yyerror("missing '(' or ')'?"); }
1962 | ISFLAGSET LPAREN NUMBER RPAREN {
1963 if (check_flag($3)==-1)
1964 yyerror("bad flag value");
1965 $$=mk_action(ISFLAGSET_T, 1, NUMBER_ST, (void*)$3);
1967 | ISFLAGSET LPAREN flag_name RPAREN {
1968 i_tmp=get_flag_no($3, strlen($3));
1969 if (i_tmp<0) yyerror("flag not declared");
1970 $$=mk_action(ISFLAGSET_T, 1, NUMBER_ST,
1971 (void*)(long)i_tmp);
1973 | ISFLAGSET error { $$=0; yyerror("missing '(' or ')'?"); }
1974 | avpflag_oper LPAREN attr_id_any_str COMMA flag_name RPAREN {
1975 i_tmp=get_avpflag_no($5);
1976 if (i_tmp==0) yyerror("avpflag not declared");
1977 $$=mk_action(AVPFLAG_OPER_T, 3, AVP_ST, $3, NUMBER_ST, (void*)(long)i_tmp, NUMBER_ST, (void*)$1);
1979 | avpflag_oper error { $$=0; yyerror("missing '(' or ')'?"); }
1980 | ERROR LPAREN STRING COMMA STRING RPAREN {$$=mk_action(ERROR_T, 2, STRING_ST, $3, STRING_ST, $5); }
1981 | ERROR error { $$=0; yyerror("missing '(' or ')' ?"); }
1982 | ERROR LPAREN error RPAREN { $$=0; yyerror("bad error argument"); }
1983 | ROUTE LPAREN route_name RPAREN {
1984 i_tmp=route_get(&main_rt, $3);
1986 yyerror("internal error");
1989 $$=mk_action(ROUTE_T, 1, NUMBER_ST,(void*)(long)i_tmp);
1991 | ROUTE error { $$=0; yyerror("missing '(' or ')' ?"); }
1992 | ROUTE LPAREN error RPAREN { $$=0; yyerror("bad route argument"); }
1993 | EXEC LPAREN STRING RPAREN { $$=mk_action(EXEC_T, 1, STRING_ST, $3); }
1994 | SET_HOST LPAREN STRING RPAREN { $$=mk_action(SET_HOST_T, 1, STRING_ST, $3); }
1995 | SET_HOST error { $$=0; yyerror("missing '(' or ')' ?"); }
1996 | SET_HOST LPAREN error RPAREN { $$=0; yyerror("bad argument, string expected"); }
1997 | PREFIX LPAREN STRING RPAREN { $$=mk_action(PREFIX_T, 1, STRING_ST, $3); }
1998 | PREFIX error { $$=0; yyerror("missing '(' or ')' ?"); }
1999 | PREFIX LPAREN error RPAREN { $$=0; yyerror("bad argument, string expected"); }
2000 | STRIP_TAIL LPAREN NUMBER RPAREN { $$=mk_action(STRIP_TAIL_T, 1, NUMBER_ST, (void*)$3); }
2001 | STRIP_TAIL error { $$=0; yyerror("missing '(' or ')' ?"); }
2002 | STRIP_TAIL LPAREN error RPAREN { $$=0; yyerror("bad argument, number expected"); }
2003 | STRIP LPAREN NUMBER RPAREN { $$=mk_action(STRIP_T, 1, NUMBER_ST, (void*) $3); }
2004 | STRIP error { $$=0; yyerror("missing '(' or ')' ?"); }
2005 | STRIP LPAREN error RPAREN { $$=0; yyerror("bad argument, number expected"); }
2006 | APPEND_BRANCH LPAREN STRING COMMA STRING RPAREN {
2008 if (str2q(&q, $5, strlen($5)) < 0) {
2009 yyerror("bad argument, q value expected");
2011 $$=mk_action(APPEND_BRANCH_T, 2, STRING_ST, $3, NUMBER_ST, (void *)(long)q);
2013 | APPEND_BRANCH LPAREN STRING RPAREN { $$=mk_action(APPEND_BRANCH_T, 2, STRING_ST, $3, NUMBER_ST, (void *)Q_UNSPECIFIED); }
2014 | APPEND_BRANCH LPAREN RPAREN { $$=mk_action(APPEND_BRANCH_T, 2, STRING_ST, 0, NUMBER_ST, (void *)Q_UNSPECIFIED); }
2015 | APPEND_BRANCH { $$=mk_action( APPEND_BRANCH_T, 1, STRING_ST, 0); }
2016 | SET_HOSTPORT LPAREN STRING RPAREN { $$=mk_action(SET_HOSTPORT_T, 1, STRING_ST, $3); }
2017 | SET_HOSTPORT error { $$=0; yyerror("missing '(' or ')' ?"); }
2018 | SET_HOSTPORT LPAREN error RPAREN { $$=0; yyerror("bad argument, string expected"); }
2019 | SET_PORT LPAREN STRING RPAREN { $$=mk_action(SET_PORT_T, 1, STRING_ST, $3); }
2020 | SET_PORT error { $$=0; yyerror("missing '(' or ')' ?"); }
2021 | SET_PORT LPAREN error RPAREN { $$=0; yyerror("bad argument, string expected"); }
2022 | SET_USER LPAREN STRING RPAREN { $$=mk_action(SET_USER_T, 1, STRING_ST, $3); }
2023 | SET_USER error { $$=0; yyerror("missing '(' or ')' ?"); }
2024 | SET_USER LPAREN error RPAREN { $$=0; yyerror("bad argument, string expected"); }
2025 | SET_USERPASS LPAREN STRING RPAREN { $$=mk_action(SET_USERPASS_T, 1, STRING_ST, $3); }
2026 | SET_USERPASS error { $$=0; yyerror("missing '(' or ')' ?"); }
2027 | SET_USERPASS LPAREN error RPAREN { $$=0; yyerror("bad argument, string expected"); }
2028 | SET_URI LPAREN STRING RPAREN { $$=mk_action(SET_URI_T, 1, STRING_ST,$3); }
2029 | SET_URI error { $$=0; yyerror("missing '(' or ')' ?"); }
2030 | SET_URI LPAREN error RPAREN { $$=0; yyerror("bad argument, string expected"); }
2031 | REVERT_URI LPAREN RPAREN { $$=mk_action(REVERT_URI_T, 0); }
2032 | REVERT_URI { $$=mk_action(REVERT_URI_T, 0); }
2033 | FORCE_RPORT LPAREN RPAREN { $$=mk_action(FORCE_RPORT_T, 0); }
2034 | FORCE_RPORT {$$=mk_action(FORCE_RPORT_T, 0); }
2035 | FORCE_TCP_ALIAS LPAREN NUMBER RPAREN {
2037 $$=mk_action(FORCE_TCP_ALIAS_T, 1, NUMBER_ST, (void*)$3);
2039 yyerror("tcp support not compiled in");
2042 | FORCE_TCP_ALIAS LPAREN RPAREN {
2044 $$=mk_action(FORCE_TCP_ALIAS_T, 0);
2046 yyerror("tcp support not compiled in");
2051 $$=mk_action(FORCE_TCP_ALIAS_T, 0);
2053 yyerror("tcp support not compiled in");
2056 | FORCE_TCP_ALIAS LPAREN error RPAREN {$$=0; yyerror("bad argument, number expected"); }
2057 | SET_ADV_ADDRESS LPAREN listen_id RPAREN {
2059 if ((str_tmp=pkg_malloc(sizeof(str)))==0) {
2060 LOG(L_CRIT, "ERROR: cfg. parser: out of memory.\n");
2063 str_tmp->len=strlen($3);
2064 $$=mk_action(SET_ADV_ADDR_T, 1, STR_ST, str_tmp);
2067 | SET_ADV_ADDRESS LPAREN error RPAREN { $$=0; yyerror("bad argument, string expected"); }
2068 | SET_ADV_ADDRESS error {$$=0; yyerror("missing '(' or ')' ?"); }
2069 | SET_ADV_PORT LPAREN NUMBER RPAREN {
2071 tmp=int2str($3, &i_tmp);
2072 if ((str_tmp=pkg_malloc(sizeof(str)))==0) {
2073 LOG(L_CRIT, "ERROR: cfg. parser: out of memory.\n");
2075 if ((str_tmp->s=pkg_malloc(i_tmp))==0) {
2076 LOG(L_CRIT, "ERROR: cfg. parser: out of memory.\n");
2078 memcpy(str_tmp->s, tmp, i_tmp);
2080 $$=mk_action(SET_ADV_PORT_T, 1, STR_ST, str_tmp);
2084 | SET_ADV_PORT LPAREN error RPAREN { $$=0; yyerror("bad argument, string expected"); }
2085 | SET_ADV_PORT error {$$=0; yyerror("missing '(' or ')' ?"); }
2086 | FORCE_SEND_SOCKET LPAREN phostport RPAREN { $$=mk_action(FORCE_SEND_SOCKET_T, 1, SOCKID_ST, $3); }
2087 | FORCE_SEND_SOCKET LPAREN error RPAREN { $$=0; yyerror("bad argument, [proto:]host[:port] expected"); }
2088 | FORCE_SEND_SOCKET error {$$=0; yyerror("missing '(' or ')' ?"); }
2089 | ID {mod_func_action = mk_action(MODULE_T, 2, MODEXP_ST, NULL, NUMBER_ST, 0); } LPAREN func_params RPAREN {
2090 mod_func_action->val[0].u.data = find_export_record($1, mod_func_action->val[1].u.number, rt);
2091 if (mod_func_action->val[0].u.data == 0) {
2092 if (find_export_record($1, mod_func_action->val[1].u.number, 0) ) {
2093 yyerror("Command cannot be used in the block\n");
2095 yyerror("unknown command, missing loadmodule?\n");
2097 pkg_free(mod_func_action);
2100 $$ = mod_func_action;
2105 | func_params COMMA func_param { }
2107 | func_params error { yyerror("call params error\n"); YYABORT; }
2111 if (mod_func_action->val[1].u.number < MAX_ACTIONS-2) {
2112 mod_func_action->val[mod_func_action->val[1].u.number+2].type = NUMBER_ST;
2113 mod_func_action->val[mod_func_action->val[1].u.number+2].u.number = $1;
2114 mod_func_action->val[1].u.number++;
2116 yyerror("Too many arguments\n");
2120 if (mod_func_action->val[1].u.number < MAX_ACTIONS-2) {
2121 mod_func_action->val[mod_func_action->val[1].u.number+2].type = STRING_ST;
2122 mod_func_action->val[mod_func_action->val[1].u.number+2].u.string = $1;
2123 mod_func_action->val[1].u.number++;
2125 yyerror("Too many arguments\n");
2133 extern int startcolumn;
2134 static void warn(char* s)
2136 LOG(L_WARN, "cfg. warning: (%d,%d-%d): %s\n", line, startcolumn,
2141 static void yyerror(char* s)
2143 LOG(L_CRIT, "parse error (%d,%d-%d): %s\n", line, startcolumn,
2149 static struct socket_id* mk_listen_id(char* host, int proto, int port)
2151 struct socket_id* l;
2152 l=pkg_malloc(sizeof(struct socket_id));
2154 LOG(L_CRIT,"ERROR: cfg. parser: out of memory.\n");
2166 int main(int argc, char ** argv)
2169 fprintf(stderr, "parsing error\n");