forked from kamailio/kamailio
-
Notifications
You must be signed in to change notification settings - Fork 1
/
cfg.y
3832 lines (3652 loc) · 108 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
*
* This file is part of Kamailio, a free SIP server.
*
* Kamailio is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version
*
* For a license to use the ser software under conditions
* other than those described here, or to purchase support for this
* software, please contact iptel.org by e-mail at the following addresses:
*
* Kamailio 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
*/
%expect 6
%{
#include <stdlib.h>
#include <stdio.h>
#include <stdarg.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netinet/ip.h>
#include <arpa/inet.h>
#include <string.h>
#include <errno.h>
#include "route_struct.h"
#include "globals.h"
#ifdef SHM_MEM
#include "shm_init.h"
#endif /* SHM_MEM */
#include "route.h"
#include "switch.h"
#include "dprint.h"
#include "sr_module.h"
#include "modparam.h"
#include "ip_addr.h"
#include "resolve.h"
#include "socket_info.h"
#include "name_alias.h"
#include "ut.h"
#include "dset.h"
#include "select.h"
#include "flags.h"
#include "tcp_init.h"
#include "tcp_options.h"
#include "sctp_core.h"
#include "pvar.h"
#include "lvalue.h"
#include "rvalue.h"
#include "sr_compat.h"
#include "msg_translator.h"
#include "async_task.h"
#include "ppcfg.h"
#include "pvapi.h"
#include "config.h"
#include "cfg_core.h"
#include "cfg/cfg.h"
#ifdef CORE_TLS
#include "tls/tls_config.h"
#endif
#include "timer_ticks.h"
#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
#define onsend_check(s) \
do{\
if (rt!=ONSEND_ROUTE) yyerror( s " allowed only in onsend_routes");\
}while(0)
#define IF_AUTO_BIND_IPV6(x) x
#ifdef USE_DNS_CACHE
#define IF_DNS_CACHE(x) x
#else
#define IF_DNS_CACHE(x) warn("dns cache support not compiled in")
#endif
#ifdef USE_DNS_FAILOVER
#define IF_DNS_FAILOVER(x) x
#else
#define IF_DNS_FAILOVER(x) warn("dns failover support not compiled in")
#endif
#ifdef USE_NAPTR
#define IF_NAPTR(x) x
#else
#define IF_NAPTR(x) warn("dns naptr support not compiled in")
#endif
#ifdef USE_DST_BLACKLIST
#define IF_DST_BLACKLIST(x) x
#else
#define IF_DST_BLACKLIST(x) warn("dst blacklist support not compiled in")
#endif
#ifdef USE_SCTP
#define IF_SCTP(x) x
#else
#define IF_SCTP(x) warn("sctp support not compiled in")
#endif
#ifdef USE_RAW_SOCKS
#define IF_RAW_SOCKS(x) x
#else
#define IF_RAW_SOCKS(x) warn("raw socket support not compiled in")
#endif
extern int yylex();
/* safer then using yytext which can be array or pointer */
extern char* yy_number_str;
static void yyerror(char* s, ...);
static void yyerror_at(struct cfg_pos* pos, char* s, ...);
static char* tmp;
static int i_tmp;
static unsigned u_tmp;
static struct socket_id* lst_tmp;
static struct name_lst* nl_tmp;
static int rt; /* Type of route block for find_export */
static str* str_tmp;
static str s_tmp;
static struct ip_addr* ip_tmp;
static struct avp_spec* s_attr;
static select_t sel;
static select_t* sel_ptr;
static pv_spec_t* pv_spec;
static struct action *mod_func_action;
static struct lvalue* lval_tmp;
static struct rvalue* rval_tmp;
static void warn(char* s, ...);
static void warn_at(struct cfg_pos* pos, char* s, ...);
static void get_cpos(struct cfg_pos* pos);
static struct rval_expr* mk_rve_rval(enum rval_type, void* v);
static struct rval_expr* mk_rve1(enum rval_expr_op op, struct rval_expr* rve1);
static struct rval_expr* mk_rve2(enum rval_expr_op op, struct rval_expr* rve1,
struct rval_expr* rve2);
static int rval_expr_int_check(struct rval_expr *rve);
static int warn_ct_rve(struct rval_expr *rve, char* name);
static struct socket_id* mk_listen_id(char*, int, int);
static struct name_lst* mk_name_lst(char* name, int flags);
static struct socket_id* mk_listen_id2(struct name_lst*, int, int);
static void free_name_lst(struct name_lst* lst);
static void free_socket_id_lst(struct socket_id* i);
static struct case_stms* mk_case_stm(struct rval_expr* ct, int is_re,
struct action* a, int* err);
static int case_check_type(struct case_stms* stms);
static int case_check_default(struct case_stms* stms);
static int mod_f_params_pre_fixup(struct action* a);
static void free_mod_func_action(struct action* a);
extern int line;
extern int column;
extern int startcolumn;
extern int startline;
extern char *finame;
extern char *routename;
extern char *default_routename;
#define set_cfg_pos(x) \
do{\
if(x) {\
(x)->cline = line;\
(x)->cfile = (finame!=0)?finame:((cfg_file!=0)?cfg_file:"default");\
(x)->rname = (routename!=0)?routename:((default_routename!=0)?default_routename:"DEFAULT");\
}\
}while(0)
%}
%union {
long intval;
unsigned long uval;
char* strval;
struct expr* expr;
struct action* action;
struct case_stms* case_stms;
struct net* ipnet;
struct ip_addr* ipaddr;
struct socket_id* sockid;
struct name_lst* name_l;
struct avp_spec* attr;
struct _pv_spec* pvar;
struct lvalue* lval;
struct rvalue* rval;
struct rval_expr* rv_expr;
select_t* select;
}
/* terminals */
/* keywords */
%token FORWARD
%token FORWARD_TCP
%token FORWARD_TLS
%token FORWARD_SCTP
%token FORWARD_UDP
%token EXIT
%token DROP
%token RETURN
%token BREAK
%token LOG_TOK
%token ERROR
%token ROUTE
%token ROUTE_REQUEST
%token ROUTE_FAILURE
%token ROUTE_ONREPLY
%token ROUTE_REPLY
%token ROUTE_BRANCH
%token ROUTE_SEND
%token ROUTE_EVENT
%token EXEC
%token SET_HOST
%token SET_HOSTPORT
%token SET_HOSTPORTTRANS
%token PREFIX
%token STRIP
%token STRIP_TAIL
%token SET_USERPHONE
%token APPEND_BRANCH
%token REMOVE_BRANCH
%token CLEAR_BRANCHES
%token SET_USER
%token SET_USERPASS
%token SET_PORT
%token SET_URI
%token REVERT_URI
%token FORCE_RPORT
%token ADD_LOCAL_RPORT
%token FORCE_TCP_ALIAS
%token UDP_MTU
%token UDP_MTU_TRY_PROTO
%token UDP4_RAW
%token UDP4_RAW_MTU
%token UDP4_RAW_TTL
%token IF
%token ELSE
%token SET_ADV_ADDRESS
%token SET_ADV_PORT
%token FORCE_SEND_SOCKET
%token SET_FWD_NO_CONNECT
%token SET_RPL_NO_CONNECT
%token SET_FWD_CLOSE
%token SET_RPL_CLOSE
%token SWITCH
%token CASE
%token DEFAULT
%token WHILE
%token CFG_SELECT
%token CFG_RESET
%token URIHOST
%token URIPORT
%token MAX_LEN
%token SETFLAG
%token RESETFLAG
%token ISFLAGSET
%token SETAVPFLAG
%token RESETAVPFLAG
%token ISAVPFLAGSET
%token METHOD
%token URI
%token FROM_URI
%token TO_URI
%token SRCIP
%token SRCPORT
%token DSTIP
%token DSTPORT
%token TOIP
%token TOPORT
%token SNDIP
%token SNDPORT
%token SNDPROTO
%token SNDAF
%token PROTO
%token AF
%token MYSELF
%token MSGLEN
%token UDP
%token TCP
%token TLS
%token SCTP
%token WS
%token WSS
/* config vars. */
%token DEBUG_V
%token FORK
%token FORK_DELAY
%token MODINIT_DELAY
%token LOGSTDERROR
%token LOGFACILITY
%token LOGNAME
%token LOGCOLOR
%token LOGPREFIX
%token LOGENGINETYPE
%token LOGENGINEDATA
%token LISTEN
%token ADVERTISE
%token ALIAS
%token SR_AUTO_ALIASES
%token DNS
%token REV_DNS
%token DNS_TRY_IPV6
%token DNS_TRY_NAPTR
%token DNS_SRV_LB
%token DNS_UDP_PREF
%token DNS_TCP_PREF
%token DNS_TLS_PREF
%token DNS_SCTP_PREF
%token DNS_RETR_TIME
%token DNS_RETR_NO
%token DNS_SERVERS_NO
%token DNS_USE_SEARCH
%token DNS_SEARCH_FMATCH
%token DNS_NAPTR_IGNORE_RFC
%token DNS_CACHE_INIT
%token DNS_USE_CACHE
%token DNS_USE_FAILOVER
%token DNS_CACHE_FLAGS
%token DNS_CACHE_NEG_TTL
%token DNS_CACHE_MIN_TTL
%token DNS_CACHE_MAX_TTL
%token DNS_CACHE_MEM
%token DNS_CACHE_GC_INT
%token DNS_CACHE_DEL_NONEXP
%token DNS_CACHE_REC_PREF
/* ipv6 auto bind */
%token AUTO_BIND_IPV6
/*blacklist*/
%token DST_BLST_INIT
%token USE_DST_BLST
%token DST_BLST_MEM
%token DST_BLST_TTL
%token DST_BLST_GC_INT
%token DST_BLST_UDP_IMASK
%token DST_BLST_TCP_IMASK
%token DST_BLST_TLS_IMASK
%token DST_BLST_SCTP_IMASK
%token PORT
%token STAT
%token CHILDREN
%token SOCKET_WORKERS
%token ASYNC_WORKERS
%token ASYNC_USLEEP
%token CHECK_VIA
%token PHONE2TEL
%token MEMLOG
%token MEMDBG
%token MEMSUM
%token MEMSAFETY
%token MEMJOIN
%token CORELOG
%token SIP_WARNING
%token SERVER_SIGNATURE
%token SERVER_HEADER
%token USER_AGENT_HEADER
%token REPLY_TO_VIA
%token LOADMODULE
%token LOADPATH
%token MODPARAM
%token MAXBUFFER
%token SQL_BUFFER_SIZE
%token USER
%token GROUP
%token CHROOT
%token WDIR
%token RUNDIR
%token MHOMED
%token DISABLE_TCP
%token TCP_ACCEPT_ALIASES
%token TCP_CHILDREN
%token TCP_CONNECT_TIMEOUT
%token TCP_SEND_TIMEOUT
%token TCP_CON_LIFETIME
%token TCP_POLL_METHOD
%token TCP_MAX_CONNECTIONS
%token TLS_MAX_CONNECTIONS
%token TCP_NO_CONNECT
%token TCP_SOURCE_IPV4
%token TCP_SOURCE_IPV6
%token TCP_OPT_FD_CACHE
%token TCP_OPT_BUF_WRITE
%token TCP_OPT_CONN_WQ_MAX
%token TCP_OPT_WQ_MAX
%token TCP_OPT_RD_BUF
%token TCP_OPT_WQ_BLK
%token TCP_OPT_DEFER_ACCEPT
%token TCP_OPT_DELAYED_ACK
%token TCP_OPT_SYNCNT
%token TCP_OPT_LINGER2
%token TCP_OPT_KEEPALIVE
%token TCP_OPT_KEEPIDLE
%token TCP_OPT_KEEPINTVL
%token TCP_OPT_KEEPCNT
%token TCP_OPT_CRLF_PING
%token TCP_OPT_ACCEPT_NO_CL
%token TCP_CLONE_RCVBUF
%token DISABLE_TLS
%token ENABLE_TLS
%token TLSLOG
%token TLS_PORT_NO
%token TLS_METHOD
%token TLS_HANDSHAKE_TIMEOUT
%token TLS_SEND_TIMEOUT
%token SSLv23
%token SSLv2
%token SSLv3
%token TLSv1
%token TLS_VERIFY
%token TLS_REQUIRE_CERTIFICATE
%token TLS_CERTIFICATE
%token TLS_PRIVATE_KEY
%token TLS_CA_LIST
%token DISABLE_SCTP
%token ENABLE_SCTP
%token SCTP_CHILDREN
%token ADVERTISED_ADDRESS
%token ADVERTISED_PORT
%token DISABLE_CORE
%token OPEN_FD_LIMIT
%token SHM_MEM_SZ
%token SHM_FORCE_ALLOC
%token MLOCK_PAGES
%token REAL_TIME
%token RT_PRIO
%token RT_POLICY
%token RT_TIMER1_PRIO
%token RT_TIMER1_POLICY
%token RT_TIMER2_PRIO
%token RT_TIMER2_POLICY
%token MCAST_LOOPBACK
%token MCAST_TTL
%token TOS
%token PMTU_DISCOVERY
%token KILL_TIMEOUT
%token MAX_WLOOPS
%token PVBUFSIZE
%token PVBUFSLOTS
%token HTTP_REPLY_PARSE
%token VERSION_TABLE_CFG
%token CFG_DESCRIPTION
%token SERVER_ID
%token MAX_RECURSIVE_LEVEL
%token MAX_BRANCHES_PARAM
%token LATENCY_LOG
%token LATENCY_LIMIT_DB
%token LATENCY_LIMIT_ACTION
%token MSG_TIME
%token ONSEND_RT_REPLY
%token FLAGS_DECL
%token AVPFLAGS_DECL
%token ATTR_MARK
%token SELECT_MARK
%token ATTR_FROM
%token ATTR_TO
%token ATTR_FROMURI
%token ATTR_TOURI
%token ATTR_FROMUSER
%token ATTR_TOUSER
%token ATTR_FROMDOMAIN
%token ATTR_TODOMAIN
%token ATTR_GLOBAL
%token ADDEQ
/*pre-processor*/
%token SUBST
%token SUBSTDEF
%token SUBSTDEFS
/* operators, C like precedence */
%right EQUAL
%left LOG_OR
%left LOG_AND
%left BIN_OR
%left BIN_AND
%left BIN_XOR
%left BIN_LSHIFT
%left BIN_RSHIFT
%left EQUAL_T DIFF MATCH INTEQ INTDIFF STREQ STRDIFF
%left GT LT GTE LTE
%left PLUS MINUS
%left STAR SLASH MODULO
%right NOT UNARY BIN_NOT
%right DEFINED
%right INTCAST STRCAST
%left DOT
/* no precedence, they use () */
%token STRLEN
%token STREMPTY
/* values */
%token <intval> NUMBER
%token <strval> ID
%token <strval> NUM_ID
%token <strval> STRING
%token <strval> IPV6ADDR
%token <strval> PVAR
/* not clear yet if this is an avp or pvar */
%token <strval> AVP_OR_PVAR
%token <strval> EVENT_RT_NAME
/* other */
%token COMMA
%token SEMICOLON
%token RPAREN
%token LPAREN
%token LBRACE
%token RBRACE
%token LBRACK
%token RBRACK
%token CR
%token COLON
/*non-terminals */
/*%type <expr> exp */
%type <expr> exp_elem
%type <intval> intno eint_op eint_op_onsend
%type <intval> eip_op eip_op_onsend
%type <action> action actions cmd fcmd if_cmd stm /*exp_stm*/ assign_action
%type <action> switch_cmd while_cmd ret_cmd
%type <case_stms> single_case case_stms
%type <ipaddr> ipv4 ipv6 ipv6addr ip
%type <ipnet> ipnet
%type <strval> host host_or_if host_if_id
%type <strval> listen_id
%type <name_l> listen_id_lst
%type <name_l> listen_id2
%type <sockid> id_lst
%type <sockid> phostport
%type <sockid> listen_phostport
%type <intval> proto eqproto port
%type <intval> equalop strop cmpop rve_cmpop rve_equalop
%type <intval> uri_type
%type <attr> attr_id
%type <attr> attr_id_num_idx
%type <attr> attr_id_no_idx
%type <attr> attr_id_ass
/*%type <attr> attr_id_val*/
%type <attr> attr_id_any
%type <attr> attr_id_any_str
%type <pvar> pvar
%type <lval> lval
%type <rv_expr> rval rval_expr ct_rval
%type <lval> avp_pvar
/* %type <intval> class_id */
%type <intval> assign_op
%type <select> select_id
%type <strval> flag_name;
%type <strval> route_name;
%type <intval> avpflag_oper
%type <intval> rve_un_op
%type <strval> cfg_var_id
/* %type <intval> rve_op */
/*%type <route_el> rules;
%type <route_el> rule;
*/
%%
cfg:
statements
;
statements:
statements statement {}
| statement {}
| statements error { yyerror(""); YYABORT;}
;
statement:
assign_stm
| preprocess_stm
| flags_decl
| avpflags_decl
| module_stm
| {rt=REQUEST_ROUTE;} route_stm
| {rt=FAILURE_ROUTE;} failure_route_stm
| onreply_route_stm
| {rt=BRANCH_ROUTE;} branch_route_stm
| {rt=ONSEND_ROUTE;} send_route_stm
| {rt=EVENT_ROUTE;} event_route_stm
| SEMICOLON /* null statement */
| CR /* null statement*/
;
listen_id:
ip {
if ($1){
tmp=ip_addr2a($1);
if (tmp==0) {
LOG(L_CRIT, "ERROR: cfg. parser: bad ip "
"address.\n");
$$=0;
} else {
$$=pkg_malloc(strlen(tmp)+1);
if ($$==0) {
LOG(L_CRIT, "ERROR: cfg. parser: out of "
"memory.\n");
} else {
strncpy($$, tmp, strlen(tmp)+1);
}
}
}
}
| STRING {
$$=pkg_malloc(strlen($1)+1);
if ($$==0) {
LOG(L_CRIT, "ERROR: cfg. parser: out of "
"memory.\n");
} else {
strncpy($$, $1, strlen($1)+1);
}
}
| host_or_if {
if ($1){
$$=pkg_malloc(strlen($1)+1);
if ($$==0) {
LOG(L_CRIT, "ERROR: cfg. parser: out of "
"memory.\n");
} else {
strncpy($$, $1, strlen($1)+1);
}
}
}
;
listen_id_lst:
listen_id { $$=mk_name_lst($1, SI_IS_MHOMED); }
| listen_id COMMA listen_id_lst { $$=mk_name_lst($1, SI_IS_MHOMED);
if ($$) $$->next=$3;
}
;
listen_id2:
LPAREN listen_id_lst RPAREN { $$=$2; }
| listen_id { $$=mk_name_lst($1, 0); }
;
proto:
UDP { $$=PROTO_UDP; }
| TCP { $$=PROTO_TCP; }
| TLS { $$=PROTO_TLS; }
| SCTP { $$=PROTO_SCTP; }
| STAR { $$=0; }
;
eqproto:
UDP { $$=PROTO_UDP; }
| TCP { $$=PROTO_TCP; }
| TLS { $$=PROTO_TLS; }
| SCTP { $$=PROTO_SCTP; }
| WS { $$=PROTO_WS; }
| WSS { $$=PROTO_WSS; }
| STAR { $$=0; }
;
port:
NUMBER { $$=$1; }
| STAR { $$=0; }
;
phostport:
listen_id { $$=mk_listen_id($1, 0, 0); }
| listen_id COLON port { $$=mk_listen_id($1, 0, $3); }
| proto COLON listen_id { $$=mk_listen_id($3, $1, 0); }
| proto COLON listen_id COLON port { $$=mk_listen_id($3, $1, $5);}
| listen_id COLON error { $$=0; yyerror(" port number expected"); }
;
listen_phostport:
listen_id2 { $$=mk_listen_id2($1, 0, 0); }
| listen_id2 COLON port { $$=mk_listen_id2($1, 0, $3); }
| proto COLON listen_id2 { $$=mk_listen_id2($3, $1, 0); }
| proto COLON listen_id2 COLON port { $$=mk_listen_id2($3, $1, $5);}
| listen_id2 COLON error { $$=0; yyerror(" port number expected"); }
;
id_lst:
listen_phostport { $$=$1 ; }
| listen_phostport id_lst { $$=$1; if ($$) $$->next=$2; }
;
intno: NUMBER
| MINUS NUMBER %prec UNARY { $$=-$2; }
;
flags_decl: FLAGS_DECL flag_list
| FLAGS_DECL error { yyerror("flag list expected\n"); }
;
flag_list: flag_spec
| flag_spec COMMA flag_list
;
flag_spec: flag_name { if (register_flag($1,-1)<0)
yyerror("register flag failed");
}
| flag_name COLON NUMBER {
if (register_flag($1, $3)<0)
yyerror("register flag failed");
}
;
flag_name: STRING { $$=$1; }
| ID { $$=$1; }
;
avpflags_decl:
AVPFLAGS_DECL avpflag_list
| AVPFLAGS_DECL error { yyerror("avpflag list expected\n"); }
;
avpflag_list:
avpflag_spec
| avpflag_spec COMMA avpflag_list
;
avpflag_spec:
flag_name {
if (register_avpflag($1)==0)
yyerror("cannot declare avpflag");
}
;
assign_stm:
DEBUG_V EQUAL intno { default_core_cfg.debug=$3; }
| DEBUG_V EQUAL error { yyerror("number expected"); }
| FORK EQUAL NUMBER { dont_fork= ! $3; }
| FORK EQUAL error { yyerror("boolean value expected"); }
| FORK_DELAY EQUAL NUMBER { set_fork_delay($3); }
| FORK_DELAY EQUAL error { yyerror("number expected"); }
| MODINIT_DELAY EQUAL NUMBER { set_modinit_delay($3); }
| MODINIT_DELAY EQUAL error { yyerror("number expected"); }
| LOGSTDERROR EQUAL NUMBER { if (!config_check) /* if set from cmd line, don't overwrite from yyparse()*/
if(log_stderr == 0) 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)
default_core_cfg.log_facility=i_tmp;
}
| LOGFACILITY EQUAL error { yyerror("ID expected"); }
| LOGNAME EQUAL STRING { log_name=$3; }
| LOGNAME EQUAL error { yyerror("string value expected"); }
| LOGCOLOR EQUAL NUMBER { log_color=$3; }
| LOGCOLOR EQUAL error { yyerror("boolean value expected"); }
| LOGPREFIX EQUAL STRING { log_prefix_fmt=$3; }
| LOGPREFIX EQUAL error { yyerror("string value expected"); }
| LOGENGINETYPE EQUAL STRING { _km_log_engine_type=$3; }
| LOGENGINETYPE EQUAL error { yyerror("string value expected"); }
| LOGENGINEDATA EQUAL STRING { _km_log_engine_data=$3; }
| LOGENGINEDATA 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 { default_core_cfg.dns_try_ipv6=$3; }
| DNS_TRY_IPV6 error { yyerror("boolean value expected"); }
| DNS_TRY_NAPTR EQUAL NUMBER { IF_NAPTR(default_core_cfg.dns_try_naptr=$3); }
| DNS_TRY_NAPTR error { yyerror("boolean value expected"); }
| DNS_SRV_LB EQUAL NUMBER { IF_DNS_FAILOVER(default_core_cfg.dns_srv_lb=$3); }
| DNS_SRV_LB error { yyerror("boolean value expected"); }
| DNS_UDP_PREF EQUAL intno { IF_NAPTR(default_core_cfg.dns_udp_pref=$3);}
| DNS_UDP_PREF error { yyerror("number expected"); }
| DNS_TCP_PREF EQUAL intno { IF_NAPTR(default_core_cfg.dns_tcp_pref=$3);}
| DNS_TCP_PREF error { yyerror("number expected"); }
| DNS_TLS_PREF EQUAL intno { IF_NAPTR(default_core_cfg.dns_tls_pref=$3);}
| DNS_TLS_PREF error { yyerror("number expected"); }
| DNS_SCTP_PREF EQUAL intno {
IF_NAPTR(default_core_cfg.dns_sctp_pref=$3); }
| DNS_SCTP_PREF error { yyerror("number expected"); }
| DNS_RETR_TIME EQUAL NUMBER { default_core_cfg.dns_retr_time=$3; }
| DNS_RETR_TIME error { yyerror("number expected"); }
| DNS_RETR_NO EQUAL NUMBER { default_core_cfg.dns_retr_no=$3; }
| DNS_RETR_NO error { yyerror("number expected"); }
| DNS_SERVERS_NO EQUAL NUMBER { default_core_cfg.dns_servers_no=$3; }
| DNS_SERVERS_NO error { yyerror("number expected"); }
| DNS_USE_SEARCH EQUAL NUMBER { default_core_cfg.dns_search_list=$3; }
| DNS_USE_SEARCH error { yyerror("boolean value expected"); }
| DNS_SEARCH_FMATCH EQUAL NUMBER { default_core_cfg.dns_search_fmatch=$3; }
| DNS_SEARCH_FMATCH error { yyerror("boolean value expected"); }
| DNS_NAPTR_IGNORE_RFC EQUAL NUMBER { default_core_cfg.dns_naptr_ignore_rfc=$3; }
| DNS_NAPTR_IGNORE_RFC error { yyerror("boolean value expected"); }
| DNS_CACHE_INIT EQUAL NUMBER { IF_DNS_CACHE(dns_cache_init=$3); }
| DNS_CACHE_INIT error { yyerror("boolean value expected"); }
| DNS_USE_CACHE EQUAL NUMBER { IF_DNS_CACHE(default_core_cfg.use_dns_cache=$3); }
| DNS_USE_CACHE error { yyerror("boolean value expected"); }
| DNS_USE_FAILOVER EQUAL NUMBER { IF_DNS_FAILOVER(default_core_cfg.use_dns_failover=$3);}
| DNS_USE_FAILOVER error { yyerror("boolean value expected"); }
| DNS_CACHE_FLAGS EQUAL NUMBER { IF_DNS_CACHE(default_core_cfg.dns_cache_flags=$3); }
| DNS_CACHE_FLAGS error { yyerror("boolean value expected"); }
| DNS_CACHE_NEG_TTL EQUAL NUMBER { IF_DNS_CACHE(default_core_cfg.dns_neg_cache_ttl=$3); }
| DNS_CACHE_NEG_TTL error { yyerror("boolean value expected"); }
| DNS_CACHE_MAX_TTL EQUAL NUMBER { IF_DNS_CACHE(default_core_cfg.dns_cache_max_ttl=$3); }
| DNS_CACHE_MAX_TTL error { yyerror("boolean value expected"); }
| DNS_CACHE_MIN_TTL EQUAL NUMBER { IF_DNS_CACHE(default_core_cfg.dns_cache_min_ttl=$3); }
| DNS_CACHE_MIN_TTL error { yyerror("boolean value expected"); }
| DNS_CACHE_MEM EQUAL NUMBER { IF_DNS_CACHE(default_core_cfg.dns_cache_max_mem=$3); }
| DNS_CACHE_MEM error { yyerror("boolean value expected"); }
| DNS_CACHE_GC_INT EQUAL NUMBER { IF_DNS_CACHE(dns_timer_interval=$3); }
| DNS_CACHE_GC_INT error { yyerror("boolean value expected"); }
| DNS_CACHE_DEL_NONEXP EQUAL NUMBER { IF_DNS_CACHE(default_core_cfg.dns_cache_del_nonexp=$3); }
| DNS_CACHE_DEL_NONEXP error { yyerror("boolean value expected"); }
| DNS_CACHE_REC_PREF EQUAL NUMBER { IF_DNS_CACHE(default_core_cfg.dns_cache_rec_pref=$3); }
| DNS_CACHE_REC_PREF error { yyerror("boolean value expected"); }
| AUTO_BIND_IPV6 EQUAL NUMBER {IF_AUTO_BIND_IPV6(auto_bind_ipv6 = $3);}
| AUTO_BIND_IPV6 error { yyerror("boolean value expected"); }
| DST_BLST_INIT EQUAL NUMBER { IF_DST_BLACKLIST(dst_blacklist_init=$3); }
| DST_BLST_INIT error { yyerror("boolean value expected"); }
| USE_DST_BLST EQUAL NUMBER {
IF_DST_BLACKLIST(default_core_cfg.use_dst_blacklist=$3);
}
| USE_DST_BLST error { yyerror("boolean value expected"); }
| DST_BLST_MEM EQUAL NUMBER {
IF_DST_BLACKLIST(default_core_cfg.blst_max_mem=$3);
}
| DST_BLST_MEM error { yyerror("boolean value expected"); }
| DST_BLST_TTL EQUAL NUMBER {
IF_DST_BLACKLIST(default_core_cfg.blst_timeout=$3);
}
| DST_BLST_TTL error { yyerror("boolean value expected"); }
| DST_BLST_GC_INT EQUAL NUMBER { IF_DST_BLACKLIST(blst_timer_interval=$3);}
| DST_BLST_GC_INT error { yyerror("boolean value expected"); }
| DST_BLST_UDP_IMASK EQUAL NUMBER {
IF_DST_BLACKLIST(default_core_cfg.blst_udp_imask=$3);
}
| DST_BLST_UDP_IMASK error { yyerror("number(flags) expected"); }
| DST_BLST_TCP_IMASK EQUAL NUMBER {
IF_DST_BLACKLIST(default_core_cfg.blst_tcp_imask=$3);
}
| DST_BLST_TCP_IMASK error { yyerror("number(flags) expected"); }
| DST_BLST_TLS_IMASK EQUAL NUMBER {
IF_DST_BLACKLIST(default_core_cfg.blst_tls_imask=$3);
}
| DST_BLST_TLS_IMASK error { yyerror("number(flags) expected"); }
| DST_BLST_SCTP_IMASK EQUAL NUMBER {
IF_DST_BLACKLIST(default_core_cfg.blst_sctp_imask=$3);
}
| DST_BLST_SCTP_IMASK error { yyerror("number(flags) expected"); }
| PORT EQUAL NUMBER { port_no=$3; }
| STAT EQUAL STRING {
#ifdef STATS
stat_file=$3;
#endif
}
| MAXBUFFER EQUAL NUMBER { maxbuffer=$3; }
| MAXBUFFER EQUAL error { yyerror("number expected"); }
| SQL_BUFFER_SIZE EQUAL NUMBER { sql_buffer_size=$3; }
| SQL_BUFFER_SIZE EQUAL error { yyerror("number expected"); }
| PORT EQUAL error { yyerror("number expected"); }
| CHILDREN EQUAL NUMBER { children_no=$3; }
| CHILDREN EQUAL error { yyerror("number expected"); }
| SOCKET_WORKERS EQUAL NUMBER { socket_workers=$3; }
| SOCKET_WORKERS EQUAL error { yyerror("number expected"); }
| ASYNC_WORKERS EQUAL NUMBER { async_task_set_workers($3); }
| ASYNC_WORKERS EQUAL error { yyerror("number expected"); }
| ASYNC_USLEEP EQUAL NUMBER { async_task_set_usleep($3); }
| ASYNC_USLEEP EQUAL error { yyerror("number expected"); }
| CHECK_VIA EQUAL NUMBER { check_via=$3; }
| CHECK_VIA EQUAL error { yyerror("boolean value expected"); }
| PHONE2TEL EQUAL NUMBER { phone2tel=$3; }
| PHONE2TEL EQUAL error { yyerror("boolean value expected"); }
| MEMLOG EQUAL intno { default_core_cfg.memlog=$3; }
| MEMLOG EQUAL error { yyerror("int value expected"); }
| MEMDBG EQUAL intno { default_core_cfg.memdbg=$3; }
| MEMDBG EQUAL error { yyerror("int value expected"); }
| MEMSUM EQUAL intno { default_core_cfg.mem_summary=$3; }
| MEMSUM EQUAL error { yyerror("int value expected"); }
| MEMSAFETY EQUAL intno { default_core_cfg.mem_safety=$3; }
| MEMSAFETY EQUAL error { yyerror("int value expected"); }
| MEMJOIN EQUAL intno { default_core_cfg.mem_join=$3; }
| MEMJOIN EQUAL error { yyerror("int value expected"); }
| CORELOG EQUAL intno { default_core_cfg.corelog=$3; }
| CORELOG EQUAL error { yyerror("int value expected"); }
| SIP_WARNING EQUAL NUMBER { sip_warning=$3; }
| SIP_WARNING EQUAL error { yyerror("boolean value expected"); }
| VERSION_TABLE_CFG EQUAL STRING { version_table.s=$3;
version_table.len=strlen(version_table.s);
}
| VERSION_TABLE_CFG EQUAL error { yyerror("string value expected"); }
| USER EQUAL STRING {
if (shm_initialized())
yyerror("user must be before any modparam or the"
" route blocks");
else if (user==0)
user=$3;
}
| USER EQUAL ID {
if (shm_initialized())
yyerror("user must be before any modparam or the"
" route blocks");
else if (user==0)
user=$3;
}
| USER EQUAL error { yyerror("string value expected"); }
| GROUP EQUAL STRING { group=$3; }
| GROUP EQUAL ID { group=$3; }
| GROUP EQUAL error { yyerror("string value expected"); }
| 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"); }
| RUNDIR EQUAL STRING { runtime_dir=$3; }
| RUNDIR EQUAL ID { runtime_dir=$3; }
| RUNDIR EQUAL error { yyerror("string value expected"); }
| MHOMED EQUAL NUMBER { mhomed=$3; }
| MHOMED EQUAL error { yyerror("boolean value expected"); }
| DISABLE_TCP EQUAL NUMBER {
#ifdef USE_TCP
tcp_disable=$3;
#else
warn("tcp support not compiled in");
#endif
}
| DISABLE_TCP EQUAL error { yyerror("boolean value expected"); }
| TCP_ACCEPT_ALIASES EQUAL NUMBER {
#ifdef USE_TCP
tcp_default_cfg.accept_aliases=$3;
#else
warn("tcp support not compiled in");
#endif
}
| TCP_ACCEPT_ALIASES EQUAL error { yyerror("boolean value expected"); }
| TCP_CHILDREN EQUAL NUMBER {
#ifdef USE_TCP
tcp_cfg_children_no=$3;
#else
warn("tcp support not compiled in");
#endif
}
| TCP_CHILDREN EQUAL error { yyerror("number expected"); }
| TCP_CONNECT_TIMEOUT EQUAL intno {
#ifdef USE_TCP
tcp_default_cfg.connect_timeout_s=$3;
#else
warn("tcp support not compiled in");
#endif
}
| TCP_CONNECT_TIMEOUT EQUAL error { yyerror("number expected"); }
| TCP_SEND_TIMEOUT EQUAL intno {
#ifdef USE_TCP
tcp_default_cfg.send_timeout=S_TO_TICKS($3);
#else
warn("tcp support not compiled in");
#endif
}
| TCP_SEND_TIMEOUT EQUAL error { yyerror("number expected"); }
| TCP_CON_LIFETIME EQUAL intno {
#ifdef USE_TCP
if ($3<0)
tcp_default_cfg.con_lifetime=-1;
else
tcp_default_cfg.con_lifetime=S_TO_TICKS($3);
#else
warn("tcp support not compiled in");
#endif
}
| TCP_CON_LIFETIME EQUAL error { yyerror("number expected"); }
| TCP_POLL_METHOD EQUAL ID {
#ifdef USE_TCP
tcp_poll_method=get_poll_type($3);
if (tcp_poll_method==POLL_NONE) {
LOG(L_CRIT, "bad poll method name:"
" %s\n, try one of %s.\n",
$3, poll_support);
yyerror("bad tcp_poll_method "
"value");