forked from OpenSIPS/opensips
-
Notifications
You must be signed in to change notification settings - Fork 1
/
cfg.y
2761 lines (2606 loc) · 81.5 KB
/
cfg.y
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
* cfg grammar
*
* Copyright (C) 2001-2003 FhG Fokus
* Copyright (C) 2005-2009 Voice Sistem S.R.L.
* Copyright (C) 2006 enum.at
*
* This file is part of opensips, a free SIP server.
*
* opensips is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version
*
* opensips is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
* History:
* ---------
* 2003-01-29 src_port added (jiri)
* 2003-01-23 mhomed added (jiri)
* 2003-03-19 replaced all mallocs/frees with pkg_malloc/pkg_free (andrei)
* 2003-03-19 Added support for route type in find_export (janakj)
* 2003-03-20 Regex support in modparam (janakj)
* 2003-04-01 added dst_port, proto , af (andrei)
* 2003-04-05 s/reply_route/failure_route, onreply_route introduced (jiri)
* 2003-04-12 added force_rport, chroot and wdir (andrei)
* 2003-04-15 added tcp_children, disable_tcp (andrei)
* 2003-04-22 strip_tail added (jiri)
* 2003-07-03 tls* (disable, certificate, private_key, ca_list, verify,
* require_certificate added (andrei)
* 2003-07-06 more tls config. vars added: tls_method, tls_port_no (andrei)
* 2003-10-02 added {,set_}advertised_{address,port} (andrei)
* 2003-10-10 added <,>,<=,>=, != operators support
* added msg:len (andrei)
* 2003-10-11 if(){} doesn't require a ';' after it anymore (andrei)
* 2003-10-13 added FIFO_DIR & proto:host:port listen/alias support (andrei)
* 2003-10-24 converted to the new socket_info lists (andrei)
* 2003-10-28 added tcp_accept_aliases (andrei)
* 2003-11-20 added {tcp_connect, tcp_send, tls_*}_timeout (andrei)
* 2004-03-30 added DISABLE_CORE and OPEN_FD_LIMIT (andrei)
* 2004-04-29 added SOCK_MODE, SOCK_USER & SOCK_GROUP (andrei)
* 2004-05-03 applied multicast support patch (MCAST_LOOPBACK) from janakj
added MCAST_TTL (andrei)
* 2004-07-05 src_ip & dst_ip will detect ip addresses between quotes
* (andrei)
* 2004-10-19 added FROM_URI, TO_URI (andrei)
* 2004-11-30 added force_send_socket (andrei)
* 2005-07-08 added TCP_CON_LIFETIME, TCP_POLL_METHOD, TCP_MAX_CONNECTIONS
* (andrei)
* 2005-07-26 default onreply route added (andrei)
* 2005-11-22 added tos configurability (thanks to Andreas Granig)
* 2005-11-29 added serialize_branches and next_branches (bogdan)
* 2006-03-02 MODULE_T action points to a cmd_export_t struct instead to
* a function address - more info is accessible (bogdan)
* 2006-03-02 store the cfg line into the action struct to be able to
* give more hints if fixups fail (bogdan)
* 2006-05-22 forward(_udp,_tcp,_tls) and send(_tcp) merged in forward() and
* send() (bogdan)
* 2006-12-22 functions for script and branch flags added (bogdan)
* 2007-01-11 auto_aliases option added (bogdan)
* 2007-01-25 disable_dns_failover option added (bogdan)
* 2012-01-19 added TCP keepalive support
* 2012-12-06 added event_route (razvanc)
* 2013-05-23 added NAPTR lookup option (dsandras)
* 2013-09-25 added TLS_CA_DIR option (chris_secusmart)
* 2013-10-06 added TLS_DH_PARAM option (mehmet_secusmart)
* 2013-10-30 added TLS_EC_CURVE option (yrjoe_secusmart)
*/
%{
#include <stdlib.h>
#include <stdio.h>
#include <sys/socket.h>
#include <unistd.h>
#include <netinet/in.h>
#include <netinet/in_systm.h>
#include <netinet/ip.h>
#include <arpa/inet.h>
#include <string.h>
#include <errno.h>
#include "route_struct.h"
#include "globals.h"
#include "route.h"
#include "dprint.h"
#include "sr_module.h"
#include "modparam.h"
#include "ip_addr.h"
#include "resolve.h"
#include "socket_info.h"
#include "name_alias.h"
#include "ut.h"
#include "dset.h"
#include "pvar.h"
#include "blacklists.h"
#include "xlog.h"
#include "db/db_insertq.h"
#include "bin_interface.h"
#include "net/trans.h"
#include "config.h"
#ifdef SHM_EXTRA_STATS
#include "mem/module_info.h"
#endif
#ifdef DEBUG_DMALLOC
#include <dmalloc.h>
#endif
/* hack to avoid alloca usage in the generated C file (needed for compiler
with no built in alloca, like icc*/
#undef _ALLOCA_H
extern int yylex();
static void yyerror(char* s);
static void yyerrorf(char* fmt, ...);
static char* tmp;
static int i_tmp, rc;
static void* cmd_tmp;
static struct socket_id* lst_tmp;
static int rt; /* Type of route block for find_export */
static str s_tmp;
static str tstr;
static struct ip_addr* ip_tmp;
static pv_spec_t *spec;
static pv_elem_t *pvmodel;
static struct bl_rule *bl_head = 0;
static struct bl_rule *bl_tail = 0;
action_elem_t elems[MAX_ACTION_ELEMS];
static action_elem_t route_elems[MAX_ACTION_ELEMS];
action_elem_t *a_tmp;
static inline void warn(char* s);
static struct socket_id* mk_listen_id(char*, enum sip_protos, int);
static struct socket_id* set_listen_id_adv(struct socket_id *, char *, int);
static struct multi_str *new_string(char *s);
extern int line;
extern int column;
extern int startcolumn;
extern char *finame;
#ifndef SHM_EXTRA_STATS
struct multi_str{
char *s;
struct multi_str* next;
};
#else
static struct multi_str *tmp_mod;
#endif
#define get_cfg_file_name \
((finame) ? finame : cfg_file ? cfg_file : "default")
#define mk_action_(_res, _type, _no, _elems) \
do { \
_res = mk_action(_type, _no, _elems, line, get_cfg_file_name); \
} while(0)
#define mk_action0(_res, _type, _p1_type, _p2_type, _p1, _p2) \
do { \
_res = mk_action(_type, 0, 0, line, get_cfg_file_name); \
} while(0)
#define mk_action1(_res, _type, _p1_type, _p1) \
do { \
elems[0].type = _p1_type; \
elems[0].u.data = _p1; \
_res = mk_action(_type, 1, elems, line, get_cfg_file_name); \
} while(0)
#define mk_action2(_res, _type, _p1_type, _p2_type, _p1, _p2) \
do { \
elems[0].type = _p1_type; \
elems[0].u.data = _p1; \
elems[1].type = _p2_type; \
elems[1].u.data = _p2; \
_res = mk_action(_type, 2, elems, line, get_cfg_file_name); \
} while(0)
#define mk_action3(_res, _type, _p1_type, _p2_type, _p3_type, _p1, _p2, _p3) \
do { \
elems[0].type = _p1_type; \
elems[0].u.data = _p1; \
elems[1].type = _p2_type; \
elems[1].u.data = _p2; \
elems[2].type = _p3_type; \
elems[2].u.data = _p3; \
_res = mk_action(_type, 3, elems, line, get_cfg_file_name); \
} while(0)
%}
%union {
long intval;
unsigned long uval;
char* strval;
struct expr* expr;
struct action* action;
struct net* ipnet;
struct ip_addr* ipaddr;
struct socket_id* sockid;
struct _pv_spec *specval;
struct multi_str* multistr;
}
/* terminals */
/* keywords */
%token FORWARD
%token SEND
%token DROP
%token ASSERT
%token EXIT
%token RETURN
%token LOG_TOK
%token ERROR
%token ROUTE
%token ROUTE_FAILURE
%token ROUTE_ONREPLY
%token ROUTE_BRANCH
%token ROUTE_ERROR
%token ROUTE_LOCAL
%token ROUTE_STARTUP
%token ROUTE_TIMER
%token ROUTE_EVENT
%token SET_HOST
%token SET_HOSTPORT
%token PREFIX
%token STRIP
%token STRIP_TAIL
%token APPEND_BRANCH
%token REMOVE_BRANCH
%token PV_PRINTF
%token SET_USER
%token SET_USERPASS
%token SET_PORT
%token SET_URI
%token REVERT_URI
%token SET_DSTURI
%token RESET_DSTURI
%token ISDSTURISET
%token FORCE_RPORT
%token FORCE_LOCAL_RPORT
%token FORCE_TCP_ALIAS
%token IF
%token ELSE
%token SWITCH
%token CASE
%token DEFAULT
%token SBREAK
%token WHILE
%token FOR
%token IN
%token SET_ADV_ADDRESS
%token SET_ADV_PORT
%token FORCE_SEND_SOCKET
%token SERIALIZE_BRANCHES
%token NEXT_BRANCHES
%token USE_BLACKLIST
%token UNUSE_BLACKLIST
%token MAX_LEN
%token SETFLAG
%token RESETFLAG
%token ISFLAGSET
%token SETBFLAG
%token RESETBFLAG
%token ISBFLAGSET
%token METHOD
%token URI
%token FROM_URI
%token TO_URI
%token SRCIP
%token SRCPORT
%token DSTIP
%token DSTPORT
%token PROTO
%token AF
%token MYSELF
%token MSGLEN
%token NULLV
%token CACHE_STORE
%token CACHE_FETCH
%token CACHE_COUNTER_FETCH
%token CACHE_REMOVE
%token CACHE_ADD
%token CACHE_SUB
%token CACHE_RAW_QUERY
%token XDBG
%token XLOG
%token XLOG_BUF_SIZE
%token XLOG_FORCE_COLOR
%token XLOG_DEFAULT_LEVEL
%token RAISE_EVENT
%token SUBSCRIBE_EVENT
%token CONSTRUCT_URI
%token GET_TIMESTAMP
%token SCRIPT_TRACE
/* config vars. */
%token FORK
%token DEBUG_MODE
%token DEBUG
%token ENABLE_ASSERTS
%token ABORT_ON_ASSERT
%token LOGLEVEL
%token LOGSTDERROR
%token LOGFACILITY
%token LOGNAME
%token AVP_ALIASES
%token LISTEN
%token MEMGROUP
%token ALIAS
%token AUTO_ALIASES
%token DNS
%token REV_DNS
%token DNS_TRY_IPV6
%token DNS_TRY_NAPTR
%token DNS_RETR_TIME
%token DNS_RETR_NO
%token DNS_SERVERS_NO
%token DNS_USE_SEARCH
%token MAX_WHILE_LOOPS
%token CHILDREN
%token CHECK_VIA
%token SHM_HASH_SPLIT_PERCENTAGE
%token SHM_SECONDARY_HASH_SIZE
%token MEM_WARMING_ENABLED
%token MEM_WARMING_PATTERN_FILE
%token MEM_WARMING_PERCENTAGE
%token MEMLOG
%token MEMDUMP
%token EXECMSGTHRESHOLD
%token EXECDNSTHRESHOLD
%token TCPTHRESHOLD
%token EVENT_SHM_THRESHOLD
%token EVENT_PKG_THRESHOLD
%token QUERYBUFFERSIZE
%token QUERYFLUSHTIME
%token SIP_WARNING
%token SOCK_MODE
%token SOCK_USER
%token SOCK_GROUP
%token UNIX_SOCK
%token UNIX_SOCK_CHILDREN
%token UNIX_TX_TIMEOUT
%token SERVER_SIGNATURE
%token SERVER_HEADER
%token USER_AGENT_HEADER
%token LOADMODULE
%token MPATH
%token MODPARAM
%token MAXBUFFER
%token CHROOT
%token WDIR
%token MHOMED
%token POLL_METHOD
%token TCP_ACCEPT_ALIASES
%token TCP_CHILDREN
%token TCP_CONNECT_TIMEOUT
%token TCP_CON_LIFETIME
%token TCP_LISTEN_BACKLOG
%token TCP_MAX_CONNECTIONS
%token TCP_NO_NEW_CONN_BFLAG
%token TCP_KEEPALIVE
%token TCP_KEEPCOUNT
%token TCP_KEEPIDLE
%token TCP_KEEPINTERVAL
%token TCP_MAX_MSG_TIME
%token ADVERTISED_ADDRESS
%token ADVERTISED_PORT
%token DISABLE_CORE
%token OPEN_FD_LIMIT
%token MCAST_LOOPBACK
%token MCAST_TTL
%token TOS
%token DISABLE_DNS_FAILOVER
%token DISABLE_DNS_BLACKLIST
%token DST_BLACKLIST
%token DISABLE_STATELESS_FWD
%token DB_VERSION_TABLE
%token DB_DEFAULT_URL
%token DB_MAX_ASYNC_CONNECTIONS
%token DISABLE_503_TRANSLATION
%token SYNC_TOKEN
%token ASYNC_TOKEN
/* operators */
%nonassoc EQUAL
%nonassoc EQUAL_T
%nonassoc GT
%nonassoc LT
%nonassoc GTE
%nonassoc LTE
%nonassoc DIFF
%nonassoc MATCH
%nonassoc NOTMATCH
%nonassoc COLONEQ
%nonassoc PLUSEQ
%nonassoc MINUSEQ
%nonassoc SLASHEQ
%nonassoc MULTEQ
%nonassoc MODULOEQ
%nonassoc BANDEQ
%nonassoc BOREQ
%nonassoc BXOREQ
%left OR AND
%left BOR BAND BXOR BLSHIFT BRSHIFT
%left PLUS MINUS SLASH MULT MODULO
%right NOT BNOT
/* values */
%token <intval> NUMBER
%token <intval> ZERO
%token <strval> ID
%token <strval> STRING
%token <strval> SCRIPTVAR
%token <strval> IPV6ADDR
/* other */
%token COMMA
%token SEMICOLON
%token RPAREN
%token LPAREN
%token LBRACE
%token RBRACE
%token LBRACK
%token RBRACK
%token SLASH
%token AS
%token USE_CHILDREN
%token DOT
%token CR
%token COLON
%token ANY
%token SCRIPTVARERR
/*non-terminals */
%type <expr> exp exp_elem exp_cond assignexp /*, condition*/
%type <action> action actions cmd if_cmd stm exp_stm assign_cmd while_cmd
foreach_cmd async_func
%type <action> switch_cmd switch_stm case_stms case_stm default_stm
%type <intval> module_func_param
%type <ipaddr> ipv4 ipv6 ipv6addr ip
%type <ipnet> ipnet
%type <specval> script_var
%type <strval> host
%type <strval> listen_id
%type <sockid> listen_def
%type <sockid> id_lst
%type <sockid> alias_def
%type <sockid> phostport
%type <intval> proto port any_proto
%type <strval> host_sep
%type <intval> uri_type
%type <intval> equalop compop matchop strop intop
%type <intval> assignop
%type <intval> snumber
%type <strval> route_name
%type <intval> route_param
%type <strval> folded_string
%type <multistr> multi_string
/*
* since "if_cmd" is inherently ambiguous,
* skip 1 harmless shift/reduce conflict when compiling our grammar
*/
%expect 1
%%
cfg: statements
;
statements: statements statement {}
| statement {}
| statements error { yyerror(""); YYABORT;}
;
statement: assign_stm
| module_stm
| {rt=REQUEST_ROUTE;} route_stm
| {rt=FAILURE_ROUTE;} failure_route_stm
| {rt=ONREPLY_ROUTE;} onreply_route_stm
| {rt=BRANCH_ROUTE;} branch_route_stm
| {rt=ERROR_ROUTE;} error_route_stm
| {rt=LOCAL_ROUTE;} local_route_stm
| {rt=STARTUP_ROUTE;} startup_route_stm
| {rt=TIMER_ROUTE;} timer_route_stm
| {rt=EVENT_ROUTE;} event_route_stm
| CR /* null statement*/
;
listen_id: ip { tmp=ip_addr2a($1);
if(tmp==0){
LM_CRIT("cfg. parser: bad ip address.\n");
$$=0;
}else{
$$=pkg_malloc(strlen(tmp)+1);
if ($$==0){
LM_CRIT("cfg. parser: out of memory.\n");
YYABORT;
}else{
strncpy($$, tmp, strlen(tmp)+1);
}
}
}
| STRING { $$=pkg_malloc(strlen($1)+1);
if ($$==0){
LM_CRIT("cfg. parser: out of memory.\n");
YYABORT;
}else{
strncpy($$, $1, strlen($1)+1);
}
}
| host { if ($1==0) {
$$ = 0;
} else {
$$=pkg_malloc(strlen($1)+1);
if ($$==0){
LM_CRIT("cfg. parser: out of memory.\n");
YYABORT;
}else{
strncpy($$, $1, strlen($1)+1);
}
}
}
;
proto: ID {
if (parse_proto((unsigned char *)$1, strlen($1), &i_tmp) < 0) {
yyerrorf("cannot handle protocol <%s>\n", $1);
YYABORT;
}
$$ = i_tmp;
}
;
port: NUMBER { $$=$1; }
| ANY { $$=0; }
;
snumber: NUMBER { $$=$1; }
| PLUS NUMBER { $$=$2; }
| MINUS NUMBER { $$=-$2; }
;
phostport: proto COLON listen_id { $$=mk_listen_id($3, $1, 0); }
| proto COLON listen_id COLON port { $$=mk_listen_id($3, $1, $5);}
| proto COLON listen_id COLON error {
$$=0;
yyerror(" port number expected");
}
;
alias_def: listen_id { $$=mk_listen_id($1, PROTO_NONE, 0); }
| ANY COLON listen_id { $$=mk_listen_id($3, PROTO_NONE, 0); }
| ANY COLON listen_id COLON port { $$=mk_listen_id($3, PROTO_NONE, $5); }
| ANY COLON listen_id COLON error {
$$=0;
yyerror(" port number expected");
}
| phostport
;
id_lst: alias_def { $$=$1 ; }
| alias_def id_lst { $$=$1; $$->next=$2; }
;
listen_def: phostport { $$=$1; }
| phostport USE_CHILDREN NUMBER { $$=$1; $$->children=$3; }
| phostport AS listen_id {
$$=$1; set_listen_id_adv((struct socket_id *)$1, $3, 5060);
}
| phostport AS listen_id USE_CHILDREN NUMBER {
$$=$1; set_listen_id_adv((struct socket_id *)$1, $3, 5060);
$1->children=$5;
}
| phostport AS listen_id COLON port{
$$=$1; set_listen_id_adv((struct socket_id *)$1, $3, $5);
}
| phostport AS listen_id COLON port USE_CHILDREN NUMBER {
$$=$1; set_listen_id_adv((struct socket_id *)$1, $3, $5);
$1->children=$7;
}
;
any_proto: ANY { $$=PROTO_NONE; }
| proto { $$=$1; }
multi_string: STRING { $$=new_string($1); }
| STRING multi_string { $$=new_string($1); $$->next=$2; }
;
blst_elem: LPAREN any_proto COMMA ipnet COMMA port COMMA STRING RPAREN {
s_tmp.s=$8;
s_tmp.len=strlen($8);
if (add_rule_to_list(&bl_head,&bl_tail,$4,&s_tmp,$6,$2,0)) {
yyerror("failed to add backlist element\n");YYABORT;
}
}
| NOT LPAREN any_proto COMMA ipnet COMMA port COMMA STRING RPAREN {
s_tmp.s=$9;
s_tmp.len=strlen($9);
if (add_rule_to_list(&bl_head,&bl_tail,$5,&s_tmp,
$7,$3,BLR_APPLY_CONTRARY)) {
yyerror("failed to add backlist element\n");YYABORT;
}
}
;
blst_elem_list: blst_elem_list COMMA blst_elem {}
| blst_elem {}
| blst_elem_list error { yyerror("bad black list element");}
;
assign_stm: DEBUG EQUAL snumber
{ yyerror("\'debug\' is deprecated, use \'log_level\' instead\n");}
| FORK EQUAL NUMBER
{yyerror("fork is deprecated, use debug_mode\n");}
| LOGLEVEL EQUAL snumber {
/* in debug mode, force logging to DEBUG level*/
*log_level = debug_mode?L_DBG:$3;
}
| ENABLE_ASSERTS EQUAL NUMBER { enable_asserts=$3; }
| ENABLE_ASSERTS EQUAL error { yyerror("boolean value expected"); }
| ABORT_ON_ASSERT EQUAL NUMBER { abort_on_assert=$3; }
| ABORT_ON_ASSERT EQUAL error { yyerror("boolean value expected"); }
| DEBUG_MODE EQUAL NUMBER { debug_mode=$3;
if (debug_mode) { *log_level = L_DBG;log_stderr=1;}
}
| DEBUG_MODE EQUAL error
{ yyerror("boolean value expected for debug_mode"); }
| LOGSTDERROR EQUAL NUMBER
/* in config-check or debug mode we force logging
* to standard error */
{ if (!config_check && !debug_mode) log_stderr=$3; }
| LOGSTDERROR EQUAL error { yyerror("boolean value expected"); }
| LOGFACILITY EQUAL ID {
if ( (i_tmp=str2facility($3))==-1)
yyerror("bad facility (see syslog(3) man page)");
if (!config_check)
log_facility=i_tmp;
}
| LOGFACILITY EQUAL error { yyerror("ID expected"); }
| LOGNAME EQUAL STRING { log_name=$3; }
| LOGNAME EQUAL error { yyerror("string value expected"); }
| DNS EQUAL NUMBER { received_dns|= ($3)?DO_DNS:0; }
| DNS EQUAL error { yyerror("boolean value expected"); }
| REV_DNS EQUAL NUMBER { received_dns|= ($3)?DO_REV_DNS:0; }
| REV_DNS EQUAL error { yyerror("boolean value expected"); }
| DNS_TRY_IPV6 EQUAL NUMBER { dns_try_ipv6=$3; }
| DNS_TRY_IPV6 error { yyerror("boolean value expected"); }
| DNS_TRY_NAPTR EQUAL NUMBER { dns_try_naptr=$3; }
| DNS_TRY_NAPTR error { yyerror("boolean value expected"); }
| DNS_RETR_TIME EQUAL NUMBER { dns_retr_time=$3; }
| DNS_RETR_TIME error { yyerror("number expected"); }
| DNS_RETR_NO EQUAL NUMBER { dns_retr_no=$3; }
| DNS_RETR_NO error { yyerror("number expected"); }
| DNS_SERVERS_NO EQUAL NUMBER { dns_servers_no=$3; }
| DNS_SERVERS_NO error { yyerror("number expected"); }
| DNS_USE_SEARCH EQUAL NUMBER { dns_search_list=$3; }
| DNS_USE_SEARCH error { yyerror("boolean value expected"); }
| MAX_WHILE_LOOPS EQUAL NUMBER { max_while_loops=$3; }
| MAX_WHILE_LOOPS EQUAL error { yyerror("number expected"); }
| MAXBUFFER EQUAL NUMBER { maxbuffer=$3; }
| MAXBUFFER EQUAL error { yyerror("number expected"); }
| CHILDREN EQUAL NUMBER { children_no=$3; }
| CHILDREN EQUAL error { yyerror("number expected"); }
| CHECK_VIA EQUAL NUMBER { check_via=$3; }
| CHECK_VIA EQUAL error { yyerror("boolean value expected"); }
| SHM_HASH_SPLIT_PERCENTAGE EQUAL NUMBER {
#ifdef HP_MALLOC
shm_hash_split_percentage=$3;
#else
yyerror("Cannot set parameter; Please recompile with support "
"for HP_MALLOC");
#endif
}
| SHM_HASH_SPLIT_PERCENTAGE EQUAL error { yyerror("number expected"); }
| SHM_SECONDARY_HASH_SIZE EQUAL NUMBER {
#ifdef HP_MALLOC
shm_secondary_hash_size=$3;
#else
yyerror("Cannot set parameter; Please recompile with support"
" for HP_MALLOC");
#endif
}
| SHM_SECONDARY_HASH_SIZE EQUAL error { yyerror("number expected"); }
| MEM_WARMING_ENABLED EQUAL NUMBER {
#ifdef HP_MALLOC
mem_warming_enabled = $3;
#else
yyerror("Cannot set parameter; Please recompile with support"
" for HP_MALLOC");
#endif
}
| MEM_WARMING_ENABLED EQUAL error { yyerror("number expected"); }
| MEM_WARMING_PATTERN_FILE EQUAL STRING {
#ifdef HP_MALLOC
mem_warming_pattern_file = $3;
#else
yyerror("Cannot set parameter; Please recompile with "
"support for HP_MALLOC");
#endif
}
| MEM_WARMING_PATTERN_FILE EQUAL error { yyerror("string expected"); }
| MEM_WARMING_PERCENTAGE EQUAL NUMBER {
#ifdef HP_MALLOC
mem_warming_percentage = $3;
#else
yyerror("Cannot set parameter; Please recompile with "
"support for HP_MALLOC");
#endif
}
| MEM_WARMING_PERCENTAGE EQUAL error { yyerror("number expected"); }
| MEMLOG EQUAL snumber { memlog=$3; memdump=$3; }
| MEMLOG EQUAL error { yyerror("int value expected"); }
| MEMDUMP EQUAL snumber { memdump=$3; }
| MEMDUMP EQUAL error { yyerror("int value expected"); }
| EXECMSGTHRESHOLD EQUAL NUMBER { execmsgthreshold=$3; }
| EXECMSGTHRESHOLD EQUAL error { yyerror("int value expected"); }
| EXECDNSTHRESHOLD EQUAL NUMBER { execdnsthreshold=$3; }
| EXECDNSTHRESHOLD EQUAL error { yyerror("int value expected"); }
| TCPTHRESHOLD EQUAL NUMBER { tcpthreshold=$3; }
| TCPTHRESHOLD EQUAL error { yyerror("int value expected"); }
| EVENT_SHM_THRESHOLD EQUAL NUMBER {
#ifdef STATISTICS
if ($3 < 0 || $3 > 100)
yyerror("SHM threshold has to be a percentage between"
" 0 and 100");
event_shm_threshold=$3;
#else
yyerror("statistics support not compiled in");
#endif /* STATISTICS */
}
| EVENT_SHM_THRESHOLD EQUAL error { yyerror("int value expected"); }
| EVENT_PKG_THRESHOLD EQUAL NUMBER {
#ifdef STATISTICS
#ifdef USE_SHM_MEM
warn("No PKG memory, all allocations are mapped to SHM; "
"Use event_shm_threshold instead or recompile with PKG_MALLOC "
"instead of USE_SHM_MEM in order to have separate PKG memory");
#else
if ($3 < 0 || $3 > 100)
yyerror("PKG threshold has to be a percentage between "
"0 and 100");
event_pkg_threshold=$3;
#endif
#else
yyerror("statistics support not compiled in");
#endif
}
| EVENT_PKG_THRESHOLD EQUAL error { yyerror("int value expected"); }
| QUERYBUFFERSIZE EQUAL NUMBER { query_buffer_size=$3; }
| QUERYBUFFERSIZE EQUAL error { yyerror("int value expected"); }
| QUERYFLUSHTIME EQUAL NUMBER { query_flush_time=$3; }
| QUERYFLUSHTIME EQUAL error { yyerror("int value expected"); }
| SIP_WARNING EQUAL NUMBER { sip_warning=$3; }
| SIP_WARNING EQUAL error { yyerror("boolean value expected"); }
| CHROOT EQUAL STRING { chroot_dir=$3; }
| CHROOT EQUAL ID { chroot_dir=$3; }
| CHROOT EQUAL error { yyerror("string value expected"); }
| WDIR EQUAL STRING { working_dir=$3; }
| WDIR EQUAL ID { working_dir=$3; }
| WDIR EQUAL error { yyerror("string value expected"); }
| MHOMED EQUAL NUMBER { mhomed=$3; }
| MHOMED EQUAL error { yyerror("boolean value expected"); }
| POLL_METHOD EQUAL ID {
io_poll_method=get_poll_type($3);
if (io_poll_method==POLL_NONE){
LM_CRIT("bad poll method name:"
" %s\n, try one of %s.\n",
$3, poll_support);
yyerror("bad poll_method "
"value");
}
}
| POLL_METHOD EQUAL STRING {
io_poll_method=get_poll_type($3);
if (io_poll_method==POLL_NONE){
LM_CRIT("bad poll method name:"
" %s\n, try one of %s.\n",
$3, poll_support);
yyerror("bad poll_method "
"value");
}
}
| POLL_METHOD EQUAL error { yyerror("poll method name expected"); }
| TCP_ACCEPT_ALIASES EQUAL NUMBER {
tcp_accept_aliases=$3;
}
| TCP_ACCEPT_ALIASES EQUAL error { yyerror("boolean value expected"); }
| TCP_CHILDREN EQUAL NUMBER {
tcp_children_no=$3;
}
| TCP_CHILDREN EQUAL error { yyerror("number expected"); }
| TCP_CONNECT_TIMEOUT EQUAL NUMBER {
tcp_connect_timeout=$3;
}
| TCP_CONNECT_TIMEOUT EQUAL error { yyerror("number expected"); }
| TCP_CON_LIFETIME EQUAL NUMBER {
tcp_con_lifetime=$3;
}
| TCP_CON_LIFETIME EQUAL error { yyerror("number expected"); }
| TCP_LISTEN_BACKLOG EQUAL NUMBER {
tcp_listen_backlog=$3;
}
| TCP_LISTEN_BACKLOG EQUAL error { yyerror("number expected"); }
| TCP_MAX_CONNECTIONS EQUAL NUMBER {
tcp_max_connections=$3;
}
| TCP_MAX_CONNECTIONS EQUAL error { yyerror("number expected"); }
| TCP_NO_NEW_CONN_BFLAG EQUAL NUMBER {
tmp = NULL;
fix_flag_name(tmp, $3);
tcp_no_new_conn_bflag =
get_flag_id_by_name(FLAG_TYPE_BRANCH, tmp);
if (!flag_in_range( (flag_t)tcp_no_new_conn_bflag ) )
yyerror("invalid TCP no_new_conn Branch Flag");
flag_idx2mask( &tcp_no_new_conn_bflag );
}
| TCP_NO_NEW_CONN_BFLAG EQUAL ID {
tcp_no_new_conn_bflag =
get_flag_id_by_name(FLAG_TYPE_BRANCH, $3);
if (!flag_in_range( (flag_t)tcp_no_new_conn_bflag ) )
yyerror("invalid TCP no_new_conn Branch Flag");
flag_idx2mask( &tcp_no_new_conn_bflag );
}
| TCP_NO_NEW_CONN_BFLAG EQUAL error { yyerror("number value expected"); }
| TCP_KEEPALIVE EQUAL NUMBER {
tcp_keepalive=$3;
}
| TCP_KEEPALIVE EQUAL error { yyerror("boolean value expected"); }
| TCP_MAX_MSG_TIME EQUAL NUMBER {
tcp_max_msg_time=$3;
}
| TCP_MAX_MSG_TIME EQUAL error { yyerror("boolean value expected"); }
| TCP_KEEPCOUNT EQUAL NUMBER {
#ifndef HAVE_TCP_KEEPCNT
warn("cannot be enabled TCP_KEEPCOUNT (no OS support)");
#else
tcp_keepcount=$3;
#endif
}
| TCP_KEEPCOUNT EQUAL error { yyerror("int value expected"); }
| TCP_KEEPIDLE EQUAL NUMBER {
#ifndef HAVE_TCP_KEEPIDLE
warn("cannot be enabled TCP_KEEPIDLE (no OS support)");
#else
tcp_keepidle=$3;
#endif
}
| TCP_KEEPIDLE EQUAL error { yyerror("int value expected"); }
| TCP_KEEPINTERVAL EQUAL NUMBER {
#ifndef HAVE_TCP_KEEPINTVL
warn("cannot be enabled TCP_KEEPINTERVAL (no OS support)");
#else
tcp_keepinterval=$3;
#endif
}
| TCP_KEEPINTERVAL EQUAL error { yyerror("int value expected"); }
| SERVER_SIGNATURE EQUAL NUMBER { server_signature=$3; }
| SERVER_SIGNATURE EQUAL error { yyerror("boolean value expected"); }
| SERVER_HEADER EQUAL STRING { server_header.s=$3;
server_header.len=strlen($3);
}
| SERVER_HEADER EQUAL error { yyerror("string value expected"); }
| USER_AGENT_HEADER EQUAL STRING { user_agent_header.s=$3;
user_agent_header.len=strlen($3);
}
| USER_AGENT_HEADER EQUAL error { yyerror("string value expected"); }
| XLOG_BUF_SIZE EQUAL NUMBER { xlog_buf_size = $3; }
| XLOG_FORCE_COLOR EQUAL NUMBER { xlog_force_color = $3; }
| XLOG_DEFAULT_LEVEL EQUAL NUMBER { xlog_default_level = $3; }
| XLOG_BUF_SIZE EQUAL error { yyerror("number expected"); }
| XLOG_FORCE_COLOR EQUAL error { yyerror("boolean value expected"); }
| XLOG_DEFAULT_LEVEL EQUAL error { yyerror("number expected"); }
| LISTEN EQUAL listen_def {
if (add_listener($3, 0)!=0){
LM_CRIT("cfg. parser: failed"
" to add listen address\n");
break;
}
}
| LISTEN EQUAL error { yyerror("ip address or hostname "
"expected (use quotes if the hostname includes"
" config keywords)"); }
| MEMGROUP EQUAL STRING COLON multi_string {
/* convert STIRNG ($3) to an ID */
/* update the memstats type for each module */
#ifndef SHM_EXTRA_STATS
LM_CRIT("SHM_EXTRA_STATS not defined");
YYABORT;
#else
#ifdef SHM_SHOW_DEFAULT_GROUP
if(strcmp($3, "default") == 0){
LM_CRIT("default group name is not allowed");
YYABORT;
}
#endif
for(tmp_mod = mod_names; tmp_mod; tmp_mod=tmp_mod->next){
if(strcmp($3, tmp_mod->s) == 0){
LM_CRIT("The same mem-group name is used twice: [%s] [%s]\n", $3, tmp_mod->s);
YYABORT;
}
}
tmp_mod = pkg_malloc(sizeof(struct multi_str));
if(!tmp_mod){
LM_CRIT("out of pkg memory");
YYABORT;
}
tmp_mod->s = $3;
tmp_mod->next = mod_names;
mod_names = tmp_mod;
for (tmp_mod = $5; tmp_mod; tmp_mod = tmp_mod->next){
if(set_mem_idx(tmp_mod->s, mem_free_idx)){
YYABORT;
}
}
mem_free_idx++;
#endif
}
| MEMGROUP EQUAL STRING COLON error { yyerror("invalid or no module specified"); }
| ALIAS EQUAL id_lst {
for(lst_tmp=$3; lst_tmp; lst_tmp=lst_tmp->next)
add_alias(lst_tmp->name, strlen(lst_tmp->name),
lst_tmp->port, lst_tmp->proto);
}
| ALIAS EQUAL error { yyerror("hostname expected (use quotes"
" if the hostname includes config keywords)"); }
| AUTO_ALIASES EQUAL NUMBER { auto_aliases=$3; }
| AUTO_ALIASES EQUAL error { yyerror("number expected"); }
| ADVERTISED_ADDRESS EQUAL listen_id {
if ($3) {
default_global_address.s=$3;
default_global_address.len=strlen($3);
}
}
| ADVERTISED_ADDRESS EQUAL error {yyerror("ip address or hostname "
"expected"); }
| ADVERTISED_PORT EQUAL NUMBER {
tmp = int2str($3, &i_tmp);
if (i_tmp > default_global_port.len)
default_global_port.s =
pkg_realloc(default_global_port.s, i_tmp);
if (!default_global_port.s) {
LM_CRIT("cfg. parser: out of memory.\n");
YYABORT;
} else {
default_global_port.len = i_tmp;
memcpy(default_global_port.s, tmp,
default_global_port.len);
}
}
|ADVERTISED_PORT EQUAL error {yyerror("ip address or hostname "
"expected"); }
| DISABLE_CORE EQUAL NUMBER {
disable_core_dump=$3;
}
| DISABLE_CORE EQUAL error { yyerror("boolean value expected"); }
| OPEN_FD_LIMIT EQUAL NUMBER {
open_files_limit=$3;
}
| OPEN_FD_LIMIT EQUAL error { yyerror("number expected"); }
| MCAST_LOOPBACK EQUAL NUMBER {
#ifdef USE_MCAST
mcast_loopback=$3;
#else
warn("no multicast support compiled in");
#endif
}
| MCAST_LOOPBACK EQUAL error { yyerror("boolean value expected"); }
| MCAST_TTL EQUAL NUMBER {