bgp

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 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

	//https://www.rfc-editor.org/rfc/rfc3392.txt
	CAPABILITIES_OPTIONAL_PARAMETER = 2 // Capabilities Optional Parameter (Parameter Type 2)

	// https://www.iana.org/assignments/capability-codes/capability-codes.xhtml
	BGP4_MP = 1 //Multiprotocol Extensions for BGP-4

	// Path attribute types
	ORIGIN          = 1
	AS_PATH         = 2
	NEXT_HOP        = 3
	MULTI_EXIT_DISC = 4
	LOCAL_PREF      = 5
	COMMUNITIES     = 8
	MP_REACH_NLRI   = 14 // Multiprotocol Reachable NLRI - MP_REACH_NLRI (Type Code 14)
	MP_UNREACH_NLRI = 15 // Multiprotocol Unreachable NLRI - MP_UNREACH_NLRI (Type Code 15)

	AS_SET      = 1
	AS_SEQUENCE = 2

	// NOTIFICATION ERROR CODES
	MESSAGE_HEADER_ERROR        = 1 // [RFC4271]
	OPEN_MESSAGE_ERROR          = 2 // [RFC4271]
	UPDATE_MESSAGE_ERROR        = 3 // [RFC4271]
	HOLD_TIMER_EXPIRED          = 4 // [RFC4271]
	FSM_ERROR                   = 5 // [RFC4271]
	CEASE                       = 6 // [RFC4271]
	ROUTE_REFRESH_MESSAGE_ERROR = 7 // [RFC7313]

	UNSUPPORTED_VERSION_NUMBER = 1 // OPEN_MESSAGE_ERROR
	BAD_BGP_ID                 = 3 // OPEN_MESSAGE_ERROR
	UNNACEPTABLE_HOLD_TIME     = 6 // OPEN_MESSAGE_ERROR
	BAD_MESSAGE_TYPE           = 3 // MESSAGE_HEADER_ERROR
	ADMINISTRATIVE_SHUTDOWN    = 2 // CEASE
	OUT_OF_RESOURCES           = 8 // CEASE

	WTCR = 64  // (Well-known, Transitive, Complete, Regular length)
	WTCE = 80  // (Well-known, Transitive, Complete, Extended length)
	ONCR = 128 // (Optional, Non-transitive, Complete, Regular length)
	ONCE = 144 // (Optional, Non-transitive, Complete, Extended length)
	OTCR = 192 // (Optional, Transitive, Complete, Regular length)
	OTCE = 208 // (Optional, Transitive, Complete, Extended 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

This section is empty.

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

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 IP6 added in v0.1.0

type IP6 [16]byte

func (IP6) MarshalJSON added in v0.1.0

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

func (IP6) String added in v0.1.0

func (i IP6) String() string

func (*IP6) UnmarshalJSON added in v0.1.0

func (i *IP6) 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"` // not sure that this can be used with Dial()

	NextHop4      IP4  `json:"next_hop_4,omitempty"`
	NextHop6      IP6  `json:"next_hop_6,omitempty"`
	Multiprotocol bool `json:"multiprotocol,omitempty"`

	// can change during session
	MED         uint32      `json:"med,omitempty"`
	LocalPref   uint32      `json:"local_pref,omitempty"`
	Communities []Community `json:"communities,omitempty"`

	Accept []netip.Prefix `json:"accept,omitempty"`
	Reject []netip.Prefix `json:"reject,omitempty"`
}

func (*Parameters) Diff

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

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) LocRIB added in v0.1.0

func (s *Session) LocRIB(r []netip.Addr)

func (*Session) RIB

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

func (*Session) Start added in v0.1.0

func (s *Session) Start(id IP, peer string, p Parameters, r []netip.Addr, l BGPNotify)

func (*Session) Status

func (s *Session) Status() Status

func (*Session) Stop added in v0.1.0

func (s *Session) Stop()

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"`
}

Jump to

Keyboard shortcuts

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