Files
akvorado/outlet/routing/provider/bmp/utils.go
2025-11-04 08:22:43 +01:00

24 lines
614 B
Go

// SPDX-FileCopyrightText: 2022 Free Mobile
// SPDX-License-Identifier: AGPL-3.0-only
package bmp
import "github.com/osrg/gobgp/v4/pkg/packet/bgp"
// asPathFlat transforms an AS path to a flat AS path: first value of
// a set is used, confed seq is considered as a regular seq.
func asPathFlat(aspath *bgp.PathAttributeAsPath) []uint32 {
s := []uint32{}
for _, param := range aspath.Value {
segType := param.GetType()
asList := param.GetAS()
switch segType {
case bgp.BGP_ASPATH_ATTR_TYPE_CONFED_SET, bgp.BGP_ASPATH_ATTR_TYPE_SET:
asList = asList[:1]
}
s = append(s, asList...)
}
return s
}