(attrList []bgp.PathAttributeInterface)
| 2926 | } |
| 2927 | |
| 2928 | func MarshalPathAttributes(attrList []bgp.PathAttributeInterface) ([]*api.Attribute, error) { |
| 2929 | apiList := make([]*api.Attribute, 0, len(attrList)) |
| 2930 | for _, attr := range attrList { |
| 2931 | var attribute api.Attribute |
| 2932 | switch a := attr.(type) { |
| 2933 | case *bgp.PathAttributeOrigin: |
| 2934 | v, err := NewOriginAttributeFromNative(a) |
| 2935 | if err != nil { |
| 2936 | return nil, err |
| 2937 | } |
| 2938 | attribute.Attr = &api.Attribute_Origin{Origin: v} |
| 2939 | case *bgp.PathAttributeAsPath: |
| 2940 | v, err := NewAsPathAttributeFromNative(a) |
| 2941 | if err != nil { |
| 2942 | return nil, err |
| 2943 | } |
| 2944 | attribute.Attr = &api.Attribute_AsPath{AsPath: v} |
| 2945 | case *bgp.PathAttributeNextHop: |
| 2946 | v, err := NewNextHopAttributeFromNative(a) |
| 2947 | if err != nil { |
| 2948 | return nil, err |
| 2949 | } |
| 2950 | attribute.Attr = &api.Attribute_NextHop{NextHop: v} |
| 2951 | case *bgp.PathAttributeMultiExitDisc: |
| 2952 | v, err := NewMultiExitDiscAttributeFromNative(a) |
| 2953 | if err != nil { |
| 2954 | return nil, err |
| 2955 | } |
| 2956 | attribute.Attr = &api.Attribute_MultiExitDisc{MultiExitDisc: v} |
| 2957 | case *bgp.PathAttributeLocalPref: |
| 2958 | v, err := NewLocalPrefAttributeFromNative(a) |
| 2959 | if err != nil { |
| 2960 | return nil, err |
| 2961 | } |
| 2962 | attribute.Attr = &api.Attribute_LocalPref{LocalPref: v} |
| 2963 | case *bgp.PathAttributeAtomicAggregate: |
| 2964 | v, err := NewAtomicAggregateAttributeFromNative(a) |
| 2965 | if err != nil { |
| 2966 | return nil, err |
| 2967 | } |
| 2968 | attribute.Attr = &api.Attribute_AtomicAggregate{AtomicAggregate: v} |
| 2969 | case *bgp.PathAttributeAggregator: |
| 2970 | v, err := NewAggregatorAttributeFromNative(a) |
| 2971 | if err != nil { |
| 2972 | return nil, err |
| 2973 | } |
| 2974 | attribute.Attr = &api.Attribute_Aggregator{Aggregator: v} |
| 2975 | case *bgp.PathAttributeCommunities: |
| 2976 | v, err := NewCommunitiesAttributeFromNative(a) |
| 2977 | if err != nil { |
| 2978 | return nil, err |
| 2979 | } |
| 2980 | attribute.Attr = &api.Attribute_Communities{Communities: v} |
| 2981 | case *bgp.PathAttributeOriginatorId: |
| 2982 | v, err := NewOriginatorIdAttributeFromNative(a) |
| 2983 | if err != nil { |
| 2984 | return nil, err |
| 2985 | } |
searching dependent graphs…