-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathl2tp_config_parse.y
1803 lines (1740 loc) · 51.3 KB
/
l2tp_config_parse.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
%{
#include <sys/types.h>
#include <sys/param.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <string.h>
#include <unistd.h>
#include <stdio.h>
#include <netdb.h>
#include <ctype.h>
#include <errno.h>
#include <stdlib.h>
#include <syslog.h>
#include "l2tp_config_types.h"
#include "l2tp_rpc.h"
static struct l2tp_api_system_msg_data system_config;
static struct l2tp_api_peer_profile_msg_data peer_profile;
static struct l2tp_api_tunnel_profile_msg_data tunnel_profile;
static struct l2tp_api_session_profile_msg_data session_profile;
static struct l2tp_api_ppp_profile_msg_data ppp_profile;
static struct l2tp_api_tunnel_msg_data tunnel;
static struct l2tp_api_session_msg_data session;
extern void l2tp_log(int level, char *fmt, ...);
extern void yyfatal(const char *s);
%}
%union {
int num;
unsigned long ulnum;
l2tp_byte_vector_t val;
}
%token SYSTEM TUNNEL SESSION PROFILE PEER PPP
%token CREATE MODIFY
%token DIGITAL_ANALOG
%token TUNNEL_AUTH_MODE
%token PEER_IPADDR LAC_LNS
%token TUNNEL_ID TUNNEL_NAME
%token SESSION_ID SESSION_NAME
%token UDP_PORT
%token TRACE_FLAGS
%token MAX_TUNNELS
%token MAX_SESSIONS
%token DRAIN_TUNNELS
%token TUNNEL_ESTABLISH_TIMEOUT
%token SESSION_ESTABLISH_TIMEOUT
%token TUNNEL_PERSIST_PEND_TIMEOUT
%token SESSION_PERSIST_PEND_TIMEOUT
%token DENY_LOCAL_TUNNEL_CREATES
%token DENY_REMOTE_TUNNEL_CREATES
%token HIDE_AVPS
%token OUR_ADDR
%token PEER_ADDR
%token OUR_UDP_PORT
%token PEER_UDP_PORT
%token CONFIG_ID
%token AUTH_MODE
%token FRAMING_CAP
%token BEARER_CAP
%token USE_TIEBREAKER
%token ALLOW_PPP_PROXY
%token USE_PPP_PROXY
%token USE_UDP_CHECKSUMS
%token HELLO_TIMEOUT
%token MAX_RETRIES
%token RX_WINDOW_SIZE
%token TX_WINDOW_SIZE
%token RETRY_TIMEOUT
%token IDLE_TIMEOUT
%token DO_PMTU_DISCOVERY
%token PERSIST
%token MTU
%token SECRET
%token HOST_NAME
%token TUNNEL_PROFILE_NAME
%token PEER_PROFILE_NAME
%token SESSION_PROFILE_NAME
%token PPP_PROFILE_NAME
%token INTERFACE_NAME
%token SESSION_TYPE
%token USER_NAME
%token USER_PASSWORD
%token PRIV_GROUP_ID
%token PROFILE_NAME
%token SEQUENCING_REQUIRED
%token USE_SEQUENCE_NUMBERS
%token NO_PPP
%token REORDER_TIMEOUT
%token FRAMING_TYPE
%token BEARER_TYPE
%token MINIMUM_BPS
%token MAXIMUM_BPS
%token CONNECT_SPEED
%token PEER_PORT
%token WE_CAN_BE_LAC
%token WE_CAN_BE_LNS
%token DEFAULT_TUNNEL_PROFILE_NAME
%token DEFAULT_SESSION_PROFILE_NAME
%token DEFAULT_PPP_PROFILE_NAME
%token NETMASK
%token ASYNCMAP
%token MRU
%token AUTH_FLAGS
%token SYNC_MODE
%token CHAP_INTERVAL
%token CHAP_MAX_CHALLENGE
%token CHAP_RESTART
%token PAP_MAX_AUTH_REQUESTS
%token PAP_RESTART_INTERVAL
%token PAP_TIMEOUT
%token IPCP_MAX_CONFIG_REQUESTS
%token IPCP_MAX_CONFIG_NAKS
%token IPCP_MAX_TERMINATE_REQUESTS
%token IPCP_RETRANSMIT_INTERVAL
%token LCP_ECHO_FAILURE_COUNT
%token LCP_ECHO_INTERVAL
%token LCP_MAX_CONFIG_REQUESTS
%token LCP_MAX_CONFIG_NAKS
%token LCP_MAX_TERMINATE_REQUESTS
%token LCP_RETRANSMIT_INTERVAL
%token MAX_CONNECT_TIME
%token MAX_FAILURE_COUNT
%token LOCAL_IPADDR
%token REMOTE_IPADDR
%token DNS_IPADDR_PRI
%token DNS_IPADDR_SEC
%token WINS_IPADDR_PRI
%token WINS_IPADDR_SEC
%token IP_POOL_NAME
%token USE_RADIUS
%token RADIUS_HINT
%token USE_AS_DEFAULT_ROUTE
%token MULTILINK
%token PROXY_ARP
%token EOT
%token SLASH
%token BLCL
%token ELCL
%token EQUALS
%token DECSTRING
%token STRING
%token HEXSTRING
%token QUOTEDSTRING
%token BOOL
%token IPADDRESS
%token INITIAL_RCVD_LCP_CONFREQ
%token CALLING_NUMBER
%token PROXY_AUTH_NAME
%token SUB_ADDRESS
%token PROXY_AUTH_TYPE
%token PROXY_AUTH_RESPONSE
%token LAST_RCVD_LCP_CONFREQ
%token CALLED_NUMBER
%token PROXY_AUTH_CHALLENGE
%token LAST_SENT_LCP_CONFREQ
%token AUTH_PAP AUTH_CHAP AUTH_MSCHAPV1 AUTH_MSCHAPV2 AUTH_EAP AUTH_NOAUTH AUTH_PEER
%token SRC_IPADDR DEST_IPADDR
%token LOCAL_NAME REMOTE_NAME
%type <ulnum> DECSTRING
%type <val> QUOTEDSTRING HEXSTRING STRING
%type <num> BOOL
%type <ulnum> IPADDRESS
%%
commands
: /* empty */
| EOT
| commands command
{
}
;
command
: system_command
| peer_profile_command
| tunnel_profile_command
| session_profile_command
| ppp_profile_command
| tunnel_command
| session_command
;
system_command
: SYSTEM MODIFY system_statements EOT
{
bool_t status;
int result;
status = l2tp_system_modify_1_svc(system_config, &result, NULL);
if ((status != TRUE) || (result < 0))
l2tp_log(LOG_ERR, "system: command failed: rc=%d", l2tp_strerror(-result));
}
;
system_statements
: /* empty */
| system_statements system_statement
;
system_statement
: TRACE_FLAGS EQUALS DECSTRING
{
system_config.config.flags |= L2TP_API_CONFIG_FLAG_TRACE_FLAGS;
system_config.config.trace_flags = $3;
}
| MAX_TUNNELS EQUALS DECSTRING
{
system_config.config.flags |= L2TP_API_CONFIG_FLAG_MAX_TUNNELS;
system_config.config.max_tunnels = $3;
}
| MAX_SESSIONS EQUALS DECSTRING
{
system_config.config.flags |= L2TP_API_CONFIG_FLAG_MAX_SESSIONS;
system_config.config.max_sessions = $3;
}
| DRAIN_TUNNELS EQUALS BOOL
{
system_config.config.flags |= L2TP_API_CONFIG_FLAG_DRAIN_TUNNELS;
system_config.config.drain_tunnels = $3;
}
| TUNNEL_ESTABLISH_TIMEOUT EQUALS DECSTRING
{
system_config.config.flags |= L2TP_API_CONFIG_FLAG_TUNNEL_ESTABLISH_TIMEOUT;
system_config.config.tunnel_establish_timeout = $3;
}
| SESSION_ESTABLISH_TIMEOUT EQUALS DECSTRING
{
system_config.config.flags |= L2TP_API_CONFIG_FLAG_SESSION_ESTABLISH_TIMEOUT;
system_config.config.session_establish_timeout = $3;
}
| TUNNEL_PERSIST_PEND_TIMEOUT EQUALS DECSTRING
{
system_config.config.flags |= L2TP_API_CONFIG_FLAG_TUNNEL_PERSIST_PEND_TIMEOUT;
system_config.config.tunnel_persist_pend_timeout = $3;
}
| SESSION_PERSIST_PEND_TIMEOUT EQUALS DECSTRING
{
system_config.config.flags |= L2TP_API_CONFIG_FLAG_SESSION_PERSIST_PEND_TIMEOUT;
system_config.config.session_persist_pend_timeout = $3;
}
| DENY_LOCAL_TUNNEL_CREATES EQUALS BOOL
{
system_config.config.flags |= L2TP_API_CONFIG_FLAG_DENY_LOCAL_TUNNEL_CREATES;
system_config.config.deny_local_tunnel_creates = $3;
}
| DENY_REMOTE_TUNNEL_CREATES EQUALS BOOL
{
system_config.config.flags |= L2TP_API_CONFIG_FLAG_DENY_REMOTE_TUNNEL_CREATES;
system_config.config.deny_remote_tunnel_creates = $3;
}
;
peer_profile_command
: peer_profile_create_command
| peer_profile_modify_command
;
peer_profile_create_command
: PEER PROFILE CREATE peer_profile_statements EOT
{
bool_t status;
int result;
if (peer_profile.profile_name == NULL)
yyfatal("missing profile name");
status = l2tp_peer_profile_create_1_svc(peer_profile, &result, NULL);
if ((status != TRUE) || ((result < 0) && (result != -L2TP_ERR_PROFILE_ALREADY_EXISTS)))
l2tp_log(LOG_ERR, "peer profile create: command failed: rc=%d", l2tp_strerror(-result));
memset(&peer_profile, 0, sizeof(peer_profile));
}
;
peer_profile_modify_command
: PEER PROFILE MODIFY peer_profile_statements EOT
{
bool_t status;
int result;
if (peer_profile.profile_name == NULL)
yyfatal("missing profile name");
status = l2tp_peer_profile_modify_1_svc(peer_profile, &result, NULL);
if ((status != TRUE) || (result < 0))
l2tp_log(LOG_ERR, "peer profile modify: command failed: rc=%d", l2tp_strerror(-result));
memset(&peer_profile, 0, sizeof(peer_profile));
}
;
peer_profile_statements
: /* empty */
| peer_profile_statements peer_profile_statement
;
peer_profile_statement
: PROFILE_NAME EQUALS STRING
{
peer_profile.profile_name = $3.buf;
}
| PROFILE_NAME EQUALS QUOTEDSTRING
{
peer_profile.profile_name = $3.buf;
}
| PEER_IPADDR EQUALS IPADDRESS
{
struct in_addr addr;
addr.s_addr = htonl($3);
peer_profile.flags |= L2TP_API_PEER_PROFILE_FLAG_PEER_IPADDR;
peer_profile.peer_addr.s_addr = addr.s_addr;
}
| PEER_PORT EQUALS DECSTRING
{
peer_profile.flags |= L2TP_API_PEER_PROFILE_FLAG_PEER_PORT;
peer_profile.peer_port = $3;
}
| NETMASK EQUALS IPADDRESS
{
struct in_addr addr;
addr.s_addr = htonl($3);
peer_profile.flags |= L2TP_API_PEER_PROFILE_FLAG_NETMASK;
peer_profile.netmask.s_addr = addr.s_addr;
}
| LAC_LNS EQUALS STRING
{
peer_profile.flags |= L2TP_API_PEER_PROFILE_FLAG_LACLNS;
if (strcasecmp($3.buf, "lac") == 0) {
peer_profile.we_can_be_lac = 1;
peer_profile.we_can_be_lns = 0;
} else if (strcasecmp($3.buf, "lns") == 0) {
peer_profile.we_can_be_lac = 0;
peer_profile.we_can_be_lns = 1;
} else if ((strcasecmp($3.buf, "laclns") == 0) ||
(strcasecmp($3.buf, "lnslac") == 0)) {
peer_profile.we_can_be_lac = 1;
peer_profile.we_can_be_lns = 1;
} else {
yyfatal("invalid lac_lns value");
}
}
| TUNNEL_PROFILE_NAME EQUALS STRING
{
peer_profile.flags |= L2TP_API_PEER_PROFILE_FLAG_TUNNEL_PROFILE_NAME;
peer_profile.default_tunnel_profile_name.optstring_u.value = $3.buf;
peer_profile.default_tunnel_profile_name.valid = 1;
}
| TUNNEL_PROFILE_NAME EQUALS QUOTEDSTRING
{
peer_profile.flags |= L2TP_API_PEER_PROFILE_FLAG_TUNNEL_PROFILE_NAME;
peer_profile.default_tunnel_profile_name.optstring_u.value = $3.buf;
peer_profile.default_tunnel_profile_name.valid = 1;
}
| SESSION_PROFILE_NAME EQUALS STRING
{
peer_profile.flags |= L2TP_API_PEER_PROFILE_FLAG_SESSION_PROFILE_NAME;
peer_profile.default_session_profile_name.optstring_u.value = $3.buf;
peer_profile.default_session_profile_name.valid = 1;
}
| SESSION_PROFILE_NAME EQUALS QUOTEDSTRING
{
peer_profile.flags |= L2TP_API_PEER_PROFILE_FLAG_SESSION_PROFILE_NAME;
peer_profile.default_session_profile_name.optstring_u.value = $3.buf;
peer_profile.default_session_profile_name.valid = 1;
}
| PPP_PROFILE_NAME EQUALS STRING
{
peer_profile.flags |= L2TP_API_PEER_PROFILE_FLAG_PPP_PROFILE_NAME;
peer_profile.default_ppp_profile_name.optstring_u.value = $3.buf;
peer_profile.default_ppp_profile_name.valid = 1;
}
| PPP_PROFILE_NAME EQUALS QUOTEDSTRING
{
peer_profile.flags |= L2TP_API_PEER_PROFILE_FLAG_PPP_PROFILE_NAME;
peer_profile.default_ppp_profile_name.optstring_u.value = $3.buf;
peer_profile.default_ppp_profile_name.valid = 1;
}
;
tunnel_profile_command
: tunnel_profile_create_command
| tunnel_profile_modify_command
;
tunnel_profile_create_command
: TUNNEL PROFILE CREATE tunnel_profile_statements EOT
{
bool_t status;
int result;
if (tunnel_profile.profile_name == NULL)
yyfatal("missing profile name");
status = l2tp_tunnel_profile_create_1_svc(tunnel_profile, &result, NULL);
if ((status != TRUE) || ((result < 0) && (result != -L2TP_ERR_PROFILE_ALREADY_EXISTS)))
l2tp_log(LOG_ERR, "tunnel profile create: command failed: rc=%d", l2tp_strerror(-result));
memset(&tunnel_profile, 0, sizeof(tunnel_profile));
}
;
tunnel_profile_modify_command
: TUNNEL PROFILE MODIFY tunnel_profile_statements EOT
{
bool_t status;
int result;
if (tunnel_profile.profile_name == NULL)
yyfatal("missing profile name");
status = l2tp_tunnel_profile_modify_1_svc(tunnel_profile, &result, NULL);
if ((status != TRUE) || (result < 0))
l2tp_log(LOG_ERR, "tunnel profile modify: command failed: rc=%d", l2tp_strerror(-result));
memset(&tunnel_profile, 0, sizeof(tunnel_profile));
}
;
tunnel_profile_statements
: /* empty */
| tunnel_profile_statements tunnel_profile_statement
;
tunnel_profile_statement
: PROFILE_NAME EQUALS STRING
{
tunnel_profile.profile_name = $3.buf;
}
| PROFILE_NAME EQUALS QUOTEDSTRING
{
tunnel_profile.profile_name = $3.buf;
}
| HIDE_AVPS EQUALS BOOL
{
tunnel_profile.flags |= L2TP_API_TUNNEL_PROFILE_FLAG_HIDE_AVPS;
tunnel_profile.hide_avps = $3;
}
| AUTH_MODE EQUALS STRING
{
tunnel_profile.flags |= L2TP_API_TUNNEL_PROFILE_FLAG_AUTH_MODE;
if (strcasecmp($3.buf, "none") == 0) {
tunnel_profile.auth_mode = L2TP_API_TUNNEL_AUTH_MODE_NONE;
} else if (strcasecmp($3.buf, "simple") == 0) {
tunnel_profile.auth_mode = L2TP_API_TUNNEL_AUTH_MODE_SIMPLE;
} else if (strcasecmp($3.buf, "challenge") == 0) {
tunnel_profile.auth_mode = L2TP_API_TUNNEL_AUTH_MODE_CHALLENGE;
} else {
yyfatal("invalid auth_mode");
}
}
| FRAMING_CAP EQUALS STRING
{
tunnel_profile.flags |= L2TP_API_TUNNEL_PROFILE_FLAG_FRAMING_CAP;
if (strcasecmp($3.buf, "sync") == 0) {
tunnel_profile.framing_cap_sync = 1;
tunnel_profile.framing_cap_async = 0;
} else if (strcasecmp($3.buf, "async") == 0) {
tunnel_profile.framing_cap_sync = 0;
tunnel_profile.framing_cap_async = 1;
} else if (strcasecmp($3.buf, "any") == 0) {
tunnel_profile.framing_cap_sync = 1;
tunnel_profile.framing_cap_async = 1;
} else {
yyfatal("invalid framing_cap");
}
}
| BEARER_CAP EQUALS STRING
{
tunnel_profile.flags |= L2TP_API_TUNNEL_PROFILE_FLAG_BEARER_CAP;
if (strcasecmp($3.buf, "analog") == 0) {
tunnel_profile.bearer_cap_analog = 1;
tunnel_profile.bearer_cap_digital = 0;
} else if (strcasecmp($3.buf, "digital") == 0) {
tunnel_profile.bearer_cap_analog = 0;
tunnel_profile.bearer_cap_digital = 1;
} else if (strcasecmp($3.buf, "any") == 0) {
tunnel_profile.bearer_cap_analog = 1;
tunnel_profile.bearer_cap_digital = 1;
} else {
yyfatal("invalid bearer_cap");
}
}
| USE_TIEBREAKER EQUALS BOOL
{
tunnel_profile.flags |= L2TP_API_TUNNEL_PROFILE_FLAG_USE_TIEBREAKER;
tunnel_profile.use_tiebreaker = $3;
}
| HELLO_TIMEOUT EQUALS DECSTRING
{
tunnel_profile.flags |= L2TP_API_TUNNEL_PROFILE_FLAG_HELLO_TIMEOUT;
tunnel_profile.hello_timeout = $3;
}
| MAX_RETRIES EQUALS DECSTRING
{
tunnel_profile.flags |= L2TP_API_TUNNEL_PROFILE_FLAG_MAX_RETRIES;
tunnel_profile.max_retries = $3;
}
| RX_WINDOW_SIZE EQUALS DECSTRING
{
tunnel_profile.flags |= L2TP_API_TUNNEL_PROFILE_FLAG_RX_WINDOW_SIZE;
tunnel_profile.rx_window_size = $3;
}
| TX_WINDOW_SIZE EQUALS DECSTRING
{
tunnel_profile.flags |= L2TP_API_TUNNEL_PROFILE_FLAG_TX_WINDOW_SIZE;
tunnel_profile.tx_window_size = $3;
}
| RETRY_TIMEOUT EQUALS DECSTRING
{
tunnel_profile.flags |= L2TP_API_TUNNEL_PROFILE_FLAG_RETRY_TIMEOUT;
tunnel_profile.retry_timeout = $3;
}
| IDLE_TIMEOUT EQUALS DECSTRING
{
tunnel_profile.flags |= L2TP_API_TUNNEL_PROFILE_FLAG_IDLE_TIMEOUT;
tunnel_profile.idle_timeout = $3;
}
| SECRET EQUALS STRING
{
tunnel_profile.flags |= L2TP_API_TUNNEL_PROFILE_FLAG_SECRET;
tunnel_profile.secret.optstring_u.value = $3.buf;
tunnel_profile.secret.valid = 1;
}
| SECRET EQUALS QUOTEDSTRING
{
tunnel_profile.flags |= L2TP_API_TUNNEL_PROFILE_FLAG_SECRET;
tunnel_profile.secret.optstring_u.value = $3.buf;
tunnel_profile.secret.valid = 1;
}
| ALLOW_PPP_PROXY EQUALS BOOL
{
tunnel_profile.flags |= L2TP_API_TUNNEL_PROFILE_FLAG_ALLOW_PPP_PROXY;
tunnel_profile.allow_ppp_proxy = $3;
}
| TRACE_FLAGS EQUALS DECSTRING
{
tunnel_profile.flags |= L2TP_API_TUNNEL_PROFILE_FLAG_TRACE_FLAGS;
tunnel_profile.trace_flags = $3;
}
| USE_UDP_CHECKSUMS EQUALS BOOL
{
tunnel_profile.flags |= L2TP_API_TUNNEL_PROFILE_FLAG_USE_UDP_CHECKSUMS;
tunnel_profile.use_udp_checksums = $3;
}
| HOST_NAME EQUALS STRING
{
tunnel_profile.flags |= L2TP_API_TUNNEL_PROFILE_FLAG_HOST_NAME;
tunnel_profile.host_name.optstring_u.value = $3.buf;
tunnel_profile.host_name.valid = 1;
}
| HOST_NAME EQUALS QUOTEDSTRING
{
tunnel_profile.flags |= L2TP_API_TUNNEL_PROFILE_FLAG_HOST_NAME;
tunnel_profile.host_name.optstring_u.value = $3.buf;
tunnel_profile.host_name.valid = 1;
}
| MAX_SESSIONS EQUALS DECSTRING
{
tunnel_profile.flags |= L2TP_API_TUNNEL_PROFILE_FLAG_MAX_SESSIONS;
tunnel_profile.max_sessions = $3;
}
| SRC_IPADDR EQUALS IPADDRESS
{
struct in_addr addr;
tunnel_profile.flags |= L2TP_API_TUNNEL_PROFILE_FLAG_OUR_ADDR;
addr.s_addr = htonl($3);
tunnel_profile.our_addr.s_addr = addr.s_addr;
}
| DEST_IPADDR EQUALS IPADDRESS
{
struct in_addr addr;
tunnel_profile.flags |= L2TP_API_TUNNEL_PROFILE_FLAG_PEER_ADDR;
addr.s_addr = htonl($3);
tunnel_profile.peer_addr.s_addr = addr.s_addr;
}
| OUR_UDP_PORT EQUALS DECSTRING
{
tunnel_profile.flags |= L2TP_API_TUNNEL_PROFILE_FLAG_OUR_UDP_PORT;
tunnel_profile.our_udp_port = $3;
}
| PEER_UDP_PORT EQUALS DECSTRING
{
tunnel_profile.flags |= L2TP_API_TUNNEL_PROFILE_FLAG_PEER_UDP_PORT;
tunnel_profile.peer_udp_port = $3;
}
| PEER_PROFILE_NAME EQUALS STRING
{
tunnel_profile.flags |= L2TP_API_TUNNEL_PROFILE_FLAG_PEER_PROFILE_NAME;
tunnel_profile.peer_profile_name.optstring_u.value = $3.buf;
tunnel_profile.peer_profile_name.valid = 1;
}
| PEER_PROFILE_NAME EQUALS QUOTEDSTRING
{
tunnel_profile.flags |= L2TP_API_TUNNEL_PROFILE_FLAG_PEER_PROFILE_NAME;
tunnel_profile.peer_profile_name.optstring_u.value = $3.buf;
tunnel_profile.peer_profile_name.valid = 1;
}
| SESSION_PROFILE_NAME EQUALS STRING
{
tunnel_profile.flags |= L2TP_API_TUNNEL_PROFILE_FLAG_SESSION_PROFILE_NAME;
tunnel_profile.session_profile_name.optstring_u.value = $3.buf;
tunnel_profile.session_profile_name.valid = 1;
}
| SESSION_PROFILE_NAME EQUALS QUOTEDSTRING
{
tunnel_profile.flags |= L2TP_API_TUNNEL_PROFILE_FLAG_SESSION_PROFILE_NAME;
tunnel_profile.session_profile_name.optstring_u.value = $3.buf;
tunnel_profile.session_profile_name.valid = 1;
}
| PPP_PROFILE_NAME EQUALS STRING
{
tunnel_profile.flags |= L2TP_API_TUNNEL_PROFILE_FLAG_PPP_PROFILE_NAME;
tunnel_profile.ppp_profile_name.optstring_u.value = $3.buf;
tunnel_profile.ppp_profile_name.valid = 1;
}
| PPP_PROFILE_NAME EQUALS QUOTEDSTRING
{
tunnel_profile.flags |= L2TP_API_TUNNEL_PROFILE_FLAG_PPP_PROFILE_NAME;
tunnel_profile.ppp_profile_name.optstring_u.value = $3.buf;
tunnel_profile.ppp_profile_name.valid = 1;
}
| DO_PMTU_DISCOVERY EQUALS BOOL
{
tunnel_profile.flags |= L2TP_API_TUNNEL_PROFILE_FLAG_DO_PMTU_DISCOVERY;
tunnel_profile.do_pmtu_discovery = $3;
}
| MTU EQUALS DECSTRING
{
tunnel_profile.flags |= L2TP_API_TUNNEL_PROFILE_FLAG_MTU;
tunnel_profile.mtu = $3;
}
;
session_profile_command
: session_profile_create_command
| session_profile_modify_command
;
session_profile_create_command
: SESSION PROFILE CREATE session_profile_statements EOT
{
bool_t status;
int result;
if (session_profile.profile_name == NULL)
yyfatal("missing profile name");
status = l2tp_session_profile_create_1_svc(session_profile, &result, NULL);
if ((status != TRUE) || ((result < 0) && (result != -L2TP_ERR_PROFILE_ALREADY_EXISTS)))
l2tp_log(LOG_ERR, "session profile create: command failed: rc=%d", l2tp_strerror(-result));
memset(&session_profile, 0, sizeof(session_profile));
}
;
session_profile_modify_command
: SESSION PROFILE MODIFY session_profile_statements EOT
{
bool_t status;
int result;
if (session_profile.profile_name == NULL)
yyfatal("missing profile name");
status = l2tp_session_profile_modify_1_svc(session_profile, &result, NULL);
if ((status != TRUE) || (result < 0))
l2tp_log(LOG_ERR, "session profile modify: command failed: rc=%d", l2tp_strerror(-result));
memset(&session_profile, 0, sizeof(session_profile));
}
;
session_profile_statements
: /* empty */
| session_profile_statements session_profile_statement
;
session_profile_statement
: PROFILE_NAME EQUALS STRING
{
session_profile.profile_name = $3.buf;
}
| PROFILE_NAME EQUALS QUOTEDSTRING
{
session_profile.profile_name = $3.buf;
}
| TRACE_FLAGS EQUALS DECSTRING
{
session_profile.flags |= L2TP_API_SESSION_PROFILE_FLAG_TRACE_FLAGS;
session_profile.trace_flags = $3;
}
| SEQUENCING_REQUIRED EQUALS BOOL
{
session_profile.flags |= L2TP_API_SESSION_PROFILE_FLAG_SEQUENCING_REQUIRED;
session_profile.sequencing_required = $3;
}
| PPP_PROFILE_NAME EQUALS STRING
{
session_profile.flags |= L2TP_API_SESSION_PROFILE_FLAG_PPP_PROFILE_NAME;
OPTSTRING(session_profile.ppp_profile_name) = $3.buf;
session_profile.ppp_profile_name.valid = 1;
}
| PPP_PROFILE_NAME EQUALS QUOTEDSTRING
{
session_profile.flags |= L2TP_API_SESSION_PROFILE_FLAG_PPP_PROFILE_NAME;
OPTSTRING(session_profile.ppp_profile_name) = $3.buf;
session_profile.ppp_profile_name.valid = 1;
}
| SESSION_TYPE EQUALS STRING
{
session_profile.flags |= L2TP_API_SESSION_PROFILE_FLAG_SESSION_TYPE;
session_profile.flags |= L2TP_API_SESSION_FLAG_SESSION_TYPE;
if (strcasecmp($3.buf, "laic") == 0) {
session_profile.session_type = L2TP_API_SESSION_TYPE_LAIC;
} else if (strcasecmp($3.buf, "laoc") == 0) {
session_profile.session_type = L2TP_API_SESSION_TYPE_LAOC;
} else if (strcasecmp($3.buf, "lnic") == 0) {
session_profile.session_type = L2TP_API_SESSION_TYPE_LNIC;
} else if (strcasecmp($3.buf, "lnoc") == 0) {
session_profile.session_type = L2TP_API_SESSION_TYPE_LNOC;
} else {
yyfatal("Bad session type: expecting laic|laoc|lnic|lnoc");
}
}
| PRIV_GROUP_ID EQUALS STRING
{
session_profile.flags |= L2TP_API_SESSION_PROFILE_FLAG_PRIV_GROUP_ID;
OPTSTRING(session_profile.priv_group_id) = $3.buf;
session_profile.priv_group_id.valid = 1;
}
| PRIV_GROUP_ID EQUALS QUOTEDSTRING
{
session_profile.flags |= L2TP_API_SESSION_PROFILE_FLAG_PRIV_GROUP_ID;
OPTSTRING(session_profile.priv_group_id) = $3.buf;
session_profile.priv_group_id.valid = 1;
}
| FRAMING_TYPE EQUALS STRING
{
session_profile.flags |= L2TP_API_SESSION_PROFILE_FLAG_FRAMING_TYPE;
session_profile.flags |= L2TP_API_SESSION_FLAG_FRAMING_TYPE;
if (strcasecmp($3.buf, "sync") == 0) {
session_profile.framing_type_sync = 1;
session_profile.framing_type_async = 0;
} else if (strcasecmp($3.buf, "async") == 0) {
session_profile.framing_type_sync = 0;
session_profile.framing_type_async = 1;
} else if (strcasecmp($3.buf, "any") == 0) {
session_profile.framing_type_sync = 1;
session_profile.framing_type_async = 1;
} else {
yyfatal("invalid framing_type");
}
}
| BEARER_TYPE EQUALS STRING
{
session_profile.flags |= L2TP_API_SESSION_PROFILE_FLAG_BEARER_TYPE;
session_profile.flags |= L2TP_API_SESSION_FLAG_BEARER_TYPE;
if (strcasecmp($3.buf, "analog") == 0) {
session_profile.bearer_type_analog = 1;
session_profile.bearer_type_digital = 0;
} else if (strcasecmp($3.buf, "digital") == 0) {
session_profile.bearer_type_analog = 0;
session_profile.bearer_type_digital = 1;
} else if (strcasecmp($3.buf, "any") == 0) {
session_profile.bearer_type_analog = 1;
session_profile.bearer_type_digital = 1;
} else {
yyfatal("invalid bearer_type");
}
}
| MINIMUM_BPS EQUALS DECSTRING
{
session_profile.flags |= L2TP_API_SESSION_PROFILE_FLAG_MINIMUM_BPS;
session_profile.minimum_bps = $3;
}
| MAXIMUM_BPS EQUALS DECSTRING
{
session_profile.flags |= L2TP_API_SESSION_PROFILE_FLAG_MAXIMUM_BPS;
session_profile.maximum_bps = $3;
}
| CONNECT_SPEED EQUALS STRING
{
session_profile.flags |= L2TP_API_SESSION_PROFILE_FLAG_CONNECT_SPEED;
int ints[2];
int num_matches;
session_profile.flags |= L2TP_API_SESSION_FLAG_CONNECT_SPEED;
num_matches = sscanf($3.buf, "%d:%d", &ints[0], &ints[1]);
if (num_matches >= 1) {
session_profile.rx_connect_speed = ints[0];
session_profile.tx_connect_speed = ints[0];
if (num_matches == 2) {
session_profile.tx_connect_speed = ints[1];
}
} else {
yyfatal("Expecting connect_speed[:tx_connect_speed]");
}
}
| USE_PPP_PROXY EQUALS BOOL
{
session_profile.flags |= L2TP_API_SESSION_PROFILE_FLAG_USE_PPP_PROXY;
session_profile.use_ppp_proxy = $3;
}
| USE_SEQUENCE_NUMBERS EQUALS BOOL
{
session_profile.flags |= L2TP_API_SESSION_PROFILE_FLAG_USE_SEQUENCE_NUMBERS;
session_profile.use_sequence_numbers = $3;
}
| NO_PPP EQUALS BOOL
{
session_profile.flags |= L2TP_API_SESSION_PROFILE_FLAG_NO_PPP;
session_profile.no_ppp = $3;
}
| REORDER_TIMEOUT EQUALS DECSTRING
{
session_profile.flags |= L2TP_API_SESSION_PROFILE_FLAG_REORDER_TIMEOUT;
session_profile.reorder_timeout = $3;
}
;
ppp_profile_command
: ppp_profile_create_command
| ppp_profile_modify_command
;
ppp_profile_create_command
: PPP PROFILE CREATE ppp_profile_statements EOT
{
bool_t status;
int result;
if (ppp_profile.profile_name == NULL)
yyfatal("missing profile name");
status = l2tp_ppp_profile_create_1_svc(ppp_profile, &result, NULL);
if ((status != TRUE) || ((result < 0) && (result != -L2TP_ERR_PROFILE_ALREADY_EXISTS)))
l2tp_log(LOG_ERR, "ppp profile create: command failed: rc=%d", l2tp_strerror(-result));
memset(&ppp_profile, 0, sizeof(ppp_profile));
}
;
ppp_profile_modify_command
: PPP PROFILE MODIFY ppp_profile_statements EOT
{
bool_t status;
int result;
if (ppp_profile.profile_name == NULL)
yyfatal("missing profile name");
status = l2tp_ppp_profile_modify_1_svc(ppp_profile, &result, NULL);
if ((status != TRUE) || (result < 0))
l2tp_log(LOG_ERR, "ppp profile modify: command failed: rc=%d", l2tp_strerror(-result));
memset(&ppp_profile, 0, sizeof(ppp_profile));
}
;
ppp_profile_statements
: /* empty */
| ppp_profile_statements ppp_profile_statement
;
ppp_profile_statement
: PROFILE_NAME EQUALS STRING
{
ppp_profile.profile_name = $3.buf;
}
| PROFILE_NAME EQUALS QUOTEDSTRING
{
ppp_profile.profile_name = $3.buf;
}
| TRACE_FLAGS EQUALS DECSTRING
{
ppp_profile.flags |= L2TP_API_PPP_PROFILE_FLAG_TRACE_FLAGS;
ppp_profile.trace_flags = $3;
}
| ASYNCMAP EQUALS DECSTRING
{
ppp_profile.flags |= L2TP_API_PPP_PROFILE_FLAG_ASYNCMAP;
ppp_profile.asyncmap = $3;
}
| MRU EQUALS DECSTRING
{
ppp_profile.flags |= L2TP_API_PPP_PROFILE_FLAG_MRU;
ppp_profile.mru = $3;
}
| MTU EQUALS DECSTRING
{
ppp_profile.flags |= L2TP_API_PPP_PROFILE_FLAG_MTU;
ppp_profile.mtu = $3;
}
| USE_RADIUS EQUALS BOOL
{
ppp_profile.flags |= L2TP_API_PPP_PROFILE_FLAG_USE_RADIUS;
ppp_profile.use_radius = $3;
}
| RADIUS_HINT EQUALS STRING
{
ppp_profile.flags |= L2TP_API_PPP_PROFILE_FLAG_RADIUS_HINT;
OPTSTRING(ppp_profile.radius_hint) = $3.buf;
ppp_profile.radius_hint.valid = 1;
}
| RADIUS_HINT EQUALS QUOTEDSTRING
{
ppp_profile.flags |= L2TP_API_PPP_PROFILE_FLAG_RADIUS_HINT;
OPTSTRING(ppp_profile.radius_hint) = $3.buf;
ppp_profile.radius_hint.valid = 1;
}
| AUTH_PAP EQUALS BOOL
{
ppp_profile.flags2 |= L2TP_API_PPP_PROFILE_FLAG_AUTH_REFUSE_PAP;
if ($3) {
ppp_profile.auth_refuse_pap = 0;
} else {
ppp_profile.auth_refuse_pap = -1;
}
}
| AUTH_CHAP EQUALS BOOL
{
ppp_profile.flags2 |= L2TP_API_PPP_PROFILE_FLAG_AUTH_REFUSE_CHAP;
if ($3) {
ppp_profile.auth_refuse_chap = 0;
} else {
ppp_profile.auth_refuse_chap = -1;
}
}
| AUTH_MSCHAPV1 EQUALS BOOL
{
ppp_profile.flags2 |= L2TP_API_PPP_PROFILE_FLAG_AUTH_REFUSE_MSCHAP;
if ($3) {
ppp_profile.auth_refuse_mschap = 0;
} else {
ppp_profile.auth_refuse_mschap = -1;
}
}
| AUTH_MSCHAPV2 EQUALS BOOL
{
ppp_profile.flags2 |= L2TP_API_PPP_PROFILE_FLAG_AUTH_REFUSE_MSCHAPV2;
if ($3) {
ppp_profile.auth_refuse_mschapv2 = 0;
} else {
ppp_profile.auth_refuse_mschapv2 = -1;
}
}
| AUTH_EAP EQUALS BOOL
{
ppp_profile.flags2 |= L2TP_API_PPP_PROFILE_FLAG_AUTH_REFUSE_EAP;
if ($3) {
ppp_profile.auth_refuse_eap = 0;
} else {
ppp_profile.auth_refuse_eap = -1;
}
}
| AUTH_NOAUTH EQUALS BOOL
{
ppp_profile.flags2 |= L2TP_API_PPP_PROFILE_FLAG_AUTH_NONE;
if ($3) {
ppp_profile.auth_none = -1;
} else {
ppp_profile.auth_none = 0;
}
}
| AUTH_PEER EQUALS BOOL
{
ppp_profile.flags2 |= L2TP_API_PPP_PROFILE_FLAG_AUTH_PEER;
if ($3) {
ppp_profile.auth_peer = -1;
} else {
ppp_profile.auth_peer = 0;
}
}
| SYNC_MODE EQUALS STRING
{
ppp_profile.flags |= L2TP_API_PPP_PROFILE_FLAG_SYNC_MODE;
if (strcasecmp($3.buf, "sync") == 0) {
ppp_profile.sync_mode = L2TP_API_PPP_SYNCMODE_SYNC;
} else if (strcasecmp($3.buf, "async") == 0) {
ppp_profile.sync_mode = L2TP_API_PPP_SYNCMODE_ASYNC;
} else if (strcasecmp($3.buf, "any") == 0) {
ppp_profile.sync_mode = L2TP_API_PPP_SYNCMODE_SYNC_ASYNC;
} else {
yyfatal("Bad sync mode: expecting sync|async|any");
}
}
| CHAP_INTERVAL EQUALS DECSTRING
{
ppp_profile.flags |= L2TP_API_PPP_PROFILE_FLAG_CHAP_INTERVAL;
ppp_profile.chap_interval = $3;
}
| CHAP_MAX_CHALLENGE EQUALS DECSTRING
{
ppp_profile.flags |= L2TP_API_PPP_PROFILE_FLAG_CHAP_MAX_CHALLENGE;
ppp_profile.chap_max_challenge = $3;
}
| CHAP_RESTART EQUALS DECSTRING
{
ppp_profile.flags |= L2TP_API_PPP_PROFILE_FLAG_CHAP_RESTART;
ppp_profile.chap_restart = $3;
}
| PAP_MAX_AUTH_REQUESTS EQUALS DECSTRING
{
ppp_profile.flags |= L2TP_API_PPP_PROFILE_FLAG_PAP_MAX_AUTH_REQUESTS;
ppp_profile.pap_max_auth_requests = $3;