diff options
Diffstat (limited to 'api/util.go')
-rw-r--r-- | api/util.go | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/api/util.go b/api/util.go index ce7a1d02..53a94ed3 100644 --- a/api/util.go +++ b/api/util.go @@ -160,3 +160,22 @@ func NewROAListFromApiStructList(l []*Roa) []*table.ROA { } return roas } + +func extractFamilyFromConfigAfiSafi(c *config.AfiSafi) uint32 { + if c == nil { + return 0 + } + // If address family value is already stored in AfiSafiState structure, + // we prefer to use this value. + if c.State.Family != 0 { + return uint32(c.State.Family) + } + // In case that Neighbor structure came from CLI or gRPC, address family + // value in AfiSafiState structure can be omitted. + // Here extracts value from AfiSafiName field in AfiSafiConfig structure. + if rf, err := bgp.GetRouteFamily(string(c.Config.AfiSafiName)); err == nil { + return uint32(rf) + } + // Ignores invalid address family name + return 0 +} |