nlri

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2025 License: MIT Imports: 9 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrLength = errors.New("invalid length")
	ErrValue  = errors.New("invalid value")
)

Functions

func Marshal

func Marshal(dst []byte, src []NLRI, as afi.AS, cps caps.Caps, dir dir.Dir) []byte

Marshal marshals prefixes in src to dst

func ToJSON

func ToJSON(dst []byte, src []NLRI) []byte

ToJSON appends JSON representation of prefixes in src to dst

Types

type NLRI

type NLRI struct {
	netip.Prefix // the IP prefix

	Options Options // controls optional features
	Val     uint32  // additional NLRI value, eg. the ADD_PATH Path Identifier
}

NLRI is Network Layer Reachability Information (RFC4271), extended to support ADD_PATH (RFC7911).

func FromAddr added in v0.5.1

func FromAddr(ip netip.Addr) NLRI

FromAddr returns normalized address ip wrapped in NLRI

func FromJSON

func FromJSON(src []byte, dst []NLRI) ([]NLRI, error)

FromJSON parses JSON representation of prefixes in src into dst

func FromPrefix

func FromPrefix(p netip.Prefix) NLRI

FromPrefix returns normalized prefix p wrapped in NLRI

func FromString added in v0.5.1

func FromString(s string) (n NLRI, e error)

FromString parses either a prefix or an address in string format, and returns it normalized and wrapped in NLRI.

func Unmarshal

func Unmarshal(dst []NLRI, src []byte, as afi.AS, cps caps.Caps, dir dir.Dir) ([]NLRI, error)

Unmarshal unmarshals IP prefixes from src into dst

func (*NLRI) FindParent

func (p *NLRI) FindParent(parents []NLRI) int

FindParent returns the first index i into parents where parents[i] fully covers p, or -1 if not found.

func (*NLRI) Marshal

func (p *NLRI) Marshal(dst []byte, addpath bool) []byte

Marshal marshals prefix p to dst

func (*NLRI) Unmarshal

func (p *NLRI) Unmarshal(src []byte, ipv6, addpath bool) (n int, err error)

Unmarshal unmarshals src into prefix p

type Options

type Options = byte
const (
	OPT_VALUE   Options // Val holds some arbitrary value (user-controlled)
	OPT_ADDPATH         // Val holds ADD_PATH
)

Jump to

Keyboard shortcuts

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