Documentation ¶
Overview ¶
Package caps implements BGP capabilities.
This package can store a set of BGP capabilities in a thread-safe map using the Caps type, and read/write a particular BGP capability representation using implementations of the Cap interface.
Index ¶
- Variables
- func CodeStrings() []string
- type AS4
- type Cap
- type Caps
- func (cps *Caps) Clear()
- func (cps *Caps) Drop(cc Code)
- func (cps *Caps) Each(cb func(i int, cc Code, cap Cap))
- func (cps *Caps) FromJSON(src []byte) error
- func (cps *Caps) Get(cc Code) (cap Cap)
- func (cps *Caps) Has(cc Code) bool
- func (cps *Caps) Init()
- func (cps *Caps) Len() int
- func (cps *Caps) MarshalJSON() (dst []byte, err error)
- func (cps *Caps) Reset()
- func (cps *Caps) Set(cc Code, value Cap)
- func (cps *Caps) SetFrom(src Caps)
- func (cps *Caps) String() string
- func (cps *Caps) ToJSON(dst []byte) []byte
- func (cps *Caps) Use(cc Code) Cap
- func (cps *Caps) Valid() bool
- type Code
- type ExtNH
- func (c *ExtNH) Add(afi af.AFI, safi af.SAFI, nhf af.AFI)
- func (c *ExtNH) Drop(afi af.AFI, safi af.SAFI, nhf af.AFI)
- func (c *ExtNH) FromJSON(src []byte) (err error)
- func (c *ExtNH) Has(afi af.AFI, safi af.SAFI, nhf af.AFI) bool
- func (c *ExtNH) Intersect(cap2 Cap) Cap
- func (c *ExtNH) Marshal(dst []byte) []byte
- func (c *ExtNH) Sorted() (dst []af.AFV)
- func (c *ExtNH) ToJSON(dst []byte) []byte
- func (c *ExtNH) Unmarshal(buf []byte, caps Caps) error
- type Fqdn
- type MP
- func (c *MP) Add(afi af.AFI, safi af.SAFI)
- func (c *MP) Drop(afi af.AFI, safi af.SAFI)
- func (c *MP) FromJSON(src []byte) (err error)
- func (c *MP) Has(afi af.AFI, safi af.SAFI) bool
- func (c *MP) Intersect(cap2 Cap) Cap
- func (c *MP) Marshal(dst []byte) []byte
- func (c *MP) Sorted() (dst []af.AF)
- func (c *MP) ToJSON(dst []byte) []byte
- func (c *MP) Unmarshal(buf []byte, caps Caps) error
- type NewFunc
- type Raw
Constants ¶
This section is empty.
Variables ¶
var ( ErrValue = errors.New("invalid value") ErrLength = errors.New("invalid length") ErrTODO = errors.New("not implemented") ErrCapCode = errors.New("invalid capability code") ErrCapValue = errors.New("invalid capability value") )
var CodeName = map[Code]string{}
var CodeValue = _CodeNameToValueMap
var NewFuncs = map[Code]NewFunc{ CAP_MP: NewMP, CAP_AS4: NewAS4, CAP_EXTENDED_NEXTHOP: NewExtNH, CAP_FQDN: NewFqdn, }
NewFuncs maps capability codes to their new func
Functions ¶
func CodeStrings ¶
func CodeStrings() []string
CodeStrings returns a slice of all String values of the enum
Types ¶
type Cap ¶
type Cap interface { // Unmarshal parses wire representation from src. // It must support multiple calls for the same message. Unmarshal(src []byte, caps Caps) error // Marshal appends wire representation to dst, including code and length. // Return nil to skip this capability. Marshal(dst []byte) []byte // ToJSON appends JSON representation of the value to dst ToJSON(dst []byte) []byte // FromJSON reads from JSON representation in src FromJSON(src []byte) error // Intersect returns a new instance that represents its intersection with cap2. // This is used during capability negotiation. Return nil if equal or N/A. Intersect(cap2 Cap) Cap }
Cap represents a particular BGP capability
type Caps ¶
type Caps struct {
// contains filtered or unexported fields
}
Caps wraps an xsync map to represent a set of BGP capabilities. It may contain nil values.
Caps is thread-safe for writes, but only after Init() or first modification.
The Cap values stored in Caps are generally *not* thread-safe for writes, so you should overwrite a particular CapCode if you need to modify a Cap stored here in a thread-safe way.
func (*Caps) Each ¶
Each executes cb for each non-nil capability in cps, in an ascending order of capability codes.
func (*Caps) Init ¶
func (cps *Caps) Init()
Init initializes Caps and makes it fully thread-safe after return. Can be called multiple times for lazy init.
func (*Caps) MarshalJSON ¶
func (*Caps) Reset ¶
func (cps *Caps) Reset()
Reset resets Caps back to initial state. Thread-unsafe.
func (*Caps) SetFrom ¶
SetFrom sets all capabilities from src, overwriting cps[cc] for existing capability codes
type Code ¶
type Code byte
Code represents BGP capability code
const ( CAP_UNSPECIFIED Code = 0 CAP_MP Code = 1 CAP_ROUTE_REFRESH Code = 2 CAP_OUTBOUND_FILTERING Code = 3 CAP_EXTENDED_NEXTHOP Code = 5 CAP_EXTENDED_MESSAGE Code = 6 CAP_BGPSEC Code = 7 CAP_MULTIPLE_LABELS Code = 8 CAP_ROLE Code = 9 CAP_GRACEFUL_RESTART Code = 64 CAP_AS4 Code = 65 CAP_DYNAMIC Code = 67 CAP_MULTISESSION Code = 68 CAP_ADDPATH Code = 69 CAP_ENHANCED_ROUTE_REFRESH Code = 70 CAP_LLGR Code = 71 CAP_ROUTING_POLICY Code = 72 CAP_FQDN Code = 73 CAP_BFD Code = 74 CAP_VERSION Code = 75 CAP_PRE_ROUTE_REFRESH Code = 128 )
capability codes
func CodeString ¶
CodeString retrieves an enum value from the enum constants string name. Throws an error if the param is not part of the enum.