zebra

package
v0.0.0-...-f4239b7 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2017 License: Apache-2.0, Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HEADER_SIZE      = 6
	HEADER_MARKER    = 255
	VERSION          = 2
	INTERFACE_NAMSIZ = 20
)
View Source
const (
	INTERFACE_ACTIVE        = 0x01
	INTERFACE_SUB           = 0x02
	INTERFACE_LINKDETECTION = 0x04
)
View Source
const (
	MESSAGE_NEXTHOP  = 0x01
	MESSAGE_IFINDEX  = 0x02
	MESSAGE_DISTANCE = 0x04
	MESSAGE_METRIC   = 0x08
)

Variables

This section is empty.

Functions

This section is empty.

Types

type API_TYPE

type API_TYPE uint16

API Types.

const (
	INTERFACE_ADD API_TYPE
	INTERFACE_DELETE
	INTERFACE_ADDRESS_ADD
	INTERFACE_ADDRESS_DELETE
	INTERFACE_UP
	INTERFACE_DOWN
	IPV4_ROUTE_ADD
	IPV4_ROUTE_DELETE
	IPV6_ROUTE_ADD
	IPV6_ROUTE_DELETE
	REDISTRIBUTE_ADD
	REDISTRIBUTE_DELETE
	REDISTRIBUTE_DEFAULT_ADD
	REDISTRIBUTE_DEFAULT_DELETE
	IPV4_NEXTHOP_LOOKUP
	IPV6_NEXTHOP_LOOKUP
	IPV4_IMPORT_LOOKUP
	IPV6_IMPORT_LOOKUP
	INTERFACE_RENAME
	ROUTER_ID_ADD
	ROUTER_ID_DELETE
	ROUTER_ID_UPDATE
	HELLO
	MESSAGE_MAX
)

func (API_TYPE) String

func (i API_TYPE) String() string

type Body

type Body interface {
	DecodeFromBytes([]byte) error
	Serialize() ([]byte, error)
}

type Client

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

func NewClient

func NewClient(network, address string, typ ROUTE_TYPE) (*Client, error)

func (*Client) Close

func (c *Client) Close() error

func (*Client) Receive

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

func (*Client) Send

func (c *Client) Send(m *Message)

func (*Client) SendCommand

func (c *Client) SendCommand(command API_TYPE, body Body) error

func (*Client) SendHello

func (c *Client) SendHello() error

func (*Client) SendInterfaceAdd

func (c *Client) SendInterfaceAdd() error

func (*Client) SendRedistribute

func (c *Client) SendRedistribute(t ROUTE_TYPE) error

func (*Client) SendRedistributeDelete

func (c *Client) SendRedistributeDelete(t ROUTE_TYPE) error

func (*Client) SendRouterIDAdd

func (c *Client) SendRouterIDAdd() error

type FLAG

type FLAG uint64

Message Flags

const (
	FLAG_INTERNAL  FLAG = 0x01
	FLAG_SELFROUTE FLAG = 0x02
	FLAG_BLACKHOLE FLAG = 0x04
	FLAG_IBGP      FLAG = 0x08
	FLAG_SELECTED  FLAG = 0x10
	FLAG_CHANGED   FLAG = 0x20
	FLAG_STATIC    FLAG = 0x40
	FLAG_REJECT    FLAG = 0x80
)

func (FLAG) String

func (t FLAG) String() string
type Header struct {
	Len     uint16
	Marker  uint8
	Version uint8
	Command API_TYPE
}

func (*Header) DecodeFromBytes

func (h *Header) DecodeFromBytes(data []byte) error

func (*Header) Serialize

func (h *Header) Serialize() ([]byte, error)

type HelloBody

type HelloBody struct {
	RedistDefault ROUTE_TYPE
}

func (*HelloBody) DecodeFromBytes

func (b *HelloBody) DecodeFromBytes(data []byte) error

func (*HelloBody) Serialize

func (b *HelloBody) Serialize() ([]byte, error)

type INTERFACE_STATUS

type INTERFACE_STATUS uint8

func (INTERFACE_STATUS) String

func (t INTERFACE_STATUS) String() string

type IPRouteBody

type IPRouteBody struct {
	Type         ROUTE_TYPE
	Flags        FLAG
	Message      uint8
	SAFI         SAFI
	Prefix       net.IP
	PrefixLength uint8
	Nexthops     []net.IP
	Ifindexs     []uint32
	Distance     uint8
	Metric       uint32
	Api          API_TYPE
}

func (*IPRouteBody) DecodeFromBytes

func (b *IPRouteBody) DecodeFromBytes(data []byte) error

func (*IPRouteBody) Serialize

func (b *IPRouteBody) Serialize() ([]byte, error)

func (*IPRouteBody) String

func (b *IPRouteBody) String() string

type ImportLookupBody

type ImportLookupBody struct {
	Api          API_TYPE
	PrefixLength uint8
	Prefix       net.IP
	Addr         net.IP
	Metric       uint32
	Nexthops     []*Nexthop
}

func (*ImportLookupBody) DecodeFromBytes

func (b *ImportLookupBody) DecodeFromBytes(data []byte) error

func (*ImportLookupBody) Serialize

func (b *ImportLookupBody) Serialize() ([]byte, error)

func (*ImportLookupBody) String

func (b *ImportLookupBody) String() string

type InterfaceAddressUpdateBody

type InterfaceAddressUpdateBody struct {
	Index  uint32
	Flags  uint8
	Prefix net.IP
	Length uint8
}

func (*InterfaceAddressUpdateBody) DecodeFromBytes

func (b *InterfaceAddressUpdateBody) DecodeFromBytes(data []byte) error

func (*InterfaceAddressUpdateBody) Serialize

func (b *InterfaceAddressUpdateBody) Serialize() ([]byte, error)

func (*InterfaceAddressUpdateBody) String

func (b *InterfaceAddressUpdateBody) String() string

type InterfaceUpdateBody

type InterfaceUpdateBody struct {
	Name         string
	Index        uint32
	Status       INTERFACE_STATUS
	Flags        uint64
	Metric       uint32
	MTU          uint32
	MTU6         uint32
	Bandwidth    uint32
	HardwareAddr net.HardwareAddr
}

func (*InterfaceUpdateBody) DecodeFromBytes

func (b *InterfaceUpdateBody) DecodeFromBytes(data []byte) error

func (*InterfaceUpdateBody) Serialize

func (b *InterfaceUpdateBody) Serialize() ([]byte, error)

func (*InterfaceUpdateBody) String

func (b *InterfaceUpdateBody) String() string

type Message

type Message struct {
	Header Header
	Body   Body
}

func ParseMessage

func ParseMessage(hdr *Header, data []byte) (*Message, error)

func (*Message) Serialize

func (m *Message) Serialize() ([]byte, error)

type NEXTHOP_FLAG

type NEXTHOP_FLAG uint8

Nexthop Flags.

const (
	NEXTHOP_IFINDEX NEXTHOP_FLAG
	NEXTHOP_IFNAME
	NEXTHOP_IPV4
	NEXTHOP_IPV4_IFINDEX
	NEXTHOP_IPV4_IFNAME
	NEXTHOP_IPV6
	NEXTHOP_IPV6_IFINDEX
	NEXTHOP_IPV6_IFNAME
	NEXTHOP_BLACKHOLE
)

func (NEXTHOP_FLAG) String

func (i NEXTHOP_FLAG) String() string

type Nexthop

type Nexthop struct {
	Ifname  string
	Ifindex uint32
	Type    NEXTHOP_FLAG
	Addr    net.IP
}

func (*Nexthop) String

func (n *Nexthop) String() string

type NexthopLookupBody

type NexthopLookupBody struct {
	Api      API_TYPE
	Addr     net.IP
	Metric   uint32
	Nexthops []*Nexthop
}

func (*NexthopLookupBody) DecodeFromBytes

func (b *NexthopLookupBody) DecodeFromBytes(data []byte) error

func (*NexthopLookupBody) Serialize

func (b *NexthopLookupBody) Serialize() ([]byte, error)

func (*NexthopLookupBody) String

func (b *NexthopLookupBody) String() string

type ROUTE_TYPE

type ROUTE_TYPE uint8

Route Types.

const (
	ROUTE_SYSTEM ROUTE_TYPE = iota
	ROUTE_KERNEL
	ROUTE_CONNECT
	ROUTE_STATIC
	ROUTE_RIP
	ROUTE_RIPNG
	ROUTE_OSPF
	ROUTE_OSPF6
	ROUTE_ISIS
	ROUTE_BGP
	ROUTE_HSLS
	ROUTE_OLSR
	ROUTE_BABEL
	ROUTE_MAX
)

func RouteTypeFromString

func RouteTypeFromString(typ string) (ROUTE_TYPE, error)

func (ROUTE_TYPE) String

func (i ROUTE_TYPE) String() string

type RedistributeBody

type RedistributeBody struct {
	Redist ROUTE_TYPE
}

func (*RedistributeBody) DecodeFromBytes

func (b *RedistributeBody) DecodeFromBytes(data []byte) error

func (*RedistributeBody) Serialize

func (b *RedistributeBody) Serialize() ([]byte, error)

type RouterIDUpdateBody

type RouterIDUpdateBody struct {
	Length uint8
	Prefix net.IP
}

func (*RouterIDUpdateBody) DecodeFromBytes

func (b *RouterIDUpdateBody) DecodeFromBytes(data []byte) error

func (*RouterIDUpdateBody) Serialize

func (b *RouterIDUpdateBody) Serialize() ([]byte, error)

func (*RouterIDUpdateBody) String

func (b *RouterIDUpdateBody) String() string

type SAFI

type SAFI uint8

Subsequent Address Family Identifier.

const (
	SAFI_UNICAST SAFI
	SAFI_MULTICAST
	SAFI_RESERVED_3
	SAFI_MPLS_VPN
	SAFI_MAX
)

func (SAFI) String

func (i SAFI) String() string

Jump to

Keyboard shortcuts

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