meta

package
v0.28.0 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2026 License: MIT Imports: 8 Imported by: 4

Documentation

Overview

Package meta represents BGP message metadata.

Exported to a separate package in order to avoid dependency loops: message parsers take Meta, which is part of msg.Msg.

Index

Constants

This section is empty.

Variables

View Source
var (
	AddPathOn  = &AddPath{All: true} // ADD-PATH in all address families
	AddPathOff = &AddPath{}          // no ADD-PATH
)
View Source
var (
	ErrValue = errors.New("invalid value")
)

Functions

This section is empty.

Types

type AddPath added in v0.25.0

type AddPath struct {
	All bool     // all address families
	AS  []afi.AS // else only these
}

AddPath tells which address families carry ADD-PATH Path Identifiers (RFC 7911). NB: shared and read-only, eg. AddPathOn and AddPathOff

func (*AddPath) Has added in v0.25.0

func (ap *AddPath) Has(as afi.AS) bool

Has returns true iff ap enables ADD-PATH for address family as

type Dir

type Dir byte

BGP message direction

const (
	DIR_L  Dir = 0b01 // L direction: "left" or "local"
	DIR_R  Dir = 0b10 // R direction: "right" or "remote"
	DIR_LR Dir = 0b11 // LR direction: both "left" and "right"
)

func DirString

func DirString(s string) (Dir, error)

DirString converts string to Dir

func (Dir) Flip

func (d Dir) Flip() Dir

Flip returns the opposite direction

func (Dir) String

func (d Dir) String() string

String converts Dir to string

type Meta

type Meta struct {
	Dir  Dir       // message direction
	Seq  int64     // sequence number
	Time time.Time // message timestamp

	// per-message parser options, overriding session capabilities
	ParseAS4     int8     // 4-byte ASN encoding (CAP_AS4): 0 = no data, -1 = off, 1 = on
	ParseAddPath *AddPath // ADD-PATH encoding (CAP_ADDPATH): nil = no data

	Tags Tags // message tags
}

Meta holds optional BGP message metadata: the direction, sequence number and timestamp, plus per-message parser options.

NB: passed by value to parsers; the zero value means "no metadata".

func (*Meta) Reset added in v0.22.0

func (mt *Meta) Reset()

Reset resets the metadata to its zero value.

type Tag added in v0.28.0

type Tag struct {
	Key, Val string
}

Tag is a message tag

type Tags added in v0.28.0

type Tags struct {
	PeerIP    netip.Addr // PEER_IP: BGP peer address
	PeerAS    uint32     // PEER_AS: BGP peer ASN
	PeerID    netip.Addr // PEER_ID: BGP peer identifier
	LocalIP   netip.Addr // LOCAL_IP: local address of the BGP session
	LocalAS   uint32     // LOCAL_AS: local ASN of the BGP session
	Collector string     // COLLECTOR: route collector name
	Router    string     // ROUTER: BMP router name or address
	Src       string     // SRC: source stage name

	Other []Tag // other tags, sorted by key
}

Tags are message tags. The well-known ones, with ALL-CAPS keys, are typed fields; the others (lowercase by convention, eg. "rov/status") are kept sorted by key. Get and Set work for all keys. An empty value means no tag.

func (*Tags) Each added in v0.28.0

func (t *Tags) Each(cb func(key, val string))

Each calls cb for each tag with a value: the well-known ones first, then the others

func (*Tags) FromJSON added in v0.28.0

func (t *Tags) FromJSON(src []byte) error

FromJSON sets the tags in a JSON object src

func (*Tags) Get added in v0.28.0

func (t *Tags) Get(key string) string

Get returns the value of tag key, or "" if not set

func (*Tags) Reset added in v0.28.0

func (t *Tags) Reset()

Reset drops all tags

func (*Tags) Set added in v0.28.0

func (t *Tags) Set(key, val string)

Set sets tag key to val; an empty or invalid val drops it

func (*Tags) ToJSON added in v0.28.0

func (t *Tags) ToJSON(dst []byte) []byte

ToJSON appends the tags as a JSON object to dst, without allocations

Jump to

Keyboard shortcuts

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