summaryrefslogtreecommitdiffhomepage
path: root/api/attribute.go
diff options
context:
space:
mode:
Diffstat (limited to 'api/attribute.go')
-rw-r--r--api/attribute.go28
1 files changed, 28 insertions, 0 deletions
diff --git a/api/attribute.go b/api/attribute.go
index a4f5734e..65ca6a4f 100644
--- a/api/attribute.go
+++ b/api/attribute.go
@@ -175,6 +175,10 @@ func MarshalRD(rd bgp.RouteDistinguisherInterface) *any.Any {
Assigned: uint32(v.Assigned),
}
default:
+ log.WithFields(log.Fields{
+ "Topic": "protobuf",
+ "RD": rd,
+ }).Warn("invalid rd type to marshal")
return nil
}
a, _ := ptypes.MarshalAny(r)
@@ -695,12 +699,24 @@ func MarshalRT(rt bgp.ExtendedCommunityInterface) *any.Any {
LocalAdmin: uint32(v.LocalAdmin),
}
default:
+ log.WithFields(log.Fields{
+ "Topic": "protobuf",
+ "RT": rt,
+ }).Warn("invalid rt type to marshal")
return nil
}
a, _ := ptypes.MarshalAny(r)
return a
}
+func MarshalRTs(values []bgp.ExtendedCommunityInterface) []*any.Any {
+ rts := make([]*any.Any, 0, len(values))
+ for _, rt := range values {
+ rts = append(rts, MarshalRT(rt))
+ }
+ return rts
+}
+
func UnmarshalRT(a *any.Any) (bgp.ExtendedCommunityInterface, error) {
var value ptypes.DynamicAny
if err := ptypes.UnmarshalAny(a, &value); err != nil {
@@ -721,6 +737,18 @@ func UnmarshalRT(a *any.Any) (bgp.ExtendedCommunityInterface, error) {
return nil, fmt.Errorf("invalid route target type: %s", a.TypeUrl)
}
+func UnmarshalRTs(values []*any.Any) ([]bgp.ExtendedCommunityInterface, error) {
+ rts := make([]bgp.ExtendedCommunityInterface, 0, len(values))
+ for _, an := range values {
+ rt, err := UnmarshalRT(an)
+ if err != nil {
+ return nil, err
+ }
+ rts = append(rts, rt)
+ }
+ return rts, nil
+}
+
func NewExtendedCommunitiesAttributeFromNative(a *bgp.PathAttributeExtendedCommunities) *ExtendedCommunitiesAttribute {
communities := make([]*any.Any, 0, len(a.Value))
for _, value := range a.Value {