/* * $Id$ * * cfg grammar * * Copyright (C) 2001-2003 FhG Fokus * * This file is part of ser, a free SIP server. * * ser is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version * * For a license to use the ser software under conditions * other than those described here, or to purchase support for this * software, please contact iptel.org by e-mail at the following addresses: * info@iptel.org * * ser is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ /* * History: * --------- * 2003-01-29 src_port added (jiri) * 2003-01-23 mhomed added (jiri) * 2003-03-19 replaced all mallocs/frees with pkg_malloc/pkg_free (andrei) * 2003-03-19 Added support for route type in find_export (janakj) * 2003-03-20 Regex support in modparam (janakj) * 2003-04-01 added dst_port, proto , af (andrei) * 2003-04-05 s/reply_route/failure_route, onreply_route introduced (jiri) * 2003-04-12 added force_rport, chroot and wdir (andrei) * 2003-04-15 added tcp_children, disable_tcp (andrei) * 2003-04-22 strip_tail added (jiri) * 2003-07-03 tls* (disable, certificate, private_key, ca_list, verify, * require_certificate added (andrei) * 2003-07-06 more tls config. vars added: tls_method, tls_port_no (andrei) * 2003-10-02 added {,set_}advertised_{address,port} (andrei) * 2003-10-10 added <,>,<=,>=, != operators support * added msg:len (andrei) * 2003-10-11 if(){} doesn't require a ';' after it anymore (andrei) * 2003-10-13 added FIFO_DIR & proto:host:port listen/alias support (andrei) * 2003-10-24 converted to the new socket_info lists (andrei) * 2003-10-28 added tcp_accept_aliases (andrei) * 2003-11-20 added {tcp_connect, tcp_send, tls_*}_timeout (andrei) * 2004-03-30 added DISABLE_CORE and OPEN_FD_LIMIT (andrei) * 2004-04-29 added SOCK_MODE, SOCK_USER & SOCK_GROUP (andrei) * 2004-05-03 applied multicast support patch (MCAST_LOOPBACK) from janakj * added MCAST_TTL (andrei) * 2004-07-05 src_ip & dst_ip will detect ip addresses between quotes * (andrei) * 2004-10-19 added FROM_URI, TO_URI (andrei) * 2004-11-30 added force_send_socket (andrei) * 2005-07-08 added TCP_CON_LIFETIME, TCP_POLL_METHOD, TCP_MAX_CONNECTIONS * (andrei) * 2005-07-11 added DNS_RETR_TIME, DNS_RETR_NO, DNS_SERVERS_NO, DNS_USE_SEARCH, * DNS_TRY_IPV6 (andrei) * 2005-07-12 default onreply route added (andrei) * 2005-11-16 fixed if (cond) cmd; (andrei) * 2005-12-11 added onsend_route support, fcmd (filtered cmd), * snd_{ip,port,proto,af}, to_{ip,proto} (andrei) * 2005-12-19 select framework (mma) * */ %{ #include #include #include #include #include #include #include #include #include "route_struct.h" #include "globals.h" #include "route.h" #include "dprint.h" #include "sr_module.h" #include "modparam.h" #include "ip_addr.h" #include "resolve.h" #include "socket_info.h" #include "name_alias.h" #include "ut.h" #include "dset.h" #include "select.h" #include "config.h" #ifdef USE_TLS #include "tls/tls_config.h" #endif #ifdef DEBUG_DMALLOC #include #endif /* hack to avoid alloca usage in the generated C file (needed for compiler with no built in alloca, like icc*/ #undef _ALLOCA_H #define onsend_check(s) \ do{\ if (rt!=ONSEND_ROUTE) yyerror( s " allowed only in onsend_routes");\ }while(0) extern int yylex(); static void yyerror(char* s); static char* tmp; static int i_tmp; static void* f_tmp; static struct socket_id* lst_tmp; static int rt; /* Type of route block for find_export */ static str* str_tmp; static str s_tmp; static struct ip_addr* ip_tmp; static struct avp_spec* s_attr; static select_t sel; static select_t* sel_ptr; static void warn(char* s); static struct socket_id* mk_listen_id(char*, int, int); %} %union { long intval; unsigned long uval; char* strval; struct expr* expr; struct action* action; struct net* ipnet; struct ip_addr* ipaddr; struct socket_id* sockid; struct avp_spec* attr; select_t* select; } /* terminals */ /* keywords */ %token FORWARD %token FORWARD_TCP %token FORWARD_TLS %token FORWARD_UDP %token SEND %token SEND_TCP %token DROP %token RETURN %token BREAK %token LOG_TOK %token ERROR %token ROUTE %token ROUTE_FAILURE %token ROUTE_ONREPLY %token ROUTE_BRANCH %token ROUTE_SEND %token EXEC %token SET_HOST %token SET_HOSTPORT %token PREFIX %token STRIP %token STRIP_TAIL %token APPEND_BRANCH %token SET_USER %token SET_USERPASS %token SET_PORT %token SET_URI %token REVERT_URI %token FORCE_RPORT %token FORCE_TCP_ALIAS %token IF %token ELSE %token SET_ADV_ADDRESS %token SET_ADV_PORT %token FORCE_SEND_SOCKET %token URIHOST %token URIPORT %token MAX_LEN %token SETFLAG %token RESETFLAG %token ISFLAGSET %token METHOD %token URI %token FROM_URI %token TO_URI %token SRCIP %token SRCPORT %token DSTIP %token DSTPORT %token TOIP %token TOPORT %token SNDIP %token SNDPORT %token SNDPROTO %token SNDAF %token PROTO %token AF %token MYSELF %token MSGLEN %token RETCODE %token UDP %token TCP %token TLS /* config vars. */ %token DEBUG_V %token FORK %token LOGSTDERROR %token LOGFACILITY %token LISTEN %token ALIAS %token DNS %token REV_DNS %token DNS_TRY_IPV6 %token DNS_RETR_TIME %token DNS_RETR_NO %token DNS_SERVERS_NO %token DNS_USE_SEARCH %token PORT %token STAT %token CHILDREN %token CHECK_VIA %token SYN_BRANCH %token MEMLOG %token SIP_WARNING %token SERVER_SIGNATURE %token REPLY_TO_VIA %token LOADMODULE %token MODPARAM %token MAXBUFFER %token USER %token GROUP %token CHROOT %token WDIR %token MHOMED %token DISABLE_TCP %token TCP_ACCEPT_ALIASES %token TCP_CHILDREN %token TCP_CONNECT_TIMEOUT %token TCP_SEND_TIMEOUT %token TCP_CON_LIFETIME %token TCP_POLL_METHOD %token TCP_MAX_CONNECTIONS %token DISABLE_TLS %token TLSLOG %token TLS_PORT_NO %token TLS_METHOD %token TLS_HANDSHAKE_TIMEOUT %token TLS_SEND_TIMEOUT %token SSLv23 %token SSLv2 %token SSLv3 %token TLSv1 %token TLS_VERIFY %token TLS_REQUIRE_CERTIFICATE %token TLS_CERTIFICATE %token TLS_PRIVATE_KEY %token TLS_CA_LIST %token ADVERTISED_ADDRESS %token ADVERTISED_PORT %token DISABLE_CORE %token OPEN_FD_LIMIT %token MCAST_LOOPBACK %token MCAST_TTL %token TOS %token ATTR_MARK %token SELECT_MARK %token ATTR_FROM %token ATTR_TO %token ATTR_USER %token ATTR_DOMAIN %token ATTR_GLOBAL %token ADDEQ /* operators */ %nonassoc EQUAL %nonassoc EQUAL_T %nonassoc GT %nonassoc LT %nonassoc GTE %nonassoc LTE %nonassoc DIFF %nonassoc MATCH %left LOG_OR %left LOG_AND %left BIN_OR %left BIN_AND %left PLUS MINUS %right NOT /* values */ %token NUMBER %token ID %token STRING %token IPV6ADDR /* other */ %token COMMA %token SEMICOLON %token RPAREN %token LPAREN %token LBRACE %token RBRACE %token LBRACK %token RBRACK %token SLASH %token DOT %token CR %token COLON %token STAR /*non-terminals */ %type exp exp_elem /*, condition*/ %type action actions cmd fcmd if_cmd stm exp_stm assign_action %type ipv4 ipv6 ipv6addr ip %type ipnet %type host %type listen_id %type id_lst %type phostport %type proto port %type equalop strop intop binop %type host_sep %type uri_type %type attr_id %type class_id %type assign_op %type