zebra

package
v3.19.0 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2023 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// MinZapiVer is minimum zebra api version which is referred in zclient
	MinZapiVer uint8 = 2
	// MaxZapiVer is maximum zebra api version which is referredd in zclient
	MaxZapiVer uint8 = 6
	// DefaultVrf is default vrf id is referredd in zclient and server
	DefaultVrf = 0
)

Variables

This section is empty.

Functions

func HeaderMarker

func HeaderMarker(version uint8) uint8

HeaderMarker returns suitable header marker from version

func HeaderSize

func HeaderSize(version uint8) uint16

HeaderSize returns suitable header size from version

Types

type APIType

type APIType uint16

APIType is referred in zclient_test.

const (
	RouteAdd    APIType // RouteAdd is referred in zclient_test
	RouteDelete         // RouteDelete is referred in zclient_test

	// BackwardIPv6RouteAdd is referred in zclient_test
	BackwardIPv6RouteAdd // quagga, frr3, frr4, frr5
	// BackwardIPv6RouteDelete is referred in zclient_test
	BackwardIPv6RouteDelete // quagga, frr3, frr4, frr5
)

For FRRouting version 8.1 (ZAPI version 6)

func (APIType) String

func (i APIType) String() string

func (APIType) ToEach

func (t APIType) ToEach(version uint8, software Software) APIType

ToEach is referred in zclient_test

type Body

type Body interface {
	// contains filtered or unexported methods
}

Body is an interface for zebra messages.

type Client

type Client struct {
	Version  uint8
	Software Software
	// contains filtered or unexported fields
}

Client is zebra client which is referred in zclient

func NewClient

func NewClient(logger log.Logger, network, address string, typ RouteType, version uint8, software Software, mplsLabelRangeSize uint32) (*Client, error)

NewClient returns a Client instance (Client constructor)

func (*Client) Receive

func (c *Client) Receive() chan *Message

Receive return incoming channel message

func (*Client) SendGetLabelChunk

func (c *Client) SendGetLabelChunk(body *GetLabelChunkBody) error

SendGetLabelChunk sends GET_LABEL_CHUNK message to zebra daemon.

func (*Client) SendHello

func (c *Client) SendHello() error

SendHello sends HELLO message to zebra daemon.

func (*Client) SendIPRoute

func (c *Client) SendIPRoute(vrfID uint32, body *IPRouteBody, isWithdraw bool) error

SendIPRoute sends ROUTE message to zebra daemon.

func (*Client) SendInterfaceAdd

func (c *Client) SendInterfaceAdd() error

SendInterfaceAdd sends INTERFACE_ADD message to zebra daemon.

func (*Client) SendNexthopRegister

func (c *Client) SendNexthopRegister(vrfID uint32, body *NexthopRegisterBody, isWithdraw bool) error

SendNexthopRegister sends NEXTHOP_REGISTER message to zebra daemon.

func (*Client) SendRedistribute

func (c *Client) SendRedistribute(t RouteType, vrfID uint32) error

SendRedistribute sends REDISTRIBUTE message to zebra daemon.

func (*Client) SendRouterIDAdd

func (c *Client) SendRouterIDAdd() error

SendRouterIDAdd sends ROUTER_ID_ADD message to zebra daemon.

func (*Client) SendVrfLabel

func (c *Client) SendVrfLabel(label uint32, vrfID uint32) error

SendVrfLabel sends VRF_LABEL message to zebra daemon.

func (Client) SetLabelFlag

func (c Client) SetLabelFlag(msgFlags *MessageFlag, nexthop *Nexthop)

SetLabelFlag is referred in zclient, this func sets label flag

func (*Client) SupportMpls

func (c *Client) SupportMpls() bool

SupportMpls is referred in zclient. It returns bool value.

type Flag

type Flag uint64

Flag is Message Flag which is referred in zclient

const (
	// FlagAllowRecursion is referred in zclient, and it is renamed from ZEBRA_FLAG_INTERNAL (https://github.com/FRRouting/frr/commit/4e8b02f4df5d6bcfde6390955b8feda2a17dc9bd)
	FlagAllowRecursion Flag = 0x01 // quagga, frr3, frr4, frr5, frr6, frr7

	// FlagIBGP is referred in zclient
	FlagIBGP Flag = 0x04
	// FlagSelected referred in zclient_test
	FlagSelected Flag = 0x08
)

func (Flag) String

func (f Flag) String(version uint8, software Software) string

String is referred in zclient

func (Flag) ToEach

func (f Flag) ToEach(version uint8, software Software) Flag

ToEach is referred in zclient

type GetLabelChunkBody

type GetLabelChunkBody struct {
	ChunkSize uint32
	Start     uint32 // The followings are used in response from Zebra
	End       uint32
	// contains filtered or unexported fields
}

GetLabelChunkBody is referred in zclient (Ref: zsend_assign_label_chunk_response)

type Header struct {
	Len     uint16
	Marker  uint8
	Version uint8
	VrfID   uint32 // ZAPI v4: 16bits, v5: 32bits
	Command APIType
}

Header is header of zebra message.

type IPRouteBody

type IPRouteBody struct {
	Type RouteType // FRR4&FRR5&FRR6&FRR7.x&FRR8

	Flags   Flag        // FRR4&FRR5&FRR6&FRR7.x&FRR8
	Message MessageFlag // FRR4&FRR5&FRR6&FRR7.x&FRR8
	Safi    Safi        // FRR4&FRR5&FRR6&FRR7.x&FRR8
	Prefix  Prefix      // FRR4&FRR5&FRR6&FRR7.x&FRR8

	Nexthops []Nexthop // FRR4&FRR5&FRR6&FRR7.x&FRR8

	Distance uint8  // FRR4&FRR5&FRR6&FRR7.x&FRR8
	Metric   uint32 // FRR4&FRR5&FRR6&FRR7.x&FRR8

	Mtu uint32 // FRR4&FRR5&FRR6&FRR7.x&FRR8

	API APIType // API is referred in zclient_test
	// contains filtered or unexported fields
}

Ref: struct zapi_route in lib/zclient.h of FRR4&FRR5&FRR6&FRR7.x&RR8 (ZAPI5&6) IPRouteBody is struct for IPRotue (zapi_route)

func (*IPRouteBody) IsWithdraw

func (b *IPRouteBody) IsWithdraw(version uint8, software Software) bool

IsWithdraw is referred in zclient

func (*IPRouteBody) RouteFamily

func (b *IPRouteBody) RouteFamily(logger log.Logger, version uint8, software Software) bgp.RouteFamily

RouteFamily is referred in zclient

type Message

type Message struct {
	Header Header
	Body   Body
}

Message is referred in zclient

type MessageFlag

type MessageFlag uint32

MESSAGE_FLAG is 32bit in frr7.5 and after frr7.5, 8bit in frr 7.4 and before frr7.4 MessageFlag is the type of API Message Flags.

const (
	// MessageNexthop is referred in zclient
	MessageNexthop MessageFlag = 0x01
	// MessageDistance is referred in zclient_test
	MessageDistance MessageFlag = 0x02
	// MessageMetric is referred in zclient
	MessageMetric MessageFlag = 0x04

	// MessageMTU is referred in zclient_test
	MessageMTU MessageFlag = 0x10

	// MessageLabel is referred in zclient
	MessageLabel MessageFlag = 0x40 // deleted in frr7.3

)

func (MessageFlag) ToEach

func (f MessageFlag) ToEach(version uint8, software Software) MessageFlag

ToEach is referred in zclient

type Nexthop

type Nexthop struct {
	Type    nexthopType //FRR5, FRR6, FRR7.x, FRR8, FRR8.1
	VrfID   uint32      //FRR5, FRR6, FRR7.x, FRR8, FRR8.1
	Ifindex uint32      // Ifindex is referred in zclient_test

	Gate net.IP //union { union g_addr gate;

	LabelNum   uint8    //FRR5, FRR6, FRR7.x, FRR8, FRR8.1
	MplsLabels []uint32 //FRR5, FRR6, FRR7.x, FRR8, FRR8.1
	// contains filtered or unexported fields
}

Ref: struct zapi_nexthop in lib/zclient.h of FRR5&FRR6&FRR7.x&FRR8, FRR8.1 (ZAPI5&6) Nexthop is referred in zclient

type NexthopRegisterBody

type NexthopRegisterBody struct {
	Nexthops []*RegisteredNexthop
	// contains filtered or unexported fields
}

NexthopRegisterBody us referred in zclient

type NexthopUpdateBody

type NexthopUpdateBody IPRouteBody

NexthopUpdateBody uses same data structure as IPRoute (zapi_route) after frr4 (Zapi5)

type Prefix

type Prefix struct {
	Family    uint8
	PrefixLen uint8
	Prefix    net.IP
}

Prefix referred in zclient is struct for network prefix and relate information

type RegisteredNexthop

type RegisteredNexthop struct {
	Family uint16
	// Note: Ignores PrefixLength (uint8), because this field should be always:
	// - 32 if Address Family is AF_INET
	// - 128 if Address Family is AF_INET6
	Prefix net.IP
	// contains filtered or unexported fields
}

RegisteredNexthop is referred in zclient

type RouteType

type RouteType uint8

RouteType is referred in zclient.

const (
	RouteStatic RouteType

	RouteBGP
)

For FRRouting version 7 (ZAPI version 6).

func RouteTypeFromString

func RouteTypeFromString(typ string, version uint8, software Software) (RouteType, error)

RouteTypeFromString converts from string to route type

func (RouteType) String

func (i RouteType) String() string

type Safi

type Safi uint8

Safi is Subsequent Address Family IDentifier.

const (
	SafiUnicast Safi
)

Safi definition in Zebra of FRRouting 4.x, 5.x, 6.x, 7.x, and 8.x(lib/zebra.h)

func (Safi) String

func (i Safi) String() string

type Software added in v3.3.0

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

Software is zebra software (quagga, frr, cumulus) which is referred in zclient

func NewSoftware added in v3.3.0

func NewSoftware(version uint8, softwareName string) Software

NewSoftware is constructor of Software strucuture

Jump to

Keyboard shortcuts

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