netiputil

package
v0.83.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 20, 2026 License: BSD-3-Clause Imports: 2 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package netiputil provides compact binary encoding for IP prefixes used in the management proto wire format.

Format: [IP bytes][1 byte prefix_len]

  • IPv4: 5 bytes total (4 IP + 1 prefix_len, 0-32)
  • IPv6: 17 bytes total (16 IP + 1 prefix_len, 0-128)

Address family is determined by length: 5 = v4, 17 = v6.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecodeAddr

func DecodeAddr(b []byte) (netip.Addr, error)

DecodeAddr decodes compact prefix bytes and returns only the address, discarding the prefix length. Useful when the prefix length is implied (e.g. peer overlay IPs are always /32 or /128).

func DecodePrefix

func DecodePrefix(b []byte) (netip.Prefix, error)

DecodePrefix decodes compact bytes into a netip.Prefix.

func EncodeAddr

func EncodeAddr(a netip.Addr) []byte

EncodeAddr encodes a netip.Addr into compact prefix bytes with a host prefix length (/32 for v4, /128 for v6). The address is always unmapped before encoding.

func EncodePrefix

func EncodePrefix(p netip.Prefix) ([]byte, error)

EncodePrefix encodes a netip.Prefix into compact bytes. The address is always unmapped before encoding.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL