Documentation
¶
Index ¶
- func AggregatePrefixes(prefixes []netip.Prefix) []netip.Prefix
- func AggregatePrefixesWithPrefixTree(prefixes []netip.Prefix) []netip.Prefix
- func AreAddressesFromSameFamily(addresses []netip.Addr) bool
- func ArePrefixesFromSameFamily(prefixes []netip.Prefix) bool
- func ContainsPrefix(p netip.Prefix, o netip.Prefix) bool
- func GroupAddressesByFamily(vs []netip.Addr) ([]netip.Addr, []netip.Addr)
- func GroupPrefixesByFamily(vs []netip.Prefix) ([]netip.Prefix, []netip.Prefix)
- func IsPrefixesAllowAll(prefixes []netip.Prefix) bool
- func ParseAddresses(vs []string) ([]netip.Addr, error)
- func ParsePrefix(v string) (netip.Prefix, error)
- type Family
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AggregatePrefixes ¶
AggregatePrefixes merges overlapping or adjacent prefixes into a single prefix. It combines prefixes that can be represented by a larger, more inclusive prefix.
Examples:
- Adjacent: [192.168.0.0/32, 192.168.0.1/32] -> 192.168.0.0/31
- Overlapping: [192.168.0.0/24, 192.168.0.1/32] -> 192.168.0.0/24
func AggregatePrefixesWithPrefixTree ¶
AggregatePrefixesWithPrefixTree merges overlapping or adjacent prefixes into a single prefix.
This function uses a prefix tree to aggregate the input prefixes. While it achieves the same result as AggregatePrefixes, it is less efficient. For better performance, use AggregatePrefixes instead.
Examples:
- Adjacent: [192.168.0.0/32, 192.168.0.1/32] -> 192.168.0.0/31
- Overlapping: [192.168.0.0/24, 192.168.0.1/32] -> 192.168.0.0/24
func ContainsPrefix ¶
ContainsPrefix checks if prefix p fully contains prefix o. It returns true if o is a subset of p, meaning all addresses in o are also in p. This is true when p overlaps with o and p has fewer or equal number of bits than o.
func GroupAddressesByFamily ¶
func GroupPrefixesByFamily ¶
GroupPrefixesByFamily groups prefixes by IP family.
func IsPrefixesAllowAll ¶
IsPrefixesAllowAll returns true if one of the prefixes allows all addresses. FIXME: it should return true if the aggregated prefix allows all addresses. Now it only checks one by one.