PageRenderTime 65ms CodeModel.GetById 25ms RepoModel.GetById 0ms app.codeStats 1ms

/cfg.y

https://bitbucket.org/Gradwell/opensips-clone
Happy | 2907 lines | 2763 code | 144 blank | 0 comment | 0 complexity | 1021c82047faf411fb86499de8ab5949 MD5 | raw file
Possible License(s): AGPL-1.0

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

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