summaryrefslogtreecommitdiffhomepage
path: root/internal/pkg
diff options
context:
space:
mode:
authorzvfvrv <franclombardo@gmail.com>2021-06-14 21:44:53 +0200
committerFUJITA Tomonori <fujita.tomonori@gmail.com>2021-06-30 07:38:00 +0900
commit8aaeb6d33902c725e2980256c0e83a9edd853124 (patch)
tree4bcd7f20fb5a49fa633f3012ba4dc00e3a31b1ec /internal/pkg
parent7f7a3c570b8b053cd323073a30455630bd983a56 (diff)
fix marshal and unmarshal
Diffstat (limited to 'internal/pkg')
-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