-
Notifications
You must be signed in to change notification settings - Fork 29
/
types.go
542 lines (527 loc) · 32 KB
/
types.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
package message
import (
"reflect"
"strconv"
"github.com/sbezverk/gobmp/pkg/base"
"github.com/sbezverk/gobmp/pkg/bgp"
"github.com/sbezverk/gobmp/pkg/bgpls"
"github.com/sbezverk/gobmp/pkg/flowspec"
"github.com/sbezverk/gobmp/pkg/prefixsid"
"github.com/sbezverk/gobmp/pkg/sr"
"github.com/sbezverk/gobmp/pkg/srpolicy"
"github.com/sbezverk/gobmp/pkg/srv6"
"github.com/sbezverk/tools/sort"
)
// PeerStateChange defines a message format sent to as a result of BMP Peer Up or Peer Down message
type PeerStateChange struct {
Key string `json:"_key,omitempty"`
ID string `json:"_id,omitempty"`
Rev string `json:"_rev,omitempty"`
Action string `json:"action,omitempty"` // Action can be "add" for peer up and "del" for peer down message
Sequence int `json:"sequence,omitempty"`
Hash string `json:"hash,omitempty"`
RouterHash string `json:"router_hash,omitempty"`
Name string `json:"name,omitempty"`
RemoteBGPID string `json:"remote_bgp_id,omitempty"`
RouterIP string `json:"router_ip,omitempty"`
Timestamp string `json:"timestamp,omitempty"`
RemoteASN uint32 `json:"remote_asn,omitempty"`
RemoteIP string `json:"remote_ip,omitempty"`
PeerType uint8 `json:"peer_type"`
PeerRD string `json:"peer_rd,omitempty"`
RemotePort int `json:"remote_port,omitempty"`
LocalASN uint32 `json:"local_asn,omitempty"`
LocalIP string `json:"local_ip,omitempty"`
LocalPort int `json:"local_port,omitempty"`
LocalBGPID string `json:"local_bgp_id,omitempty"`
InfoData []byte `json:"info_data,omitempty"`
AdvCapabilities bgp.Capability `json:"adv_cap,omitempty"`
RcvCapabilities bgp.Capability `json:"recv_cap,omitempty"`
RemoteHolddown int `json:"remote_holddown,omitempty"`
AdvHolddown int `json:"adv_holddown,omitempty"`
BMPReason int `json:"bmp_reason,omitempty"`
BMPErrorCode int `json:"bmp_error_code,omitempty"`
BMPErrorSubCode int `json:"bmp_error_sub_code,omitempty"`
ErrorText string `json:"error_text,omitempty"`
IsL3VPN bool `json:"is_l"`
IsPrepolicy bool `json:"is_prepolicy"`
IsIPv4 bool `json:"is_ipv4"`
TableName string `json:"table_name,omitempty"`
// Values are assigned based on PerPeerHeader flas
IsAdjRIBInPost bool `json:"is_adj_rib_in_post_policy"`
IsAdjRIBOutPost bool `json:"is_adj_rib_out_post_policy"`
IsLocRIBFiltered bool `json:"is_loc_rib_filtered"`
}
// UnicastPrefix defines a message format sent as a result of BMP Route Monitor message
// which carries BGP Update with original NLRI information.
type UnicastPrefix struct {
Key string `json:"_key,omitempty"`
ID string `json:"_id,omitempty"`
Rev string `json:"_rev,omitempty"`
Action string `json:"action,omitempty"` // Action can be "add" or "del"
Sequence int `json:"sequence,omitempty"`
Hash string `json:"hash,omitempty"`
RouterHash string `json:"router_hash,omitempty"`
RouterIP string `json:"router_ip,omitempty"`
BaseAttributes *bgp.BaseAttributes `json:"base_attrs,omitempty"`
PeerHash string `json:"peer_hash,omitempty"`
PeerIP string `json:"peer_ip,omitempty"`
PeerType uint8 `json:"peer_type"`
PeerASN uint32 `json:"peer_asn,omitempty"`
Timestamp string `json:"timestamp,omitempty"`
Prefix string `json:"prefix,omitempty"`
PrefixLen int32 `json:"prefix_len,omitempty"`
IsIPv4 bool `json:"is_ipv4"`
OriginAS int32 `json:"origin_as,omitempty"`
Nexthop string `json:"nexthop,omitempty"`
IsNexthopIPv4 bool `json:"is_nexthop_ipv4"`
PathID int32 `json:"path_id,omitempty"`
Labels []uint32 `json:"labels,omitempty"`
PrefixSID *prefixsid.PSid `json:"prefix_sid,omitempty"`
IsEOR bool `json:"is_eor,omitempty"`
// Values are assigned based on PerPeerHeader flags
IsAdjRIBInPost bool `json:"is_adj_rib_in_post_policy"`
IsAdjRIBOutPost bool `json:"is_adj_rib_out_post_policy"`
IsLocRIBFiltered bool `json:"is_loc_rib_filtered"`
}
func (u *UnicastPrefix) Equal(ou *UnicastPrefix) (bool, []string) {
equal := true
diffs := make([]string, 0)
if u.RouterIP != ou.RouterIP {
equal = false
diffs = append(diffs, "router_ip mismatch: "+u.RouterIP+" and "+ou.RouterIP)
}
if u.BaseAttributes != nil {
if ou.BaseAttributes == nil {
equal = false
diffs = append(diffs, "bgp base attributes mismatch expected BGP BaseAttribute object is not nil, but received object is nil")
}
if eq, df := u.BaseAttributes.Equal(ou.BaseAttributes); !eq {
equal = false
diffs = append(diffs, df...)
}
} else {
if ou.BaseAttributes != nil {
equal = false
diffs = append(diffs, "bgp base attributes mismatch expected BGP BaseAttribute object is nil, but received object is not nil")
}
}
if u.PeerIP != ou.PeerIP {
equal = false
diffs = append(diffs, "peer_ip mismatch: "+u.PeerIP+" and "+ou.PeerIP)
}
if u.PeerType != ou.PeerType {
equal = false
diffs = append(diffs, "peer_type mismatch: "+strconv.Itoa(int(u.PeerType))+" and "+strconv.Itoa(int(ou.PeerType)))
}
if u.PeerASN != ou.PeerASN {
equal = false
diffs = append(diffs, "peer_asn mismatch: "+strconv.Itoa(int(u.PeerASN))+" and "+strconv.Itoa(int(ou.PeerASN)))
}
if u.Prefix != ou.Prefix {
equal = false
diffs = append(diffs, "prefix mismatch: "+u.Prefix+" and "+ou.Prefix)
}
if u.PrefixLen != ou.PrefixLen {
equal = false
diffs = append(diffs, "prefix len mismatch: "+strconv.Itoa(int(u.PrefixLen))+" and "+strconv.Itoa(int(ou.PrefixLen)))
}
if u.IsIPv4 && !ou.IsIPv4 {
equal = false
diffs = append(diffs, "is_ipv4 mismatch: "+strconv.FormatBool(u.IsIPv4)+" and "+strconv.FormatBool(ou.IsIPv4))
}
if u.OriginAS != ou.OriginAS {
equal = false
diffs = append(diffs, "origin_as mismatch: "+strconv.Itoa(int(u.OriginAS))+" and "+strconv.Itoa(int(ou.OriginAS)))
}
if u.Nexthop != ou.Nexthop {
equal = false
diffs = append(diffs, "nexthop mismatch: "+u.Nexthop+" and "+ou.Nexthop)
}
if u.IsNexthopIPv4 && !ou.IsNexthopIPv4 {
equal = false
diffs = append(diffs, "is_nexthop_ipv4 mismatch: "+strconv.FormatBool(u.IsNexthopIPv4)+" and "+strconv.FormatBool(ou.IsNexthopIPv4))
}
if u.PathID != ou.PathID {
equal = false
diffs = append(diffs, "path_id mismatch: "+strconv.Itoa(int(u.PathID))+" and "+strconv.Itoa(int(ou.PathID)))
}
if !reflect.DeepEqual(sort.SortMergeComparableSlice(u.Labels), sort.SortMergeComparableSlice(ou.Labels)) {
equal = false
diffs = append(diffs, "labels mismatch")
}
if u.PrefixSID != ou.PrefixSID {
equal = false
diffs = append(diffs, "prefix sid mismatch")
}
// if u.PrefixSID != nil {
// TODO (sbezverk) Add calling equal for PrefixSID object when it is implemented
// }
if u.IsAdjRIBInPost && !ou.IsAdjRIBInPost {
equal = false
diffs = append(diffs, "is_adj_rib_in_post_policy mismatch: "+strconv.FormatBool(u.IsAdjRIBInPost)+" and "+strconv.FormatBool(ou.IsAdjRIBInPost))
}
if u.IsAdjRIBOutPost && !ou.IsAdjRIBOutPost {
equal = false
diffs = append(diffs, "is_adj_rib_out_post_policy: "+strconv.FormatBool(u.IsAdjRIBOutPost)+" and "+strconv.FormatBool(ou.IsAdjRIBOutPost))
}
if u.IsLocRIBFiltered && !ou.IsLocRIBFiltered {
equal = false
diffs = append(diffs, "is_loc_rib_filtered mismatch: "+strconv.FormatBool(u.IsLocRIBFiltered)+" and "+strconv.FormatBool(ou.IsLocRIBFiltered))
}
return equal, diffs
}
// LSNode defines a structure of LS Node message
type LSNode struct {
Key string `json:"_key,omitempty"`
ID string `json:"_id,omitempty"`
Rev string `json:"_rev,omitempty"`
Action string `json:"action,omitempty"` // Action can be "add" or "del"
Sequence int `json:"sequence,omitempty"`
Hash string `json:"hash,omitempty"`
RouterHash string `json:"router_hash,omitempty"`
DomainID int64 `json:"domain_id"`
RouterIP string `json:"router_ip,omitempty"`
PeerHash string `json:"peer_hash,omitempty"`
PeerIP string `json:"peer_ip,omitempty"`
PeerType uint8 `json:"peer_type"`
PeerASN uint32 `json:"peer_asn,omitempty"`
Timestamp string `json:"timestamp,omitempty"`
IGPRouterID string `json:"igp_router_id,omitempty"`
RouterID string `json:"router_id,omitempty"`
ASN uint32 `json:"asn,omitempty"`
LSID uint32 `json:"ls_id,omitempty"`
MTID []*base.MultiTopologyIdentifier `json:"mt_id_tlv,omitempty"`
AreaID string `json:"area_id"`
Protocol string `json:"protocol,omitempty"`
ProtocolID base.ProtoID `json:"protocol_id,omitempty"`
NodeFlags *bgpls.NodeAttrFlags `json:"node_flags,omitempty"`
Name string `json:"name,omitempty"`
SRCapabilities *sr.Capability `json:"ls_sr_capabilities,omitempty"`
SRAlgorithm []int `json:"sr_algorithm,omitempty"`
SRLocalBlock *sr.LocalBlock `json:"sr_local_block,omitempty"`
SRv6CapabilitiesTLV *srv6.CapabilityTLV `json:"srv6_capabilities_tlv,omitempty"`
NodeMSD []*base.MSDTV `json:"node_msd,omitempty"`
FlexAlgoDefinition []*bgpls.FlexAlgoDefinition `json:"flex_algo_definition,omitempty"`
// Values are assigned based on PerPeerHeader flas
IsAdjRIBInPost bool `json:"is_adj_rib_in_post_policy"`
IsAdjRIBOutPost bool `json:"is_adj_rib_out_post_policy"`
IsLocRIBFiltered bool `json:"is_loc_rib_filtered"`
}
// LSLink defines a structure of LS link message
type LSLink struct {
Key string `json:"_key,omitempty"`
ID string `json:"_id,omitempty"`
Rev string `json:"_rev,omitempty"`
Action string `json:"action,omitempty"`
Sequence int `json:"sequence,omitempty"`
Hash string `json:"hash,omitempty"`
RouterHash string `json:"router_hash,omitempty"`
RouterIP string `json:"router_ip,omitempty"`
DomainID int64 `json:"domain_id"`
PeerHash string `json:"peer_hash,omitempty"`
PeerIP string `json:"peer_ip,omitempty"`
PeerType uint8 `json:"peer_type"`
PeerASN uint32 `json:"peer_asn,omitempty"`
Timestamp string `json:"timestamp,omitempty"`
IGPRouterID string `json:"igp_router_id,omitempty"`
RouterID string `json:"router_id,omitempty"`
LSID uint32 `json:"ls_id,omitempty"`
Protocol string `json:"protocol,omitempty"`
ProtocolID base.ProtoID `json:"protocol_id,omitempty"`
AreaID string `json:"area_id"`
Nexthop string `json:"nexthop,omitempty"`
MTID *base.MultiTopologyIdentifier `json:"mt_id_tlv,omitempty"`
LocalLinkID uint32 `json:"local_link_id,omitempty"`
RemoteLinkID uint32 `json:"remote_link_id,omitempty"`
LocalLinkIP string `json:"local_link_ip,omitempty"`
RemoteLinkIP string `json:"remote_link_ip,omitempty"`
IGPMetric uint32 `json:"igp_metric,omitempty"`
AdminGroup uint32 `json:"admin_group,omitempty"`
MaxLinkBW uint32 `json:"max_link_bw,omitempty"`
MaxResvBW uint32 `json:"max_resv_bw,omitempty"`
UnResvBW []uint32 `json:"unresv_bw,omitempty"`
MaxLinkBWKbps uint64 `json:"max_link_bw_kbps,omitempty"`
MaxResvBWKbps uint64 `json:"max_resv_bw_kbps,omitempty"`
UnResvBWKbps []uint64 `json:"unresv_bw_kbps,omitempty"`
TEDefaultMetric uint32 `json:"te_default_metric,omitempty"`
LinkProtection uint16 `json:"link_protection,omitempty"`
MPLSProtoMask uint8 `json:"mpls_proto_mask,omitempty"`
SRLG []uint32 `json:"srlg,omitempty"`
LinkName string `json:"link_name,omitempty"`
RemoteNodeHash string `json:"remote_node_hash,omitempty"`
LocalNodeHash string `json:"local_node_hash,omitempty"`
RemoteIGPRouterID string `json:"remote_igp_router_id,omitempty"`
RemoteRouterID string `json:"remote_router_id,omitempty"`
LocalNodeASN uint32 `json:"local_node_asn,omitempty"`
RemoteNodeASN uint32 `json:"remote_node_asn,omitempty"`
BGPRouterID string `json:"bgp_router_id,omitempty"` // Local Node Descriptor's TLV 516
BGPRemoteRouterID string `json:"bgp_remote_router_id,omitempty"` // Remote Node Descriptor's TLV 516
MemberAS uint32 `json:"member_as,omitempty"` // Node Descriptor's TLV 517
PeerNodeSID *sr.PeerSID `json:"peer_node_sid,omitempty"`
PeerAdjSID *sr.PeerSID `json:"peer_adj_sid,omitempty"`
PeerSetSID *sr.PeerSID `json:"peer_set_sid,omitempty"`
SRv6BGPPeerNodeSID *srv6.BGPPeerNodeSID `json:"srv6_bgp_peer_node_sid,omitempty"`
SRv6ENDXSID []*srv6.EndXSIDTLV `json:"srv6_endx_sid,omitempty"`
LSAdjacencySID []*sr.AdjacencySIDTLV `json:"ls_adjacency_sid,omitempty"`
LinkMSD []*base.MSDTV `json:"link_msd,omitempty"`
AppSpecLinkAttr []*bgpls.AppSpecLinkAttr `json:"app_spec_link_attr,omitempty"`
UnidirLinkDelay uint32 `json:"unidir_link_delay,omitempty"`
UnidirLinkDelayMinMax []uint32 `json:"unidir_link_delay_min_max,omitempty"`
UnidirDelayVariation uint32 `json:"unidir_delay_variation,omitempty"`
UnidirPacketLoss uint32 `json:"unidir_packet_loss,omitempty"`
UnidirResidualBW uint32 `json:"unidir_residual_bw,omitempty"`
UnidirAvailableBW uint32 `json:"unidir_available_bw,omitempty"`
UnidirBWUtilization uint32 `json:"unidir_bw_utilization,omitempty"`
// Values are assigned based on PerPeerHeader flas
IsAdjRIBInPost bool `json:"is_adj_rib_in_post_policy"`
IsAdjRIBOutPost bool `json:"is_adj_rib_out_post_policy"`
IsLocRIBFiltered bool `json:"is_loc_rib_filtered"`
}
// L3VPNPrefix defines the structure of Layer 3 VPN message
type L3VPNPrefix struct {
Key string `json:"_key,omitempty"`
ID string `json:"_id,omitempty"`
Rev string `json:"_rev,omitempty"`
Action string `json:"action,omitempty"` // Action can be "add" or "del"
Sequence int `json:"sequence,omitempty"`
Hash string `json:"hash,omitempty"`
RouterHash string `json:"router_hash,omitempty"`
RouterIP string `json:"router_ip,omitempty"`
BaseAttributes *bgp.BaseAttributes `json:"base_attrs,omitempty"`
PeerHash string `json:"peer_hash,omitempty"`
PeerIP string `json:"peer_ip,omitempty"`
PeerType uint8 `json:"peer_type"`
PeerASN uint32 `json:"peer_asn,omitempty"`
Timestamp string `json:"timestamp,omitempty"`
Prefix string `json:"prefix,omitempty"`
PrefixLen int32 `json:"prefix_len,omitempty"`
IsIPv4 bool `json:"is_ipv4"`
OriginAS int32 `json:"origin_as,omitempty"`
Nexthop string `json:"nexthop,omitempty"`
ClusterList string `json:"cluster_list,omitempty"`
IsNexthopIPv4 bool `json:"is_nexthop_ipv4"`
PathID int32 `json:"path_id,omitempty"`
Labels []uint32 `json:"labels,omitempty"`
VPNRD string `json:"vpn_rd,omitempty"`
VPNRDType uint16 `json:"vpn_rd_type"`
PrefixSID *prefixsid.PSid `json:"prefix_sid,omitempty"`
// Values are assigned based on PerPeerHeader flas
IsAdjRIBInPost bool `json:"is_adj_rib_in_post_policy"`
IsAdjRIBOutPost bool `json:"is_adj_rib_out_post_policy"`
IsLocRIBFiltered bool `json:"is_loc_rib_filtered"`
}
// LSPrefix defines a structure of LS Prefix message
type LSPrefix struct {
Key string `json:"_key,omitempty"`
ID string `json:"_id,omitempty"`
Rev string `json:"_rev,omitempty"`
Action string `json:"action,omitempty"`
Sequence int `json:"sequence,omitempty"`
Hash string `json:"hash,omitempty"`
RouterHash string `json:"router_hash,omitempty"`
RouterIP string `json:"router_ip,omitempty"`
DomainID int64 `json:"domain_id"`
PeerHash string `json:"peer_hash,omitempty"`
PeerIP string `json:"peer_ip,omitempty"`
PeerType uint8 `json:"peer_type"`
PeerASN uint32 `json:"peer_asn,omitempty"`
Timestamp string `json:"timestamp,omitempty"`
IGPRouterID string `json:"igp_router_id,omitempty"`
RouterID string `json:"router_id,omitempty"`
LSID uint32 `json:"ls_id,omitempty"`
ProtocolID base.ProtoID `json:"protocol_id,omitempty"`
Protocol string `json:"protocol,omitempty"`
AreaID string `json:"area_id"`
Nexthop string `json:"nexthop,omitempty"`
LocalNodeHash string `json:"local_node_hash,omitempty"`
MTID *base.MultiTopologyIdentifier `json:"mt_id_tlv,omitempty"`
OSPFRouteType uint8 `json:"ospf_route_type,omitempty"`
IGPFlags *bgpls.IGPFlags `json:"igp_flags,omitempty"`
IGPRouteTag []uint32 `json:"route_tag,omitempty"`
IGPExtRouteTag []uint64 `json:"ext_route_tag,omitempty"`
OSPFFwdAddr string `json:"ospf_fwd_addr,omitempty"`
Prefix string `json:"prefix,omitempty"`
PrefixLen int32 `json:"prefix_len,omitempty"`
PrefixMetric uint32 `json:"prefix_metric,omitempty"`
PrefixAttrTLVs *bgpls.PrefixAttrTLVs `json:"prefix_attr_tlvs,omitempty"`
FlexAlgoPrefixMetric []*bgpls.FlexAlgoPrefixMetric `json:"flex_algo_prefix_metric,omitempty"`
SRv6Locator *srv6.LocatorTLV `json:"srv6_locator,omitempty"`
// Values are assigned based on PerPeerHeader flas
IsAdjRIBInPost bool `json:"is_adj_rib_in_post_policy"`
IsAdjRIBOutPost bool `json:"is_adj_rib_out_post_policy"`
IsLocRIBFiltered bool `json:"is_loc_rib_filtered"`
}
// LSSRv6SID defines a structure of LS SRv6 SID message
type LSSRv6SID struct {
Key string `json:"_key,omitempty"`
ID string `json:"_id,omitempty"`
Rev string `json:"_rev,omitempty"`
Action string `json:"action,omitempty"`
Sequence int `json:"sequence,omitempty"`
Hash string `json:"hash,omitempty"`
RouterHash string `json:"router_hash,omitempty"`
RouterIP string `json:"router_ip,omitempty"`
DomainID int64 `json:"domain_id"`
PeerHash string `json:"peer_hash,omitempty"`
PeerIP string `json:"peer_ip,omitempty"`
PeerType uint8 `json:"peer_type"`
PeerASN uint32 `json:"peer_asn,omitempty"`
Timestamp string `json:"timestamp,omitempty"`
IGPRouterID string `json:"igp_router_id,omitempty"`
LocalNodeASN uint32 `json:"local_node_asn,omitempty"`
RouterID string `json:"router_id,omitempty"`
LSID uint32 `json:"ls_id,omitempty"`
AreaID string `json:"area_id,omitempty"`
ProtocolID base.ProtoID `json:"protocol_id,omitempty"`
Protocol string `json:"protocol,omitempty"`
Nexthop string `json:"nexthop,omitempty"`
LocalNodeHash string `json:"local_node_hash,omitempty"`
MTID *base.MultiTopologyIdentifier `json:"mt_id_tlv,omitempty"`
IGPFlags uint8 `json:"igp_flags"`
IGPRouteTag uint8 `json:"route_tag,omitempty"`
IGPExtRouteTag uint8 `json:"ext_route_tag,omitempty"`
OSPFFwdAddr string `json:"ospf_fwd_addr,omitempty"`
IGPMetric uint32 `json:"igp_metric,omitempty"`
Prefix string `json:"prefix,omitempty"`
PrefixLen int32 `json:"prefix_len,omitempty"`
SRv6SID string `json:"srv6_sid,omitempty"`
SRv6EndpointBehavior *srv6.EndpointBehavior `json:"srv6_endpoint_behavior,omitempty"`
SRv6BGPPeerNodeSID *srv6.BGPPeerNodeSID `json:"srv6_bgp_peer_node_sid,omitempty"`
SRv6SIDStructure *srv6.SIDStructure `json:"srv6_sid_structure,omitempty"`
// Values are assigned based on PerPeerHeader flas
IsAdjRIBInPost bool `json:"is_adj_rib_in_post_policy"`
IsAdjRIBOutPost bool `json:"is_adj_rib_out_post_policy"`
IsLocRIBFiltered bool `json:"is_loc_rib_filtered"`
}
// EVPNPrefix defines the structure of EVPN message
type EVPNPrefix struct {
Key string `json:"_key,omitempty"`
ID string `json:"_id,omitempty"`
Rev string `json:"_rev,omitempty"`
Action string `json:"action,omitempty"` // Action can be "add" or "del"
Sequence int `json:"sequence,omitempty"`
Hash string `json:"hash,omitempty"`
RouterHash string `json:"router_hash,omitempty"`
RouterIP string `json:"router_ip,omitempty"`
BaseAttributes *bgp.BaseAttributes `json:"base_attrs,omitempty"`
PeerHash string `json:"peer_hash,omitempty"`
RemoteBGPID string `json:"remote_bgp_id,omitempty"`
PeerIP string `json:"peer_ip,omitempty"`
PeerType uint8 `json:"peer_type"`
PeerASN uint32 `json:"peer_asn,omitempty"`
Timestamp string `json:"timestamp,omitempty"`
IsIPv4 bool `json:"is_ipv4"`
OriginAS int32 `json:"origin_as,omitempty"`
Nexthop string `json:"nexthop,omitempty"`
ClusterList string `json:"cluster_list,omitempty"`
IsNexthopIPv4 bool `json:"is_nexthop_ipv4"`
PathID int32 `json:"path_id,omitempty"`
Labels []uint32 `json:"labels,omitempty"`
RawLabels []uint32 `json:"rawlabels,omitempty"`
VPNRD string `json:"vpn_rd,omitempty"`
VPNRDType uint16 `json:"vpn_rd_type"`
ESI string `json:"eth_segment_id,omitempty"`
EthTag []byte `json:"eth_tag,omitempty"`
IPAddress string `json:"ip_address,omitempty"`
IPLength uint8 `json:"ip_len,omitempty"`
GWAddress string `json:"gw_address,omitempty"`
MAC string `json:"mac,omitempty"`
MACLength uint8 `json:"mac_len,omitempty"`
RouteType uint8 `json:"route_type,omitempty"`
// TODO Type 3 carries nlri 22
// https://tools.ietf.org/html/rfc6514
// Add to the message
// Values are assigned based on PerPeerHeader flas
IsAdjRIBInPost bool `json:"is_adj_rib_in_post_policy"`
IsAdjRIBOutPost bool `json:"is_adj_rib_out_post_policy"`
IsLocRIBFiltered bool `json:"is_loc_rib_filtered"`
}
// SRPolicy defines the structure of SR Policy message
type SRPolicy struct {
Key string `json:"_key,omitempty"`
ID string `json:"_id,omitempty"`
Rev string `json:"_rev,omitempty"`
Action string `json:"action,omitempty"` // Action can be "add" or "del"
Sequence int `json:"sequence,omitempty"`
Hash string `json:"hash,omitempty"`
RouterHash string `json:"router_hash,omitempty"`
RouterIP string `json:"router_ip,omitempty"`
BaseAttributes *bgp.BaseAttributes `json:"base_attrs,omitempty"`
PeerHash string `json:"peer_hash,omitempty"`
PeerIP string `json:"peer_ip,omitempty"`
PeerType uint8 `json:"peer_type"`
PeerASN uint32 `json:"peer_asn,omitempty"`
Timestamp string `json:"timestamp,omitempty"`
IsIPv4 bool `json:"is_ipv4"`
OriginAS int32 `json:"origin_as,omitempty"`
Nexthop string `json:"nexthop,omitempty"`
ClusterList string `json:"cluster_list,omitempty"`
IsNexthopIPv4 bool `json:"is_nexthop_ipv4"`
PathID int32 `json:"path_id,omitempty"`
Labels []uint32 `json:"labels,omitempty"`
Distinguisher uint32 `json:"distinguisher,omitempty"`
Color uint32 `json:"color,omitempty"`
Endpoint []byte `json:"endpoint,omitempty"`
PolicyName string `json:"policy_name,omitempty"`
BSID *srpolicy.BindingSID `json:"binding_sid,omitempty"`
Preference *srpolicy.Preference `json:"preference_subtlv,omitempty"`
Priority byte `json:"priority_subtlv,omitempty"`
PolicyPathName string `json:"policy_path_name,omitempty"`
ENLP *srpolicy.ENLP `json:"enlp_subtlv,omitempty"`
SegmentList []*srpolicy.SegmentList `json:"segment_list_subtlv,omitempty"`
// Values are assigned based on PerPeerHeader flas
IsAdjRIBInPost bool `json:"is_adj_rib_in_post_policy"`
IsAdjRIBOutPost bool `json:"is_adj_rib_out_post_policy"`
IsLocRIBFiltered bool `json:"is_loc_rib_filtered"`
}
// Flowspec defines the structure of SR Policy message
type Flowspec struct {
Key string `json:"_key,omitempty"`
ID string `json:"_id,omitempty"`
Rev string `json:"_rev,omitempty"`
Action string `json:"action,omitempty"` // Action can be "add" or "del"
Sequence int `json:"sequence,omitempty"`
RouterIP string `json:"router_ip,omitempty"`
BaseAttributes *bgp.BaseAttributes `json:"base_attrs,omitempty"`
PeerIP string `json:"peer_ip,omitempty"`
PeerType uint8 `json:"peer_type"`
PeerASN uint32 `json:"peer_asn,omitempty"`
Timestamp string `json:"timestamp,omitempty"`
IsIPv4 bool `json:"is_ipv4"`
OriginAS int32 `json:"origin_as,omitempty"`
Nexthop string `json:"nexthop,omitempty"`
IsNexthopIPv4 bool `json:"is_nexthop_ipv4"`
PathID int32 `json:"path_id,omitempty"`
SpecHash string `json:"spec_hash,omitempty"`
Spec []flowspec.Spec `json:"spec,omitempty"`
// Values are assigned based on PerPeerHeader flas
IsAdjRIBInPost bool `json:"is_adj_rib_in_post_policy"`
IsAdjRIBOutPost bool `json:"is_adj_rib_out_post_policy"`
IsLocRIBFiltered bool `json:"is_loc_rib_filtered"`
}
// Stats defines a message format sent to as a result of BMP Stats Message
type Stats struct {
Key string `json:"_key,omitempty"`
ID string `json:"_id,omitempty"`
Rev string `json:"_rev,omitempty"`
Sequence int `json:"sequence,omitempty"`
RouterHash string `json:"router_hash,omitempty"`
RouterIP string `json:"router_ip,omitempty"`
PeerType uint8 `json:"peer_type"`
RemoteBGPID string `json:"remote_bgp_id,omitempty"`
RemoteASN uint32 `json:"remote_asn,omitempty"`
RemoteIP string `json:"remote_ip,omitempty"`
PeerRD string `json:"peer_rd,omitempty"`
Timestamp string `json:"timestamp,omitempty"`
DuplicatePrefixs uint32 `json:"duplicate_prefix,omitempty"`
DuplicateWithDraws uint32 `json:"duplicate_withdraws,omitempty"`
InvalidatedDueCluster uint32 `json:"invalidated_due_cluster,omitempty"`
InvalidatedDueAspath uint32 `json:"invalidated_due_aspath,omitempty"`
InvalidatedDueOriginatorId uint32 `json:"invalidated_due_originator_id,omitempty"`
InvalidatedAsConfed uint32 `json:"invalidated_due_asconfed,omitempty"`
AdjRIBsIn uint64 `json:"ads_rib_in,omitempty"`
LocalRib uint64 `json:"local_rib,omitempty"`
UpdatesAsWithdraw uint32 `json:"updates_as_withdraw,omitempty"`
PrefixesAsWithdraw uint32 `json:"prefixes_as_withdraw,omitempty"`
}