-
Notifications
You must be signed in to change notification settings - Fork 1
/
cfg.y
1956 lines (1893 loc) · 60.3 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
/*
* $Id: cfg.y 166 2007-03-02 19:28:23Z vingarzan $
*
* cfg grammar
*
* Copyright (C) 2001-2003 FhG Fokus
*
* This file is part of ser, a free SIP server.
*
* ser is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version
*
* For a license to use the ser software under conditions
* other than those described here, or to purchase support for this
* software, please contact iptel.org by e-mail at the following addresses:
* info@iptel.org
*
* ser is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/*
* 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-11 added DNS_RETR_TIME, DNS_RETR_NO, DNS_SERVERS_NO, DNS_USE_SEARCH,
* DNS_TRY_IPV6 (andrei)
* 2005-07-12 default onreply route added (andrei)
* 2005-11-16 fixed if (cond) cmd; (andrei)
* 2005-12-11 added onsend_route support, fcmd (filtered cmd),
* snd_{ip,port,proto,af}, to_{ip,proto} (andrei)
* 2005-12-19 select framework (mma)
* 2006-01-06 AVP index support (mma)
* 2005-01-07 optional semicolon in statement, PARAM_STR&PARAM_STRING
* 2006-02-02 named flags support (andrei)
* 2006-02-06 named routes support (andrei)
* 2006-05-30 avp flags (tma)
* 2006-09-11 added dns cache (use, flags, ttls, mem ,gc) & dst blacklist
* options (andrei)
* 2006-10-13 added STUN_ALLOW_STUN, STUN_ALLOW_FP, STUN_REFRESH_INTERVAL
* (vlada)
* 2007-02-09 separated command needed for tls-in-core and for tls in general
* (andrei)
*/
%{
#include <stdlib.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.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 "select.h"
#include "flags.h"
#include "config.h"
#ifdef CORE_TLS
#include "tls/tls_config.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
#define onsend_check(s) \
do{\
if (rt!=ONSEND_ROUTE) yyerror( s " allowed only in onsend_routes");\
}while(0)
#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_DST_BLACKLIST
#define IF_DST_BLACKLIST(x) x
#else
#define IF_DST_BLACKLIST(x) warn("dst blacklist support not compiled in")
#endif
#ifdef USE_STUN
#define IF_STUN(x) x
#else
#define IF_STUN(x) warn("stun support not compiled in")
#endif
extern int yylex();
static void yyerror(char* s);
static char* tmp;
static int i_tmp;
static struct socket_id* lst_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 struct action *mod_func_action;
static void warn(char* s);
static struct socket_id* mk_listen_id(char*, int, int);
%}
%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 avp_spec* attr;
select_t* select;
}
/* terminals */
/* keywords */
%token FORWARD
%token FORWARD_TCP
%token FORWARD_TLS
%token FORWARD_UDP
%token SEND
%token SEND_TCP
%token DROP
%token RETURN
%token BREAK
%token LOG_TOK
%token ERROR
%token ROUTE
%token ROUTE_FAILURE
%token ROUTE_ONREPLY
%token ROUTE_BRANCH
%token ROUTE_SEND
%token EXEC
%token SET_HOST
%token SET_HOSTPORT
%token PREFIX
%token STRIP
%token STRIP_TAIL
%token APPEND_BRANCH
%token SET_USER
%token SET_USERPASS
%token SET_PORT
%token SET_URI
%token REVERT_URI
%token FORCE_RPORT
%token FORCE_TCP_ALIAS
%token IF
%token ELSE
%token SET_ADV_ADDRESS
%token SET_ADV_PORT
%token FORCE_SEND_SOCKET
%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 RETCODE
%token UDP
%token TCP
%token TLS
/* config vars. */
%token DEBUG_V
%token FORK
%token LOGSTDERROR
%token LOGFACILITY
%token LISTEN
%token ALIAS
%token DNS
%token REV_DNS
%token DNS_TRY_IPV6
%token DNS_RETR_TIME
%token DNS_RETR_NO
%token DNS_SERVERS_NO
%token DNS_USE_SEARCH
%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
/*blacklist*/
%token USE_DST_BLST
%token DST_BLST_MEM
%token DST_BLST_TTL
%token DST_BLST_GC_INT
%token PORT
%token STAT
%token CHILDREN
%token CHECK_VIA
%token SYN_BRANCH
%token MEMLOG
%token MEMDBG
%token SIP_WARNING
%token SERVER_SIGNATURE
%token REPLY_TO_VIA
%token LOADMODULE
%token MODPARAM
%token MAXBUFFER
%token USER
%token GROUP
%token CHROOT
%token WDIR
%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 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 ADVERTISED_ADDRESS
%token ADVERTISED_PORT
%token DISABLE_CORE
%token OPEN_FD_LIMIT
%token MCAST_LOOPBACK
%token MCAST_TTL
%token TOS
%token KILL_TIMEOUT
%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
%token STUN_REFRESH_INTERVAL
%token STUN_ALLOW_STUN
%token STUN_ALLOW_FP
/* operators */
%nonassoc EQUAL
%nonassoc EQUAL_T
%nonassoc GT
%nonassoc LT
%nonassoc GTE
%nonassoc LTE
%nonassoc DIFF
%nonassoc MATCH
%left LOG_OR
%left LOG_AND
%left BIN_OR
%left BIN_AND
%left PLUS MINUS
%right NOT
/* values */
%token <intval> NUMBER
%token <strval> ID
%token <strval> STRING
%token <strval> IPV6ADDR
/* other */
%token COMMA
%token SEMICOLON
%token RPAREN
%token LPAREN
%token LBRACE
%token RBRACE
%token LBRACK
%token RBRACK
%token SLASH
%token DOT
%token CR
%token COLON
%token STAR
/*non-terminals */
%type <expr> exp exp_elem /*, condition*/
%type <action> action actions cmd fcmd if_cmd stm exp_stm assign_action
%type <ipaddr> ipv4 ipv6 ipv6addr ip
%type <ipnet> ipnet
%type <strval> host
%type <strval> listen_id
%type <sockid> id_lst
%type <sockid> phostport
%type <intval> proto port
%type <intval> equalop strop intop binop
%type <strval> host_sep
%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 <intval> class_id */
%type <intval> assign_op
%type <select> select_id
%type <strval> flag_name;
%type <strval> route_name;
%type <intval> avpflag_oper
/*%type <route_el> rules;
%type <route_el> rule;
*/
%%
cfg:
statements
;
statements:
statements statement {}
| statement {}
| statements error { yyerror(""); YYABORT;}
;
statement:
assign_stm
| flags_decl
| avpflags_decl
| 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=ONSEND_ROUTE;} send_route_stm
| SEMICOLON /* null statement */
| CR /* null statement*/
;
listen_id:
ip {
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 {
$$=pkg_malloc(strlen($1)+1);
if ($$==0) {
LOG(L_CRIT, "ERROR: cfg. parser: out of "
"memory.\n");
} else {
strncpy($$, $1, strlen($1)+1);
}
}
;
proto:
UDP { $$=PROTO_UDP; }
| TCP { $$=PROTO_TCP; }
| TLS { $$=PROTO_TLS; }
| 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"); }
;
id_lst:
phostport { $$=$1 ; }
| phostport id_lst { $$=$1; $$->next=$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 NUMBER { debug=$3; }
| DEBUG_V EQUAL error { yyerror("number expected"); }
| FORK EQUAL NUMBER { dont_fork= ! $3; }
| FORK EQUAL error { yyerror("boolean value expected"); }
| LOGSTDERROR EQUAL NUMBER { if (!config_check) 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"); }
| 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_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"); }
| DNS_USE_CACHE EQUAL NUMBER { IF_DNS_CACHE(use_dns_cache=$3); }
| DNS_USE_CACHE error { yyerror("boolean value expected"); }
| DNS_USE_FAILOVER EQUAL NUMBER { IF_DNS_FAILOVER(use_dns_failover=$3);}
| DNS_USE_FAILOVER error { yyerror("boolean value expected"); }
| DNS_CACHE_FLAGS EQUAL NUMBER { IF_DNS_CACHE(dns_flags=$3); }
| DNS_CACHE_FLAGS error { yyerror("boolean value expected"); }
| DNS_CACHE_NEG_TTL EQUAL NUMBER { IF_DNS_CACHE(dns_neg_cache_ttl=$3); }
| DNS_CACHE_NEG_TTL error { yyerror("boolean value expected"); }
| DNS_CACHE_MAX_TTL EQUAL NUMBER { IF_DNS_CACHE(dns_cache_max_ttl=$3); }
| DNS_CACHE_MAX_TTL error { yyerror("boolean value expected"); }
| DNS_CACHE_MIN_TTL EQUAL NUMBER { IF_DNS_CACHE(dns_cache_min_ttl=$3); }
| DNS_CACHE_MIN_TTL error { yyerror("boolean value expected"); }
| DNS_CACHE_MEM EQUAL NUMBER { IF_DNS_CACHE(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"); }
| USE_DST_BLST EQUAL NUMBER { IF_DST_BLACKLIST(use_dst_blacklist=$3); }
| USE_DST_BLST error { yyerror("boolean value expected"); }
| DST_BLST_MEM EQUAL NUMBER { IF_DST_BLACKLIST(blst_max_mem=$3); }
| DST_BLST_MEM error { yyerror("boolean value expected"); }
| DST_BLST_TTL EQUAL NUMBER { IF_DST_BLACKLIST(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"); }
| 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"); }
| PORT EQUAL error { yyerror("number expected"); }
| CHILDREN EQUAL NUMBER { children_no=$3; }
| CHILDREN EQUAL error { yyerror("number expected"); }
| CHECK_VIA EQUAL NUMBER { check_via=$3; }
| CHECK_VIA EQUAL error { yyerror("boolean value expected"); }
| SYN_BRANCH EQUAL NUMBER { syn_branch=$3; }
| SYN_BRANCH EQUAL error { yyerror("boolean value expected"); }
| MEMLOG EQUAL NUMBER { memlog=$3; }
| MEMLOG EQUAL error { yyerror("int value expected"); }
| MEMDBG EQUAL NUMBER { memdbg=$3; }
| MEMDBG EQUAL error { yyerror("int value expected"); }
| SIP_WARNING EQUAL NUMBER { sip_warning=$3; }
| SIP_WARNING EQUAL error { yyerror("boolean value expected"); }
| USER EQUAL STRING { user=$3; }
| USER EQUAL ID { user=$3; }
| USER EQUAL error { yyerror("string value expected"); }
| GROUP EQUAL STRING { group=$3; }
| GROUP EQUAL ID { group=$3; }
| GROUP EQUAL error { yyerror("string value expected"); }
| 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"); }
| 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_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_children_no=$3;
#else
warn("tcp support not compiled in");
#endif
}
| TCP_CHILDREN EQUAL error { yyerror("number expected"); }
| TCP_CONNECT_TIMEOUT EQUAL NUMBER {
#ifdef USE_TCP
tcp_connect_timeout=$3;
#else
warn("tcp support not compiled in");
#endif
}
| TCP_CONNECT_TIMEOUT EQUAL error { yyerror("number expected"); }
| TCP_SEND_TIMEOUT EQUAL NUMBER {
#ifdef USE_TCP
tcp_send_timeout=$3;
#else
warn("tcp support not compiled in");
#endif
}
| TCP_SEND_TIMEOUT EQUAL error { yyerror("number expected"); }
| TCP_CON_LIFETIME EQUAL NUMBER {
#ifdef USE_TCP
tcp_con_lifetime=$3;
#else
warn("tcp support not compiled in");
#endif
}
| TCP_CON_LIFETIME EQUAL error { yyerror("number expected"); }
| TCP_POLL_METHOD EQUAL ID {
#ifdef USE_TCP
tcp_poll_method=get_poll_type($3);
if (tcp_poll_method==POLL_NONE) {
LOG(L_CRIT, "bad poll method name:"
" %s\n, try one of %s.\n",
$3, poll_support);
yyerror("bad tcp_poll_method "
"value");
}
#else
warn("tcp support not compiled in");
#endif
}
| TCP_POLL_METHOD EQUAL STRING {
#ifdef USE_TCP
tcp_poll_method=get_poll_type($3);
if (tcp_poll_method==POLL_NONE) {
LOG(L_CRIT, "bad poll method name:"
" %s\n, try one of %s.\n",
$3, poll_support);
yyerror("bad tcp_poll_method "
"value");
}
#else
warn("tcp support not compiled in");
#endif
}
| TCP_POLL_METHOD EQUAL error { yyerror("poll method name expected"); }
| TCP_MAX_CONNECTIONS EQUAL NUMBER {
#ifdef USE_TCP
tcp_max_connections=$3;
#else
warn("tcp support not compiled in");
#endif
}
| TCP_MAX_CONNECTIONS EQUAL error { yyerror("number expected"); }
| DISABLE_TLS EQUAL NUMBER {
#ifdef USE_TLS
tls_disable=$3;
#else
warn("tls support not compiled in");
#endif
}
| DISABLE_TLS EQUAL error { yyerror("boolean value expected"); }
| ENABLE_TLS EQUAL NUMBER {
#ifdef USE_TLS
tls_disable=!($3);
#else
warn("tls support not compiled in");
#endif
}
| ENABLE_TLS EQUAL error { yyerror("boolean value expected"); }
| TLSLOG EQUAL NUMBER {
#ifdef CORE_TLS
tls_log=$3;
#else
warn("tls-in-core support not compiled in");
#endif
}
| TLSLOG EQUAL error { yyerror("int value expected"); }
| TLS_PORT_NO EQUAL NUMBER {
#ifdef USE_TLS
tls_port_no=$3;
#else
warn("tls support not compiled in");
#endif
}
| TLS_PORT_NO EQUAL error { yyerror("number expected"); }
| TLS_METHOD EQUAL SSLv23 {
#ifdef CORE_TLS
tls_method=TLS_USE_SSLv23;
#else
warn("tls-in-core support not compiled in");
#endif
}
| TLS_METHOD EQUAL SSLv2 {
#ifdef CORE_TLS
tls_method=TLS_USE_SSLv2;
#else
warn("tls-in-core support not compiled in");
#endif
}
| TLS_METHOD EQUAL SSLv3 {
#ifdef CORE_TLS
tls_method=TLS_USE_SSLv3;
#else
warn("tls-in-core support not compiled in");
#endif
}
| TLS_METHOD EQUAL TLSv1 {
#ifdef CORE_TLS
tls_method=TLS_USE_TLSv1;
#else
warn("tls-in-core support not compiled in");
#endif
}
| TLS_METHOD EQUAL error {
#ifdef CORE_TLS
yyerror("SSLv23, SSLv2, SSLv3 or TLSv1 expected");
#else
warn("tls-in-core support not compiled in");
#endif
}
| TLS_VERIFY EQUAL NUMBER {
#ifdef CORE_TLS
tls_verify_cert=$3;
#else
warn("tls-in-core support not compiled in");
#endif
}
| TLS_VERIFY EQUAL error { yyerror("boolean value expected"); }
| TLS_REQUIRE_CERTIFICATE EQUAL NUMBER {
#ifdef CORE_TLS
tls_require_cert=$3;
#else
warn( "tls-in-core support not compiled in");
#endif
}
| TLS_REQUIRE_CERTIFICATE EQUAL error { yyerror("boolean value expected"); }
| TLS_CERTIFICATE EQUAL STRING {
#ifdef CORE_TLS
tls_cert_file=$3;
#else
warn("tls-in-core support not compiled in");
#endif
}
| TLS_CERTIFICATE EQUAL error { yyerror("string value expected"); }
| TLS_PRIVATE_KEY EQUAL STRING {
#ifdef CORE_TLS
tls_pkey_file=$3;
#else
warn("tls-in-core support not compiled in");
#endif
}
| TLS_PRIVATE_KEY EQUAL error { yyerror("string value expected"); }
| TLS_CA_LIST EQUAL STRING {
#ifdef CORE_TLS
tls_ca_file=$3;
#else
warn("tls-in-core support not compiled in");
#endif
}
| TLS_CA_LIST EQUAL error { yyerror("string value expected"); }
| TLS_HANDSHAKE_TIMEOUT EQUAL NUMBER {
#ifdef CORE_TLS
tls_handshake_timeout=$3;
#else
warn("tls-in-core support not compiled in");
#endif
}
| TLS_HANDSHAKE_TIMEOUT EQUAL error { yyerror("number expected"); }
| TLS_SEND_TIMEOUT EQUAL NUMBER {
#ifdef CORE_TLS
tls_send_timeout=$3;
#else
warn("tls-in-core support not compiled in");
#endif
}
| TLS_SEND_TIMEOUT EQUAL error { yyerror("number expected"); }
| SERVER_SIGNATURE EQUAL NUMBER { server_signature=$3; }
| SERVER_SIGNATURE EQUAL error { yyerror("boolean value expected"); }
| REPLY_TO_VIA EQUAL NUMBER { reply_to_via=$3; }
| REPLY_TO_VIA EQUAL error { yyerror("boolean value expected"); }
| LISTEN EQUAL id_lst {
for(lst_tmp=$3; lst_tmp; lst_tmp=lst_tmp->next) {
if (add_listen_iface(lst_tmp->name, lst_tmp->port, lst_tmp->proto, 0)!=0) {
LOG(L_CRIT, "ERROR: cfg. parser: failed to add listen address\n");
break;
}
}
}
| LISTEN EQUAL error { yyerror("ip address or hostname expected"); }
| 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"); }
| ADVERTISED_ADDRESS EQUAL listen_id {
default_global_address.s=$3;
default_global_address.len=strlen($3);
}
| ADVERTISED_ADDRESS EQUAL error {yyerror("ip address or hostname expected"); }
| ADVERTISED_PORT EQUAL NUMBER {
tmp=int2str($3, &i_tmp);
if ((default_global_port.s=pkg_malloc(i_tmp))==0) {
LOG(L_CRIT, "ERROR: cfg. parser: out of memory.\n");
default_global_port.len=0;
} else {
default_global_port.len=i_tmp;
memcpy(default_global_port.s, tmp, default_global_port.len);
};
}
|ADVERTISED_PORT EQUAL error {yyerror("ip address or hostname expected"); }
| 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 {
#ifdef USE_MCAST
mcast_ttl=$3;
#else
warn("no multicast support compiled in");
#endif
}
| MCAST_TTL EQUAL error { yyerror("number expected"); }
| TOS EQUAL NUMBER { tos=$3; }
| TOS EQUAL error { yyerror("number expected"); }
| KILL_TIMEOUT EQUAL NUMBER { ser_kill_timeout=$3; }
| KILL_TIMEOUT EQUAL error { yyerror("number expected"); }
| STUN_REFRESH_INTERVAL EQUAL NUMBER { IF_STUN(stun_refresh_interval=$3); }
| STUN_REFRESH_INTERVAL EQUAL error{ yyerror("number expected"); }
| STUN_ALLOW_STUN EQUAL NUMBER { IF_STUN(stun_allow_stun=$3); }
| STUN_ALLOW_STUN EQUAL error{ yyerror("number expected"); }
| STUN_ALLOW_FP EQUAL NUMBER { IF_STUN(stun_allow_fp=$3) ; }
| STUN_ALLOW_FP EQUAL error{ yyerror("number expected"); }
| error EQUAL { yyerror("unknown config variable"); }
;
module_stm:
LOADMODULE STRING {
DBG("loading module %s\n", $2);
if (load_module($2)!=0) {
yyerror("failed to load module");
}
}
| LOADMODULE error { yyerror("string expected"); }
| MODPARAM LPAREN STRING COMMA STRING COMMA STRING RPAREN {
if (set_mod_param_regex($3, $5, PARAM_STRING, $7) != 0) {
yyerror("Can't set module parameter");
}
}
| MODPARAM LPAREN STRING COMMA STRING COMMA NUMBER RPAREN {
if (set_mod_param_regex($3, $5, PARAM_INT, (void*)$7) != 0) {
yyerror("Can't set module parameter");
}
}
| MODPARAM error { yyerror("Invalid arguments"); }
;
ip:
ipv4 { $$=$1; }
| ipv6 { $$=$1; }
;
ipv4:
NUMBER DOT NUMBER DOT NUMBER DOT NUMBER {
$$=pkg_malloc(sizeof(struct ip_addr));
if ($$==0) {
LOG(L_CRIT, "ERROR: cfg. parser: out of memory.\n");
} else {
memset($$, 0, sizeof(struct ip_addr));
$$->af=AF_INET;
$$->len=4;
if (($1>255) || ($1<0) ||
($3>255) || ($3<0) ||
($5>255) || ($5<0) ||
($7>255) || ($7<0)) {
yyerror("invalid ipv4 address");
$$->u.addr32[0]=0;
/* $$=0; */
} else {
$$->u.addr[0]=$1;
$$->u.addr[1]=$3;
$$->u.addr[2]=$5;
$$->u.addr[3]=$7;
/*
$$=htonl( ($1<<24)|
($3<<16)| ($5<<8)|$7 );
*/
}
}
}
;
ipv6addr:
IPV6ADDR {
$$=pkg_malloc(sizeof(struct ip_addr));
if ($$==0) {
LOG(L_CRIT, "ERROR: cfg. parser: out of memory.\n");
} else {
memset($$, 0, sizeof(struct ip_addr));
$$->af=AF_INET6;
$$->len=16;
#ifdef USE_IPV6
if (inet_pton(AF_INET6, $1, $$->u.addr)<=0) {
yyerror("bad ipv6 address");
}
#else
yyerror("ipv6 address & no ipv6 support compiled in");
YYABORT;
#endif
}
}
;
ipv6:
ipv6addr { $$=$1; }
| LBRACK ipv6addr RBRACK {$$=$2; }
;
route_name: NUMBER {
tmp=int2str($1, &i_tmp);
if (($$=pkg_malloc(i_tmp+1))==0) {
yyerror("out of memory");
YYABORT;
} else {
memcpy($$, tmp, i_tmp);
$$[i_tmp]=0;
}
}
| ID { $$=$1; }
| STRING { $$=$1; }
;
route_stm:
ROUTE LBRACE actions RBRACE { push($3, &main_rt.rlist[DEFAULT_RT]); }
| ROUTE LBRACK route_name RBRACK LBRACE actions RBRACE {
i_tmp=route_get(&main_rt, $3);
if (i_tmp==-1){
yyerror("internal error");
YYABORT;
}