PageRenderTime 19ms CodeModel.GetById 3ms app.highlight 7ms RepoModel.GetById 1ms app.codeStats 0ms

/cfg.y

https://bitbucket.org/Gradwell/opensips-clone
Happy | 2907 lines | 2763 code | 144 blank | 0 comment | 0 complexity | 1021c82047faf411fb86499de8ab5949 MD5 | raw file

Large files files are truncated, but you can click here to view the full file

   1/*
   2 * $Id$
   3 *
   4 *  cfg grammar
   5 *
   6 * Copyright (C) 2001-2003 FhG Fokus
   7 * Copyright (C) 2005-2009 Voice Sistem S.R.L.
   8 * Copyright (C) 2006 enum.at
   9 *
  10 * This file is part of opensips, a free SIP server.
  11 *
  12 * opensips is free software; you can redistribute it and/or modify
  13 * it under the terms of the GNU General Public License as published by
  14 * the Free Software Foundation; either version 2 of the License, or
  15 * (at your option) any later version
  16 *
  17 * opensips is distributed in the hope that it will be useful,
  18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
  19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  20 * GNU General Public License for more details.
  21 *
  22 * You should have received a copy of the GNU General Public License 
  23 * along with this program; if not, write to the Free Software 
  24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  25 */
  26 /*
  27 * History:
  28 * ---------
  29 * 2003-01-29  src_port added (jiri)
  30 * 2003-01-23  mhomed added (jiri)
  31 * 2003-03-19  replaced all mallocs/frees with pkg_malloc/pkg_free (andrei)
  32 * 2003-03-19  Added support for route type in find_export (janakj)
  33 * 2003-03-20  Regex support in modparam (janakj)
  34 * 2003-04-01  added dst_port, proto , af (andrei)
  35 * 2003-04-05  s/reply_route/failure_route, onreply_route introduced (jiri)
  36 * 2003-04-12  added force_rport, chroot and wdir (andrei)
  37 * 2003-04-15  added tcp_children, disable_tcp (andrei)
  38 * 2003-04-22  strip_tail added (jiri)
  39 * 2003-07-03  tls* (disable, certificate, private_key, ca_list, verify, 
  40 *              require_certificate added (andrei)
  41 * 2003-07-06  more tls config. vars added: tls_method, tls_port_no (andrei)
  42 * 2003-10-02  added {,set_}advertised_{address,port} (andrei)
  43 * 2003-10-10  added <,>,<=,>=, != operators support
  44 *             added msg:len (andrei)
  45 * 2003-10-11  if(){} doesn't require a ';' after it anymore (andrei)
  46 * 2003-10-13  added FIFO_DIR & proto:host:port listen/alias support (andrei)
  47 * 2003-10-24  converted to the new socket_info lists (andrei)
  48 * 2003-10-28  added tcp_accept_aliases (andrei)
  49 * 2003-11-20  added {tcp_connect, tcp_send, tls_*}_timeout (andrei)
  50 * 2004-03-30  added DISABLE_CORE and OPEN_FD_LIMIT (andrei)
  51 * 2004-04-29  added SOCK_MODE, SOCK_USER & SOCK_GROUP (andrei)
  52 * 2004-05-03  applied multicast support patch (MCAST_LOOPBACK) from janakj
  53               added MCAST_TTL (andrei)
  54 * 2004-07-05  src_ip & dst_ip will detect ip addresses between quotes
  55 *              (andrei)
  56 * 2004-10-19  added FROM_URI, TO_URI (andrei)
  57 * 2004-11-30  added force_send_socket (andrei)
  58 * 2005-07-08  added TCP_CON_LIFETIME, TCP_POLL_METHOD, TCP_MAX_CONNECTIONS
  59 *              (andrei)
  60 * 2005-07-26  default onreply route added (andrei)
  61 * 2005-11-22  added tos configurability (thanks to Andreas Granig)
  62 * 2005-11-29  added serialize_branches and next_branches (bogdan)
  63 * 2006-03-02  MODULE_T action points to a cmd_export_t struct instead to 
  64 *              a function address - more info is accessible (bogdan)
  65 * 2006-03-02  store the cfg line into the action struct to be able to
  66 *              give more hints if fixups fail (bogdan)
  67 * 2006-05-22  forward(_udp,_tcp,_tls) and send(_tcp) merged in forward() and
  68 *              send() (bogdan)
  69 *  2006-12-22  functions for script and branch flags added (bogdan)
  70 *  2007-01-11  auto_aliases option added (bogdan)
  71 *  2007-01-25  disable_dns_failover option added (bogdan)
  72 *  2012-01-19  added TCP keepalive support
  73 *  2012-12-06  added event_route (razvanc)
  74 */
  75
  76
  77%{
  78
  79#include <stdlib.h>
  80#include <stdio.h>
  81#include <sys/types.h>
  82#include <sys/socket.h>
  83#include <sys/stat.h>
  84#include <unistd.h>
  85#include <netinet/in.h>
  86#include <netinet/in_systm.h>
  87#include <netinet/ip.h>
  88#include <arpa/inet.h>
  89#include <string.h>
  90#include <errno.h>
  91#include "route_struct.h"
  92#include "globals.h"
  93#include "route.h"
  94#include "dprint.h"
  95#include "sr_module.h"
  96#include "modparam.h"
  97#include "ip_addr.h"
  98#include "resolve.h"
  99#include "socket_info.h"
 100#include "name_alias.h"
 101#include "ut.h"
 102#include "dset.h"
 103#include "pvar.h"
 104#include "blacklists.h"
 105#include "xlog.h"
 106#include "tcp_server.h"
 107#include "tcp_conn.h"
 108#include "db/db_insertq.h"
 109
 110
 111#include "config.h"
 112#ifdef USE_TLS
 113#include "tls/tls_config.h"
 114#include "tls/tls_domain.h"
 115#endif
 116
 117#ifdef DEBUG_DMALLOC
 118#include <dmalloc.h>
 119#endif
 120
 121/* hack to avoid alloca usage in the generated C file (needed for compiler
 122 with no built in alloca, like icc*/
 123#undef _ALLOCA_H
 124
 125
 126extern int yylex();
 127static void yyerror(char* s);
 128static void yyerrorf(char* fmt, ...);
 129static char* tmp;
 130static int i_tmp;
 131static void* cmd_tmp;
 132static struct socket_id* lst_tmp;
 133static int rt;  /* Type of route block for find_export */
 134static str* str_tmp;
 135static str s_tmp;
 136static str tstr;
 137static struct ip_addr* ip_tmp;
 138static pv_spec_t *spec;
 139static pv_elem_t *pvmodel;
 140static struct bl_rule *bl_head = 0;
 141static struct bl_rule *bl_tail = 0;
 142static struct stat statf;
 143
 144action_elem_t elems[MAX_ACTION_ELEMS];
 145static action_elem_t route_elems[MAX_ACTION_ELEMS];
 146action_elem_t *a_tmp;
 147
 148static inline void warn(char* s);
 149static struct socket_id* mk_listen_id(char*, int, int);
 150static struct socket_id* set_listen_id_adv(struct socket_id *, char *, int);
 151
 152static char *mpath=NULL;
 153static char mpath_buf[256];
 154static int  mpath_len = 0;
 155
 156extern int line;
 157
 158#define mk_action0(_res, _type, _p1_type, _p2_type, _p1, _p2) \
 159	do { \
 160		_res = mk_action(_type, 0, 0, line); \
 161	} while(0)
 162#define mk_action1(_res, _type, _p1_type, _p1) \
 163	do { \
 164		elems[0].type = _p1_type; \
 165		elems[0].u.data = _p1; \
 166		_res = mk_action(_type, 1, elems, line); \
 167	} while(0)
 168#define	mk_action2(_res, _type, _p1_type, _p2_type, _p1, _p2) \
 169	do { \
 170		elems[0].type = _p1_type; \
 171		elems[0].u.data = _p1; \
 172		elems[1].type = _p2_type; \
 173		elems[1].u.data = _p2; \
 174		_res = mk_action(_type, 2, elems, line); \
 175	} while(0)
 176#define mk_action3(_res, _type, _p1_type, _p2_type, _p3_type, _p1, _p2, _p3) \
 177	do { \
 178		elems[0].type = _p1_type; \
 179		elems[0].u.data = _p1; \
 180		elems[1].type = _p2_type; \
 181		elems[1].u.data = _p2; \
 182		elems[2].type = _p3_type; \
 183		elems[2].u.data = _p3; \
 184		_res = mk_action(_type, 3, elems, line); \
 185	} while(0)
 186
 187%}
 188
 189%union {
 190	long intval;
 191	unsigned long uval;
 192	char* strval;
 193	struct expr* expr;
 194	struct action* action;
 195	struct net* ipnet;
 196	struct ip_addr* ipaddr;
 197	struct socket_id* sockid;
 198	struct _pv_spec *specval;
 199}
 200
 201/* terminals */
 202
 203
 204/* keywords */
 205%token FORWARD
 206%token SEND
 207%token DROP
 208%token EXIT
 209%token RETURN
 210%token LOG_TOK
 211%token ERROR
 212%token ROUTE
 213%token ROUTE_FAILURE
 214%token ROUTE_ONREPLY
 215%token ROUTE_BRANCH
 216%token ROUTE_ERROR
 217%token ROUTE_LOCAL
 218%token ROUTE_STARTUP
 219%token ROUTE_TIMER
 220%token ROUTE_EVENT
 221%token SET_HOST
 222%token SET_HOSTPORT
 223%token PREFIX
 224%token STRIP
 225%token STRIP_TAIL
 226%token APPEND_BRANCH
 227%token REMOVE_BRANCH
 228%token PV_PRINTF
 229%token SET_USER
 230%token SET_USERPASS
 231%token SET_PORT
 232%token SET_URI
 233%token REVERT_URI
 234%token SET_DSTURI
 235%token RESET_DSTURI
 236%token ISDSTURISET
 237%token FORCE_RPORT
 238%token FORCE_LOCAL_RPORT
 239%token FORCE_TCP_ALIAS
 240%token IF
 241%token ELSE
 242%token SWITCH
 243%token CASE
 244%token DEFAULT
 245%token SBREAK
 246%token WHILE
 247%token SET_ADV_ADDRESS
 248%token SET_ADV_PORT
 249%token FORCE_SEND_SOCKET
 250%token SERIALIZE_BRANCHES
 251%token NEXT_BRANCHES
 252%token USE_BLACKLIST
 253%token UNUSE_BLACKLIST
 254%token MAX_LEN
 255%token SETDEBUG
 256%token SETFLAG
 257%token RESETFLAG
 258%token ISFLAGSET
 259%token SETBFLAG
 260%token RESETBFLAG
 261%token ISBFLAGSET
 262%token SETSFLAG
 263%token RESETSFLAG
 264%token ISSFLAGSET
 265%token METHOD
 266%token URI
 267%token FROM_URI
 268%token TO_URI
 269%token SRCIP
 270%token SRCPORT
 271%token DSTIP
 272%token DSTPORT
 273%token PROTO
 274%token AF
 275%token MYSELF
 276%token MSGLEN 
 277%token UDP
 278%token TCP
 279%token TLS
 280%token SCTP
 281%token NULLV
 282%token CACHE_STORE
 283%token CACHE_FETCH
 284%token CACHE_COUNTER_FETCH
 285%token CACHE_REMOVE
 286%token CACHE_ADD
 287%token CACHE_SUB
 288%token CACHE_RAW_QUERY
 289%token XDBG
 290%token XLOG
 291%token XLOG_BUF_SIZE
 292%token XLOG_FORCE_COLOR
 293%token RAISE_EVENT
 294%token SUBSCRIBE_EVENT
 295%token CONSTRUCT_URI
 296%token GET_TIMESTAMP
 297%token SCRIPT_TRACE
 298
 299/* config vars. */
 300%token DEBUG
 301%token FORK
 302%token LOGSTDERROR
 303%token LOGFACILITY
 304%token LOGNAME
 305%token AVP_ALIASES
 306%token LISTEN
 307%token ALIAS
 308%token AUTO_ALIASES
 309%token DNS
 310%token REV_DNS
 311%token DNS_TRY_IPV6
 312%token DNS_RETR_TIME
 313%token DNS_RETR_NO
 314%token DNS_SERVERS_NO
 315%token DNS_USE_SEARCH
 316%token MAX_WHILE_LOOPS
 317%token PORT
 318%token CHILDREN
 319%token CHECK_VIA
 320%token MEMLOG
 321%token MEMDUMP
 322%token EXECMSGTHRESHOLD
 323%token EXECDNSTHRESHOLD
 324%token TCPTHRESHOLD
 325%token EVENT_SHM_THRESHOLD
 326%token EVENT_PKG_THRESHOLD
 327%token QUERYBUFFERSIZE
 328%token QUERYFLUSHTIME
 329%token SIP_WARNING
 330%token SOCK_MODE
 331%token SOCK_USER
 332%token SOCK_GROUP
 333%token UNIX_SOCK
 334%token UNIX_SOCK_CHILDREN
 335%token UNIX_TX_TIMEOUT
 336%token SERVER_SIGNATURE
 337%token SERVER_HEADER
 338%token USER_AGENT_HEADER
 339%token LOADMODULE
 340%token MPATH
 341%token MODPARAM
 342%token MAXBUFFER
 343%token USER
 344%token GROUP
 345%token CHROOT
 346%token WDIR
 347%token MHOMED
 348%token DISABLE_TCP
 349%token TCP_ACCEPT_ALIASES
 350%token TCP_CHILDREN
 351%token TCP_CONNECT_TIMEOUT
 352%token TCP_SEND_TIMEOUT
 353%token TCP_CON_LIFETIME
 354%token TCP_LISTEN_BACKLOG
 355%token TCP_POLL_METHOD
 356%token TCP_MAX_CONNECTIONS
 357%token TCP_OPT_CRLF_PINGPONG
 358%token TCP_NO_NEW_CONN_BFLAG
 359%token TCP_KEEPALIVE
 360%token TCP_KEEPCOUNT
 361%token TCP_KEEPIDLE
 362%token TCP_KEEPINTERVAL
 363%token DISABLE_TLS
 364%token TLSLOG
 365%token TLS_PORT_NO
 366%token TLS_METHOD
 367%token TLS_HANDSHAKE_TIMEOUT
 368%token TLS_SEND_TIMEOUT
 369%token TLS_SERVER_DOMAIN
 370%token TLS_CLIENT_DOMAIN
 371%token TLS_CLIENT_DOMAIN_AVP
 372%token SSLv23
 373%token SSLv2
 374%token SSLv3
 375%token TLSv1
 376%token TLS_VERIFY_CLIENT
 377%token TLS_VERIFY_SERVER
 378%token TLS_REQUIRE_CLIENT_CERTIFICATE
 379%token TLS_CERTIFICATE
 380%token TLS_PRIVATE_KEY
 381%token TLS_CA_LIST
 382%token TLS_CIPHERS_LIST
 383%token ADVERTISED_ADDRESS
 384%token ADVERTISED_PORT
 385%token DISABLE_CORE
 386%token OPEN_FD_LIMIT
 387%token MCAST_LOOPBACK
 388%token MCAST_TTL
 389%token TOS
 390%token DISABLE_DNS_FAILOVER
 391%token DISABLE_DNS_BLACKLIST
 392%token DST_BLACKLIST
 393%token DISABLE_STATELESS_FWD
 394%token DB_VERSION_TABLE
 395%token DB_DEFAULT_URL
 396%token DISABLE_503_TRANSLATION
 397
 398
 399
 400
 401/* operators */
 402%nonassoc EQUAL
 403%nonassoc EQUAL_T
 404%nonassoc GT
 405%nonassoc LT
 406%nonassoc GTE
 407%nonassoc LTE
 408%nonassoc DIFF
 409%nonassoc MATCH
 410%nonassoc NOTMATCH
 411%nonassoc COLONEQ
 412%nonassoc PLUSEQ
 413%nonassoc MINUSEQ
 414%nonassoc SLASHEQ
 415%nonassoc MULTEQ
 416%nonassoc MODULOEQ
 417%nonassoc BANDEQ
 418%nonassoc BOREQ
 419%nonassoc BXOREQ
 420
 421%left OR AND
 422%left BOR BAND BXOR BLSHIFT BRSHIFT
 423%left PLUS MINUS SLASH MULT MODULO
 424%right NOT BNOT
 425
 426/* values */
 427%token <intval> NUMBER
 428%token <intval> ZERO
 429%token <strval> ID
 430%token <strval> STRING
 431%token <strval> SCRIPTVAR
 432%token <strval> IPV6ADDR
 433
 434/* other */
 435%token COMMA
 436%token SEMICOLON
 437%token RPAREN
 438%token LPAREN
 439%token LBRACE
 440%token RBRACE
 441%token LBRACK
 442%token RBRACK
 443%token SLASH
 444%token AS
 445%token USE_CHILDREN
 446%token DOT
 447%token CR
 448%token COLON
 449%token ANY
 450%token SCRIPTVARERR
 451
 452
 453/*non-terminals */
 454%type <expr> exp exp_elem exp_cond assignexp /*, condition*/
 455%type <action> action actions cmd if_cmd stm exp_stm assign_cmd while_cmd
 456%type <action> switch_cmd switch_stm case_stms case_stm default_stm
 457%type <intval> module_func_param
 458%type <ipaddr> ipv4 ipv6 ipv6addr ip
 459%type <ipnet> ipnet
 460%type <specval> script_var
 461%type <strval> host
 462%type <strval> listen_id
 463%type <sockid> listen_lst
 464%type <sockid> listen_def
 465%type <sockid> id_lst
 466%type <sockid> phostport
 467%type <intval> proto port
 468%type <strval> host_sep
 469%type <intval> uri_type
 470%type <intval> equalop compop matchop strop intop
 471%type <intval> assignop
 472%type <intval> snumber
 473%type <strval> route_name
 474%type <intval> route_param
 475
 476
 477
 478%%
 479
 480
 481cfg:	statements
 482	;
 483
 484statements:	statements statement {}
 485		| statement {}
 486		| statements error { yyerror(""); YYABORT;}
 487	;
 488
 489statement:	assign_stm 
 490		| module_stm
 491		| {rt=REQUEST_ROUTE;} route_stm 
 492		| {rt=FAILURE_ROUTE;} failure_route_stm
 493		| {rt=ONREPLY_ROUTE;} onreply_route_stm
 494		| {rt=BRANCH_ROUTE;} branch_route_stm
 495		| {rt=ERROR_ROUTE;} error_route_stm
 496		| {rt=LOCAL_ROUTE;} local_route_stm
 497		| {rt=STARTUP_ROUTE;} startup_route_stm
 498		| {rt=TIMER_ROUTE;} timer_route_stm
 499		| {rt=EVENT_ROUTE;} event_route_stm
 500
 501		| CR	/* null statement*/
 502	;
 503
 504listen_id:	ip			{	tmp=ip_addr2a($1);
 505							if(tmp==0){
 506								LM_CRIT("cfg. parser: bad ip address.\n");
 507								$$=0;
 508							}else{
 509								$$=pkg_malloc(strlen(tmp)+1);
 510								if ($$==0){
 511									LM_CRIT("cfg. parser: out of memory.\n");
 512								}else{
 513									strncpy($$, tmp, strlen(tmp)+1);
 514								}
 515							}
 516						}
 517		|	STRING			{	$$=pkg_malloc(strlen($1)+1);
 518							if ($$==0){
 519									LM_CRIT("cfg. parser: out of memory.\n");
 520							}else{
 521									strncpy($$, $1, strlen($1)+1);
 522							}
 523						}
 524		|	host		{	if ($1==0) {
 525								$$ = 0;
 526							} else {
 527								$$=pkg_malloc(strlen($1)+1);
 528								if ($$==0){
 529									LM_CRIT("cfg. parser: out of memory.\n");
 530								}else{
 531									strncpy($$, $1, strlen($1)+1);
 532								}
 533							}
 534						}
 535	;
 536
 537proto:	  UDP	{ $$=PROTO_UDP; }
 538		| TCP	{ $$=PROTO_TCP; }
 539		| TLS	{
 540			#ifdef USE_TLS
 541				$$=PROTO_TLS;
 542			#else
 543				$$=PROTO_TCP;
 544				warn("tls support not compiled in");
 545			#endif
 546			}
 547		| SCTP  { 
 548			#ifdef USE_SCTP
 549				$$=PROTO_SCTP;
 550			#else
 551				yyerror("sctp support not compiled in\n");YYABORT;
 552			#endif
 553			}
 554		| ANY	{ $$=0; }
 555		;
 556
 557port:	  NUMBER	{ $$=$1; }
 558		| ANY		{ $$=0; }
 559;
 560
 561snumber:	NUMBER	{ $$=$1; }
 562		| PLUS NUMBER	{ $$=$2; }
 563		| MINUS NUMBER	{ $$=-$2; }
 564;
 565
 566
 567phostport:	listen_id				{ $$=mk_listen_id($1, 0, 0); }
 568			| listen_id COLON port	{ $$=mk_listen_id($1, 0, $3); }
 569			| proto COLON listen_id	{ $$=mk_listen_id($3, $1, 0); }
 570			| proto COLON listen_id COLON port	{ $$=mk_listen_id($3, $1, $5);}
 571			| listen_id COLON error { $$=0; yyerror(" port number expected"); }
 572			;
 573
 574id_lst:		phostport		{  $$=$1 ; }
 575		| phostport id_lst	{ $$=$1; $$->next=$2; }
 576		;
 577
 578
 579listen_def:	phostport				{ $$=$1; }
 580			| phostport USE_CHILDREN NUMBER { $$=$1; $$->children=$3; }
 581			| phostport AS listen_id { $$=$1; set_listen_id_adv((struct socket_id *)$1, $3, 5060); }
 582			| phostport AS listen_id USE_CHILDREN NUMBER { $$=$1; set_listen_id_adv((struct socket_id *)$1, $3, 5060); $1->children=$5; }
 583			| phostport AS listen_id COLON port{ $$=$1; set_listen_id_adv((struct socket_id *)$1, $3, $5); }
 584			| phostport AS listen_id COLON port USE_CHILDREN NUMBER { $$=$1; set_listen_id_adv((struct socket_id *)$1, $3, $5); $1->children=$7; }
 585			;
 586
 587listen_lst:		listen_def		{  $$=$1 ; }
 588		| listen_def listen_lst	{ $$=$1; $$->next=$2; }
 589		;
 590
 591
 592blst_elem: LPAREN  proto COMMA ipnet COMMA port COMMA STRING RPAREN {
 593				s_tmp.s=$8;
 594				s_tmp.len=strlen($8);
 595				if (add_rule_to_list(&bl_head,&bl_tail,$4,&s_tmp,$6,$2,0)) {
 596					yyerror("failed to add backlist element\n");YYABORT;
 597				}
 598			}
 599		| NOT  LPAREN  proto COMMA ipnet COMMA port COMMA STRING RPAREN {
 600				s_tmp.s=$9;
 601				s_tmp.len=strlen($9);
 602				if (add_rule_to_list(&bl_head,&bl_tail,$5,&s_tmp,
 603				$7,$3,BLR_APPLY_CONTRARY)) {
 604					yyerror("failed to add backlist element\n");YYABORT;
 605				}
 606			}
 607		;
 608
 609blst_elem_list: blst_elem_list COMMA blst_elem {}
 610		| blst_elem {}
 611		| blst_elem_list error { yyerror("bad black list element");}
 612		;
 613
 614
 615assign_stm: DEBUG EQUAL snumber { 
 616#ifdef CHANGEABLE_DEBUG_LEVEL
 617					*debug=$3;
 618#else
 619					debug=$3;
 620#endif
 621			}
 622		| DEBUG EQUAL error  { yyerror("number  expected"); }
 623		| FORK  EQUAL NUMBER { dont_fork= !dont_fork ? ! $3:1; }
 624		| FORK  EQUAL error  { yyerror("boolean value expected"); }
 625		| LOGSTDERROR EQUAL NUMBER { if (!config_check) log_stderr=$3; }
 626		| LOGSTDERROR EQUAL error { yyerror("boolean value expected"); }
 627		| LOGFACILITY EQUAL ID {
 628					if ( (i_tmp=str2facility($3))==-1)
 629						yyerror("bad facility (see syslog(3) man page)");
 630					if (!config_check)
 631						log_facility=i_tmp;
 632									}
 633		| LOGFACILITY EQUAL error { yyerror("ID expected"); }
 634		| LOGNAME EQUAL STRING { log_name=$3; }
 635		| LOGNAME EQUAL error { yyerror("string value expected"); }
 636		| AVP_ALIASES EQUAL STRING { 
 637				yyerror("AVP_ALIASES shouldn't be used anymore\n");
 638			}
 639		| AVP_ALIASES EQUAL error { yyerror("string value expected"); }
 640		| DNS EQUAL NUMBER   { received_dns|= ($3)?DO_DNS:0; }
 641		| DNS EQUAL error { yyerror("boolean value expected"); }
 642		| REV_DNS EQUAL NUMBER { received_dns|= ($3)?DO_REV_DNS:0; }
 643		| REV_DNS EQUAL error { yyerror("boolean value expected"); }
 644		| DNS_TRY_IPV6 EQUAL NUMBER   { dns_try_ipv6=$3; }
 645		| DNS_TRY_IPV6 error { yyerror("boolean value expected"); }
 646		| DNS_RETR_TIME EQUAL NUMBER   { dns_retr_time=$3; }
 647		| DNS_RETR_TIME error { yyerror("number expected"); }
 648		| DNS_RETR_NO EQUAL NUMBER   { dns_retr_no=$3; }
 649		| DNS_RETR_NO error { yyerror("number expected"); }
 650		| DNS_SERVERS_NO EQUAL NUMBER   { dns_servers_no=$3; }
 651		| DNS_SERVERS_NO error { yyerror("number expected"); }
 652		| DNS_USE_SEARCH EQUAL NUMBER   { dns_search_list=$3; }
 653		| DNS_USE_SEARCH error { yyerror("boolean value expected"); }
 654		| PORT EQUAL NUMBER   { port_no=$3; }
 655		| PORT EQUAL error    { yyerror("number expected"); } 
 656		| MAX_WHILE_LOOPS EQUAL NUMBER { max_while_loops=$3; }
 657		| MAX_WHILE_LOOPS EQUAL error { yyerror("number expected"); } 
 658		| MAXBUFFER EQUAL NUMBER { maxbuffer=$3; }
 659		| MAXBUFFER EQUAL error { yyerror("number expected"); }
 660		| CHILDREN EQUAL NUMBER { children_no=$3; }
 661		| CHILDREN EQUAL error { yyerror("number expected"); } 
 662		| CHECK_VIA EQUAL NUMBER { check_via=$3; }
 663		| CHECK_VIA EQUAL error { yyerror("boolean value expected"); }
 664		| MEMLOG EQUAL NUMBER { memlog=$3; memdump=$3; }
 665		| MEMLOG EQUAL error { yyerror("int value expected"); }
 666		| MEMDUMP EQUAL NUMBER { memdump=$3; }
 667		| MEMDUMP EQUAL error { yyerror("int value expected"); }
 668		| EXECMSGTHRESHOLD EQUAL NUMBER { execmsgthreshold=$3; }
 669		| EXECMSGTHRESHOLD EQUAL error { yyerror("int value expected"); }
 670		| EXECDNSTHRESHOLD EQUAL NUMBER { execdnsthreshold=$3; }
 671		| EXECDNSTHRESHOLD EQUAL error { yyerror("int value expected"); }
 672		| TCPTHRESHOLD EQUAL NUMBER { tcpthreshold=$3; }
 673		| TCPTHRESHOLD EQUAL error { yyerror("int value expected"); }
 674		| EVENT_SHM_THRESHOLD EQUAL NUMBER {
 675			#ifdef SHM_MEM
 676				#ifdef STATISTICS
 677					if ($3 < 0 || $3 > 100)
 678						yyerror("SHM threshold has to be a percentage between 0 and 100");
 679					event_shm_threshold=$3;
 680				#else
 681					yyerror("statistics support not compiled in");
 682				#endif /* STATISTICS */
 683			#else /* SHM_MEM */
 684				yyerror("shm memory support not compiled in");
 685			#endif
 686			}
 687		| EVENT_SHM_THRESHOLD EQUAL error { yyerror("int value expected"); }
 688		| EVENT_PKG_THRESHOLD EQUAL NUMBER {
 689			#ifdef PKG_MEM
 690                                #ifdef STATISTICS
 691                                        if ($3 < 0 || $3 > 100)
 692                                                yyerror("PKG threshold has to be a percentage between 0 and 100");
 693                                        event_pkg_threshold=$3;
 694                                #else
 695                                        yyerror("statistics support not compiled in");
 696                                #endif
 697			#else /* PKG_MEM */
 698				yyerror("pkg memory support not compiled in");
 699			#endif
 700			}
 701		| EVENT_PKG_THRESHOLD EQUAL error { yyerror("int value expected"); }
 702		| QUERYBUFFERSIZE EQUAL NUMBER { query_buffer_size=$3; }
 703		| QUERYBUFFERSIZE EQUAL error { yyerror("int value expected"); }
 704		| QUERYFLUSHTIME EQUAL NUMBER { query_flush_time=$3; }
 705		| QUERYFLUSHTIME EQUAL error { yyerror("int value expected"); }
 706		| SIP_WARNING EQUAL NUMBER { sip_warning=$3; }
 707		| SIP_WARNING EQUAL error { yyerror("boolean value expected"); }
 708		| USER EQUAL STRING     { user=$3; }
 709		| USER EQUAL ID         { user=$3; }
 710		| USER EQUAL error      { yyerror("string value expected"); }
 711		| GROUP EQUAL STRING     { group=$3; }
 712		| GROUP EQUAL ID         { group=$3; }
 713		| GROUP EQUAL error      { yyerror("string value expected"); }
 714		| CHROOT EQUAL STRING     { chroot_dir=$3; }
 715		| CHROOT EQUAL ID         { chroot_dir=$3; }
 716		| CHROOT EQUAL error      { yyerror("string value expected"); }
 717		| WDIR EQUAL STRING     { working_dir=$3; }
 718		| WDIR EQUAL ID         { working_dir=$3; }
 719		| WDIR EQUAL error      { yyerror("string value expected"); }
 720		| MHOMED EQUAL NUMBER { mhomed=$3; }
 721		| MHOMED EQUAL error { yyerror("boolean value expected"); }
 722		| DISABLE_TCP EQUAL NUMBER {
 723									#ifdef USE_TCP
 724										tcp_disable=$3;
 725									#else
 726										warn("tcp support not compiled in");
 727									#endif
 728									}
 729		| DISABLE_TCP EQUAL error { yyerror("boolean value expected"); }
 730		| TCP_ACCEPT_ALIASES EQUAL NUMBER {
 731									#ifdef USE_TCP
 732										tcp_accept_aliases=$3;
 733									#else
 734										warn("tcp support not compiled in");
 735									#endif
 736									}
 737		| TCP_ACCEPT_ALIASES EQUAL error { yyerror("boolean value expected"); }
 738		| TCP_CHILDREN EQUAL NUMBER {
 739									#ifdef USE_TCP
 740										tcp_children_no=$3;
 741									#else
 742										warn("tcp support not compiled in");
 743									#endif
 744									}
 745		| TCP_CHILDREN EQUAL error { yyerror("number expected"); }
 746		| TCP_CONNECT_TIMEOUT EQUAL NUMBER {
 747									#ifdef USE_TCP
 748										tcp_connect_timeout=$3;
 749									#else
 750										warn("tcp support not compiled in");
 751									#endif
 752									}
 753		| TCP_CONNECT_TIMEOUT EQUAL error { yyerror("number expected"); }
 754		| TCP_SEND_TIMEOUT EQUAL NUMBER {
 755									#ifdef USE_TCP
 756										tcp_send_timeout=$3;
 757									#else
 758										warn("tcp support not compiled in");
 759									#endif
 760									}
 761		| TCP_SEND_TIMEOUT EQUAL error { yyerror("number expected"); }
 762		| TCP_CON_LIFETIME EQUAL NUMBER {
 763									#ifdef USE_TCP
 764										tcp_con_lifetime=$3;
 765									#else
 766										warn("tcp support not compiled in");
 767									#endif
 768									}
 769		| TCP_CON_LIFETIME EQUAL error { yyerror("number expected"); }
 770		| TCP_LISTEN_BACKLOG EQUAL NUMBER {
 771									#ifdef USE_TCP
 772										tcp_listen_backlog=$3;
 773									#else
 774										warn("tcp support not compiled in");
 775									#endif
 776									}
 777		| TCP_LISTEN_BACKLOG EQUAL error { yyerror("number expected"); }
 778		| TCP_POLL_METHOD EQUAL ID {
 779									#ifdef USE_TCP
 780										tcp_poll_method=get_poll_type($3);
 781										if (tcp_poll_method==POLL_NONE){
 782											LM_CRIT("bad poll method name:"
 783												" %s\n, try one of %s.\n",
 784												$3, poll_support);
 785											yyerror("bad tcp_poll_method "
 786												"value");
 787										}
 788									#else
 789										warn("tcp support not compiled in");
 790									#endif
 791									}
 792		| TCP_POLL_METHOD EQUAL STRING {
 793									#ifdef USE_TCP
 794										tcp_poll_method=get_poll_type($3);
 795										if (tcp_poll_method==POLL_NONE){
 796											LM_CRIT("bad poll method name:"
 797												" %s\n, try one of %s.\n",
 798												$3, poll_support);
 799											yyerror("bad tcp_poll_method "
 800												"value");
 801										}
 802									#else
 803										warn("tcp support not compiled in");
 804									#endif
 805									}
 806		| TCP_POLL_METHOD EQUAL error { yyerror("poll method name expected"); }
 807		| TCP_MAX_CONNECTIONS EQUAL NUMBER {
 808									#ifdef USE_TCP
 809										tcp_max_connections=$3;
 810									#else
 811										warn("tcp support not compiled in");
 812									#endif
 813									}
 814		| TCP_MAX_CONNECTIONS EQUAL error { yyerror("number expected"); }
 815		| TCP_OPT_CRLF_PINGPONG EQUAL NUMBER {
 816			#ifdef USE_TCP
 817				tcp_crlf_pingpong=$3;
 818			#else
 819				warn("tcp support not compiled in");
 820			#endif
 821		}
 822		| TCP_OPT_CRLF_PINGPONG EQUAL error { yyerror("boolean value expected"); }
 823		| TCP_NO_NEW_CONN_BFLAG EQUAL NUMBER {
 824			#ifdef USE_TCP
 825				fix_flag_name(&tmp, $3);
 826				tcp_no_new_conn_bflag = get_flag_id_by_name(FLAG_TYPE_BRANCH, tmp);
 827				if (!flag_in_range( (flag_t)tcp_no_new_conn_bflag ) )
 828					yyerror("invalid TCP no_new_conn Branch Flag");
 829				flag_idx2mask( &tcp_no_new_conn_bflag );
 830			#else
 831				warn("tcp support not compiled in");
 832			#endif
 833		}
 834		| TCP_NO_NEW_CONN_BFLAG EQUAL ID {
 835			#ifdef USE_TCP
 836				tcp_no_new_conn_bflag = get_flag_id_by_name(FLAG_TYPE_BRANCH, $3);
 837				if (!flag_in_range( (flag_t)tcp_no_new_conn_bflag ) )
 838					yyerror("invalid TCP no_new_conn Branch Flag");
 839				flag_idx2mask( &tcp_no_new_conn_bflag );
 840			#else
 841				warn("tcp support not compiled in");
 842			#endif
 843		}
 844		| TCP_NO_NEW_CONN_BFLAG EQUAL error { yyerror("number value expected"); }
 845		| TCP_KEEPALIVE EQUAL NUMBER {
 846			#ifdef USE_TCP
 847			        tcp_keepalive=$3;
 848			#else
 849				warn("tcp support not compiled in");
 850			#endif
 851		}
 852		| TCP_KEEPALIVE EQUAL error { yyerror("boolean value expected"); }
 853		| TCP_KEEPCOUNT EQUAL NUMBER 		{ 
 854			#ifdef USE_TCP
 855			    #ifndef HAVE_TCP_KEEPCNT
 856				warn("cannot be enabled (no OS support)");
 857			    #else
 858			        tcp_keepcount=$3;
 859			    #endif
 860		        #else
 861				warn("tcp support not compiled in");
 862			#endif
 863		}
 864		| TCP_KEEPCOUNT EQUAL error { yyerror("int value expected"); }
 865		| TCP_KEEPIDLE EQUAL NUMBER 		{ 
 866			#ifdef USE_TCP
 867			    #ifndef HAVE_TCP_KEEPIDLE
 868				warn("cannot be enabled (no OS support)");
 869			    #else
 870			        tcp_keepidle=$3;
 871			    #endif
 872		        #else
 873				warn("tcp support not compiled in");
 874			#endif
 875		}
 876		| TCP_KEEPIDLE EQUAL error { yyerror("int value expected"); }
 877		| TCP_KEEPINTERVAL EQUAL NUMBER 		{ 
 878			#ifdef USE_TCP
 879			    #ifndef HAVE_TCP_KEEPINTVL
 880				warn("cannot be enabled (no OS support)");
 881			    #else
 882			        tcp_keepinterval=$3;
 883			    #endif
 884		        #else
 885				warn("tcp support not compiled in");
 886			#endif
 887		}
 888		| TCP_KEEPINTERVAL EQUAL error { yyerror("int value expected"); }
 889		| DISABLE_TLS EQUAL NUMBER {
 890									#ifdef USE_TLS
 891										tls_disable=$3;
 892									#else
 893										warn("tls support not compiled in");
 894									#endif
 895									}
 896		| DISABLE_TLS EQUAL error { yyerror("boolean value expected"); }
 897		| TLSLOG EQUAL NUMBER 		{ 
 898									#ifdef USE_TLS
 899										tls_log=$3;
 900									#else
 901										warn("tls support not compiled in");
 902									#endif
 903									}
 904		| TLSLOG EQUAL error { yyerror("int value expected"); }
 905		| TLS_PORT_NO EQUAL NUMBER {
 906									#ifdef USE_TLS
 907										tls_port_no=$3;
 908									#else
 909										warn("tls support not compiled in");
 910									#endif
 911									}
 912		| TLS_PORT_NO EQUAL error { yyerror("number expected"); }
 913		| TLS_METHOD EQUAL SSLv23 {
 914									#ifdef USE_TLS
 915										tls_default_server_domain->method =
 916											TLS_USE_SSLv23;
 917										tls_default_client_domain->method =
 918											TLS_USE_SSLv23;
 919									#else
 920										warn("tls support not compiled in");
 921									#endif
 922									}
 923		| TLS_METHOD EQUAL SSLv2 {
 924									#ifdef USE_TLS
 925										tls_default_server_domain->method =
 926											TLS_USE_SSLv2;
 927										tls_default_client_domain->method =
 928											TLS_USE_SSLv2;
 929									#else
 930										warn("tls support not compiled in");
 931									#endif
 932									}
 933		| TLS_METHOD EQUAL SSLv3 {
 934									#ifdef USE_TLS
 935										tls_default_server_domain->method =
 936											TLS_USE_SSLv3;
 937										tls_default_client_domain->method =
 938											TLS_USE_SSLv3;
 939									#else
 940										warn("tls support not compiled in");
 941									#endif
 942									}
 943		| TLS_METHOD EQUAL TLSv1 {
 944									#ifdef USE_TLS
 945										tls_default_server_domain->method =
 946											TLS_USE_TLSv1;
 947										tls_default_client_domain->method =
 948											TLS_USE_TLSv1;
 949									#else
 950										warn("tls support not compiled in");
 951									#endif
 952									}
 953		| TLS_METHOD EQUAL error {
 954									#ifdef USE_TLS
 955										yyerror("SSLv23, SSLv2, SSLv3 or TLSv1"
 956													" expected");
 957									#else
 958										warn("tls support not compiled in");
 959									#endif
 960									}
 961										
 962		| TLS_VERIFY_CLIENT EQUAL NUMBER {
 963									#ifdef USE_TLS
 964										tls_default_server_domain->verify_cert
 965											= $3;
 966									#else
 967										warn("tls support not compiled in");
 968									#endif
 969									}
 970		| TLS_VERIFY_CLIENT EQUAL error { yyerror("boolean value expected"); }
 971		| TLS_VERIFY_SERVER EQUAL NUMBER {
 972									#ifdef USE_TLS
 973										tls_default_client_domain->verify_cert
 974											=$3;
 975									#else
 976										warn("tls support not compiled in");
 977									#endif
 978									}
 979		| TLS_VERIFY_SERVER EQUAL error { yyerror("boolean value expected"); }
 980		| TLS_REQUIRE_CLIENT_CERTIFICATE EQUAL NUMBER {
 981									#ifdef USE_TLS
 982										tls_default_server_domain->require_client_cert=$3;
 983									#else
 984										warn( "tls support not compiled in");
 985									#endif
 986									}
 987		| TLS_REQUIRE_CLIENT_CERTIFICATE EQUAL error { yyerror("boolean value expected"); }
 988		| TLS_CERTIFICATE EQUAL STRING { 
 989									#ifdef USE_TLS
 990										tls_default_server_domain->cert_file=
 991											$3;
 992										tls_default_client_domain->cert_file=
 993											$3;
 994									#else
 995										warn("tls support not compiled in");
 996									#endif
 997									}
 998		| TLS_CERTIFICATE EQUAL error { yyerror("string value expected"); }
 999		| TLS_PRIVATE_KEY EQUAL STRING { 
1000									#ifdef USE_TLS
1001										tls_default_server_domain->pkey_file=
1002											$3;
1003										tls_default_client_domain->pkey_file=
1004											$3;
1005									#else
1006										warn("tls support not compiled in");
1007									#endif
1008									}
1009		| TLS_PRIVATE_KEY EQUAL error { yyerror("string value expected"); }
1010		| TLS_CA_LIST EQUAL STRING { 
1011									#ifdef USE_TLS
1012										tls_default_server_domain->ca_file =
1013											$3;
1014										tls_default_client_domain->ca_file =
1015											$3;
1016									#else
1017										warn("tls support not compiled in");
1018									#endif
1019									}
1020		| TLS_CA_LIST EQUAL error { yyerror("string value expected"); }
1021		| TLS_CIPHERS_LIST EQUAL STRING { 
1022									#ifdef USE_TLS
1023										tls_default_server_domain->ciphers_list
1024											= $3;
1025										tls_default_client_domain->ciphers_list
1026											= $3;
1027									#else
1028										warn("tls support not compiled in");
1029									#endif
1030									}
1031		| TLS_CIPHERS_LIST EQUAL error { yyerror("string value expected"); }
1032		| TLS_HANDSHAKE_TIMEOUT EQUAL NUMBER {
1033									#ifdef USE_TLS
1034										tls_handshake_timeout=$3;
1035									#else
1036										warn("tls support not compiled in");
1037									#endif
1038									}
1039		| TLS_HANDSHAKE_TIMEOUT EQUAL error { yyerror("number expected"); }
1040		| TLS_SEND_TIMEOUT EQUAL NUMBER {
1041									#ifdef USE_TLS
1042										tls_send_timeout=$3;
1043									#else
1044										warn("tls support not compiled in");
1045									#endif
1046									}
1047		| TLS_SEND_TIMEOUT EQUAL error { yyerror("number expected"); }
1048		| TLS_CLIENT_DOMAIN_AVP EQUAL STRING {
1049									#ifdef USE_TLS
1050										tstr.s = $3;
1051										tstr.len = strlen(tstr.s);
1052										if (parse_avp_spec(&tstr, &tls_client_domain_avp)) {
1053											yyerror("cannot parse tls_client_avp");
1054										}
1055									#else
1056										warn("tls support not compiled in");
1057									#endif
1058									}
1059		| TLS_CLIENT_DOMAIN_AVP EQUAL error { yyerror("number expected"); }
1060		| tls_server_domain_stm
1061		| tls_client_domain_stm
1062		| SERVER_SIGNATURE EQUAL NUMBER { server_signature=$3; }
1063		| SERVER_SIGNATURE EQUAL error { yyerror("boolean value expected"); }
1064		| SERVER_HEADER EQUAL STRING { server_header.s=$3;
1065									server_header.len=strlen($3);
1066									}
1067		| SERVER_HEADER EQUAL error { yyerror("string value expected"); }
1068		| USER_AGENT_HEADER EQUAL STRING { user_agent_header.s=$3;
1069									user_agent_header.len=strlen($3);
1070									}
1071		| USER_AGENT_HEADER EQUAL error { yyerror("string value expected"); }
1072		| XLOG_BUF_SIZE EQUAL NUMBER { xlog_buf_size = $3; }
1073		| XLOG_FORCE_COLOR EQUAL NUMBER { xlog_force_color = $3; } 
1074		| XLOG_BUF_SIZE EQUAL error { yyerror("number expected"); }
1075		| XLOG_FORCE_COLOR EQUAL error { yyerror("boolean value expected"); }
1076			
1077		| LISTEN EQUAL listen_lst {
1078							for(lst_tmp=$3; lst_tmp; lst_tmp=lst_tmp->next){
1079								if (add_listen_iface(	lst_tmp->name,
1080														lst_tmp->port,
1081														lst_tmp->proto,
1082														lst_tmp->adv_name,
1083														lst_tmp->adv_port,
1084														lst_tmp->children,
1085														0
1086													)!=0){
1087									LM_CRIT("cfg. parser: failed"
1088											" to add listen address\n");
1089									break;
1090								}
1091							}
1092							 }
1093		| LISTEN EQUAL  error { yyerror("ip address or hostname "
1094						"expected (use quotes if the hostname includes"
1095						" config keywords)"); }
1096		| ALIAS EQUAL  id_lst { 
1097							for(lst_tmp=$3; lst_tmp; lst_tmp=lst_tmp->next)
1098								add_alias(lst_tmp->name, strlen(lst_tmp->name),
1099											lst_tmp->port, lst_tmp->proto);
1100							  }
1101		| ALIAS  EQUAL error  { yyerror("hostname expected (use quotes"
1102							" if the hostname includes config keywords)"); }
1103		| AUTO_ALIASES EQUAL NUMBER { auto_aliases=$3; }
1104		| AUTO_ALIASES EQUAL error  { yyerror("number  expected"); }
1105		| ADVERTISED_ADDRESS EQUAL listen_id {
1106								if ($3) {
1107									default_global_address.s=$3;
1108									default_global_address.len=strlen($3);
1109								}
1110								}
1111		|ADVERTISED_ADDRESS EQUAL error {yyerror("ip address or hostname "
1112												"expected"); }
1113		| ADVERTISED_PORT EQUAL NUMBER {
1114								tmp=int2str($3, &i_tmp);
1115								if ((default_global_port.s=pkg_malloc(i_tmp))
1116										==0){
1117										LM_CRIT("cfg. parser: out of memory.\n");
1118										default_global_port.len=0;
1119								}else{
1120									default_global_port.len=i_tmp;
1121									memcpy(default_global_port.s, tmp,
1122											default_global_port.len);
1123								};
1124								}
1125		|ADVERTISED_PORT EQUAL error {yyerror("ip address or hostname "
1126												"expected"); }
1127		| DISABLE_CORE EQUAL NUMBER {
1128										disable_core_dump=$3;
1129									}
1130		| DISABLE_CORE EQUAL error { yyerror("boolean value expected"); }
1131		| OPEN_FD_LIMIT EQUAL NUMBER {
1132										open_files_limit=$3;
1133									}
1134		| OPEN_FD_LIMIT EQUAL error { yyerror("number expected"); }
1135		| MCAST_LOOPBACK EQUAL NUMBER {
1136								#ifdef USE_MCAST
1137										mcast_loopback=$3;
1138								#else
1139									warn("no multicast support compiled in");
1140								#endif
1141		  }
1142		| MCAST_LOOPBACK EQUAL error { yyerror("boolean value expected"); }
1143		| MCAST_TTL EQUAL NUMBER {
1144								#ifdef USE_MCAST
1145										mcast_ttl=$3;
1146								#else
1147									warn("no multicast support compiled in");
1148								#endif
1149		  }
1150		| MCAST_TTL EQUAL error { yyerror("number expected as tos"); }
1151		| TOS EQUAL NUMBER { tos = $3;
1152							if (tos<=0)
1153								yyerror("invalid tos value");
1154		 }
1155		| TOS EQUAL ID { if (strcasecmp($3,"IPTOS_LOWDELAY")) {
1156								tos=IPTOS_LOWDELAY;
1157							} else if (strcasecmp($3,"IPTOS_THROUGHPUT")) {
1158								tos=IPTOS_THROUGHPUT;
1159							} else if (strcasecmp($3,"IPTOS_RELIABILITY")) {
1160								tos=IPTOS_RELIABILITY;
1161#if defined(IPTOS_MINCOST)
1162							} else if (strcasecmp($3,"IPTOS_MINCOST")) {
1163								tos=IPTOS_MINCOST;
1164#endif
1165#if defined(IPTOS_LOWCOST)
1166							} else if (strcasecmp($3,"IPTOS_LOWCOST")) {
1167								tos=IPTOS_LOWCOST;
1168#endif
1169							} else {
1170								yyerror("invalid tos value - allowed: "
1171									"IPTOS_LOWDELAY,IPTOS_THROUGHPUT,"
1172									"IPTOS_RELIABILITY"
1173#if defined(IPTOS_LOWCOST)
1174									",IPTOS_LOWCOST"
1175#endif
1176#if defined(IPTOS_MINCOST)
1177									",IPTOS_MINCOST"
1178#endif
1179									"\n");
1180							}
1181		 }
1182		| TOS EQUAL error { yyerror("number expected"); }
1183		| MPATH EQUAL STRING { mpath=$3; strcpy(mpath_buf, $3);
1184								mpath_len=strlen($3); 
1185								if(mpath_buf[mpath_len-1]!='/') {
1186									mpath_buf[mpath_len]='/';
1187									mpath_len++;
1188									mpath_buf[mpath_len]='\0';
1189								}
1190							}
1191		| MPATH EQUAL error  { yyerror("string value expected"); }
1192		| DISABLE_DNS_FAILOVER EQUAL NUMBER {
1193										disable_dns_failover=$3;
1194									}
1195		| DISABLE_DNS_FAILOVER error { yyerror("boolean value expected"); }
1196		| DISABLE_DNS_BLACKLIST EQUAL NUMBER {
1197										disable_dns_blacklist=$3;
1198									}
1199		| DISABLE_DNS_BLACKLIST error { yyerror("boolean value expected"); }
1200		| DST_BLACKLIST EQUAL ID COLON LBRACE blst_elem_list RBRACE {
1201				s_tmp.s = $3;
1202				s_tmp.len = strlen($3);
1203				if ( create_bl_head( BL_CORE_ID, BL_READONLY_LIST,
1204				bl_head, bl_tail, &s_tmp)==0) {
1205					yyerror("failed to create blacklist\n");
1206					YYABORT;
1207				}
1208				bl_head = bl_tail = 0;
1209				}
1210		| DISABLE_STATELESS_FWD EQUAL NUMBER {
1211				sl_fwd_disabled=$3;
1212				}
1213		| DB_VERSION_TABLE EQUAL STRING { db_version_table=$3; }
1214		| DB_VERSION_TABLE EQUAL error { yyerror("string value expected"); }
1215		| DB_DEFAULT_URL EQUAL STRING { db_default_url=$3; }
1216		| DB_DEFAULT_URL EQUAL error { yyerror("string value expected"); }
1217		| DISABLE_503_TRANSLATION EQUAL NUMBER { disable_503_translation=$3; }
1218		| DISABLE_503_TRANSLATION EQUAL error {
1219				yyerror("string value expected");
1220				}
1221		| error EQUAL { yyerror("unknown config variable"); }
1222	;
1223
1224module_stm:	LOADMODULE STRING	{
1225			if(*$2!='/' && mpath!=NULL
1226					&& strlen($2)+mpath_len<255)
1227			{
1228				strcpy(mpath_buf+mpath_len, $2);
1229				if (stat(mpath_buf, &statf) == -1) {
1230					i_tmp = strlen(mpath_buf);
1231					if(strchr($2, '/')==NULL &&
1232							strncmp(mpath_buf+i_tmp-3, ".so", 3)==0)
1233					{
1234						if(i_tmp+strlen($2)<255)
1235						{
1236							strcpy(mpath_buf+i_tmp-3, "/");
1237							strcpy(mpath_buf+i_tmp-2, $2);
1238							if (stat(mpath_buf, &statf) == -1) {
1239								mpath_buf[mpath_len]='\0';
1240								LM_ERR("module '%s' not found in '%s'\n",
1241									$2, mpath_buf);
1242								yyerror("failed to load module");
1243							}
1244						} else {
1245							yyerror("failed to load module - path too long");
1246						}
1247					} else {
1248						yyerror("failed to load module - not found");
1249					}
1250				}
1251				LM_DBG("loading module %s\n", mpath_buf);
1252				if (sr_load_module(mpath_buf)!=0){
1253					yyerror("failed to load module");
1254				}
1255				mpath_buf[mpath_len]='\0';
1256			} else {
1257				LM_DBG("loading module %s\n", $2);
1258				if (sr_load_module($2)!=0){
1259					yyerror("failed to load module");
1260				}
1261			}
1262		}
1263		| LOADMODULE error	{ yyerror("string expected");  }
1264		| MODPARAM LPAREN STRING COMMA STRING COMMA STRING RPAREN {
1265				if (set_mod_param_regex($3, $5, STR_PARAM, $7) != 0) {
1266					yyerrorf("Parameter <%s> not found in module <%s> - can't set",
1267						$5, $3);
1268				}
1269			}
1270		| MODPARAM LPAREN STRING COMMA STRING COMMA snumber RPAREN {
1271				if (set_mod_param_regex($3, $5, INT_PARAM, (void*)$7) != 0) {
1272					yyerrorf("Parameter <%s> not found in module <%s> - can't set",
1273						$5, $3);
1274				}
1275			}
1276		| MODPARAM error { yyerror("Invalid arguments"); }
1277		;
1278
1279
1280ip:		 ipv4  { $$=$1; }
1281		|ipv6  { $$=$1; }
1282		;
1283
1284ipv4:	NUMBER DOT NUMBER DOT NUMBER DOT NUMBER { 
1285											$$=pkg_malloc(
1286													sizeof(struct ip_addr));
1287											if ($$==0){
1288												LM_CRIT("cfg. "
1289													"parser: out of memory.\n"
1290													);
1291											}else{
1292												memset($$, 0, 
1293													sizeof(struct ip_addr));
1294												$$->af=AF_INET;
1295												$$->len=4;
1296												if (($1>255) || ($1<0) ||
1297													($3>255) || ($3<0) ||
1298													($5>255) || ($5<0) ||
1299													($7>255) || ($7<0)){
1300													yyerror("invalid ipv4"
1301															"address");
1302													$$->u.addr32[0]=0;
1303													/* $$=0; */
1304												}else{
1305													$$->u.addr[0]=$1;
1306													$$->u.addr[1]=$3;
1307													$$->u.addr[2]=$5;
1308													$$->u.addr[3]=$7;
1309													/*
1310													$$=htonl( ($1<<24)|
1311													($3<<16)| ($5<<8)|$7 );
1312													*/
1313												}
1314											}
1315												}
1316	;
1317
1318ipv6addr:	IPV6ADDR {
1319					$$=pkg_malloc(sizeof(struct ip_addr));
1320					if ($$==0){
1321						LM_CRIT("ERROR: cfg. parser: out of memory.\n");
1322					}else{
1323						memset($$, 0, sizeof(struct ip_addr));
1324						$$->af=AF_INET6;
1325						$$->len=16;
1326					#ifdef USE_IPV6
1327						if (inet_pton(AF_INET6, $1, $$->u.addr)<=0){
1328							yyerror("bad ipv6 address");
1329						}
1330					#else
1331						yyerror("ipv6 address & no ipv6 support compiled in");
1332						YYABORT;
1333					#endif
1334					}
1335				}
1336	;
1337
1338ipv6:	ipv6addr { $$=$1; }
1339	| LBRACK ipv6addr RBRACK {$$=$2; }
1340;
1341
1342tls_server_domain_stm : TLS_SERVER_DOMAIN LBRACK ip COLON port RBRACK { 
1343						#ifdef USE_TLS
1344							if (tls_new_server_domain($3, $5)) 
1345								yyerror("tls_new_server_domain failed");
1346						#else	
1347							warn("tls support not compiled in");
1348						#endif
1349							}
1350	         LBRACE tls_server_decls RBRACE
1351;
1352
1353tls_client_domain_stm : TLS_CLIENT_DOMAIN LBRACK ip COLON port RBRACK { 
1354						#ifdef USE_TLS
1355							if (tls_new_client_domain($3, $5))
1356								yyerror("tls_new_client_domain failed");
1357						#else	
1358							warn("tls support not compiled in");
1359						#endif
1360							}
1361	         LBRACE tls_client_decls RBRACE
1362;
1363
1364tls_client_domain_stm : TLS_CLIENT_DOMAIN LBRACK STRING RBRACK { 
1365						#ifdef USE_TLS
1366							if (tls_new_client_domain_name($3, strlen($3)))
1367								yyerror("tls_new_client_domain_name failed");
1368						#else	
1369							warn("tls support not compiled in");
1370						#endif
1371							}
1372	         LBRACE tls_client_decls RBRACE
1373;
1374
1375tls_server_decls : tls_server_var
1376          | tls_server_decls tls_server_var
1377;
1378
1379tls_client_decls : tls_client_var
1380          | tls_client_decls tls_client_var
1381;
1382	
1383tls_server_var : TLS_METHOD EQUAL SSLv23 { 
1384						#ifdef USE_TLS
1385									tls_server_domains->method=TLS_USE_SSLv23;
1386						#else
1387									warn("tls support not compiled in");
1388						#endif
1389								}
1390	| TLS_METHOD EQUAL SSLv2 { 
1391						#ifdef USE_TLS
1392									tls_server_domains->method=TLS_USE_SSLv2;
1393						#else
1394									warn("tls support not compiled in");
1395						#endif
1396								}
1397	| TLS_METHOD EQUAL SSLv3 { 
1398						#ifdef USE_TLS
1399									tls_server_domains->method=TLS_USE_SSLv3;
1400						#else
1401									warn("tls support not compiled in");
1402						#endif
1403								}
1404	| TLS_METHOD EQUAL TLSv1 { 
1405						#ifdef USE_TLS
1406									tls_server_domains->method=TLS_USE_TLSv1;
1407						#else
1408									warn("tls support not compiled in");
1409						#endif
1410								}
1411	| TLS_METHOD EQUAL error { yyerror("SSLv23, SSLv2, SSLv3 or TLSv1 expected"); }
1412	| TLS_CERTIFICATE EQUAL STRING { 
1413						#ifdef USE_TLS
1414									tls_server_domains->cert_file=$3;
1415						#else
1416									warn("tls support not compiled in");
1417						#endif
1418								}
1419	| TLS_CERTIFICATE EQUAL error { yyerror("string value expected"); }
1420
1421	| TLS_PRIVATE_KEY EQUAL STRING { 
1422						#ifdef USE_TLS
1423									tls_server_domains->pkey_file=$3;
1424						#else
1425									warn("tls support not compiled in");
1426						#endif
1427								}
1428	| TLS_PRIVATE_KEY EQUAL error { yyerror("string value expected"); }
1429
1430	| TLS_CA_LIST EQUAL STRING { 
1431						#ifdef USE_TLS
1432									tls_server_domains->ca_file=$3; 
1433						#else
1434									warn("tls support not compiled in");
1435						#endif
1436								}	
1437	| TLS_CA_LIST EQUAL error { yyerror("string value expected"); }
1438	| TLS_CIPHERS_LIST EQUAL STRING { 
1439						#ifdef USE_TLS
1440									tls_server_domains->ciphers_list=$3;
1441						#else
1442									warn("tls support not compiled in");
1443						#endif
1444								}
1445	| TLS_CIPHERS_LIST EQUAL error { yyerror("string value expected"); }
1446	| TLS_VERIFY_CLIENT EQUAL NUMBER {
1447						#ifdef USE_TLS
1448									tls_server_domains->verify_cert=$3;
1449						#else
1450									warn("tls support not compiled in");
1451						#endif
1452								}
1453	| TLS_VERIFY_CLIENT EQUAL error { yyerror("boolean value expected"); }
1454	| TLS_REQUIRE_CLIENT_CERTIFICATE EQUAL NUMBER {
1455						#ifdef USE_TLS
1456									tls_server_domains->require_client_cert=$3;
1457						#else
1458									warn( "tls support not compiled in");
1459						#endif
1460								}
1461	| TLS_REQUIRE_CLIENT_CERTIFICATE EQUAL error { 
1462						yyerror("boolean value expected"); }
1463;
1464
1465tls_client_var : TLS_METHOD EQUAL SSLv23 { 
1466						#ifdef USE_TLS
1467									tls_client_domains->method=TLS_USE_SSLv23;
1468						#else
1469									warn("tls support not compiled in");
1470						#endif
1471								}
1472	| TLS_METHOD EQUAL SSLv2 { 
1473						#ifdef USE_TLS
1474									tls_client_domains->method=TLS_USE_SSLv2;
1475						#else
1476									warn("tls support not compiled in");
1477						#endif
1478								}
1479	| TLS_METHOD EQUAL SSLv3 { 
1480						#ifdef USE_TLS
1481									tls_client_domains->method=TLS_USE_SSLv3;
1482						#else
1483									warn("tls support not compiled in");
1484						#endif
1485								}
1486	| TLS_METHOD EQUAL TLSv1 { 
1487						#ifdef USE_TLS
1488									tls_client_domains->method=TLS_USE_TLSv1;
1489						#else
1490									warn("tls support not compiled in");
1491						#endif
1492								}
1493	| TLS_METHOD EQUAL error {
1494						yyerror("SSLv23, SSLv2, SSLv3 or TLSv1 expected"); }
1495	| TLS_CERTIFICATE EQUAL STRING { 
1496						#ifdef USE_TLS
1497									tls_client_domains->cert_file=$3;
1498						#else
1499									warn("tls support not compiled in");
1500						#endif
1501								}
1502	| TLS_CERTIFICATE EQUAL error { yyerror("string value expected"); }
1503
1504	| TLS_PRIVATE_KEY EQUAL STRING { 
1505						#ifdef USE_TLS
1506									tls_client_domains->pkey_file=$3;
1507						#else
1508									warn("tls support not compiled in");
1509						#endif
1510								}
1511	| TLS_PRIVATE_KEY EQUAL error { yyerror("string value expected"); }
1512
1513	| TLS_CA_LIST EQUAL STRING { 
1514						#ifdef USE_TLS
1515									tls_client_domains->ca_file=$3; 
1516						#else
1517									warn("tls support not compiled in");
1518						#endif
1519								}	
1520	| TLS_CA_LIST EQUAL error { yyerror("string value expected"); }
1521	| TLS_CIPHERS_LIST EQUAL STRING { 
1522						#ifdef USE_TLS
1523									tls_client_domains->ciphers_list=$3;
1524						#else
1525									warn("tls support not compiled in");
1526						#endif
1527								}
1528	| TLS_CIPHERS_LIST EQUAL error { yyerror("string value expected"); }
1529	| TLS_VERIFY_SERVER EQUAL NUMBER {
1530						#ifdef USE_TLS
1531									tls_client_domains->verify_cert=$3;
1532						#else
1533									warn("tls support not compiled in");
1534						#endif
1535								}
1536	| TLS_VERIFY_SERVER EQUAL error { yyerror("boolean value expected"); }
1537;
1538
1539route_name:  ID {
1540				$$ = $1;
1541				}
1542		| NUMBER {
1543				tmp=int2str($1, &i_tmp);
1544				if (($$=pkg_malloc(i_tmp+1))==0)
1545					yyerror("cfg. parser: out of memory.\n");
1546				memcpy( $$, tmp, i_tmp);
1547				$$[i_tmp] = 0;
1548				}
1549		|STRING {
1550				$$ = $1;
1551		}
1552;
1553
1554route_stm:  ROUTE LBRACE actions RBRACE {
1555						if (rlist[DEFAULT_RT].a!=0) {
1556							yyerror("overwritting default "
1557								"request routing table");
1558							YYABORT;
1559						}
1560						push($3, &rlist[DEFAULT_RT].a);
1561					}
1562		| ROUTE LBRACK route_name RBRACK LBRACE actions RBRACE { 
1563						if ( strtol($3,&tmp,10)==0 && *tmp==0) {
1564							/* route[0] detected */
1565							if (rlist[DEFAULT_RT].a!=0) {
1566								yyerror("overwritting(2) default "
1567									"request routing table");
1568								YYABORT;
1569							}
1570							push($6, &rlist[DEFAULT_RT].a);
1571						} else {
1572							i_tmp = get_script_route_idx($3,rlist,RT_NO,1);
1573							if (i_tmp==-1) YYABORT;
1574							push($6, &rlist[i_tmp].a);
1575						}
1576					}
1577		| ROUTE error { yyerror("invalid  route  statement"); }
1578	;
1579
1580failure_route_stm: ROUTE_FAILURE LBRACK route_name RBRACK LBRACE actions RBRACE {
1581						i_tmp = get_script_route_idx($3,failure_rlist,
1582								FAILURE_RT_NO,1);
1583						if (i_tmp==-1) YYABORT;
1584						push($6, &failure_rlist[i_tmp].a);
1585					}
1586		| ROUTE_FAILURE error { yyerror("invalid failure_route statement"); }
1587	;
1588
1589onreply_route_stm: ROUTE_ONREPLY LBRACE actions RBRACE {
1590						if (onreply_rlist[DEFAULT_RT].a!=0) {
1591							yyerror("overwritting default "
1592								"onreply routing table");
1593							YYABORT;
1594						}
1595						push($3, &onreply_rlist[DEFAULT_RT].a);
1596					}
1597		| ROUTE_ONREPLY LBRACK route_name RBRACK LBRACE actions RBRACE {
1598						i_tmp = get_script_route_idx($3,onreply_rlist,
1599								ONREPLY_RT_NO,1);
1600						if (i_tmp==-1) YYABORT;
1601						push($6, &onreply_rlist[i_tmp].a);
1602					}
1603		| ROUTE_ONREPLY error { yyerror("invalid onreply_route statement"); }
1604	;
1605
1606branch_route_stm: ROUTE_BRANCH LBRACK route_name RBRACK LBRACE actions RBRACE {
1607						i_tmp = get_script_route_idx($3,branch_rlist,
1608								BRANCH_RT_NO,1);
1609						if (i_tmp==-1) YYABORT;
1610						push($6, &branch_rlist[i_tmp].a);
1611					}
1612		| ROUTE_BRANCH error { yyerror("invalid branch_route statement"); }
1613	;
1614
1615error_route_stm:  ROUTE_ERROR LBRACE actions RBRACE {
1616						if (error_rlist.a!=0) {
1617							yyerror("overwritting default "
1618								"error routing table");
1619							YYABORT;
1620						}
1621						push($3, &error_rlist.a);
1622					}
1623		| ROUTE_ERROR error { yyerror("invalid error_route statement"); }
1624	;
1625
1626local_route_stm:  ROUTE_LOCAL LBRACE actions RBRACE {
1627						if (local_rlist.a!=0) {
1628							yyerror("re-definition of local "
1629								"route detected");
1630							YYABORT;
1631						}
1632						push($3, &local_rlist.a);
1633					}
1634		| ROUTE_LOCAL error { yyerror("invalid local_route statement"); }
1635	;
1636
1637startup_route_stm:  ROUTE_STARTUP LBRACE actions RBRACE {
1638						if (startup_rlist.a!=0) {
1639							yyerror("re-definition of startup "
1640								"route detected");
1641							YYABORT;
1642						}
1643						push($3, &startup_rlist.a);
1644					}
1645		| ROUTE_STARTUP error { yyerror("invalid startup_route statement"); }
1646	;
1647
1648timer_route_stm:  ROUTE_TIMER LBRACK route_name COMMA NUMBER RBRACK LBRACE actions RBRACE {
1649						i_tmp = 0;
1650						while (timer_rlist[i_tmp].a!=0 && i_tmp < TIMER_RT_NO) {
1651							i_tmp++;
1652						}
1653						if(i_tmp == TIMER_RT_NO) {
1654							yyerror("Too many timer routes defined\n");
1655							YYABORT;
1656						}
1657						timer_rlist[i_tmp].interval = $5;
1658						push($8, &timer_rlist[i_tmp].a);
1659					}
1660		| ROUTE_TIMER error { yyerror("invalid timer_route statement"); }
1661	;
1662
1663event_route_stm: ROUTE_EVENT LBRACK route_name RBRACK LBRACE actions RBRACE {
1664						i_tmp = get_script_route_idx($3,event_rlist,
1665								EVENT_RT_NO,1);
1666						if (i_tmp==-1) YYABORT;
1667						push($6, &event_rlist[i_tmp].a);
1668					}
1669		| ROUTE_EVENT error { yyerror("invalid timer_route statement"); }
1670	;
1671
1672
1673
1674exp:	exp AND exp 	{ $$=mk_exp(AND_OP, $1, $3); }
1675	| exp OR  exp		{ $$=mk_exp(OR_OP, $1, $3);  }
1676	| NOT exp 			{ $$=mk_exp(NOT_OP, $2, 0);  }
1677	| LPAREN exp RPAREN	{ $$=mk_exp(EVAL_OP, $2, 0); }
1678	| LBRACK assignexp RBRACK { $$=$2; }
1679	| exp_elem			{ $$=$1; }
1680	;
1681
1682equalop:	  EQUAL_T {$$=EQUAL_OP; }
1683			| DIFF	{$$=DIFF_OP; }
1684		;
1685
1686compop:	GT	{$$=GT_OP; }
1687		| LT	{$$=LT_OP; }
1688		| GTE	{$$=GTE_OP; }
1689		| LTE	{$$=LTE_OP; }
1690	;		
1691matchop: MATCH	{$$=MATCH_OP; }
1692		| NOTMATCH	{$$=NOTMATCH_OP; }
1693	;
1694
1695intop:	equalop	{$$=$1; }
1696	 | compop	{$$=$1; }
1697	;
1698		
1699strop:	equalop	{$$=$1; }
1700	    | compop {$$=$1; }
1701		| matchop	{$$=$1; }
1702	;
1703
1704uri_type:	URI			{$$=URI_O;}
1705		|	FROM_URI	{$$=FROM_URI_O;}
1706		|	TO_URI		{$$=TO_URI_O;}
1707		;
1708
1709script_var:	SCRIPTVAR	{ 
1710				spec = (pv_spec_t*)pkg_malloc(sizeof(pv_spec_t));
1711				if (spec==NULL){
1712					yyerror("no more pkg memory\n");
1713				}
1714				memset(spec, 0, sizeof(pv_spec_t));
1715				tstr.s = $1;
1716				tstr.len = strlen(tstr.s);
1717				if(pv_parse_spec(&tstr, spec)==NULL)
1718				{
1719					yyerror("unknown script variable");
1720				}
1721				$$ = spec;
1722			}
1723		| SCRIPTVARERR {
1724			$$=0; yyerror("invalid script variable name");
1725		}
1726		;
1727
1728exp_elem: exp_cond		{$$=$1; }
1729		| exp_stm		{$$=mk_elem( NO_OP, ACTION_O, 0, ACTIONS_ST, $1 ); }
1730		| snumber		{$$=mk_elem( NO_OP, NUMBER_O, 0, NUMBER_ST, 
1731											(void*)$1 ); }
1732		| script_var    {
1733				$$=…

Large files files are truncated, but you can click here to view the full file