forked from osrg/gobgp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbgp_configs.go
6190 lines (5763 loc) · 204 KB
/
bgp_configs.go
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
// DO NOT EDIT
// generated by pyang using OpenConfig https://github.com/openconfig/public
//
// Copyright (C) 2014-2016 Nippon Telegraph and Telephone Corporation.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
// implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package config
import (
"fmt"
"github.com/osrg/gobgp/packet/bgp"
)
func mapkey(index int, name string) string {
if name != "" {
return name
}
return fmt.Sprintf("%v", index)
}
// typedef for typedef openconfig-types:std-regexp.
type StdRegexp string
// typedef for typedef openconfig-types:percentage.
type Percentage uint8
// typedef for typedef bgp-types:rr-cluster-id-type.
type RrClusterIdType string
// typedef for identity bgp-types:remove-private-as-option.
// set of options for configuring how private AS path numbers
// are removed from advertisements.
type RemovePrivateAsOption string
const (
REMOVE_PRIVATE_AS_OPTION_ALL RemovePrivateAsOption = "all"
REMOVE_PRIVATE_AS_OPTION_REPLACE RemovePrivateAsOption = "replace"
)
var RemovePrivateAsOptionToIntMap = map[RemovePrivateAsOption]int{
REMOVE_PRIVATE_AS_OPTION_ALL: 0,
REMOVE_PRIVATE_AS_OPTION_REPLACE: 1,
}
func (v RemovePrivateAsOption) ToInt() int {
i, ok := RemovePrivateAsOptionToIntMap[v]
if !ok {
return -1
}
return i
}
var IntToRemovePrivateAsOptionMap = map[int]RemovePrivateAsOption{
0: REMOVE_PRIVATE_AS_OPTION_ALL,
1: REMOVE_PRIVATE_AS_OPTION_REPLACE,
}
func (v RemovePrivateAsOption) Validate() error {
if _, ok := RemovePrivateAsOptionToIntMap[v]; !ok {
return fmt.Errorf("invalid RemovePrivateAsOption: %s", v)
}
return nil
}
// typedef for typedef bgp-types:bgp-community-regexp-type.
type BgpCommunityRegexpType StdRegexp
// typedef for identity bgp-types:community-type.
// type describing variations of community attributes:
// STANDARD: standard BGP community [rfc1997]
// EXTENDED: extended BGP community [rfc4360]
// BOTH: both standard and extended community.
type CommunityType string
const (
COMMUNITY_TYPE_STANDARD CommunityType = "standard"
COMMUNITY_TYPE_EXTENDED CommunityType = "extended"
COMMUNITY_TYPE_BOTH CommunityType = "both"
COMMUNITY_TYPE_NONE CommunityType = "none"
)
var CommunityTypeToIntMap = map[CommunityType]int{
COMMUNITY_TYPE_STANDARD: 0,
COMMUNITY_TYPE_EXTENDED: 1,
COMMUNITY_TYPE_BOTH: 2,
COMMUNITY_TYPE_NONE: 3,
}
func (v CommunityType) ToInt() int {
i, ok := CommunityTypeToIntMap[v]
if !ok {
return -1
}
return i
}
var IntToCommunityTypeMap = map[int]CommunityType{
0: COMMUNITY_TYPE_STANDARD,
1: COMMUNITY_TYPE_EXTENDED,
2: COMMUNITY_TYPE_BOTH,
3: COMMUNITY_TYPE_NONE,
}
func (v CommunityType) Validate() error {
if _, ok := CommunityTypeToIntMap[v]; !ok {
return fmt.Errorf("invalid CommunityType: %s", v)
}
return nil
}
// typedef for typedef bgp-types:bgp-ext-community-type.
type BgpExtCommunityType string
// typedef for typedef bgp-types:bgp-std-community-type.
type BgpStdCommunityType string
// typedef for identity bgp-types:peer-type.
// labels a peer or peer group as explicitly internal or
// external.
type PeerType string
const (
PEER_TYPE_INTERNAL PeerType = "internal"
PEER_TYPE_EXTERNAL PeerType = "external"
)
var PeerTypeToIntMap = map[PeerType]int{
PEER_TYPE_INTERNAL: 0,
PEER_TYPE_EXTERNAL: 1,
}
func (v PeerType) ToInt() int {
i, ok := PeerTypeToIntMap[v]
if !ok {
return -1
}
return i
}
var IntToPeerTypeMap = map[int]PeerType{
0: PEER_TYPE_INTERNAL,
1: PEER_TYPE_EXTERNAL,
}
func (v PeerType) Validate() error {
if _, ok := PeerTypeToIntMap[v]; !ok {
return fmt.Errorf("invalid PeerType: %s", v)
}
return nil
}
// typedef for identity bgp-types:bgp-session-direction.
// Type to describe the direction of NLRI transmission.
type BgpSessionDirection string
const (
BGP_SESSION_DIRECTION_INBOUND BgpSessionDirection = "inbound"
BGP_SESSION_DIRECTION_OUTBOUND BgpSessionDirection = "outbound"
)
var BgpSessionDirectionToIntMap = map[BgpSessionDirection]int{
BGP_SESSION_DIRECTION_INBOUND: 0,
BGP_SESSION_DIRECTION_OUTBOUND: 1,
}
func (v BgpSessionDirection) ToInt() int {
i, ok := BgpSessionDirectionToIntMap[v]
if !ok {
return -1
}
return i
}
var IntToBgpSessionDirectionMap = map[int]BgpSessionDirection{
0: BGP_SESSION_DIRECTION_INBOUND,
1: BGP_SESSION_DIRECTION_OUTBOUND,
}
func (v BgpSessionDirection) Validate() error {
if _, ok := BgpSessionDirectionToIntMap[v]; !ok {
return fmt.Errorf("invalid BgpSessionDirection: %s", v)
}
return nil
}
// typedef for identity bgp-types:bgp-origin-attr-type.
// Type definition for standard BGP origin attribute.
type BgpOriginAttrType string
const (
BGP_ORIGIN_ATTR_TYPE_IGP BgpOriginAttrType = "igp"
BGP_ORIGIN_ATTR_TYPE_EGP BgpOriginAttrType = "egp"
BGP_ORIGIN_ATTR_TYPE_INCOMPLETE BgpOriginAttrType = "incomplete"
)
var BgpOriginAttrTypeToIntMap = map[BgpOriginAttrType]int{
BGP_ORIGIN_ATTR_TYPE_IGP: 0,
BGP_ORIGIN_ATTR_TYPE_EGP: 1,
BGP_ORIGIN_ATTR_TYPE_INCOMPLETE: 2,
}
func (v BgpOriginAttrType) ToInt() int {
i, ok := BgpOriginAttrTypeToIntMap[v]
if !ok {
return -1
}
return i
}
var IntToBgpOriginAttrTypeMap = map[int]BgpOriginAttrType{
0: BGP_ORIGIN_ATTR_TYPE_IGP,
1: BGP_ORIGIN_ATTR_TYPE_EGP,
2: BGP_ORIGIN_ATTR_TYPE_INCOMPLETE,
}
func (v BgpOriginAttrType) Validate() error {
if _, ok := BgpOriginAttrTypeToIntMap[v]; !ok {
return fmt.Errorf("invalid BgpOriginAttrType: %s", v)
}
return nil
}
// typedef for identity bgp-types:afi-safi-type.
// Base identity type for AFI,SAFI tuples for BGP-4.
type AfiSafiType string
const (
AFI_SAFI_TYPE_IPV4_UNICAST AfiSafiType = "ipv4-unicast"
AFI_SAFI_TYPE_IPV6_UNICAST AfiSafiType = "ipv6-unicast"
AFI_SAFI_TYPE_IPV4_LABELLED_UNICAST AfiSafiType = "ipv4-labelled-unicast"
AFI_SAFI_TYPE_IPV6_LABELLED_UNICAST AfiSafiType = "ipv6-labelled-unicast"
AFI_SAFI_TYPE_L3VPN_IPV4_UNICAST AfiSafiType = "l3vpn-ipv4-unicast"
AFI_SAFI_TYPE_L3VPN_IPV6_UNICAST AfiSafiType = "l3vpn-ipv6-unicast"
AFI_SAFI_TYPE_L3VPN_IPV4_MULTICAST AfiSafiType = "l3vpn-ipv4-multicast"
AFI_SAFI_TYPE_L3VPN_IPV6_MULTICAST AfiSafiType = "l3vpn-ipv6-multicast"
AFI_SAFI_TYPE_L2VPN_VPLS AfiSafiType = "l2vpn-vpls"
AFI_SAFI_TYPE_L2VPN_EVPN AfiSafiType = "l2vpn-evpn"
AFI_SAFI_TYPE_IPV4_MULTICAST AfiSafiType = "ipv4-multicast"
AFI_SAFI_TYPE_IPV6_MULTICAST AfiSafiType = "ipv6-multicast"
AFI_SAFI_TYPE_RTC AfiSafiType = "rtc"
AFI_SAFI_TYPE_IPV4_ENCAP AfiSafiType = "ipv4-encap"
AFI_SAFI_TYPE_IPV6_ENCAP AfiSafiType = "ipv6-encap"
AFI_SAFI_TYPE_IPV4_FLOWSPEC AfiSafiType = "ipv4-flowspec"
AFI_SAFI_TYPE_L3VPN_IPV4_FLOWSPEC AfiSafiType = "l3vpn-ipv4-flowspec"
AFI_SAFI_TYPE_IPV6_FLOWSPEC AfiSafiType = "ipv6-flowspec"
AFI_SAFI_TYPE_L3VPN_IPV6_FLOWSPEC AfiSafiType = "l3vpn-ipv6-flowspec"
AFI_SAFI_TYPE_L2VPN_FLOWSPEC AfiSafiType = "l2vpn-flowspec"
AFI_SAFI_TYPE_OPAQUE AfiSafiType = "opaque"
)
var AfiSafiTypeToIntMap = map[AfiSafiType]int{
AFI_SAFI_TYPE_IPV4_UNICAST: 0,
AFI_SAFI_TYPE_IPV6_UNICAST: 1,
AFI_SAFI_TYPE_IPV4_LABELLED_UNICAST: 2,
AFI_SAFI_TYPE_IPV6_LABELLED_UNICAST: 3,
AFI_SAFI_TYPE_L3VPN_IPV4_UNICAST: 4,
AFI_SAFI_TYPE_L3VPN_IPV6_UNICAST: 5,
AFI_SAFI_TYPE_L3VPN_IPV4_MULTICAST: 6,
AFI_SAFI_TYPE_L3VPN_IPV6_MULTICAST: 7,
AFI_SAFI_TYPE_L2VPN_VPLS: 8,
AFI_SAFI_TYPE_L2VPN_EVPN: 9,
AFI_SAFI_TYPE_IPV4_MULTICAST: 10,
AFI_SAFI_TYPE_IPV6_MULTICAST: 11,
AFI_SAFI_TYPE_RTC: 12,
AFI_SAFI_TYPE_IPV4_ENCAP: 13,
AFI_SAFI_TYPE_IPV6_ENCAP: 14,
AFI_SAFI_TYPE_IPV4_FLOWSPEC: 15,
AFI_SAFI_TYPE_L3VPN_IPV4_FLOWSPEC: 16,
AFI_SAFI_TYPE_IPV6_FLOWSPEC: 17,
AFI_SAFI_TYPE_L3VPN_IPV6_FLOWSPEC: 18,
AFI_SAFI_TYPE_L2VPN_FLOWSPEC: 19,
AFI_SAFI_TYPE_OPAQUE: 20,
}
func (v AfiSafiType) ToInt() int {
i, ok := AfiSafiTypeToIntMap[v]
if !ok {
return -1
}
return i
}
var IntToAfiSafiTypeMap = map[int]AfiSafiType{
0: AFI_SAFI_TYPE_IPV4_UNICAST,
1: AFI_SAFI_TYPE_IPV6_UNICAST,
2: AFI_SAFI_TYPE_IPV4_LABELLED_UNICAST,
3: AFI_SAFI_TYPE_IPV6_LABELLED_UNICAST,
4: AFI_SAFI_TYPE_L3VPN_IPV4_UNICAST,
5: AFI_SAFI_TYPE_L3VPN_IPV6_UNICAST,
6: AFI_SAFI_TYPE_L3VPN_IPV4_MULTICAST,
7: AFI_SAFI_TYPE_L3VPN_IPV6_MULTICAST,
8: AFI_SAFI_TYPE_L2VPN_VPLS,
9: AFI_SAFI_TYPE_L2VPN_EVPN,
10: AFI_SAFI_TYPE_IPV4_MULTICAST,
11: AFI_SAFI_TYPE_IPV6_MULTICAST,
12: AFI_SAFI_TYPE_RTC,
13: AFI_SAFI_TYPE_IPV4_ENCAP,
14: AFI_SAFI_TYPE_IPV6_ENCAP,
15: AFI_SAFI_TYPE_IPV4_FLOWSPEC,
16: AFI_SAFI_TYPE_L3VPN_IPV4_FLOWSPEC,
17: AFI_SAFI_TYPE_IPV6_FLOWSPEC,
18: AFI_SAFI_TYPE_L3VPN_IPV6_FLOWSPEC,
19: AFI_SAFI_TYPE_L2VPN_FLOWSPEC,
20: AFI_SAFI_TYPE_OPAQUE,
}
func (v AfiSafiType) Validate() error {
if _, ok := AfiSafiTypeToIntMap[v]; !ok {
return fmt.Errorf("invalid AfiSafiType: %s", v)
}
return nil
}
// typedef for identity bgp-types:bgp-capability.
// Base identity for a BGP capability.
type BgpCapability string
const (
BGP_CAPABILITY_MPBGP BgpCapability = "mpbgp"
BGP_CAPABILITY_ROUTE_REFRESH BgpCapability = "route-refresh"
BGP_CAPABILITY_ASN32 BgpCapability = "asn32"
BGP_CAPABILITY_GRACEFUL_RESTART BgpCapability = "graceful-restart"
BGP_CAPABILITY_ADD_PATHS BgpCapability = "add-paths"
)
var BgpCapabilityToIntMap = map[BgpCapability]int{
BGP_CAPABILITY_MPBGP: 0,
BGP_CAPABILITY_ROUTE_REFRESH: 1,
BGP_CAPABILITY_ASN32: 2,
BGP_CAPABILITY_GRACEFUL_RESTART: 3,
BGP_CAPABILITY_ADD_PATHS: 4,
}
func (v BgpCapability) ToInt() int {
i, ok := BgpCapabilityToIntMap[v]
if !ok {
return -1
}
return i
}
var IntToBgpCapabilityMap = map[int]BgpCapability{
0: BGP_CAPABILITY_MPBGP,
1: BGP_CAPABILITY_ROUTE_REFRESH,
2: BGP_CAPABILITY_ASN32,
3: BGP_CAPABILITY_GRACEFUL_RESTART,
4: BGP_CAPABILITY_ADD_PATHS,
}
func (v BgpCapability) Validate() error {
if _, ok := BgpCapabilityToIntMap[v]; !ok {
return fmt.Errorf("invalid BgpCapability: %s", v)
}
return nil
}
// typedef for identity bgp-types:bgp-well-known-std-community.
// Reserved communities within the standard community space
// defined by RFC1997. These communities must fall within the
// range 0x00000000 to 0xFFFFFFFF.
type BgpWellKnownStdCommunity string
const (
BGP_WELL_KNOWN_STD_COMMUNITY_NO_EXPORT BgpWellKnownStdCommunity = "no_export"
BGP_WELL_KNOWN_STD_COMMUNITY_NO_ADVERTISE BgpWellKnownStdCommunity = "no_advertise"
BGP_WELL_KNOWN_STD_COMMUNITY_NO_EXPORT_SUBCONFED BgpWellKnownStdCommunity = "no_export_subconfed"
BGP_WELL_KNOWN_STD_COMMUNITY_NOPEER BgpWellKnownStdCommunity = "nopeer"
)
var BgpWellKnownStdCommunityToIntMap = map[BgpWellKnownStdCommunity]int{
BGP_WELL_KNOWN_STD_COMMUNITY_NO_EXPORT: 0,
BGP_WELL_KNOWN_STD_COMMUNITY_NO_ADVERTISE: 1,
BGP_WELL_KNOWN_STD_COMMUNITY_NO_EXPORT_SUBCONFED: 2,
BGP_WELL_KNOWN_STD_COMMUNITY_NOPEER: 3,
}
func (v BgpWellKnownStdCommunity) ToInt() int {
i, ok := BgpWellKnownStdCommunityToIntMap[v]
if !ok {
return -1
}
return i
}
var IntToBgpWellKnownStdCommunityMap = map[int]BgpWellKnownStdCommunity{
0: BGP_WELL_KNOWN_STD_COMMUNITY_NO_EXPORT,
1: BGP_WELL_KNOWN_STD_COMMUNITY_NO_ADVERTISE,
2: BGP_WELL_KNOWN_STD_COMMUNITY_NO_EXPORT_SUBCONFED,
3: BGP_WELL_KNOWN_STD_COMMUNITY_NOPEER,
}
func (v BgpWellKnownStdCommunity) Validate() error {
if _, ok := BgpWellKnownStdCommunityToIntMap[v]; !ok {
return fmt.Errorf("invalid BgpWellKnownStdCommunity: %s", v)
}
return nil
}
// typedef for identity ptypes:match-set-options-restricted-type.
// Options that govern the behavior of a match statement. The
// default behavior is ANY, i.e., the given value matches any
// of the members of the defined set. Note this type is a
// restricted version of the match-set-options-type.
type MatchSetOptionsRestrictedType string
const (
MATCH_SET_OPTIONS_RESTRICTED_TYPE_ANY MatchSetOptionsRestrictedType = "any"
MATCH_SET_OPTIONS_RESTRICTED_TYPE_INVERT MatchSetOptionsRestrictedType = "invert"
)
var MatchSetOptionsRestrictedTypeToIntMap = map[MatchSetOptionsRestrictedType]int{
MATCH_SET_OPTIONS_RESTRICTED_TYPE_ANY: 0,
MATCH_SET_OPTIONS_RESTRICTED_TYPE_INVERT: 1,
}
func (v MatchSetOptionsRestrictedType) ToInt() int {
i, ok := MatchSetOptionsRestrictedTypeToIntMap[v]
if !ok {
return -1
}
return i
}
var IntToMatchSetOptionsRestrictedTypeMap = map[int]MatchSetOptionsRestrictedType{
0: MATCH_SET_OPTIONS_RESTRICTED_TYPE_ANY,
1: MATCH_SET_OPTIONS_RESTRICTED_TYPE_INVERT,
}
func (v MatchSetOptionsRestrictedType) Validate() error {
if _, ok := MatchSetOptionsRestrictedTypeToIntMap[v]; !ok {
return fmt.Errorf("invalid MatchSetOptionsRestrictedType: %s", v)
}
return nil
}
func (v MatchSetOptionsRestrictedType) Default() MatchSetOptionsRestrictedType {
return MATCH_SET_OPTIONS_RESTRICTED_TYPE_ANY
}
func (v MatchSetOptionsRestrictedType) DefaultAsNeeded() MatchSetOptionsRestrictedType {
if string(v) == "" {
return v.Default()
}
return v
}
// typedef for identity ptypes:match-set-options-type.
// Options that govern the behavior of a match statement. The
// default behavior is ANY, i.e., the given value matches any
// of the members of the defined set.
type MatchSetOptionsType string
const (
MATCH_SET_OPTIONS_TYPE_ANY MatchSetOptionsType = "any"
MATCH_SET_OPTIONS_TYPE_ALL MatchSetOptionsType = "all"
MATCH_SET_OPTIONS_TYPE_INVERT MatchSetOptionsType = "invert"
)
var MatchSetOptionsTypeToIntMap = map[MatchSetOptionsType]int{
MATCH_SET_OPTIONS_TYPE_ANY: 0,
MATCH_SET_OPTIONS_TYPE_ALL: 1,
MATCH_SET_OPTIONS_TYPE_INVERT: 2,
}
func (v MatchSetOptionsType) ToInt() int {
i, ok := MatchSetOptionsTypeToIntMap[v]
if !ok {
return -1
}
return i
}
var IntToMatchSetOptionsTypeMap = map[int]MatchSetOptionsType{
0: MATCH_SET_OPTIONS_TYPE_ANY,
1: MATCH_SET_OPTIONS_TYPE_ALL,
2: MATCH_SET_OPTIONS_TYPE_INVERT,
}
func (v MatchSetOptionsType) Validate() error {
if _, ok := MatchSetOptionsTypeToIntMap[v]; !ok {
return fmt.Errorf("invalid MatchSetOptionsType: %s", v)
}
return nil
}
func (v MatchSetOptionsType) Default() MatchSetOptionsType {
return MATCH_SET_OPTIONS_TYPE_ANY
}
func (v MatchSetOptionsType) DefaultAsNeeded() MatchSetOptionsType {
if string(v) == "" {
return v.Default()
}
return v
}
// typedef for typedef ptypes:tag-type.
type TagType string
// typedef for identity ptypes:install-protocol-type.
// Base type for protocols which can install prefixes into the
// RIB.
type InstallProtocolType string
const (
INSTALL_PROTOCOL_TYPE_BGP InstallProtocolType = "bgp"
INSTALL_PROTOCOL_TYPE_ISIS InstallProtocolType = "isis"
INSTALL_PROTOCOL_TYPE_OSPF InstallProtocolType = "ospf"
INSTALL_PROTOCOL_TYPE_OSPF3 InstallProtocolType = "ospf3"
INSTALL_PROTOCOL_TYPE_STATIC InstallProtocolType = "static"
INSTALL_PROTOCOL_TYPE_DIRECTLY_CONNECTED InstallProtocolType = "directly-connected"
INSTALL_PROTOCOL_TYPE_LOCAL_AGGREGATE InstallProtocolType = "local-aggregate"
)
var InstallProtocolTypeToIntMap = map[InstallProtocolType]int{
INSTALL_PROTOCOL_TYPE_BGP: 0,
INSTALL_PROTOCOL_TYPE_ISIS: 1,
INSTALL_PROTOCOL_TYPE_OSPF: 2,
INSTALL_PROTOCOL_TYPE_OSPF3: 3,
INSTALL_PROTOCOL_TYPE_STATIC: 4,
INSTALL_PROTOCOL_TYPE_DIRECTLY_CONNECTED: 5,
INSTALL_PROTOCOL_TYPE_LOCAL_AGGREGATE: 6,
}
func (v InstallProtocolType) ToInt() int {
i, ok := InstallProtocolTypeToIntMap[v]
if !ok {
return -1
}
return i
}
var IntToInstallProtocolTypeMap = map[int]InstallProtocolType{
0: INSTALL_PROTOCOL_TYPE_BGP,
1: INSTALL_PROTOCOL_TYPE_ISIS,
2: INSTALL_PROTOCOL_TYPE_OSPF,
3: INSTALL_PROTOCOL_TYPE_OSPF3,
4: INSTALL_PROTOCOL_TYPE_STATIC,
5: INSTALL_PROTOCOL_TYPE_DIRECTLY_CONNECTED,
6: INSTALL_PROTOCOL_TYPE_LOCAL_AGGREGATE,
}
func (v InstallProtocolType) Validate() error {
if _, ok := InstallProtocolTypeToIntMap[v]; !ok {
return fmt.Errorf("invalid InstallProtocolType: %s", v)
}
return nil
}
// typedef for identity ptypes:attribute-comparison.
// base type for supported comparison operators on route
// attributes.
type AttributeComparison string
const (
ATTRIBUTE_COMPARISON_ATTRIBUTE_EQ AttributeComparison = "attribute-eq"
ATTRIBUTE_COMPARISON_ATTRIBUTE_GE AttributeComparison = "attribute-ge"
ATTRIBUTE_COMPARISON_ATTRIBUTE_LE AttributeComparison = "attribute-le"
ATTRIBUTE_COMPARISON_EQ AttributeComparison = "eq"
ATTRIBUTE_COMPARISON_GE AttributeComparison = "ge"
ATTRIBUTE_COMPARISON_LE AttributeComparison = "le"
)
var AttributeComparisonToIntMap = map[AttributeComparison]int{
ATTRIBUTE_COMPARISON_ATTRIBUTE_EQ: 0,
ATTRIBUTE_COMPARISON_ATTRIBUTE_GE: 1,
ATTRIBUTE_COMPARISON_ATTRIBUTE_LE: 2,
ATTRIBUTE_COMPARISON_EQ: 3,
ATTRIBUTE_COMPARISON_GE: 4,
ATTRIBUTE_COMPARISON_LE: 5,
}
func (v AttributeComparison) ToInt() int {
i, ok := AttributeComparisonToIntMap[v]
if !ok {
return -1
}
return i
}
var IntToAttributeComparisonMap = map[int]AttributeComparison{
0: ATTRIBUTE_COMPARISON_ATTRIBUTE_EQ,
1: ATTRIBUTE_COMPARISON_ATTRIBUTE_GE,
2: ATTRIBUTE_COMPARISON_ATTRIBUTE_LE,
3: ATTRIBUTE_COMPARISON_EQ,
4: ATTRIBUTE_COMPARISON_GE,
5: ATTRIBUTE_COMPARISON_LE,
}
func (v AttributeComparison) Validate() error {
if _, ok := AttributeComparisonToIntMap[v]; !ok {
return fmt.Errorf("invalid AttributeComparison: %s", v)
}
return nil
}
// typedef for identity rpol:route-disposition.
// Select the final disposition for the route, either
// accept or reject.
type RouteDisposition string
const (
ROUTE_DISPOSITION_NONE RouteDisposition = "none"
ROUTE_DISPOSITION_ACCEPT_ROUTE RouteDisposition = "accept-route"
ROUTE_DISPOSITION_REJECT_ROUTE RouteDisposition = "reject-route"
)
var RouteDispositionToIntMap = map[RouteDisposition]int{
ROUTE_DISPOSITION_NONE: 0,
ROUTE_DISPOSITION_ACCEPT_ROUTE: 1,
ROUTE_DISPOSITION_REJECT_ROUTE: 2,
}
func (v RouteDisposition) ToInt() int {
i, ok := RouteDispositionToIntMap[v]
if !ok {
return -1
}
return i
}
var IntToRouteDispositionMap = map[int]RouteDisposition{
0: ROUTE_DISPOSITION_NONE,
1: ROUTE_DISPOSITION_ACCEPT_ROUTE,
2: ROUTE_DISPOSITION_REJECT_ROUTE,
}
func (v RouteDisposition) Validate() error {
if _, ok := RouteDispositionToIntMap[v]; !ok {
return fmt.Errorf("invalid RouteDisposition: %s", v)
}
return nil
}
// typedef for identity rpol:route-type.
// Condition to check the route type in the route update.
type RouteType string
const (
ROUTE_TYPE_NONE RouteType = "none"
ROUTE_TYPE_INTERNAL RouteType = "internal"
ROUTE_TYPE_EXTERNAL RouteType = "external"
ROUTE_TYPE_LOCAL RouteType = "local"
)
var RouteTypeToIntMap = map[RouteType]int{
ROUTE_TYPE_NONE: 0,
ROUTE_TYPE_INTERNAL: 1,
ROUTE_TYPE_EXTERNAL: 2,
ROUTE_TYPE_LOCAL: 3,
}
func (v RouteType) ToInt() int {
i, ok := RouteTypeToIntMap[v]
if !ok {
return -1
}
return i
}
var IntToRouteTypeMap = map[int]RouteType{
0: ROUTE_TYPE_NONE,
1: ROUTE_TYPE_INTERNAL,
2: ROUTE_TYPE_EXTERNAL,
3: ROUTE_TYPE_LOCAL,
}
func (v RouteType) Validate() error {
if _, ok := RouteTypeToIntMap[v]; !ok {
return fmt.Errorf("invalid RouteType: %s", v)
}
return nil
}
// typedef for identity rpol:default-policy-type.
// type used to specify default route disposition in
// a policy chain.
type DefaultPolicyType string
const (
DEFAULT_POLICY_TYPE_ACCEPT_ROUTE DefaultPolicyType = "accept-route"
DEFAULT_POLICY_TYPE_REJECT_ROUTE DefaultPolicyType = "reject-route"
)
var DefaultPolicyTypeToIntMap = map[DefaultPolicyType]int{
DEFAULT_POLICY_TYPE_ACCEPT_ROUTE: 0,
DEFAULT_POLICY_TYPE_REJECT_ROUTE: 1,
}
func (v DefaultPolicyType) ToInt() int {
i, ok := DefaultPolicyTypeToIntMap[v]
if !ok {
return -1
}
return i
}
var IntToDefaultPolicyTypeMap = map[int]DefaultPolicyType{
0: DEFAULT_POLICY_TYPE_ACCEPT_ROUTE,
1: DEFAULT_POLICY_TYPE_REJECT_ROUTE,
}
func (v DefaultPolicyType) Validate() error {
if _, ok := DefaultPolicyTypeToIntMap[v]; !ok {
return fmt.Errorf("invalid DefaultPolicyType: %s", v)
}
return nil
}
// typedef for identity bgp:session-state.
// Operational state of the BGP peer.
type SessionState string
const (
SESSION_STATE_IDLE SessionState = "idle"
SESSION_STATE_CONNECT SessionState = "connect"
SESSION_STATE_ACTIVE SessionState = "active"
SESSION_STATE_OPENSENT SessionState = "opensent"
SESSION_STATE_OPENCONFIRM SessionState = "openconfirm"
SESSION_STATE_ESTABLISHED SessionState = "established"
)
var SessionStateToIntMap = map[SessionState]int{
SESSION_STATE_IDLE: 0,
SESSION_STATE_CONNECT: 1,
SESSION_STATE_ACTIVE: 2,
SESSION_STATE_OPENSENT: 3,
SESSION_STATE_OPENCONFIRM: 4,
SESSION_STATE_ESTABLISHED: 5,
}
func (v SessionState) ToInt() int {
i, ok := SessionStateToIntMap[v]
if !ok {
return -1
}
return i
}
var IntToSessionStateMap = map[int]SessionState{
0: SESSION_STATE_IDLE,
1: SESSION_STATE_CONNECT,
2: SESSION_STATE_ACTIVE,
3: SESSION_STATE_OPENSENT,
4: SESSION_STATE_OPENCONFIRM,
5: SESSION_STATE_ESTABLISHED,
}
func (v SessionState) Validate() error {
if _, ok := SessionStateToIntMap[v]; !ok {
return fmt.Errorf("invalid SessionState: %s", v)
}
return nil
}
// typedef for identity bgp:admin-state.
type AdminState string
const (
ADMIN_STATE_UP AdminState = "up"
ADMIN_STATE_DOWN AdminState = "down"
ADMIN_STATE_PFX_CT AdminState = "pfx_ct"
)
var AdminStateToIntMap = map[AdminState]int{
ADMIN_STATE_UP: 0,
ADMIN_STATE_DOWN: 1,
ADMIN_STATE_PFX_CT: 2,
}
func (v AdminState) ToInt() int {
i, ok := AdminStateToIntMap[v]
if !ok {
return -1
}
return i
}
var IntToAdminStateMap = map[int]AdminState{
0: ADMIN_STATE_UP,
1: ADMIN_STATE_DOWN,
2: ADMIN_STATE_PFX_CT,
}
func (v AdminState) Validate() error {
if _, ok := AdminStateToIntMap[v]; !ok {
return fmt.Errorf("invalid AdminState: %s", v)
}
return nil
}
// typedef for identity bgp:mode.
// Ths leaf indicates the mode of operation of BGP graceful
// restart with the peer.
type Mode string
const (
MODE_HELPER_ONLY Mode = "helper-only"
MODE_BILATERAL Mode = "bilateral"
MODE_REMOTE_HELPER Mode = "remote-helper"
)
var ModeToIntMap = map[Mode]int{
MODE_HELPER_ONLY: 0,
MODE_BILATERAL: 1,
MODE_REMOTE_HELPER: 2,
}
func (v Mode) ToInt() int {
i, ok := ModeToIntMap[v]
if !ok {
return -1
}
return i
}
var IntToModeMap = map[int]Mode{
0: MODE_HELPER_ONLY,
1: MODE_BILATERAL,
2: MODE_REMOTE_HELPER,
}
func (v Mode) Validate() error {
if _, ok := ModeToIntMap[v]; !ok {
return fmt.Errorf("invalid Mode: %s", v)
}
return nil
}
// typedef for typedef bgp-pol:bgp-next-hop-type.
type BgpNextHopType string
// typedef for typedef bgp-pol:bgp-as-path-prepend-repeat.
type BgpAsPathPrependRepeat uint8
// typedef for typedef bgp-pol:bgp-set-med-type.
type BgpSetMedType string
// typedef for identity bgp-pol:bgp-set-community-option-type.
// Type definition for options when setting the community
// attribute in a policy action.
type BgpSetCommunityOptionType string
const (
BGP_SET_COMMUNITY_OPTION_TYPE_ADD BgpSetCommunityOptionType = "add"
BGP_SET_COMMUNITY_OPTION_TYPE_REMOVE BgpSetCommunityOptionType = "remove"
BGP_SET_COMMUNITY_OPTION_TYPE_REPLACE BgpSetCommunityOptionType = "replace"
)
var BgpSetCommunityOptionTypeToIntMap = map[BgpSetCommunityOptionType]int{
BGP_SET_COMMUNITY_OPTION_TYPE_ADD: 0,
BGP_SET_COMMUNITY_OPTION_TYPE_REMOVE: 1,
BGP_SET_COMMUNITY_OPTION_TYPE_REPLACE: 2,
}
func (v BgpSetCommunityOptionType) ToInt() int {
i, ok := BgpSetCommunityOptionTypeToIntMap[v]
if !ok {
return -1
}
return i
}
var IntToBgpSetCommunityOptionTypeMap = map[int]BgpSetCommunityOptionType{
0: BGP_SET_COMMUNITY_OPTION_TYPE_ADD,
1: BGP_SET_COMMUNITY_OPTION_TYPE_REMOVE,
2: BGP_SET_COMMUNITY_OPTION_TYPE_REPLACE,
}
func (v BgpSetCommunityOptionType) Validate() error {
if _, ok := BgpSetCommunityOptionTypeToIntMap[v]; !ok {
return fmt.Errorf("invalid BgpSetCommunityOptionType: %s", v)
}
return nil
}
// typedef for identity gobgp:bmp-route-monitoring-policy-type.
type BmpRouteMonitoringPolicyType string
const (
BMP_ROUTE_MONITORING_POLICY_TYPE_PRE_POLICY BmpRouteMonitoringPolicyType = "pre-policy"
BMP_ROUTE_MONITORING_POLICY_TYPE_POST_POLICY BmpRouteMonitoringPolicyType = "post-policy"
BMP_ROUTE_MONITORING_POLICY_TYPE_BOTH BmpRouteMonitoringPolicyType = "both"
BMP_ROUTE_MONITORING_POLICY_TYPE_LOCAL_RIB BmpRouteMonitoringPolicyType = "local-rib"
BMP_ROUTE_MONITORING_POLICY_TYPE_ALL BmpRouteMonitoringPolicyType = "all"
)
var BmpRouteMonitoringPolicyTypeToIntMap = map[BmpRouteMonitoringPolicyType]int{
BMP_ROUTE_MONITORING_POLICY_TYPE_PRE_POLICY: 0,
BMP_ROUTE_MONITORING_POLICY_TYPE_POST_POLICY: 1,
BMP_ROUTE_MONITORING_POLICY_TYPE_BOTH: 2,
BMP_ROUTE_MONITORING_POLICY_TYPE_LOCAL_RIB: 3,
BMP_ROUTE_MONITORING_POLICY_TYPE_ALL: 4,
}
func (v BmpRouteMonitoringPolicyType) ToInt() int {
i, ok := BmpRouteMonitoringPolicyTypeToIntMap[v]
if !ok {
return -1
}
return i
}
var IntToBmpRouteMonitoringPolicyTypeMap = map[int]BmpRouteMonitoringPolicyType{
0: BMP_ROUTE_MONITORING_POLICY_TYPE_PRE_POLICY,
1: BMP_ROUTE_MONITORING_POLICY_TYPE_POST_POLICY,
2: BMP_ROUTE_MONITORING_POLICY_TYPE_BOTH,
3: BMP_ROUTE_MONITORING_POLICY_TYPE_LOCAL_RIB,
4: BMP_ROUTE_MONITORING_POLICY_TYPE_ALL,
}
func (v BmpRouteMonitoringPolicyType) Validate() error {
if _, ok := BmpRouteMonitoringPolicyTypeToIntMap[v]; !ok {
return fmt.Errorf("invalid BmpRouteMonitoringPolicyType: %s", v)
}
return nil
}
// typedef for identity gobgp:mrt-type.
type MrtType string
const (
MRT_TYPE_UPDATES MrtType = "updates"
MRT_TYPE_TABLE MrtType = "table"
)
var MrtTypeToIntMap = map[MrtType]int{
MRT_TYPE_UPDATES: 0,
MRT_TYPE_TABLE: 1,
}
func (v MrtType) ToInt() int {
i, ok := MrtTypeToIntMap[v]
if !ok {
return -1
}
return i
}
var IntToMrtTypeMap = map[int]MrtType{
0: MRT_TYPE_UPDATES,
1: MRT_TYPE_TABLE,
}
func (v MrtType) Validate() error {
if _, ok := MrtTypeToIntMap[v]; !ok {
return fmt.Errorf("invalid MrtType: %s", v)
}
return nil
}
// typedef for identity gobgp:rpki-validation-result-type.
// indicate the validation result of RPKI based on ROA.
type RpkiValidationResultType string
const (
RPKI_VALIDATION_RESULT_TYPE_NONE RpkiValidationResultType = "none"
RPKI_VALIDATION_RESULT_TYPE_NOT_FOUND RpkiValidationResultType = "not-found"
RPKI_VALIDATION_RESULT_TYPE_VALID RpkiValidationResultType = "valid"
RPKI_VALIDATION_RESULT_TYPE_INVALID RpkiValidationResultType = "invalid"
)
var RpkiValidationResultTypeToIntMap = map[RpkiValidationResultType]int{
RPKI_VALIDATION_RESULT_TYPE_NONE: 0,
RPKI_VALIDATION_RESULT_TYPE_NOT_FOUND: 1,
RPKI_VALIDATION_RESULT_TYPE_VALID: 2,
RPKI_VALIDATION_RESULT_TYPE_INVALID: 3,
}
func (v RpkiValidationResultType) ToInt() int {
i, ok := RpkiValidationResultTypeToIntMap[v]
if !ok {
return -1
}
return i
}
var IntToRpkiValidationResultTypeMap = map[int]RpkiValidationResultType{
0: RPKI_VALIDATION_RESULT_TYPE_NONE,
1: RPKI_VALIDATION_RESULT_TYPE_NOT_FOUND,
2: RPKI_VALIDATION_RESULT_TYPE_VALID,
3: RPKI_VALIDATION_RESULT_TYPE_INVALID,
}
func (v RpkiValidationResultType) Validate() error {
if _, ok := RpkiValidationResultTypeToIntMap[v]; !ok {
return fmt.Errorf("invalid RpkiValidationResultType: %s", v)