cfg.y
3c1a8ef8
 /*
  * $Id$
  *
  *  cfg grammar
2d4b798e
  *
53c7e0f1
  * Copyright (C) 2001-2003 FhG Fokus
2d4b798e
  *
  * 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
aeb805d5
  */
  /*
2d4b798e
  * History:
  * ---------
e3dccdc9
  * 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)
51c38611
  * 2003-03-19  Added support for route type in find_export (janakj)
270255ff
  * 2003-03-20  Regex support in modparam (janakj)
aeb805d5
  * 2003-04-01  added dst_port, proto , af (andrei)
87405423
  * 2003-04-05  s/reply_route/failure_route, onreply_route introduced (jiri)
3e8c3475
  * 2003-04-12  added force_rport, chroot and wdir (andrei)
5dcfb23d
  * 2003-04-15  added tcp_children, disable_tcp (andrei)
1d9f91d6
  * 2003-04-22  strip_tail added (jiri)
46506980
  * 2003-07-03  tls* (disable, certificate, private_key, ca_list, verify, 
  *              require_certificate added (andrei)
057f0454
  * 2003-07-06  more tls config. vars added: tls_method, tls_port_no (andrei)
6bfaa042
  * 2003-10-02  added {,set_}advertised_{address,port} (andrei)
dda578ba
  * 2003-10-10  added <,>,<=,>=, != operators support
  *             added msg:len (andrei)
  * 2003-10-11  if(){} doesn't require a ';' after it anymore (andrei)
e5f4cdaf
  * 2003-10-13  added FIFO_DIR & proto:host:port listen/alias support (andrei)
9f4c52ce
  * 2003-10-24  converted to the new socket_info lists (andrei)
59653eb8
  * 2003-10-28  added tcp_accept_aliases (andrei)
bc977837
  * 2003-11-20  added {tcp_connect, tcp_send, tls_*}_timeout (andrei)
385c63eb
  * 2004-03-30  added DISABLE_CORE and OPEN_FD_LIMIT (andrei)
71fd3ebd
  * 2004-04-29  added SOCK_MODE, SOCK_USER & SOCK_GROUP (andrei)
956d111a
  * 2004-05-03  applied multicast support patch (MCAST_LOOPBACK) from janakj
55d8155e
  *             added MCAST_TTL (andrei)
5260ef32
  * 2004-07-05  src_ip & dst_ip will detect ip addresses between quotes
  *              (andrei)
6b7de230
  * 2004-10-19  added FROM_URI, TO_URI (andrei)
6cd48835
  * 2004-11-30  added force_send_socket (andrei)
55d8155e
  * 2005-07-08  added TCP_CON_LIFETIME, TCP_POLL_METHOD, TCP_MAX_CONNECTIONS
  *              (andrei)
878fc194
  * 2005-07-11 added DNS_RETR_TIME, DNS_RETR_NO, DNS_SERVERS_NO, DNS_USE_SEARCH,
  *             DNS_TRY_IPV6 (andrei)
6b6642f4
  * 2005-07-12  default onreply route added (andrei)
  *
2d4b798e
  */
 
3c1a8ef8
 
 %{
 
3e429f5c
 #include <stdlib.h>
63fa628f
 #include <stdio.h>
c75aa645
 #include <sys/types.h>
7268726e
 #include <sys/socket.h>
 #include <netinet/in.h>
 #include <arpa/inet.h>
f20a56a2
 #include <string.h>
4e2fdd79
 #include <errno.h>
c07508e2
 #include "route_struct.h"
3e429f5c
 #include "globals.h"
 #include "route.h"
7268726e
 #include "dprint.h"
3bf76e49
 #include "sr_module.h"
31309a3a
 #include "modparam.h"
4e2fdd79
 #include "ip_addr.h"
5260ef32
 #include "resolve.h"
9f4c52ce
 #include "socket_info.h"
e278821b
 #include "name_alias.h"
6bfaa042
 #include "ut.h"
035f593c
 #include "dset.h"
3e429f5c
 
9f4c52ce
 
1f377e97
 #include "config.h"
057f0454
 #ifdef USE_TLS
 #include "tls/tls_config.h"
 #endif
f571aa35
 
03150098
 #ifdef DEBUG_DMALLOC
 #include <dmalloc.h>
 #endif
 
f3f0a4de
 /* hack to avoid alloca usage in the generated C file (needed for compiler
  with no built in alloca, like icc*/
 #undef _ALLOCA_H
1f377e97
 
57e2cd15
 
e22bbdb8
 extern int yylex();
194b6a35
 static void yyerror(char* s);
6bfaa042
 static char* tmp;
 static int i_tmp;
 static void* f_tmp;
6cd48835
 static struct socket_id* lst_tmp;
6bfaa042
 static int rt;  /* Type of route block for find_export */
 static str* str_tmp;
5260ef32
 static str s_tmp;
 static struct ip_addr* ip_tmp;
057f0454
 
194b6a35
 static void warn(char* s);
6cd48835
 static struct socket_id* mk_listen_id(char*, int, int);
51c38611
  
c07508e2
 
3c1a8ef8
 %}
 
 %union {
9a694681
 	long intval;
 	unsigned long uval;
3c1a8ef8
 	char* strval;
c07508e2
 	struct expr* expr;
 	struct action* action;
4e2fdd79
 	struct net* ipnet;
 	struct ip_addr* ipaddr;
6cd48835
 	struct socket_id* sockid;
3c1a8ef8
 }
 
 /* terminals */
 
 
3e429f5c
 /* keywords */
3c1a8ef8
 %token FORWARD
0c5da34b
 %token FORWARD_TCP
e9b02e8e
 %token FORWARD_TLS
f2f969dd
 %token FORWARD_UDP
3c1a8ef8
 %token SEND
0c5da34b
 %token SEND_TCP
3c1a8ef8
 %token DROP
7268726e
 %token LOG_TOK
3c1a8ef8
 %token ERROR
 %token ROUTE
15dde484
 %token ROUTE_FAILURE
 %token ROUTE_ONREPLY
7662b2e7
 %token ROUTE_BRANCH
09e52ebb
 %token EXEC
7268726e
 %token SET_HOST
 %token SET_HOSTPORT
1f377e97
 %token PREFIX
 %token STRIP
1d9f91d6
 %token STRIP_TAIL
caf80ae6
 %token APPEND_BRANCH
7268726e
 %token SET_USER
 %token SET_USERPASS
 %token SET_PORT
 %token SET_URI
caf80ae6
 %token REVERT_URI
3e8c3475
 %token FORCE_RPORT
59653eb8
 %token FORCE_TCP_ALIAS
f20a56a2
 %token IF
 %token ELSE
6bfaa042
 %token SET_ADV_ADDRESS
 %token SET_ADV_PORT
6cd48835
 %token FORCE_SEND_SOCKET
5ada8f8a
 %token URIHOST
 %token URIPORT
1f377e97
 %token MAX_LEN
3881f12c
 %token SETFLAG
 %token RESETFLAG
 %token ISFLAGSET
3c1a8ef8
 %token METHOD
 %token URI
6b7de230
 %token FROM_URI
 %token TO_URI
3c1a8ef8
 %token SRCIP
049f64c2
 %token SRCPORT
3c1a8ef8
 %token DSTIP
aeb805d5
 %token DSTPORT
 %token PROTO
 %token AF
855c2e68
 %token MYSELF
dda578ba
 %token MSGLEN 
e5f4cdaf
 %token UDP
 %token TCP
 %token TLS
3c1a8ef8
 
 /* config vars. */
 %token DEBUG
 %token FORK
 %token LOGSTDERROR
26456ace
 %token LOGFACILITY
3c1a8ef8
 %token LISTEN
e278821b
 %token ALIAS
3c1a8ef8
 %token DNS
 %token REV_DNS
878fc194
 %token DNS_TRY_IPV6
 %token DNS_RETR_TIME
 %token DNS_RETR_NO
 %token DNS_SERVERS_NO
 %token DNS_USE_SEARCH
7268726e
 %token PORT
f571aa35
 %token STAT
7268726e
 %token CHILDREN
 %token CHECK_VIA
caf80ae6
 %token SYN_BRANCH
843b2927
 %token MEMLOG
caf80ae6
 %token SIP_WARNING
 %token FIFO
e5f4cdaf
 %token FIFO_DIR
71fd3ebd
 %token SOCK_MODE
 %token SOCK_USER
 %token SOCK_GROUP
ed7856ed
 %token FIFO_DB_URL
58ec33d5
 %token UNIX_SOCK
 %token UNIX_SOCK_CHILDREN
9a4cec7f
 %token UNIX_TX_TIMEOUT
caf80ae6
 %token SERVER_SIGNATURE
 %token REPLY_TO_VIA
3bf76e49
 %token LOADMODULE
31309a3a
 %token MODPARAM
c3ce2841
 %token MAXBUFFER
054cb6cf
 %token USER
 %token GROUP
3e8c3475
 %token CHROOT
 %token WDIR
2d4b798e
 %token MHOMED
5dcfb23d
 %token DISABLE_TCP
59653eb8
 %token TCP_ACCEPT_ALIASES
5dcfb23d
 %token TCP_CHILDREN
bc977837
 %token TCP_CONNECT_TIMEOUT
 %token TCP_SEND_TIMEOUT
55d8155e
 %token TCP_CON_LIFETIME
 %token TCP_POLL_METHOD
 %token TCP_MAX_CONNECTIONS
46506980
 %token DISABLE_TLS
057f0454
 %token TLSLOG
 %token TLS_PORT_NO
 %token TLS_METHOD
bc977837
 %token TLS_HANDSHAKE_TIMEOUT
 %token TLS_SEND_TIMEOUT
057f0454
 %token SSLv23
 %token SSLv2
 %token SSLv3
 %token TLSv1
46506980
 %token TLS_VERIFY
 %token TLS_REQUIRE_CERTIFICATE
 %token TLS_CERTIFICATE
 %token TLS_PRIVATE_KEY
 %token TLS_CA_LIST
6bfaa042
 %token ADVERTISED_ADDRESS
 %token ADVERTISED_PORT
385c63eb
 %token DISABLE_CORE
 %token OPEN_FD_LIMIT
2ba73117
 %token MCAST_LOOPBACK
956d111a
 %token MCAST_TTL
5dcfb23d
 
7268726e
 
3c1a8ef8
 
 
 /* operators */
 %nonassoc EQUAL
 %nonassoc EQUAL_T
dda578ba
 %nonassoc GT
 %nonassoc LT
 %nonassoc GTE
 %nonassoc LTE
 %nonassoc DIFF
3c1a8ef8
 %nonassoc MATCH
 %left OR
09e52ebb
 %left AND
 %left NOT
91ab6402
 %left PLUS
 %left MINUS
3c1a8ef8
 
 /* values */
c07508e2
 %token <intval> NUMBER
 %token <strval> ID
 %token <strval> STRING
4e2fdd79
 %token <strval> IPV6ADDR
3c1a8ef8
 
 /* other */
 %token COMMA
 %token SEMICOLON
 %token RPAREN
 %token LPAREN
 %token LBRACE
 %token RBRACE
 %token LBRACK
 %token RBRACK
 %token SLASH
 %token DOT
 %token CR
e5f4cdaf
 %token COLON
 %token STAR
3c1a8ef8
 
 
 /*non-terminals */
ca6ef89b
 %type <expr> exp exp_elem /*, condition*/
 %type <action> action actions cmd if_cmd stm
e5f4cdaf
 %type <ipaddr> ipv4 ipv6 ipv6addr ip
4e2fdd79
 %type <ipnet> ipnet
09e52ebb
 %type <strval> host
57e2cd15
 %type <strval> listen_id
6cd48835
 %type <sockid>  id_lst
 %type <sockid>  phostport
e5f4cdaf
 %type <intval> proto port
dda578ba
 %type <intval> equalop strop intop
91ab6402
 %type <strval> host_sep
6b7de230
 %type <intval> uri_type
f20a56a2
 /*%type <route_el> rules;
   %type <route_el> rule;
 */
3c1a8ef8
 
 
 
 %%
 
 
 cfg:	statements
 	;
 
3e429f5c
 statements:	statements statement {}
 		| statement {}
 		| statements error { yyerror(""); YYABORT;}
3c1a8ef8
 	;
 
7268726e
 statement:	assign_stm 
3bf76e49
 		| module_stm
51c38611
 		| {rt=REQUEST_ROUTE;} route_stm 
87405423
 		| {rt=FAILURE_ROUTE;} failure_route_stm
 		| {rt=ONREPLY_ROUTE;} onreply_route_stm
7662b2e7
 		| {rt=BRANCH_ROUTE;} branch_route_stm
51c38611
 
c07508e2
 		| CR	/* null statement*/
3c1a8ef8
 	;
 
57e2cd15
 listen_id:	ip			{	tmp=ip_addr2a($1);
 		 					if(tmp==0){
 								LOG(L_CRIT, "ERROR: cfg. parser: bad ip "
53c7e0f1
 										"address.\n");
57e2cd15
 								$$=0;
 							}else{
e3dccdc9
 								$$=pkg_malloc(strlen(tmp)+1);
57e2cd15
 								if ($$==0){
 									LOG(L_CRIT, "ERROR: cfg. parser: out of "
 											"memory.\n");
 								}else{
 									strncpy($$, tmp, strlen(tmp)+1);
 								}
 							}
 						}
e3dccdc9
 		 |	STRING			{	$$=pkg_malloc(strlen($1)+1);
57e2cd15
 		 					if ($$==0){
 									LOG(L_CRIT, "ERROR: cfg. parser: out of "
 											"memory.\n");
 							}else{
 									strncpy($$, $1, strlen($1)+1);
 							}
 						}
e3dccdc9
 		 |	host		{	$$=pkg_malloc(strlen($1)+1);
57e2cd15
 		 					if ($$==0){
 									LOG(L_CRIT, "ERROR: cfg. parser: out of "
 											"memory.\n");
 							}else{
 									strncpy($$, $1, strlen($1)+1);
 							}
 						}
 	;
 
e5f4cdaf
 proto:	  UDP	{ $$=PROTO_UDP; }
 		| TCP	{ $$=PROTO_TCP; }
 		| TLS	{ $$=PROTO_TLS; }
9f4c52ce
 		| STAR	{ $$=0; }
e5f4cdaf
 		;
 
 port:	  NUMBER	{ $$=$1; }
 		| STAR		{ $$=0; }
 ;
 
 phostport:	listen_id				{ $$=mk_listen_id($1, 0, 0); }
 			| listen_id COLON port	{ $$=mk_listen_id($1, 0, $3); }
 			| proto COLON listen_id	{ $$=mk_listen_id($3, $1, 0); }
 			| proto COLON listen_id COLON port	{ $$=mk_listen_id($3, $1, $5);}
 			| listen_id COLON error { $$=0; yyerror(" port number expected"); }
 			;
 
 id_lst:		phostport		{  $$=$1 ; }
 		| phostport id_lst	{ $$=$1; $$->next=$2; }
57e2cd15
 		;
 
 
7268726e
 assign_stm:	DEBUG EQUAL NUMBER { debug=$3; }
c07508e2
 		| DEBUG EQUAL error  { yyerror("number  expected"); }
7268726e
 		| FORK  EQUAL NUMBER { dont_fork= ! $3; }
c07508e2
 		| FORK  EQUAL error  { yyerror("boolean value expected"); }
dda578ba
 		| LOGSTDERROR EQUAL NUMBER { if (!config_check) log_stderr=$3; }
c07508e2
 		| LOGSTDERROR EQUAL error { yyerror("boolean value expected"); }
26456ace
 		| LOGFACILITY EQUAL ID {
 					if ( (i_tmp=str2facility($3))==-1)
 						yyerror("bad facility (see syslog(3) man page)");
 					if (!config_check)
 						log_facility=i_tmp;
 									}
 		| LOGFACILITY EQUAL error { yyerror("ID expected"); }
7268726e
 		| DNS EQUAL NUMBER   { received_dns|= ($3)?DO_DNS:0; }
c07508e2
 		| DNS EQUAL error { yyerror("boolean value expected"); }
7268726e
 		| REV_DNS EQUAL NUMBER { received_dns|= ($3)?DO_REV_DNS:0; }
c07508e2
 		| REV_DNS EQUAL error { yyerror("boolean value expected"); }
878fc194
 		| DNS_TRY_IPV6 EQUAL NUMBER   { dns_try_ipv6=$3; }
 		| DNS_TRY_IPV6 error { yyerror("boolean value expected"); }
 		| DNS_RETR_TIME EQUAL NUMBER   { dns_retr_time=$3; }
 		| DNS_RETR_TIME error { yyerror("number expected"); }
 		| DNS_RETR_NO EQUAL NUMBER   { dns_retr_no=$3; }
 		| DNS_RETR_NO error { yyerror("number expected"); }
 		| DNS_SERVERS_NO EQUAL NUMBER   { dns_servers_no=$3; }
 		| DNS_SERVERS_NO error { yyerror("number expected"); }
 		| DNS_USE_SEARCH EQUAL NUMBER   { dns_search_list=$3; }
 		| DNS_USE_SEARCH error { yyerror("boolean value expected"); }
9f4c52ce
 		| PORT EQUAL NUMBER   { port_no=$3; }
e4067ffb
 		| STAT EQUAL STRING {
 					#ifdef STATS
 							stat_file=$3;
 					#endif
 							}
c3ce2841
 		| MAXBUFFER EQUAL NUMBER { maxbuffer=$3; }
 		| MAXBUFFER EQUAL error { yyerror("number expected"); }
7268726e
 		| PORT EQUAL error    { yyerror("number expected"); } 
 		| CHILDREN EQUAL NUMBER { children_no=$3; }
 		| CHILDREN EQUAL error { yyerror("number expected"); } 
 		| CHECK_VIA EQUAL NUMBER { check_via=$3; }
 		| CHECK_VIA EQUAL error { yyerror("boolean value expected"); }
caf80ae6
 		| SYN_BRANCH EQUAL NUMBER { syn_branch=$3; }
 		| SYN_BRANCH EQUAL error { yyerror("boolean value expected"); }
843b2927
 		| MEMLOG EQUAL NUMBER { memlog=$3; }
 		| MEMLOG EQUAL error { yyerror("int value expected"); }
caf80ae6
 		| SIP_WARNING EQUAL NUMBER { sip_warning=$3; }
 		| SIP_WARNING EQUAL error { yyerror("boolean value expected"); }
 		| FIFO EQUAL STRING { fifo=$3; }
 		| FIFO EQUAL error { yyerror("string value expected"); }
e5f4cdaf
 		| FIFO_DIR EQUAL STRING { fifo_dir=$3; }
 		| FIFO_DIR EQUAL error { yyerror("string value expected"); }
71fd3ebd
 		| SOCK_MODE EQUAL NUMBER { sock_mode=$3; }
 		| SOCK_MODE EQUAL error { yyerror("int value expected"); }
 		| SOCK_USER EQUAL STRING { sock_user=$3; }
 		| SOCK_USER EQUAL ID     { sock_user=$3; }
 		| SOCK_USER EQUAL error { yyerror("string value expected"); }
 		| SOCK_GROUP EQUAL STRING { sock_group=$3; }
 		| SOCK_GROUP EQUAL ID     { sock_group=$3; }
 		| SOCK_GROUP EQUAL error { yyerror("string value expected"); }
ed7856ed
 		| FIFO_DB_URL EQUAL STRING { fifo_db_url=$3; }
1580c821
 		| FIFO_DB_URL EQUAL error  { yyerror("string value expected"); }
71fd3ebd
 		| UNIX_SOCK EQUAL STRING { unixsock_name=$3; }
 		| UNIX_SOCK EQUAL error { yyerror("string value expected"); }
 		| UNIX_SOCK_CHILDREN EQUAL NUMBER { unixsock_children=$3; }
 		| UNIX_SOCK_CHILDREN EQUAL error { yyerror("int value expected\n"); }
9a4cec7f
 		| UNIX_TX_TIMEOUT EQUAL NUMBER { unixsock_tx_timeout=$3; }
 		| UNIX_TX_TIMEOUT EQUAL error { yyerror("int value expected\n"); }
054cb6cf
 		| USER EQUAL STRING     { user=$3; }
 		| USER EQUAL ID         { user=$3; }
 		| USER EQUAL error      { yyerror("string value expected"); }
 		| GROUP EQUAL STRING     { group=$3; }
 		| GROUP EQUAL ID         { group=$3; }
 		| GROUP EQUAL error      { yyerror("string value expected"); }
3e8c3475
 		| CHROOT EQUAL STRING     { chroot_dir=$3; }
 		| CHROOT EQUAL ID         { chroot_dir=$3; }
 		| CHROOT EQUAL error      { yyerror("string value expected"); }
 		| WDIR EQUAL STRING     { working_dir=$3; }
 		| WDIR EQUAL ID         { working_dir=$3; }
 		| WDIR EQUAL error      { yyerror("string value expected"); }
2d4b798e
 		| MHOMED EQUAL NUMBER { mhomed=$3; }
 		| MHOMED EQUAL error { yyerror("boolean value expected"); }
5dcfb23d
 		| DISABLE_TCP EQUAL NUMBER {
 									#ifdef USE_TCP
 										tcp_disable=$3;
 									#else
057f0454
 										warn("tcp support not compiled in");
5dcfb23d
 									#endif
 									}
 		| DISABLE_TCP EQUAL error { yyerror("boolean value expected"); }
59653eb8
 		| TCP_ACCEPT_ALIASES EQUAL NUMBER {
 									#ifdef USE_TCP
 										tcp_accept_aliases=$3;
 									#else
 										warn("tcp support not compiled in");
 									#endif
 									}
 		| TCP_ACCEPT_ALIASES EQUAL error { yyerror("boolean value expected"); }
5dcfb23d
 		| TCP_CHILDREN EQUAL NUMBER {
 									#ifdef USE_TCP
 										tcp_children_no=$3;
 									#else
057f0454
 										warn("tcp support not compiled in");
5dcfb23d
 									#endif
 									}
 		| TCP_CHILDREN EQUAL error { yyerror("number expected"); }
bc977837
 		| TCP_CONNECT_TIMEOUT EQUAL NUMBER {
 									#ifdef USE_TCP
 										tcp_connect_timeout=$3;
 									#else
 										warn("tcp support not compiled in");
 									#endif
 									}
 		| TCP_CONNECT_TIMEOUT EQUAL error { yyerror("number expected"); }
 		| TCP_SEND_TIMEOUT EQUAL NUMBER {
 									#ifdef USE_TCP
 										tcp_send_timeout=$3;
 									#else
 										warn("tcp support not compiled in");
 									#endif
 									}
 		| TCP_SEND_TIMEOUT EQUAL error { yyerror("number expected"); }
55d8155e
 		| TCP_CON_LIFETIME EQUAL NUMBER {
 									#ifdef USE_TCP
 										tcp_con_lifetime=$3;
 									#else
 										warn("tcp support not compiled in");
 									#endif
 									}
 		| TCP_CON_LIFETIME EQUAL error { yyerror("number expected"); }
 		| TCP_POLL_METHOD EQUAL ID {
 									#ifdef USE_TCP
 										tcp_poll_method=get_poll_type($3);
 										if (tcp_poll_method==POLL_NONE){
 											LOG(L_CRIT, "bad poll method name:"
 													" %s\n, try one of %s.\n",
 													$3, poll_support);
 											yyerror("bad tcp_poll_method "
 													"value");
 										}
 									#else
 										warn("tcp support not compiled in");
 									#endif
 									}
 		| TCP_POLL_METHOD EQUAL STRING {
 									#ifdef USE_TCP
 										tcp_poll_method=get_poll_type($3);
 										if (tcp_poll_method==POLL_NONE){
 											LOG(L_CRIT, "bad poll method name:"
 													" %s\n, try one of %s.\n",
 													$3, poll_support);
 											yyerror("bad tcp_poll_method "
 													"value");
 										}
 									#else
 										warn("tcp support not compiled in");
 									#endif
 									}
 		| TCP_POLL_METHOD EQUAL error { yyerror("poll method name expected"); }
 		| TCP_MAX_CONNECTIONS EQUAL NUMBER {
 									#ifdef USE_TCP
 										tcp_max_connections=$3;
 									#else
 										warn("tcp support not compiled in");
 									#endif
 									}
 		| TCP_MAX_CONNECTIONS EQUAL error { yyerror("number expected"); }
46506980
 		| DISABLE_TLS EQUAL NUMBER {
 									#ifdef USE_TLS
 										tls_disable=$3;
 									#else
057f0454
 										warn("tls support not compiled in");
46506980
 									#endif
 									}
 		| DISABLE_TLS EQUAL error { yyerror("boolean value expected"); }
057f0454
 		| TLSLOG EQUAL NUMBER 		{ 
 									#ifdef USE_TLS
 										tls_log=$3;
 									#else
 										warn("tls support not compiled in");
 									#endif
 									}
 		| TLSLOG EQUAL error { yyerror("int value expected"); }
 		| TLS_PORT_NO EQUAL NUMBER {
 									#ifdef USE_TLS
 										tls_port_no=$3;
 									#else
 										warn("tls support not compiled in");
 									#endif
 									}
 		| TLS_PORT_NO EQUAL error { yyerror("number expected"); }
 		| TLS_METHOD EQUAL SSLv23 {
 									#ifdef USE_TLS
 										tls_method=TLS_USE_SSLv23;
 									#else
 										warn("tls support not compiled in");
 									#endif
 									}
 		| TLS_METHOD EQUAL SSLv2 {
 									#ifdef USE_TLS
 										tls_method=TLS_USE_SSLv2;
 									#else
 										warn("tls support not compiled in");
 									#endif
 									}
 		| TLS_METHOD EQUAL SSLv3 {
 									#ifdef USE_TLS
 										tls_method=TLS_USE_SSLv3;
 									#else
 										warn("tls support not compiled in");
 									#endif
 									}
 		| TLS_METHOD EQUAL TLSv1 {
 									#ifdef USE_TLS
 										tls_method=TLS_USE_TLSv1;
 									#else
 										warn("tls support not compiled in");
 									#endif
 									}
 		| TLS_METHOD EQUAL error {
 									#ifdef USE_TLS
 										yyerror("SSLv23, SSLv2, SSLv3 or TLSv1"
 													" expected");
 									#else
 										warn("tls support not compiled in");
 									#endif
 									}
 										
46506980
 		| TLS_VERIFY EQUAL NUMBER {
 									#ifdef USE_TLS
 										tls_verify_cert=$3;
 									#else
057f0454
 										warn("tls support not compiled in");
46506980
 									#endif
 									}
 		| TLS_VERIFY EQUAL error { yyerror("boolean value expected"); }
 		| TLS_REQUIRE_CERTIFICATE EQUAL NUMBER {
 									#ifdef USE_TLS
 										tls_require_cert=$3;
 									#else
057f0454
 										warn( "tls support not compiled in");
46506980
 									#endif
 									}
 		| TLS_REQUIRE_CERTIFICATE EQUAL error { yyerror("boolean value"
 																" expected"); }
 		| TLS_CERTIFICATE EQUAL STRING { 
 									#ifdef USE_TLS
 											tls_cert_file=$3;
 									#else
057f0454
 										warn("tls support not compiled in");
46506980
 									#endif
 									}
 		| TLS_CERTIFICATE EQUAL error { yyerror("string value expected"); }
 		| TLS_PRIVATE_KEY EQUAL STRING { 
 									#ifdef USE_TLS
 											tls_pkey_file=$3;
 									#else
057f0454
 										warn("tls support not compiled in");
46506980
 									#endif
 									}
 		| TLS_PRIVATE_KEY EQUAL error { yyerror("string value expected"); }
 		| TLS_CA_LIST EQUAL STRING { 
 									#ifdef USE_TLS
 											tls_ca_file=$3;
 									#else
057f0454
 										warn("tls support not compiled in");
46506980
 									#endif
 									}
 		| TLS_CA_LIST EQUAL error { yyerror("string value expected"); }
bc977837
 		| TLS_HANDSHAKE_TIMEOUT EQUAL NUMBER {
 									#ifdef USE_TLS
 										tls_handshake_timeout=$3;
 									#else
 										warn("tls support not compiled in");
 									#endif
 									}
 		| TLS_HANDSHAKE_TIMEOUT EQUAL error { yyerror("number expected"); }
 		| TLS_SEND_TIMEOUT EQUAL NUMBER {
 									#ifdef USE_TLS
 										tls_send_timeout=$3;
 									#else
 										warn("tls support not compiled in");
 									#endif
 									}
 		| TLS_SEND_TIMEOUT EQUAL error { yyerror("number expected"); }
caf80ae6
 		| SERVER_SIGNATURE EQUAL NUMBER { server_signature=$3; }
 		| SERVER_SIGNATURE EQUAL error { yyerror("boolean value expected"); }
 		| REPLY_TO_VIA EQUAL NUMBER { reply_to_via=$3; }
 		| REPLY_TO_VIA EQUAL error { yyerror("boolean value expected"); }
57e2cd15
 		| LISTEN EQUAL id_lst {
 							for(lst_tmp=$3; lst_tmp; lst_tmp=lst_tmp->next){
9f4c52ce
 								if (add_listen_iface(	lst_tmp->name,
 														lst_tmp->port,
 														lst_tmp->proto,
 														0
 													)!=0){
 									LOG(L_CRIT,  "ERROR: cfg. parser: failed"
 											" to add listen address\n");
57e2cd15
 									break;
7268726e
 								}
57e2cd15
 							}
 							 }
c07508e2
 		| LISTEN EQUAL  error { yyerror("ip address or hostname"
 						"expected"); }
57e2cd15
 		| ALIAS EQUAL  id_lst { 
1baa06b5
 							for(lst_tmp=$3; lst_tmp; lst_tmp=lst_tmp->next)
9f4c52ce
 								add_alias(lst_tmp->name, strlen(lst_tmp->name),
50d5fa87
 											lst_tmp->port, lst_tmp->proto);
57e2cd15
 							  }
e278821b
 		| ALIAS  EQUAL error  { yyerror(" hostname expected"); }
6bfaa042
 		| ADVERTISED_ADDRESS EQUAL listen_id {
 								default_global_address.s=$3;
 								default_global_address.len=strlen($3);
 								}
 		|ADVERTISED_ADDRESS EQUAL error {yyerror("ip address or hostname "
 												"expected"); }
 		| ADVERTISED_PORT EQUAL NUMBER {
 								tmp=int2str($3, &i_tmp);
 								if ((default_global_port.s=pkg_malloc(i_tmp))
 										==0){
 										LOG(L_CRIT, "ERROR: cfg. parser:"
 													" out of memory.\n");
 										default_global_port.len=0;
 								}else{
 									default_global_port.len=i_tmp;
 									memcpy(default_global_port.s, tmp,
 											default_global_port.len);
 								};
 								}
 		|ADVERTISED_PORT EQUAL error {yyerror("ip address or hostname "
 												"expected"); }
385c63eb
 		| DISABLE_CORE EQUAL NUMBER {
 										disable_core_dump=$3;
 									}
 		| DISABLE_CORE EQUAL error { yyerror("boolean value expected"); }
 		| OPEN_FD_LIMIT EQUAL NUMBER {
 										open_files_limit=$3;
 									}
 		| OPEN_FD_LIMIT EQUAL error { yyerror("number expected"); }
2ba73117
 		| MCAST_LOOPBACK EQUAL NUMBER {
 								#ifdef USE_MCAST
 										mcast_loopback=$3;
 								#else
 									warn("no multicast support compiled in");
 								#endif
 		  }
956d111a
 		| MCAST_LOOPBACK EQUAL error { yyerror("boolean value expected"); }
 		| MCAST_TTL EQUAL NUMBER {
 								#ifdef USE_MCAST
 										mcast_ttl=$3;
 								#else
 									warn("no multicast support compiled in");
 								#endif
 		  }
 		| MCAST_TTL EQUAL error { yyerror("number expected"); }
c07508e2
 		| error EQUAL { yyerror("unknown config variable"); }
3c1a8ef8
 	;
 
96001c50
 module_stm:	LOADMODULE STRING	{ DBG("loading module %s\n", $2);
3bf76e49
 		  						  if (load_module($2)!=0){
 								  		yyerror("failed to load module");
 								  }
 								}
31309a3a
 		 | LOADMODULE error	{ yyerror("string expected");  }
                  | MODPARAM LPAREN STRING COMMA STRING COMMA STRING RPAREN {
270255ff
 			 if (set_mod_param_regex($3, $5, STR_PARAM, $7) != 0) {
31309a3a
 				 yyerror("Can't set module parameter");
 			 }
 		   }
                  | MODPARAM LPAREN STRING COMMA STRING COMMA NUMBER RPAREN {
270255ff
 			 if (set_mod_param_regex($3, $5, INT_PARAM, (void*)$7) != 0) {
31309a3a
 				 yyerror("Can't set module parameter");
 			 }
 		   }
                  | MODPARAM error { yyerror("Invalid arguments"); }
3bf76e49
 		 ;
 
3c1a8ef8
 
4e2fdd79
 ip:		 ipv4  { $$=$1; }
 		|ipv6  { $$=$1; }
 		;
 
09e52ebb
 ipv4:	NUMBER DOT NUMBER DOT NUMBER DOT NUMBER { 
e3dccdc9
 											$$=pkg_malloc(
 													sizeof(struct ip_addr));
4e2fdd79
 											if ($$==0){
 												LOG(L_CRIT, "ERROR: cfg. "
 													"parser: out of memory.\n"
 													);
09e52ebb
 											}else{
4e2fdd79
 												memset($$, 0, 
 													sizeof(struct ip_addr));
 												$$->af=AF_INET;
 												$$->len=4;
 												if (($1>255) || ($1<0) ||
 													($3>255) || ($3<0) ||
 													($5>255) || ($5<0) ||
 													($7>255) || ($7<0)){
 													yyerror("invalid ipv4"
 															"address");
 													$$->u.addr32[0]=0;
 													/* $$=0; */
 												}else{
 													$$->u.addr[0]=$1;
 													$$->u.addr[1]=$3;
 													$$->u.addr[2]=$5;
 													$$->u.addr[3]=$7;
 													/*
 													$$=htonl( ($1<<24)|
3e429f5c
 													($3<<16)| ($5<<8)|$7 );
4e2fdd79
 													*/
 												}
09e52ebb
 											}
 												}
3c1a8ef8
 	;
 
e5f4cdaf
 ipv6addr:	IPV6ADDR {
e3dccdc9
 					$$=pkg_malloc(sizeof(struct ip_addr));
4e2fdd79
 					if ($$==0){
 						LOG(L_CRIT, "ERROR: cfg. parser: out of memory.\n");
 					}else{
 						memset($$, 0, sizeof(struct ip_addr));
 						$$->af=AF_INET6;
 						$$->len=16;
381659ac
 					#ifdef USE_IPV6
4e2fdd79
 						if (inet_pton(AF_INET6, $1, $$->u.addr)<=0){
 							yyerror("bad ipv6 address");
 						}
381659ac
 					#else
 						yyerror("ipv6 address & no ipv6 support compiled in");
 						YYABORT;
 					#endif
4e2fdd79
 					}
 				}
 	;
 
e5f4cdaf
 ipv6:	ipv6addr { $$=$1; }
 	| LBRACK ipv6addr RBRACK {$$=$2; }
 ;
 
4e2fdd79
 
51c38611
 route_stm:  ROUTE LBRACE actions RBRACE { push($3, &rlist[DEFAULT_RT]); }
3e429f5c
 
51c38611
 	    | ROUTE LBRACK NUMBER RBRACK LBRACE actions RBRACE { 
3e429f5c
 										if (($3<RT_NO) && ($3>=0)){
 											push($6, &rlist[$3]);
 										}else{
c5eea708
 											yyerror("invalid routing "
3e429f5c
 													"table number");
 											YYABORT; }
 										}
c07508e2
 		| ROUTE error { yyerror("invalid  route  statement"); }
3c1a8ef8
 	;
caf80ae6
 
15dde484
 failure_route_stm: ROUTE_FAILURE LBRACK NUMBER RBRACK LBRACE actions RBRACE {
87405423
 										if (($3<FAILURE_RT_NO)&&($3>=1)){
 											push($6, &failure_rlist[$3]);
caf80ae6
 										} else {
 											yyerror("invalid reply routing"
 												"table number");
 											YYABORT; }
 										}
15dde484
 		| ROUTE_FAILURE error { yyerror("invalid failure_route statement"); }
87405423
 	;
 
6b6642f4
 onreply_route_stm: ROUTE LBRACE actions RBRACE {
 										push($3, &onreply_rlist[DEFAULT_RT]);
 											  }
 				| ROUTE_ONREPLY LBRACK NUMBER RBRACK LBRACE actions RBRACE {
87405423
 										if (($3<ONREPLY_RT_NO)&&($3>=1)){
 											push($6, &onreply_rlist[$3]);
 										} else {
 											yyerror("invalid reply routing"
 												"table number");
 											YYABORT; }
 										}
72069b94
 		| ROUTE_ONREPLY error { yyerror("invalid onreply_route statement"); }
caf80ae6
 	;
7662b2e7
 branch_route_stm: ROUTE_BRANCH LBRACE actions RBRACE {
 										push($3, &branch_rlist[DEFAULT_RT]);
 											  }
 				| ROUTE_BRANCH LBRACK NUMBER RBRACK LBRACE actions RBRACE {
 										if (($3<BRANCH_RT_NO)&&($3>=1)){
 											push($6, &branch_rlist[$3]);
 										} else {
 											yyerror("invalid branch routing"
 												"table number");
 											YYABORT; }
 										}
 		| ROUTE_BRANCH error { yyerror("invalid branch_route statement"); }
 	;
f20a56a2
 /*
7268726e
 rules:	rules rule { push($2, &$1); $$=$1; }
 	| rule {$$=$1; }
3e429f5c
 	| rules error { $$=0; yyerror("invalid rule"); }
3c1a8ef8
 	 ;
 
09e52ebb
 rule:	condition	actions CR {
3e429f5c
 								$$=0;
 								if (add_rule($1, $2, &$$)<0) {
 									yyerror("error calling add_rule");
 									YYABORT;
 								}
 							  }
f20a56a2
 	| CR		{ $$=0;}
3e429f5c
 	| condition error { $$=0; yyerror("bad actions in rule"); }
3c1a8ef8
 	;
 
09e52ebb
 condition:	exp {$$=$1;}
f20a56a2
 */
3c1a8ef8
 
09e52ebb
 exp:	exp AND exp 	{ $$=mk_exp(AND_OP, $1, $3); }
 	| exp OR  exp		{ $$=mk_exp(OR_OP, $1, $3);  }
 	| NOT exp 			{ $$=mk_exp(NOT_OP, $2, 0);  }
 	| LPAREN exp RPAREN	{ $$=$2; }
 	| exp_elem			{ $$=$1; }
3c1a8ef8
 	;
 
dda578ba
 equalop:	  EQUAL_T {$$=EQUAL_OP; }
 			| DIFF	{$$=DIFF_OP; }
 		;
 		
 intop:	equalop	{$$=$1; }
 		|  GT	{$$=GT_OP; }
 		| LT	{$$=LT_OP; }
 		| GTE	{$$=GTE_OP; }
 		| LTE	{$$=LTE_OP; }
 		;
 		
 strop:	equalop	{$$=$1; }
 		| MATCH	{$$=MATCH_OP; }
 		;
 
6b7de230
 uri_type:	URI			{$$=URI_O;}
 		|	FROM_URI	{$$=FROM_URI_O;}
 		|	TO_URI		{$$=TO_URI_O;}
 		;
 
dda578ba
 exp_elem:	METHOD strop STRING	{$$= mk_elem(	$2, STRING_ST, 
09e52ebb
 													METHOD_O, $3);
 									}
dda578ba
 		| METHOD strop  ID	{$$ = mk_elem(	$2, STRING_ST,
09e52ebb
 											METHOD_O, $3); 
 				 			}
dda578ba
 		| METHOD strop error { $$=0; yyerror("string expected"); }
09e52ebb
 		| METHOD error	{ $$=0; yyerror("invalid operator,"
dda578ba
 										"== , !=, or =~ expected");
09e52ebb
 						}
6b7de230
 		| uri_type strop STRING	{$$ = mk_elem(	$2, STRING_ST,
 												$1, $3); 
09e52ebb
 				 				}
6b7de230
 		| uri_type strop host 	{$$ = mk_elem(	$2, STRING_ST,
 											$1, $3); 
09e52ebb
 				 			}
6b7de230
 		| uri_type equalop MYSELF	{ $$=mk_elem(	$2, MYSELF_ST,
 													$1, 0);
855c2e68
 								}
6b7de230
 		| uri_type strop error { $$=0; yyerror("string or MYSELF expected"); }
 		| uri_type error	{ $$=0; yyerror("invalid operator,"
dda578ba
 									" == , != or =~ expected");
09e52ebb
 					}
dda578ba
 		| SRCPORT intop NUMBER	{ $$=mk_elem(	$2, NUMBER_ST,
049f64c2
 												SRCPORT_O, (void *) $3 ); }
dda578ba
 		| SRCPORT intop error { $$=0; yyerror("number expected"); }
 		| SRCPORT error { $$=0; yyerror("==, !=, <,>, >= or <=  expected"); }
 		| DSTPORT intop NUMBER	{ $$=mk_elem(	$2, NUMBER_ST,
aeb805d5
 												DSTPORT_O, (void *) $3 ); }
dda578ba
 		| DSTPORT intop error { $$=0; yyerror("number expected"); }
 		| DSTPORT error { $$=0; yyerror("==, !=, <,>, >= or <=  expected"); }
e5f4cdaf
 		| PROTO intop proto	{ $$=mk_elem(	$2, NUMBER_ST,
aeb805d5
 												PROTO_O, (void *) $3 ); }
e5f4cdaf
 		| PROTO intop error { $$=0;
 								yyerror("protocol expected (udp, tcp or tls)");
 							}
dda578ba
 		| PROTO error { $$=0; yyerror("equal/!= operator expected"); }
 		| AF intop NUMBER	{ $$=mk_elem(	$2, NUMBER_ST,
aeb805d5
 												AF_O, (void *) $3 ); }
dda578ba
 		| AF intop error { $$=0; yyerror("number expected"); }
 		| AF error { $$=0; yyerror("equal/!= operator expected"); }
 		| MSGLEN intop NUMBER	{ $$=mk_elem(	$2, NUMBER_ST,
 												MSGLEN_O, (void *) $3 ); }
 		| MSGLEN intop MAX_LEN	{ $$=mk_elem(	$2, NUMBER_ST,
 												MSGLEN_O, (void *) BUF_SIZE); }
 		| MSGLEN intop error { $$=0; yyerror("number expected"); }
 		| MSGLEN error { $$=0; yyerror("equal/!= operator expected"); }
 		| SRCIP equalop ipnet	{ $$=mk_elem(	$2, NET_ST,
09e52ebb
 												SRCIP_O, $3);
 								}
5260ef32
 		| SRCIP strop STRING	{	s_tmp.s=$3;
 									s_tmp.len=strlen($3);
 									ip_tmp=str2ip(&s_tmp);
 									if (ip_tmp==0)
 										ip_tmp=str2ip6(&s_tmp);
 									if (ip_tmp){
 										$$=mk_elem(	$2, NET_ST, SRCIP_O,
 												mk_net_bitlen(ip_tmp, 
 														ip_tmp->len*8) );
 									}else{
 										$$=mk_elem(	$2, STRING_ST,
09e52ebb
 												SRCIP_O, $3);
5260ef32
 									}
09e52ebb
 								}
dda578ba
 		| SRCIP strop host	{ $$=mk_elem(	$2, STRING_ST,
09e52ebb
 												SRCIP_O, $3);
 								}
dda578ba
 		| SRCIP equalop MYSELF  { $$=mk_elem(	$2, MYSELF_ST,
855c2e68
 												SRCIP_O, 0);
 								}
dda578ba
 		| SRCIP strop error { $$=0; yyerror( "ip address or hostname"
c07508e2
 						 "expected" ); }
09e52ebb
 		| SRCIP error  { $$=0; 
dda578ba
 						 yyerror("invalid operator, ==, != or =~ expected");}
 		| DSTIP equalop ipnet	{ $$=mk_elem(	$2, NET_ST,
09e52ebb
 												DSTIP_O, $3);
 								}
5260ef32
 		| DSTIP strop STRING	{	s_tmp.s=$3;
 									s_tmp.len=strlen($3);
 									ip_tmp=str2ip(&s_tmp);
 									if (ip_tmp==0)
 										ip_tmp=str2ip6(&s_tmp);
 									if (ip_tmp){
 										$$=mk_elem(	$2, NET_ST, DSTIP_O,
 												mk_net_bitlen(ip_tmp, 
 														ip_tmp->len*8) );
 									}else{
 										$$=mk_elem(	$2, STRING_ST,
09e52ebb
 												DSTIP_O, $3);
5260ef32
 									}
09e52ebb
 								}
dda578ba
 		| DSTIP strop host	{ $$=mk_elem(	$2, STRING_ST,
09e52ebb
 												DSTIP_O, $3);
 								}
dda578ba
 		| DSTIP equalop MYSELF  { $$=mk_elem(	$2, MYSELF_ST,
855c2e68
 												DSTIP_O, 0);
 								}
dda578ba
 		| DSTIP strop error { $$=0; yyerror( "ip address or hostname"
09e52ebb
 						 			"expected" ); }
 		| DSTIP error { $$=0; 
dda578ba
 						yyerror("invalid operator, ==, != or =~ expected");}
6b7de230
 		| MYSELF equalop uri_type	{ $$=mk_elem(	$2, MYSELF_ST,
 													$3, 0);
855c2e68
 								}
dda578ba
 		| MYSELF equalop SRCIP  { $$=mk_elem(	$2, MYSELF_ST,
855c2e68
 												SRCIP_O, 0);
 								}
dda578ba
 		| MYSELF equalop DSTIP  { $$=mk_elem(	$2, MYSELF_ST,
855c2e68
 												DSTIP_O, 0);
 								}
dda578ba
 		| MYSELF equalop error {	$$=0; 
855c2e68
 									yyerror(" URI, SRCIP or DSTIP expected"); }
dda578ba
 		| MYSELF error	{ $$=0; 
 							yyerror ("invalid operator, == or != expected");
 						}
f20a56a2
 		| stm				{ $$=mk_elem( NO_OP, ACTIONS_ST, ACTION_O, $1 ); }
 		| NUMBER		{$$=mk_elem( NO_OP, NUMBER_ST, NUMBER_O, (void*)$1 ); }
3c1a8ef8
 	;
 
4e2fdd79
 ipnet:	ip SLASH ip	{ $$=mk_net($1, $3); } 
 	| ip SLASH NUMBER 	{	if (($3<0) || ($3>$1->len*8)){
09e52ebb
 								yyerror("invalid bit number in netmask");
 								$$=0;
 							}else{
4e2fdd79
 								$$=mk_net_bitlen($1, $3);
 							/*
f20a56a2
 								$$=mk_net($1, 
 										htonl( ($3)?~( (1<<(32-$3))-1 ):0 ) );
4e2fdd79
 							*/
09e52ebb
 							}
 						}
4e2fdd79
 	| ip				{ $$=mk_net_bitlen($1, $1->len*8); }
 	| ip SLASH error	{ $$=0;
 						 yyerror("netmask (eg:255.0.0.0 or 8) expected");
 						}
3c1a8ef8
 	;
 
91ab6402
 
 
 host_sep:	DOT {$$=".";}
 		|	MINUS {$$="-"; }
 		;
 
09e52ebb
 host:	ID				{ $$=$1; }
91ab6402
 	| host host_sep ID	{ $$=(char*)pkg_malloc(strlen($1)+1+strlen($3)+1);
09e52ebb
 						  if ($$==0){
f20a56a2
 						  	LOG(L_CRIT, "ERROR: cfg. parser: memory allocation"
 										" failure while parsing host\n");
09e52ebb
 						  }else{
91ab6402
 							memcpy($$, $1, strlen($1));
 							$$[strlen($1)]=*$2;
 							memcpy($$+strlen($1)+1, $3, strlen($3));
 							$$[strlen($1)+1+strlen($3)]=0;
09e52ebb
 						  }
e3dccdc9
 						  pkg_free($1); pkg_free($3);
ca6ef89b
 						}
e3dccdc9
 	| host DOT error { $$=0; pkg_free($1); yyerror("invalid hostname"); }
3c1a8ef8
 	;
 
 
f20a56a2
 stm:		cmd						{ $$=$1; }
dda578ba
 		|	if_cmd					{ $$=$1; }
f20a56a2
 		|	LBRACE actions RBRACE	{ $$=$2; }
 	;
 
09e52ebb
 actions:	actions action	{$$=append_action($1, $2); }
 		| action			{$$=$1;}
 		| actions error { $$=0; yyerror("bad command"); }
c07508e2
 	;
 
09e52ebb
 action:		cmd SEMICOLON {$$=$1;}
dda578ba
 		| if_cmd {$$=$1;}
09e52ebb
 		| SEMICOLON /* null action */ {$$=0;}
 		| cmd error { $$=0; yyerror("bad command: missing ';'?"); }
3c1a8ef8
 	;
 
f20a56a2
 if_cmd:		IF exp stm				{ $$=mk_action3( IF_T,
 													 EXPR_ST,
 													 ACTIONS_ST,
 													 NOSUBTYPE,
 													 $2,
 													 $3,
 													 0);
 									}
 		|	IF exp stm ELSE stm		{ $$=mk_action3( IF_T,
 													 EXPR_ST,
 													 ACTIONS_ST,
 													 ACTIONS_ST,
 													 $2,
 													 $3,
 													 $5);
 									}
 	;
 
09e52ebb
 cmd:		FORWARD LPAREN host RPAREN	{ $$=mk_action(	FORWARD_T,
 														STRING_ST,
 														NUMBER_ST,
 														$3,
 														0);
 										}
 		| FORWARD LPAREN STRING RPAREN	{ $$=mk_action(	FORWARD_T,
 														STRING_ST,
 														NUMBER_ST,
 														$3,
 														0);
 										}
4e2fdd79
 		| FORWARD LPAREN ip RPAREN	{ $$=mk_action(	FORWARD_T,
09e52ebb
 														IP_ST,
 														NUMBER_ST,
 														(void*)$3,
 														0);
 										}
 		| FORWARD LPAREN host COMMA NUMBER RPAREN { $$=mk_action(FORWARD_T,
 																 STRING_ST,
 																 NUMBER_ST,
 																$3,
 																(void*)$5);
 												 }
 		| FORWARD LPAREN STRING COMMA NUMBER RPAREN {$$=mk_action(FORWARD_T,
 																 STRING_ST,
 																 NUMBER_ST,
 																$3,
 																(void*)$5);
 													}
4e2fdd79
 		| FORWARD LPAREN ip COMMA NUMBER RPAREN { $$=mk_action(FORWARD_T,
09e52ebb
 																 IP_ST,
 																 NUMBER_ST,
 																 (void*)$3,
 																(void*)$5);
 												  }
5ada8f8a
 		| FORWARD LPAREN URIHOST COMMA URIPORT RPAREN {
 													$$=mk_action(FORWARD_T,
 																 URIHOST_ST,
 																 URIPORT_ST,
 																0,
 																0);
 													}
 													
 									
 		| FORWARD LPAREN URIHOST COMMA NUMBER RPAREN {
 													$$=mk_action(FORWARD_T,
 																 URIHOST_ST,
 																 NUMBER_ST,
 																0,
 																(void*)$5);
 													}
 		| FORWARD LPAREN URIHOST RPAREN {
 													$$=mk_action(FORWARD_T,
 																 URIHOST_ST,
 																 NUMBER_ST,
 																0,
 																0);
 										}
09e52ebb
 		| FORWARD error { $$=0; yyerror("missing '(' or ')' ?"); }
 		| FORWARD LPAREN error RPAREN { $$=0; yyerror("bad forward"
 										"argument"); }
f2f969dd
 		| FORWARD_UDP LPAREN host RPAREN	{ $$=mk_action(	FORWARD_UDP_T,
 														STRING_ST,
 														NUMBER_ST,
 														$3,
 														0);
 										}
 		| FORWARD_UDP LPAREN STRING RPAREN	{ $$=mk_action(	FORWARD_UDP_T,
 														STRING_ST,
 														NUMBER_ST,
 														$3,
 														0);
 										}
 		| FORWARD_UDP LPAREN ip RPAREN	{ $$=mk_action(	FORWARD_UDP_T,
 														IP_ST,
 														NUMBER_ST,
 														(void*)$3,
 														0);
 										}
 		| FORWARD_UDP LPAREN host COMMA NUMBER RPAREN { $$=mk_action(
 																FORWARD_UDP_T,
 																 STRING_ST,
 																 NUMBER_ST,
 																$3,
 																(void*)$5);
 												 }
 		| FORWARD_UDP LPAREN STRING COMMA NUMBER RPAREN {$$=mk_action(
 																FORWARD_UDP_T,
 																 STRING_ST,
 																 NUMBER_ST,
 																$3,
 																(void*)$5);
 													}
 		| FORWARD_UDP LPAREN ip COMMA NUMBER RPAREN { $$=mk_action(
 																FORWARD_UDP_T,
 																 IP_ST,
 																 NUMBER_ST,
 																 (void*)$3,
 																(void*)$5);
 												  }
 		| FORWARD_UDP LPAREN URIHOST COMMA URIPORT RPAREN {
 													$$=mk_action(FORWARD_UDP_T,
 																 URIHOST_ST,
 																 URIPORT_ST,
 																0,
 																0);
 													}
 													
 									
 		| FORWARD_UDP LPAREN URIHOST COMMA NUMBER RPAREN {
 													$$=mk_action(FORWARD_UDP_T,
 																 URIHOST_ST,
 																 NUMBER_ST,
 																0,
 																(void*)$5);
 													}
 		| FORWARD_UDP LPAREN URIHOST RPAREN {
 													$$=mk_action(FORWARD_UDP_T,
 																 URIHOST_ST,
 																 NUMBER_ST,
 																0,
 																0);
 										}
 		| FORWARD_UDP error { $$=0; yyerror("missing '(' or ')' ?"); }
 		| FORWARD_UDP LPAREN error RPAREN { $$=0; yyerror("bad forward_udp"
 										"argument"); }
 		| FORWARD_TCP LPAREN host RPAREN	{ $$=mk_action(	FORWARD_TCP_T,
 														STRING_ST,
 														NUMBER_ST,
 														$3,
 														0);
 										}
 		| FORWARD_TCP LPAREN STRING RPAREN	{ $$=mk_action(	FORWARD_TCP_T,
 														STRING_ST,
 														NUMBER_ST,
 														$3,
 														0);
 										}
 		| FORWARD_TCP LPAREN ip RPAREN	{ $$=mk_action(	FORWARD_TCP_T,
 														IP_ST,
 														NUMBER_ST,
 														(void*)$3,
 														0);
 										}
 		| FORWARD_TCP LPAREN host COMMA NUMBER RPAREN { $$=mk_action(
 																FORWARD_TCP_T,
 																 STRING_ST,
 																 NUMBER_ST,
 																$3,
 																(void*)$5);
 												 }
 		| FORWARD_TCP LPAREN STRING COMMA NUMBER RPAREN {$$=mk_action(
 																FORWARD_TCP_T,
 																 STRING_ST,
 																 NUMBER_ST,
 																$3,
 																(void*)$5);
 													}
 		| FORWARD_TCP LPAREN ip COMMA NUMBER RPAREN { $$=mk_action(FORWARD_TCP_T,
 																 IP_ST,
 																 NUMBER_ST,
 																 (void*)$3,
 																(void*)$5);
 												  }
 		| FORWARD_TCP LPAREN URIHOST COMMA URIPORT RPAREN {
 													$$=mk_action(FORWARD_TCP_T,
 																 URIHOST_ST,
 																 URIPORT_ST,
 																0,
 																0);
 													}
 													
 									
 		| FORWARD_TCP LPAREN URIHOST COMMA NUMBER RPAREN {
 													$$=mk_action(FORWARD_TCP_T,
 																 URIHOST_ST,
 																 NUMBER_ST,
 																0,
 																(void*)$5);
 													}
 		| FORWARD_TCP LPAREN URIHOST RPAREN {
 													$$=mk_action(FORWARD_TCP_T,
 																 URIHOST_ST,
 																 NUMBER_ST,
 																0,
 																0);
 										}
 		| FORWARD_TCP error { $$=0; yyerror("missing '(' or ')' ?"); }
 		| FORWARD_TCP LPAREN error RPAREN { $$=0; yyerror("bad forward_tcp"
 										"argument"); }
057f0454
 		| FORWARD_TLS LPAREN host RPAREN	{
 										#ifdef USE_TLS
 											$$=mk_action(	FORWARD_TLS_T,
e9b02e8e
 														STRING_ST,
 														NUMBER_ST,
 														$3,
 														0);
057f0454
 										#else
b23a7a00
 											$$=0;
057f0454
 											yyerror("tls support not "
 													"compiled in");
 										#endif
e9b02e8e
 										}
057f0454
 		| FORWARD_TLS LPAREN STRING RPAREN	{
 										#ifdef USE_TLS
 											$$=mk_action(	FORWARD_TLS_T,
 															STRING_ST,
 															NUMBER_ST,
 															$3,
 															0);
 										#else
b23a7a00
 											$$=0;
057f0454
 											yyerror("tls support not "
 													"compiled in");
 										#endif
e9b02e8e
 										}
057f0454
 		| FORWARD_TLS LPAREN ip RPAREN	{ 
 										#ifdef USE_TLS
 											$$=mk_action(	FORWARD_TLS_T,
 															IP_ST,
 															NUMBER_ST,
 															(void*)$3,
 															0);
 										#else
b23a7a00
 											$$=0;
057f0454
 											yyerror("tls support not "
 													"compiled in");
 										#endif
e9b02e8e
 										}
057f0454
 		| FORWARD_TLS LPAREN host COMMA NUMBER RPAREN { 
 										#ifdef USE_TLS
 											$$=mk_action(	FORWARD_TLS_T,
 															 STRING_ST,
 															 NUMBER_ST,
 															$3,
 															(void*)$5);
 										#else
b23a7a00
 											$$=0;
057f0454
 											yyerror("tls support not "
 													"compiled in");
 										#endif
e9b02e8e
 												 }
057f0454
 		| FORWARD_TLS LPAREN STRING COMMA NUMBER RPAREN {
 										#ifdef USE_TLS
 											$$=mk_action(	FORWARD_TLS_T,
 															 STRING_ST,
 															 NUMBER_ST,
 															$3,
 															(void*)$5);
 										#else
b23a7a00
 											$$=0;
057f0454
 											yyerror("tls support not "
 													"compiled in");
 										#endif
e9b02e8e
 													}
057f0454
 		| FORWARD_TLS LPAREN ip COMMA NUMBER RPAREN {
 										#ifdef USE_TLS
 											$$=mk_action(	FORWARD_TLS_T,
 															 IP_ST,
 															 NUMBER_ST,
 															 (void*)$3,
 															(void*)$5);
 										#else
b23a7a00
 											$$=0;
057f0454
 											yyerror("tls support not "
 													"compiled in");
 										#endif
e9b02e8e
 												  }
 		| FORWARD_TLS LPAREN URIHOST COMMA URIPORT RPAREN {
057f0454
 										#ifdef USE_TLS
 											$$=mk_action(	FORWARD_TLS_T,
 															 URIHOST_ST,
 															 URIPORT_ST,
 															0,
 															0);
 										#else
b23a7a00
 											$$=0;
057f0454
 											yyerror("tls support not "
 													"compiled in");
 										#endif
e9b02e8e
 													}
 													
 									
 		| FORWARD_TLS LPAREN URIHOST COMMA NUMBER RPAREN {
057f0454
 										#ifdef USE_TLS
 											$$=mk_action(	FORWARD_TLS_T,
 															 URIHOST_ST,
 															 NUMBER_ST,
 															0,
 															(void*)$5);
 										#else
b23a7a00
 											$$=0;
057f0454
 											yyerror("tls support not "
 													"compiled in");
 										#endif
e9b02e8e
 													}
 		| FORWARD_TLS LPAREN URIHOST RPAREN {
057f0454
 										#ifdef USE_TLS
 											$$=mk_action(	FORWARD_TLS_T,
 															 URIHOST_ST,
 															 NUMBER_ST,
 															0,
 															0);
 										#else
b23a7a00
 											$$=0;
057f0454
 											yyerror("tls support not "
 													"compiled in");
 										#endif
e9b02e8e
 										}
 		| FORWARD_TLS error { $$=0; yyerror("missing '(' or ')' ?"); }
057f0454
 		| FORWARD_TLS LPAREN error RPAREN { $$=0; yyerror("bad forward_tls"
e9b02e8e
 										"argument"); }
 		
09e52ebb
 		| SEND LPAREN host RPAREN	{ $$=mk_action(	SEND_T,
 													STRING_ST,
 													NUMBER_ST,
 													$3,
 													0);
 									}
 		| SEND LPAREN STRING RPAREN { $$=mk_action(	SEND_T,
 													STRING_ST,
 													NUMBER_ST,
 													$3,
 													0);
 									}
4e2fdd79
 		| SEND LPAREN ip RPAREN		{ $$=mk_action(	SEND_T,
09e52ebb
 													IP_ST,
 													NUMBER_ST,
 													(void*)$3,
 													0);
 									}
 		| SEND LPAREN host COMMA NUMBER RPAREN	{ $$=mk_action(	SEND_T,
 																STRING_ST,
 																NUMBER_ST,
 																$3,
 																(void*)$5);
 												}
 		| SEND LPAREN STRING COMMA NUMBER RPAREN {$$=mk_action(	SEND_T,
 																STRING_ST,
 																NUMBER_ST,
 																$3,
 																(void*)$5);
 												}
4e2fdd79
 		| SEND LPAREN ip COMMA NUMBER RPAREN { $$=mk_action(	SEND_T,
09e52ebb
 																IP_ST,
 																NUMBER_ST,
 																(void*)$3,
 																(void*)$5);
 											   }
 		| SEND error { $$=0; yyerror("missing '(' or ')' ?"); }
 		| SEND LPAREN error RPAREN { $$=0; yyerror("bad send"
 													"argument"); }
0c5da34b
 		| SEND_TCP LPAREN host RPAREN	{ $$=mk_action(	SEND_TCP_T,
 													STRING_ST,
 													NUMBER_ST,
 													$3,
 													0);
 									}
 		| SEND_TCP LPAREN STRING RPAREN { $$=mk_action(	SEND_TCP_T,
 													STRING_ST,
 													NUMBER_ST,
 													$3,
 													0);
 									}
 		| SEND_TCP LPAREN ip RPAREN		{ $$=mk_action(	SEND_TCP_T,
 													IP_ST,
 													NUMBER_ST,
 													(void*)$3,
 													0);
 									}
 		| SEND_TCP LPAREN host COMMA NUMBER RPAREN	{ $$=mk_action(	SEND_TCP_T,
 																STRING_ST,
 																NUMBER_ST,
 																$3,
 																(void*)$5);
 												}
 		| SEND_TCP LPAREN STRING COMMA NUMBER RPAREN {$$=mk_action(	SEND_TCP_T,
 																STRING_ST,
 																NUMBER_ST,
 																$3,
 																(void*)$5);
 												}
 		| SEND_TCP LPAREN ip COMMA NUMBER RPAREN { $$=mk_action(	SEND_TCP_T,
 																IP_ST,
 																NUMBER_ST,
 																(void*)$3,
 																(void*)$5);
 											   }
 		| SEND_TCP error { $$=0; yyerror("missing '(' or ')' ?"); }
 		| SEND_TCP LPAREN error RPAREN { $$=0; yyerror("bad send_tcp"
 													"argument"); }
09e52ebb
 		| DROP LPAREN RPAREN	{$$=mk_action(DROP_T,0, 0, 0, 0); }
 		| DROP					{$$=mk_action(DROP_T,0, 0, 0, 0); }
7268726e
 		| LOG_TOK LPAREN STRING RPAREN	{$$=mk_action(	LOG_T, NUMBER_ST, 
09e52ebb
 													STRING_ST,(void*)4,$3);
 									}
7268726e
 		| LOG_TOK LPAREN NUMBER COMMA STRING RPAREN	{$$=mk_action(	LOG_T,
09e52ebb
 																NUMBER_ST, 
 																STRING_ST,
 																(void*)$3,
 																$5);
 												}
7268726e
 		| LOG_TOK error { $$=0; yyerror("missing '(' or ')' ?"); }
 		| LOG_TOK LPAREN error RPAREN { $$=0; yyerror("bad log"
09e52ebb
 									"argument"); }
3881f12c
 		| SETFLAG LPAREN NUMBER RPAREN {$$=mk_action( SETFLAG_T, NUMBER_ST, 0,
 													(void *)$3, 0 ); }
 		| SETFLAG error { $$=0; yyerror("missing '(' or ')'?"); }
 		| RESETFLAG LPAREN NUMBER RPAREN {$$=mk_action(	RESETFLAG_T, NUMBER_ST, 0,
 													(void *)$3, 0 ); }
 		| RESETFLAG error { $$=0; yyerror("missing '(' or ')'?"); }
 		| ISFLAGSET LPAREN NUMBER RPAREN {$$=mk_action(	ISFLAGSET_T, NUMBER_ST, 0,
 													(void *)$3, 0 ); }
 		| ISFLAGSET error { $$=0; yyerror("missing '(' or ')'?"); }
09e52ebb
 		| ERROR LPAREN STRING COMMA STRING RPAREN {$$=mk_action(ERROR_T,
 																STRING_ST, 
 																STRING_ST,
 																$3,
 																$5);
 												  }
 		| ERROR error { $$=0; yyerror("missing '(' or ')' ?"); }
 		| ERROR LPAREN error RPAREN { $$=0; yyerror("bad error"
 														"argument"); }
 		| ROUTE LPAREN NUMBER RPAREN	{ $$=mk_action(ROUTE_T, NUMBER_ST,
 														0, (void*)$3, 0);
 										}
 		| ROUTE error { $$=0; yyerror("missing '(' or ')' ?"); }
 		| ROUTE LPAREN error RPAREN { $$=0; yyerror("bad route"
c07508e2
 						"argument"); }
09e52ebb
 		| EXEC LPAREN STRING RPAREN	{ $$=mk_action(	EXEC_T, STRING_ST, 0,
 													$3, 0);
 									}
f20a56a2
 		| SET_HOST LPAREN STRING RPAREN { $$=mk_action(SET_HOST_T, STRING_ST,
 														0, $3, 0); }
7268726e
 		| SET_HOST error { $$=0; yyerror("missing '(' or ')' ?"); }
f20a56a2
 		| SET_HOST LPAREN error RPAREN { $$=0; yyerror("bad argument, "
 														"string expected"); }
1f377e97
 
 		| PREFIX LPAREN STRING RPAREN { $$=mk_action(PREFIX_T, STRING_ST,
 														0, $3, 0); }
 		| PREFIX error { $$=0; yyerror("missing '(' or ')' ?"); }
 		| PREFIX LPAREN error RPAREN { $$=0; yyerror("bad argument, "
 														"string expected"); }
1d9f91d6
 		| STRIP_TAIL LPAREN NUMBER RPAREN { $$=mk_action(STRIP_TAIL_T, 
 									NUMBER_ST, 0, (void *) $3, 0); }
 		| STRIP_TAIL error { $$=0; yyerror("missing '(' or ')' ?"); }
 		| STRIP_TAIL LPAREN error RPAREN { $$=0; yyerror("bad argument, "
 														"number expected"); }
 
1f377e97
 		| STRIP LPAREN NUMBER RPAREN { $$=mk_action(STRIP_T, NUMBER_ST,
 														0, (void *) $3, 0); }
 		| STRIP error { $$=0; yyerror("missing '(' or ')' ?"); }
 		| STRIP LPAREN error RPAREN { $$=0; yyerror("bad argument, "
 														"number expected"); }
0b4b7601
                 | APPEND_BRANCH LPAREN STRING COMMA STRING RPAREN { 
 		    {   qvalue_t q;
 			if (str2q(&q, $5, strlen($5)) < 0) {
53c7e0f1
 				yyerror("bad argument, q value expected");
0b4b7601
 			}
4d080f49
 			$$=mk_action(APPEND_BRANCH_T, STRING_ST, NUMBER_ST, $3, 
 							(void *)(long)q); } 
0b4b7601
 		}
 	
caf80ae6
 		| APPEND_BRANCH LPAREN STRING RPAREN { $$=mk_action( APPEND_BRANCH_T,
035f593c
 													STRING_ST, NUMBER_ST, $3, (void *)Q_UNSPECIFIED) ; }
caf80ae6
 		| APPEND_BRANCH LPAREN RPAREN { $$=mk_action( APPEND_BRANCH_T,
035f593c
 													STRING_ST, NUMBER_ST, 0, (void *)Q_UNSPECIFIED ) ; }
caf80ae6
 		| APPEND_BRANCH {  $$=mk_action( APPEND_BRANCH_T, STRING_ST, 0, 0, 0 ) ; }
 
f20a56a2
 		| SET_HOSTPORT LPAREN STRING RPAREN { $$=mk_action( SET_HOSTPORT_T, 
 														STRING_ST, 0, $3, 0); }
7268726e
 		| SET_HOSTPORT error { $$=0; yyerror("missing '(' or ')' ?"); }
f20a56a2
 		| SET_HOSTPORT LPAREN error RPAREN { $$=0; yyerror("bad argument,"
 												" string expected"); }
 		| SET_PORT LPAREN STRING RPAREN { $$=mk_action( SET_PORT_T, STRING_ST,
 														0, $3, 0); }
7268726e
 		| SET_PORT error { $$=0; yyerror("missing '(' or ')' ?"); }
f20a56a2
 		| SET_PORT LPAREN error RPAREN { $$=0; yyerror("bad argument, "
 														"string expected"); }
 		| SET_USER LPAREN STRING RPAREN { $$=mk_action( SET_USER_T, STRING_ST,
 														0, $3, 0); }
7268726e
 		| SET_USER error { $$=0; yyerror("missing '(' or ')' ?"); }
f20a56a2
 		| SET_USER LPAREN error RPAREN { $$=0; yyerror("bad argument, "
 														"string expected"); }
 		| SET_USERPASS LPAREN STRING RPAREN { $$=mk_action( SET_USERPASS_T, 
 														STRING_ST, 0, $3, 0); }
7268726e
 		| SET_USERPASS error { $$=0; yyerror("missing '(' or ')' ?"); }
f20a56a2
 		| SET_USERPASS LPAREN error RPAREN { $$=0; yyerror("bad argument, "
 														"string expected"); }
 		| SET_URI LPAREN STRING RPAREN { $$=mk_action( SET_URI_T, STRING_ST, 
 														0, $3, 0); }
7268726e
 		| SET_URI error { $$=0; yyerror("missing '(' or ')' ?"); }
f20a56a2
 		| SET_URI LPAREN error RPAREN { $$=0; yyerror("bad argument, "
 										"string expected"); }
caf80ae6
 		| REVERT_URI LPAREN RPAREN { $$=mk_action( REVERT_URI_T, 0,0,0,0); }
 		| REVERT_URI { $$=mk_action( REVERT_URI_T, 0,0,0,0); }
a8af804e
 		| FORCE_RPORT LPAREN RPAREN	{ $$=mk_action(FORCE_RPORT_T,0, 0, 0, 0); }
3e8c3475
 		| FORCE_RPORT				{$$=mk_action(FORCE_RPORT_T,0, 0, 0, 0); }
59653eb8
 		| FORCE_TCP_ALIAS LPAREN NUMBER RPAREN	{
 					#ifdef USE_TCP
 						$$=mk_action(FORCE_TCP_ALIAS_T,NUMBER_ST, 0,
 										(void*)$3, 0);
 					#else
 						yyerror("tcp support not compiled in");
 					#endif
 												}
 		| FORCE_TCP_ALIAS LPAREN RPAREN	{
 					#ifdef USE_TCP
 						$$=mk_action(FORCE_TCP_ALIAS_T,0, 0, 0, 0); 
 					#else
 						yyerror("tcp support not compiled in");
 					#endif
 										}
 		| FORCE_TCP_ALIAS				{
 					#ifdef USE_TCP
 						$$=mk_action(FORCE_TCP_ALIAS_T,0, 0, 0, 0);
 					#else
 						yyerror("tcp support not compiled in");
 					#endif
 										}
 		| FORCE_TCP_ALIAS LPAREN error RPAREN	{$$=0; 
1580c821
 					yyerror("bad argument, number expected");
 					}
6bfaa042
 		| SET_ADV_ADDRESS LPAREN listen_id RPAREN {
 								$$=0;
 								if ((str_tmp=pkg_malloc(sizeof(str)))==0){
 										LOG(L_CRIT, "ERROR: cfg. parser:"
 													" out of memory.\n");
 								}else{
 										str_tmp->s=$3;
 										str_tmp->len=strlen($3);
 										$$=mk_action(SET_ADV_ADDR_T, STR_ST,
 										             0, str_tmp, 0);
 								}
 												  }
 		| SET_ADV_ADDRESS LPAREN error RPAREN { $$=0; yyerror("bad argument, "
 														"string expected"); }
 		| SET_ADV_ADDRESS error {$$=0; yyerror("missing '(' or ')' ?"); }
 		| SET_ADV_PORT LPAREN NUMBER RPAREN {
 								$$=0;
 								tmp=int2str($3, &i_tmp);
 								if ((str_tmp=pkg_malloc(sizeof(str)))==0){
 										LOG(L_CRIT, "ERROR: cfg. parser:"
 													" out of memory.\n");
 								}else{
 									if ((str_tmp->s=pkg_malloc(i_tmp))==0){
 										LOG(L_CRIT, "ERROR: cfg. parser:"
 													" out of memory.\n");
 									}else{
 										memcpy(str_tmp->s, tmp, i_tmp);
 										str_tmp->len=i_tmp;
 										$$=mk_action(SET_ADV_PORT_T, STR_ST,
 													0, str_tmp, 0);
 									}
 								}
 								            }
 		| SET_ADV_PORT LPAREN error RPAREN { $$=0; yyerror("bad argument, "
 														"string expected"); }
 		| SET_ADV_PORT  error {$$=0; yyerror("missing '(' or ')' ?"); }
6cd48835
 		| FORCE_SEND_SOCKET LPAREN phostport RPAREN {
 										$$=mk_action(FORCE_SEND_SOCKET_T,
 														SOCKID_ST, 0, $3, 0);
 													}
 		| FORCE_SEND_SOCKET LPAREN error RPAREN { $$=0; yyerror("bad argument,"
 											" [proto:]host[:port] expected"); }
 		| FORCE_SEND_SOCKET error {$$=0; yyerror("missing '(' or ')' ?"); }
51c38611
 		| ID LPAREN RPAREN			{ f_tmp=(void*)find_export($1, 0, rt);
34fd2612
 									   if (f_tmp==0){
51c38611
 										   if (find_export($1, 0, 0)) {
 											   yyerror("Command cannot be used in the block\n");
 										   } else {
 											   yyerror("unknown command, missing"
 												   " loadmodule?\n");
 										   }
34fd2612
 										$$=0;
 									   }else{
 										$$=mk_action(	MODULE_T,
 														CMDF_ST,
 														0,
 														f_tmp,
 														0
 													);
 									   }
 									}
51c38611
 		| ID LPAREN STRING RPAREN { f_tmp=(void*)find_export($1, 1, rt);
3bf76e49
 									if (f_tmp==0){
51c38611
 										if (find_export($1, 1, 0)) {
 											yyerror("Command cannot be used in the block\n");
 										} else {
 											yyerror("unknown command, missing"
 												" loadmodule?\n");
 										}
3bf76e49
 										$$=0;
 									}else{
 										$$=mk_action(	MODULE_T,
 														CMDF_ST,
 														STRING_ST,
 														f_tmp,
 														$3
 													);
 									}
 								  }
34fd2612
 		| ID LPAREN STRING  COMMA STRING RPAREN 
51c38611
 								  { f_tmp=(void*)find_export($1, 2, rt);
34fd2612
 									if (f_tmp==0){
51c38611
 										if (find_export($1, 2, 0)) {
 											yyerror("Command cannot be used in the block\n");
 										} else {
 											yyerror("unknown command, missing"
 												" loadmodule?\n");
 										}
34fd2612
 										$$=0;
 									}else{
 										$$=mk_action3(	MODULE_T,
 														CMDF_ST,
 														STRING_ST,
 														STRING_ST,
 														f_tmp,
 														$3,
 														$5
 													);
 									}
 								  }
3bf76e49
 		| ID LPAREN error RPAREN { $$=0; yyerror("bad arguments"); }
3c1a8ef8
 	;
 
 
 %%
 
 extern int line;
 extern int column;
09e52ebb
 extern int startcolumn;
194b6a35
 static void warn(char* s)
057f0454
 {
 	LOG(L_WARN, "cfg. warning: (%d,%d-%d): %s\n", line, startcolumn, 
 			column, s);
 	cfg_errors++;
 }
 
194b6a35
 static void yyerror(char* s)
3c1a8ef8
 {
7268726e
 	LOG(L_CRIT, "parse error (%d,%d-%d): %s\n", line, startcolumn, 
09e52ebb
 			column, s);
63fa628f
 	cfg_errors++;
3c1a8ef8
 }
 
e5f4cdaf
 
6cd48835
 static struct socket_id* mk_listen_id(char* host, int proto, int port)
e5f4cdaf
 {
6cd48835
 	struct socket_id* l;
 	l=pkg_malloc(sizeof(struct socket_id));
e5f4cdaf
 	if (l==0){
 		LOG(L_CRIT,"ERROR: cfg. parser: out of memory.\n");
 	}else{
9f4c52ce
 		l->name=host;
e5f4cdaf
 		l->port=port;
 		l->proto=proto;
 		l->next=0;
 	}
 	return l;
 }
 
 
a15c363f
 /*
3c1a8ef8
 int main(int argc, char ** argv)
 {
 	if (yyparse()!=0)
 		fprintf(stderr, "parsing error\n");
 }
a15c363f
 */