Skip to content

Commit

Permalink
Marshal and Unmarshal BgpPeerSegmentSID
Browse files Browse the repository at this point in the history
  • Loading branch information
yas-nyan committed Jan 10, 2023
1 parent cfb39b1 commit 18b04d2
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions pkg/apiutil/attribute.go
Original file line number Diff line number Diff line change
Expand Up @@ -785,6 +785,38 @@ func MarshalLsPrefixV6NLRI(n *bgp.LsPrefixV6NLRI) (*apb.Any, error) {
return a, nil
}

func MarshalLsBgpPeerSegmentSid(n *bgp.LsBgpPeerSegmentSID) (*api.LsBgpPeerSegmentSID, error) {
flags := &api.LsBgpPeerSegmentSIDFlags{
Value: n.Flags.Value,
Local: n.Flags.Local,
Backup: n.Flags.Backup,
Persistent: n.Flags.Persistent,
}
sid := &api.LsBgpPeerSegmentSID{
Flags: flags,
Weight: uint32(n.Weight),
Sid: n.SID,
}

return sid, nil
}
func UnmarshalLsBgpPeerSegmentSid(a *api.LsBgpPeerSegmentSID) (*bgp.LsBgpPeerSegmentSID, error) {
flags := &bgp.LsAttributeBgpPeerSegmentSIDFlags{
Value: a.Flags.Value,
Local: a.Flags.Local,
Backup: a.Flags.Backup,
Persistent: a.Flags.Persistent,
}

sid := &bgp.LsBgpPeerSegmentSID{
Flags: *flags,
Weight: uint8(a.Weight),
SID: a.Sid,
}

return sid, nil
}

func UnmarshalLsNodeDescriptor(nd *api.LsNodeDescriptor) (*bgp.LsNodeDescriptor, error) {
return &bgp.LsNodeDescriptor{
Asn: nd.Asn,
Expand Down

0 comments on commit 18b04d2

Please sign in to comment.