TODO(kradalby): Remove after go 1.23, will be in stdlib. Compare returns an integer comparing two prefixes. The result will be 0 if p == p2, -1 if p < p2, and +1 if p > p2. Prefixes sort first by validity (invalid before valid), then address family (IPv4 before IPv6), then prefix length, then addres
(p, p2 netip.Prefix)
| 774 | // address family (IPv4 before IPv6), then prefix length, then |
| 775 | // address. |
| 776 | func comparePrefix(p, p2 netip.Prefix) int { |
| 777 | if c := cmp.Compare(p.Addr().BitLen(), p2.Addr().BitLen()); c != 0 { |
| 778 | return c |
| 779 | } |
| 780 | if c := cmp.Compare(p.Bits(), p2.Bits()); c != 0 { |
| 781 | return c |
| 782 | } |
| 783 | return p.Addr().Compare(p2.Addr()) |
| 784 | } |
| 785 | |
| 786 | type mapRequestType int |
| 787 |