bgp

package
v0.0.11 Latest Latest
Warning

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

Go to latest
Published: May 2, 2024 License: GPL-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	M_OPEN         = 1
	M_UPDATE       = 2
	M_NOTIFICATION = 3
	M_KEEPALIVE    = 4

	IGP = 0
	EGP = 1

	ORIGIN          = 1
	AS_PATH         = 2
	NEXT_HOP        = 3
	MULTI_EXIT_DISC = 4
	LOCAL_PREF      = 5
	COMMUNITIES     = 8

	AS_SET      = 1
	AS_SEQUENCE = 2

	// NOTIFICATION ERROR CODES
	MESSAGE_HEADER_ERROR = 1
	OPEN_ERROR           = 2
	HOLD_TIMER_EXPIRED   = 4
	FSM_ERROR            = 5
	CEASE                = 6

	// MESSAGE_HEADER_ERROR
	BAD_MESSAGE_TYPE = 3

	// OPEN_ERROR
	UNSUPPORTED_VERSION_NUMBER = 1
	BAD_BGP_ID                 = 3
	UNNACEPTABLE_HOLD_TIME     = 6

	MAXIMUM_PREFIXES_REACHED        = 1
	ADMINISTRATIVE_SHUTDOWN         = 2
	PEER_DECONFIGURED               = 3
	ADMINISTRATIVE_RESET            = 4
	CONNECTION_REJECTED             = 5
	OTHER_CONFIGURATION_CHANGE      = 6
	CONNECTION_COLLISION_RESOLUTION = 7
	OUT_OF_RESOURCES                = 8

	WTCR = 64  // (Well-known, Transitive, Complete, Regular length)
	WTCE = 80  // (Well-known, Transitive, Complete, Extended length)
	ONCR = 128 // (Optional, Non-transitive, Complete, Regular length)
	OTCR = 192 // (Optional, Transitive, Complete, Regular length)
)
View Source
const (
	IDLE         = "IDLE"
	ACTIVE       = "ACTIVE"
	CONNECT      = "CONNECT"
	OPEN_SENT    = "OPEN_SENT"
	OPEN_CONFIRM = "OPEN_CONFIRM"
	ESTABLISHED  = "ESTABLISHED"
)
View Source
const (
	CONNECTION_FAILED = iota
	REMOTE_SHUTDOWN
	LOCAL_SHUTDOWN
	INVALID_LOCALIP
)

Variables

This section is empty.

Functions

func RIBSDiffer

func RIBSDiffer(a, b []IP) bool

Types

type BGPNotify added in v0.0.6

type BGPNotify interface {
	BGPPeer(peer string, params Parameters, add bool)  // Peer added if "add" is true, peer was removed if not
	BGPSession(peer string, local bool, reason string) // Session shutdown was locally requested if "local" is true
}

type Community

type Community uint32

func (*Community) MarshalJSON

func (c *Community) MarshalJSON() ([]byte, error)

func (*Community) UnmarshalJSON

func (c *Community) UnmarshalJSON(data []byte) error

type IP

type IP = [4]byte

func Filter

func Filter(dest []IP, filter []IP) []IP

type IP4

type IP4 [4]byte

func (IP4) MarshalJSON

func (i IP4) MarshalJSON() ([]byte, error)

func (IP4) String

func (i IP4) String() string

func (*IP4) UnmarshalJSON

func (i *IP4) UnmarshalJSON(d []byte) error

type IPNet

type IPNet net.IPNet

func (*IPNet) MarshalJSON

func (i *IPNet) MarshalJSON() ([]byte, error)

func (*IPNet) UnmarshalJSON

func (i *IPNet) UnmarshalJSON(data []byte) error

func (*IPNet) UnmarshalText

func (i *IPNet) UnmarshalText(data []byte) error

type Parameters

type Parameters struct {
	// only used at session start
	ASNumber uint16 `json:"as_number,omitempty"`
	HoldTime uint16 `json:"hold_time,omitempty"`
	SourceIP IP4    `json:"source_ip,omitempty"`

	// can change during session
	MED         uint32      `json:"med,omitempty"`
	LocalPref   uint32      `json:"local_pref,omitempty"`
	Communities []Community `json:"communities,omitempty"`
	Accept      []IPNet     `json:"accept,omitempty"`
	Reject      []IPNet     `json:"reject,omitempty"`
}

func (*Parameters) Diff

func (a *Parameters) Diff(b Parameters) (r bool)

func (*Parameters) Filter

func (p *Parameters) Filter(dest []IP) []IP

type Pool

type Pool struct {
	// contains filtered or unexported fields
}

func NewPool

func NewPool(routerid IP, peers map[string]Parameters, rib_ []IP, log BGPNotify) *Pool

func (*Pool) Close

func (p *Pool) Close()

func (*Pool) Configure

func (p *Pool) Configure(c map[string]Parameters)

func (*Pool) RIB

func (p *Pool) RIB(r []netip.Addr)

func (*Pool) Status

func (p *Pool) Status() status

type Session

type Session struct {
	// contains filtered or unexported fields
}

func NewSession

func NewSession(id IP, peer string, p Parameters, r []IP, l BGPNotify) *Session

func (*Session) Close

func (s *Session) Close()

func (*Session) Configure

func (s *Session) Configure(p Parameters)

func (*Session) RIB

func (s *Session) RIB(r []IP)

func (*Session) Status

func (s *Session) Status() Status

type Status

type Status struct {
	State             string        `json:"state"`
	When              time.Time     `json:"when"`
	Duration          time.Duration `json:"duration_s"`
	UpdateCalculation time.Duration `json:"update_calculation_ms"`
	Advertised        uint64        `json:"advertised_routes"`
	Withdrawn         uint64        `json:"withdrawn_routes"`
	Prefixes          int           `json:"current_routes"`
	Attempts          uint64        `json:"connection_attempts"`
	Connections       uint64        `json:"successful_connections"`
	Established       uint64        `json:"established_sessions"`
	LastError         string        `json:"last_error"`
	HoldTime          uint16        `json:"hold_time"`
	LocalASN          uint16        `json:"local_asn"`
	RemoteASN         uint16        `json:"remote_asn"`
	AdjRIBOut         []string      `json:"adj_rib_out"`
	LocalIP           string        `json:"local_ip"`
}

type Update

type Update struct {
	RIB        []IP
	Parameters Parameters
}

func (Update) Copy

func (r Update) Copy() Update

func (*Update) Filter

func (r *Update) Filter() []IP

func (*Update) Source

func (u *Update) Source() net.IP

Jump to

Keyboard shortcuts

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