summaryrefslogtreecommitdiffhomepage
path: root/internal/pkg/apiutil
diff options
context:
space:
mode:
Diffstat (limited to 'internal/pkg/apiutil')
-rw-r--r--internal/pkg/apiutil/attribute.go46
1 files changed, 44 insertions, 2 deletions
diff --git a/internal/pkg/apiutil/attribute.go b/internal/pkg/apiutil/attribute.go
index f6003a6a..30737cc4 100644
--- a/internal/pkg/apiutil/attribute.go
+++ b/internal/pkg/apiutil/attribute.go
@@ -1826,7 +1826,19 @@ func UnmarshalSRBSID(bsid *any.Any) (bgp.TunnelEncapSubTLVInterface, error) {
Flags: flags,
}, nil
case *api.SRv6BindingSID:
- return nil, fmt.Errorf("srv6 binding sid is not yet supported")
+ b, err := bgp.NewBSID(v.Sid)
+ if err != nil {
+ return nil, err
+ }
+ return &bgp.TunnelEncapSubTLVSRv6BSID{
+ TunnelEncapSubTLV: bgp.TunnelEncapSubTLV{
+ Type: bgp.ENCAP_SUBTLV_TYPE_SRBINDING_SID,
+ Length: uint16(2 + b.Len()),
+ },
+ Flags: 0,
+ BSID: b,
+ EPBAS: &bgp.SRv6EndpointBehaviorStructure{},
+ }, nil
default:
return nil, fmt.Errorf("unknown binding sid type %+v", v)
}
@@ -1849,6 +1861,17 @@ func MarshalSRSegments(segs []bgp.TunnelEncapSubTLVInterface) []*any.Any {
},
}
// TODO (sbezverk) Add Type B Segment when SRv6 Binding SID gets finalized.
+ case *bgp.SegmentTypeB:
+ r = &api.SegmentTypeB{
+ Flags: &api.SegmentFlags{
+ VFlag: s.Flags&0x80 == 0x80,
+ AFlag: s.Flags&0x40 == 0x40,
+ SFlag: s.Flags&0x20 == 0x20,
+ BFlag: s.Flags&0x10 == 0x10,
+ },
+ Sid: s.SID,
+ //EndpointBehaviorStructure: &api.SRv6EndPointBehavior{},
+ }
default:
// Unrecognize Segment type, skip it
continue
@@ -1893,7 +1916,26 @@ func UnmarshalSRSegments(s []*any.Any) ([]bgp.TunnelEncapSubTLVInterface, error)
}
segments[i] = seg
case *api.SegmentTypeB:
- return nil, fmt.Errorf("segment of type B is not yet supported")
+ seg := &bgp.SegmentTypeB{
+ TunnelEncapSubTLV: bgp.TunnelEncapSubTLV{
+ Type: bgp.EncapSubTLVType(bgp.TypeB),
+ Length: 18,
+ },
+ SID: v.GetSid(),
+ }
+ if v.Flags.VFlag {
+ seg.Flags += 0x80
+ }
+ if v.Flags.AFlag {
+ seg.Flags += 0x40
+ }
+ if v.Flags.SFlag {
+ seg.Flags += 0x20
+ }
+ if v.Flags.BFlag {
+ seg.Flags += 0x10
+ }
+ segments[i] = seg
}
}
return segments, nil