Documentation ¶
Index ¶
- Constants
- Variables
- func HeaderMarker(version uint8) uint8
- func HeaderSize(version uint8) uint16
- type APIType
- type Body
- type Client
- func (c *Client) Receive() chan *Message
- func (c *Client) SendGetLabelChunk(body *GetLabelChunkBody) error
- func (c *Client) SendHello() error
- func (c *Client) SendIPRoute(vrfID uint32, body *IPRouteBody, isWithdraw bool) error
- func (c *Client) SendInterfaceAdd() error
- func (c *Client) SendNexthopRegister(vrfID uint32, body *NexthopRegisterBody, isWithdraw bool) error
- func (c *Client) SendRedistribute(t RouteType, vrfID uint32) error
- func (c *Client) SendRouterIDAdd() error
- func (c *Client) SendVrfLabel(label uint32, vrfID uint32) error
- func (c Client) SetLabelFlag(msgFlags *MessageFlag, nexthop *Nexthop)
- func (c *Client) SupportMpls() bool
- type Flag
- type GetLabelChunkBody
- type Header
- type HelloBody
- type IPRouteBody
- type Message
- type MessageFlag
- type Nexthop
- type NexthopRegisterBody
- type NexthopUpdateBody
- type Prefix
- type RegisteredNexthop
- type RouteType
- type Safi
- type Software
Constants ¶
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 ¶
var (
MaxSoftware = NewSoftware(MaxZapiVer, "frr8.2")
)
Functions ¶
func HeaderMarker ¶
HeaderMarker returns suitable header marker from version
func HeaderSize ¶
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 Hello RedistributeRouteAdd // 33 // 30 in frr8.2 RedistributeRouteDel // 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)
type Body ¶
type Body interface {
// contains filtered or unexported methods
}
Body is an interface for zebra messages.
type Client ¶
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) SendGetLabelChunk ¶
func (c *Client) SendGetLabelChunk(body *GetLabelChunkBody) error
SendGetLabelChunk sends GET_LABEL_CHUNK 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 ¶
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 ¶
SendRedistribute sends REDISTRIBUTE message to zebra daemon.
func (*Client) SendRouterIDAdd ¶
SendRouterIDAdd sends ROUTER_ID_ADD message to zebra daemon.
func (*Client) SendVrfLabel ¶
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 ¶
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 )
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 ¶
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 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 Weight uint32 //FRR7.3, FRR7.4, FRR7.5, 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 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 ¶
RouteTypeFromString converts from string to route type