summaryrefslogtreecommitdiffhomepage
path: root/internal/pkg/table/path.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/pkg/table/path.go')
-rw-r--r--internal/pkg/table/path.go26
1 files changed, 26 insertions, 0 deletions
diff --git a/internal/pkg/table/path.go b/internal/pkg/table/path.go
index 9f68fde3..0a6debca 100644
--- a/internal/pkg/table/path.go
+++ b/internal/pkg/table/path.go
@@ -1217,3 +1217,29 @@ func (p *Path) SetHash(v uint32) {
func (p *Path) GetHash() uint32 {
return p.attrsHash
}
+
+func nlriToIPNet(nlri bgp.AddrPrefixInterface) *net.IPNet {
+ switch T := nlri.(type) {
+ case *bgp.IPAddrPrefix:
+ return &net.IPNet{
+ IP: net.IP(T.Prefix.To4()),
+ Mask: net.CIDRMask(int(T.Length), 32),
+ }
+ case *bgp.IPv6AddrPrefix:
+ return &net.IPNet{
+ IP: net.IP(T.Prefix.To16()),
+ Mask: net.CIDRMask(int(T.Length), 128),
+ }
+ case *bgp.LabeledIPAddrPrefix:
+ return &net.IPNet{
+ IP: net.IP(T.Prefix.To4()),
+ Mask: net.CIDRMask(int(T.Length), 32),
+ }
+ case *bgp.LabeledIPv6AddrPrefix:
+ return &net.IPNet{
+ IP: net.IP(T.Prefix.To4()),
+ Mask: net.CIDRMask(int(T.Length), 128),
+ }
+ }
+ return nil
+}