nlamsg

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2019 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BRIDGE_VLAN_PORT_NONE   = 0
	BRIDGE_VLAN_PORT_ACCESS = 1
	BRIDGE_VLAN_PORT_TRUNK  = 2
	BRIDGE_VLAN_PORT_MASTER = 3
)
View Source
const BRVLAN_INFO_IFNAME_SIZE = 16
View Source
const NODE_ID_ALL uint8 = 255

Variables

View Source
var NlMsgSrc_name = map[NlMsgSrc]string{
	SRC_NOP: "NOP",
	SRC_KNL: "KNL",
	SRC_API: "API",
}
View Source
var RTMGRPStrings = map[uint16]string{
	nlalink.RTMGRP_NODE:   "RTMGRP_NODE",
	nlalink.RTMGRP_VPN:    "RTMGRP_VPN",
	nlalink.RTMGRP_BRIDGE: "RTMGRP_BRIDGE",
	nlalink.RTMGRP_LINK:   "RTMGRP_LINK",
	nlalink.RTMGRP_ADDR:   "RTMGRP_ADDR",
	nlalink.RTMGRP_NEIGH:  "RTMGRP_NEIGH",
	nlalink.RTMGRP_ROUTE:  "RTMGRP_ROUTE",
}
View Source
var RTMStrings = map[uint16]string{
	nlalink.RTM_NEWNODE:   "RTM_NEWNODE",
	nlalink.RTM_DELNODE:   "RTM_DELNODE",
	nlalink.RTM_SETNODE:   "RTM_SETNODE",
	nlalink.RTM_NEWVPN:    "RTM_NEWVPN",
	nlalink.RTM_DELVPN:    "RTM_DELVPN",
	nlalink.RTM_SETVPN:    "RTM_SETVPN",
	nlalink.RTM_NEWBRIDGE: "RTM_NEWBRIDGE",
	nlalink.RTM_DELBRIDGE: "RTM_DELBRIDGE",
	nlalink.RTM_SETBRIDGE: "RTM_SETBRIDGE",
	syscall.RTM_NEWLINK:   "RTM_NEWLINK",
	syscall.RTM_DELLINK:   "RTM_DELLINK",
	syscall.RTM_SETLINK:   "RTM_SETLINK",
	syscall.RTM_NEWADDR:   "RTM_NEWADDR",
	syscall.RTM_DELADDR:   "RTM_DELADDR",
	nlalink.RTM_SETADDR:   "RTM_SETADDR",
	syscall.RTM_NEWNEIGH:  "RTM_NEWNEIGH",
	syscall.RTM_DELNEIGH:  "RTM_DELNEIGH",
	nlalink.RTM_SETNEIGH:  "RTM_SETNEIGH",
	syscall.RTM_NEWROUTE:  "RTM_NEWROUTE",
	syscall.RTM_DELROUTE:  "RTM_DELROUTE",
	nlalink.RTM_SETROUTE:  "RTM_SETROUTE",
}
View Source
var RT_SCOPE_strings = map[uint8]string{
	syscall.RT_SCOPE_UNIVERSE: "UNIVERSE",
	syscall.RT_SCOPE_SITE:     "SITE",
	syscall.RT_SCOPE_LINK:     "LINK",
	syscall.RT_SCOPE_HOST:     "HOST",
	syscall.RT_SCOPE_NOWHERE:  "NOWHERE",
}

Functions

func CopyAddr

func CopyAddr(src *netlink.Addr) *netlink.Addr

netlink.Addr

func CopyNeigh

func CopyNeigh(src *netlink.Neigh) *netlink.Neigh

netlink.Neigh

func CopyNode

func CopyNode(src *nlalink.Node) *nlalink.Node

func CopyRoute

func CopyRoute(src *netlink.Route) *netlink.Route

netlink.Route

func CopyVpn

func CopyVpn(src *nlalink.Vpn) *nlalink.Vpn

func Dispatch

func Dispatch(nlmsg *NetlinkMessage, app interface{}) error

func DispatchAddr

func DispatchAddr(nlmsg *NetlinkMessage, addr *Addr, app interface{})

func DispatchBridgeVlanInfo added in v0.4.0

func DispatchBridgeVlanInfo(nlmsg *NetlinkMessage, brVlan *BridgeVlanInfo, app interface{})
func DispatchLink(nlmsg *NetlinkMessage, link *Link, app interface{})

func DispatchNeigh

func DispatchNeigh(nlmsg *NetlinkMessage, neigh *Neigh, app interface{})

func DispatchNetlinkMessage

func DispatchNetlinkMessage(nlmsg *NetlinkMessage, app interface{})

func DispatchNode

func DispatchNode(nlmsg *NetlinkMessage, node *Node, app interface{})

func DispatchRoute

func DispatchRoute(nlmsg *NetlinkMessage, route *Route, app interface{})

func DispatchToAddr

func DispatchToAddr(nlmsg *NetlinkMessage, app interface{}) error

func DispatchToBridgeVlanInfo added in v0.4.0

func DispatchToBridgeVlanInfo(nlmsg *NetlinkMessage, app interface{}) error
func DispatchToLink(nlmsg *NetlinkMessage, app interface{}) error

func DispatchToNeigh

func DispatchToNeigh(nlmsg *NetlinkMessage, app interface{}) error

func DispatchToNode

func DispatchToNode(nlmsg *NetlinkMessage, app interface{}) error

func DispatchToRoute

func DispatchToRoute(nlmsg *NetlinkMessage, app interface{}) error

func DispatchToVpn

func DispatchToVpn(nlmsg *NetlinkMessage, app interface{}) error

func DispatchUnion

func DispatchUnion(nlmsg *NetlinkMessageUnion, app interface{}) error

func DispatchVpn

func DispatchVpn(nlmsg *NetlinkMessage, vpn *Vpn, app interface{})

func NlMsgGroupFromType

func NlMsgGroupFromType(nlmsgType uint16) uint16

Netlink type to RTMGRP

func NlMsgGroupStr

func NlMsgGroupStr(g uint16) string

func NlMsgHdrStr

func NlMsgHdrStr(hdr *syscall.NlMsghdr) string

func NlMsgStr

func NlMsgStr(nlmsg *syscall.NetlinkMessage) string

func NlMsgTypeStr

func NlMsgTypeStr(t uint16) string

func ScopeStr

func ScopeStr(scope uint8) string

Types

type Addr

type Addr struct {
	*netlink.Addr
	AdId   uint32 // auto increment
	Family int32
	Index  int32
	NId    uint8
}

Addr

func AddrDeserialize

func AddrDeserialize(nlmsg *NetlinkMessage) (*Addr, error)

func NewAddr

func NewAddr(addr *netlink.Addr, family int32, index int32, nid uint8, id uint32) *Addr

func (*Addr) Copy

func (a *Addr) Copy() *Addr

func (*Addr) String

func (a *Addr) String() string

type BridgeSlaveInfo added in v0.4.0

type BridgeSlaveInfo struct {
}

func (*BridgeSlaveInfo) SlaveType added in v0.4.0

func (b *BridgeSlaveInfo) SlaveType() string

type BridgeVlanInfo added in v0.4.0

type BridgeVlanInfo struct {
	nl.BridgeVlanInfo
	Index       int
	Name        string
	MasterIndex int
	Mtu         uint16
	BrId        uint32
	NId         uint8
}

func BridgeVlanInfoDeserialize added in v0.4.0

func BridgeVlanInfoDeserialize(nlmsg *NetlinkMessage) (*BridgeVlanInfo, error)

func NewBridgeVlanInfo added in v0.4.0

func NewBridgeVlanInfo(bridgeVlan nl.BridgeVlanInfo, index int, name string, master int, nid uint8, id uint32) *BridgeVlanInfo
func NewBridgeVlanInfoFromNetlink(nid uint8, brvlan *nl.BridgeVlanInfo, link netlink.Link) *BridgeVlanInfo

func ParseBridgeVlanInfo added in v0.4.0

func ParseBridgeVlanInfo(b []byte) (*BridgeVlanInfo, error)

func (*BridgeVlanInfo) Bytes added in v0.4.0

func (b *BridgeVlanInfo) Bytes() ([]byte, error)

func (*BridgeVlanInfo) Copy added in v0.4.0

func (b *BridgeVlanInfo) Copy() *BridgeVlanInfo

func (*BridgeVlanInfo) Equals added in v0.4.0

func (b *BridgeVlanInfo) Equals(other *BridgeVlanInfo) bool

func (*BridgeVlanInfo) PortType added in v0.4.0

func (b *BridgeVlanInfo) PortType() BridgeVlanPortType

func (*BridgeVlanInfo) String added in v0.4.0

func (b *BridgeVlanInfo) String() string

func (*BridgeVlanInfo) ToNetlinkMessage added in v0.4.0

func (b *BridgeVlanInfo) ToNetlinkMessage(msgType uint16) (*syscall.NetlinkMessage, error)

type BridgeVlanPortType added in v0.4.0

type BridgeVlanPortType uint8

func ParseBridgeVlanPortType added in v0.4.0

func ParseBridgeVlanPortType(s string) (BridgeVlanPortType, error)

func (BridgeVlanPortType) String added in v0.4.0

func (t BridgeVlanPortType) String() string

type EncapInfo

type EncapInfo struct {
	Dst  *net.IPNet
	Vrf  uint32
	EnId uint32
}

EncapInfo

func NewEncapInfo

func NewEncapInfo(dst *net.IPNet, vrf uint32, enId uint32) *EncapInfo

func (*EncapInfo) Copy

func (e *EncapInfo) Copy() *EncapInfo

func (*EncapInfo) String

func (e *EncapInfo) String() string

type Iptun added in v0.3.1

type Iptun struct {
	*Link
	TnlId    uint16
	LocalMAC net.HardwareAddr
}

func NewIptun added in v0.3.1

func NewIptun(link *Link) *Iptun

func (*Iptun) Copy added in v0.3.1

func (e *Iptun) Copy() *Iptun

func (*Iptun) Local added in v0.3.1

func (e *Iptun) Local() net.IP

func (*Iptun) Remote added in v0.3.1

func (e *Iptun) Remote() net.IP

func (*Iptun) String added in v0.3.1

func (v *Iptun) String() string
type Link struct {
	netlink.Link
	LnId uint16 // auto increment
	NId  uint8
}

Link

func LinkDeserialize

func LinkDeserialize(nlmsg *NetlinkMessage) (*Link, error)
func NewLink(link netlink.Link, nid uint8, id uint16) *Link

func (*Link) Bond

func (ln *Link) Bond() *netlink.Bond

func (*Link) Bridge added in v0.4.0

func (ln *Link) Bridge() *netlink.Bridge

func (*Link) Copy

func (ln *Link) Copy() *Link

func (*Link) GetSlaveInfo added in v0.4.0

func (ln *Link) GetSlaveInfo() netlink.LinkSlaveInfo

func (*Link) Iptun added in v0.3.1

func (ln *Link) Iptun() *netlink.Iptun

func (*Link) String

func (ln *Link) String() string

func (*Link) Vlan

func (ln *Link) Vlan() *netlink.Vlan

func (*Link) VlanId

func (ln *Link) VlanId() uint16

type Neigh

type Neigh struct {
	*netlink.Neigh
	PhyLink int
	Tunnel  NeighTunnel
	NeId    uint16
	NId     uint8
}

Neigh

func NeighDeserialize

func NeighDeserialize(nlmsg *NetlinkMessage) (*Neigh, error)

func NewNeigh

func NewNeigh(neigh *netlink.Neigh, nid uint8, id uint16) *Neigh

func (*Neigh) Copy

func (n *Neigh) Copy() *Neigh

func (*Neigh) GetIptun added in v0.3.1

func (n *Neigh) GetIptun() *NeighIptun

func (*Neigh) IsFdbEntry added in v0.4.0

func (n *Neigh) IsFdbEntry() bool

func (*Neigh) IsTunnelRemote added in v0.3.1

func (n *Neigh) IsTunnelRemote() bool

func (*Neigh) SetTunnel added in v0.3.1

func (n *Neigh) SetTunnel(phyLink int, tunnel NeighTunnel)

func (*Neigh) String

func (n *Neigh) String() string

type NeighIptun added in v0.3.1

type NeighIptun struct {
	TunType string
	SrcIP   net.IP
}

func NewNeighIptun added in v0.3.1

func NewNeighIptun(tunType string, srcIp net.IP) *NeighIptun

func (*NeighIptun) Copy added in v0.3.1

func (n *NeighIptun) Copy() NeighTunnel

func (*NeighIptun) String added in v0.3.1

func (n *NeighIptun) String() string

type NeighTunnel added in v0.3.1

type NeighTunnel interface {
	Copy() NeighTunnel
	String() string
}

func CopyNeighTunnel added in v0.3.1

func CopyNeighTunnel(src NeighTunnel) NeighTunnel

type NetlinkAddrHandler

type NetlinkAddrHandler interface {
	NetlinkAddr(*NetlinkMessage, *Addr)
}

type NetlinkBridgeVlanInfoHandler added in v0.4.0

type NetlinkBridgeVlanInfoHandler interface {
	NetlinkBridgeVlanInfo(*NetlinkMessage, *BridgeVlanInfo)
}

type NetlinkLinkHandler

type NetlinkLinkHandler interface {
	NetlinkLink(*NetlinkMessage, *Link)
}

type NetlinkMessage

type NetlinkMessage struct {
	syscall.NetlinkMessage
	NId uint8
	Src NlMsgSrc
}

NetlinkMessage

func BridgeVlanInfoSerialize added in v0.4.0

func BridgeVlanInfoSerialize(brvlan *BridgeVlanInfo, msgType uint16) (*NetlinkMessage, error)

BridgeVlanInfoSerialize coverts BridgeVlanInfo struct to netlink message. msgType is RTM_NEWBRIDGE, RTM_DELBRIDGE, RTM_SETBRIDGE (gonla/nlamsg/nlalink package)

func NewNetlinkMessage

func NewNetlinkMessage(msg *syscall.NetlinkMessage, nid uint8, src NlMsgSrc) *NetlinkMessage

func NodeSerialize

func NodeSerialize(node *Node, msgType uint16) (*NetlinkMessage, error)

func VpnSerialize

func VpnSerialize(vpn *Vpn, msgType uint16) (*NetlinkMessage, error)

func (*NetlinkMessage) Group

func (m *NetlinkMessage) Group() uint16

func (*NetlinkMessage) Len

func (m *NetlinkMessage) Len() uint32

func (*NetlinkMessage) String

func (m *NetlinkMessage) String() string

func (*NetlinkMessage) Type

func (m *NetlinkMessage) Type() uint16

type NetlinkMessageHandler

type NetlinkMessageHandler interface {
	NetlinkMessage(*NetlinkMessage)
}

type NetlinkMessageUnion

type NetlinkMessageUnion struct {
	Header syscall.NlMsghdr
	Msg    interface{}
	NId    uint8
	Src    NlMsgSrc
}

func NewNetlinkMessageUnion

func NewNetlinkMessageUnion(header *syscall.NlMsghdr, msg interface{}, nid uint8, src NlMsgSrc) *NetlinkMessageUnion

func (*NetlinkMessageUnion) GetAddr

func (n *NetlinkMessageUnion) GetAddr() *Addr

func (*NetlinkMessageUnion) GetBridgeVlanInfo added in v0.4.0

func (n *NetlinkMessageUnion) GetBridgeVlanInfo() *BridgeVlanInfo
func (n *NetlinkMessageUnion) GetLink() *Link

func (*NetlinkMessageUnion) GetNeigh

func (n *NetlinkMessageUnion) GetNeigh() *Neigh

func (*NetlinkMessageUnion) GetNode

func (n *NetlinkMessageUnion) GetNode() *Node

func (*NetlinkMessageUnion) GetRoute

func (n *NetlinkMessageUnion) GetRoute() *Route

func (*NetlinkMessageUnion) GetVpn

func (n *NetlinkMessageUnion) GetVpn() *Vpn

func (*NetlinkMessageUnion) Group

func (m *NetlinkMessageUnion) Group() uint16

func (*NetlinkMessageUnion) String

func (m *NetlinkMessageUnion) String() string

func (*NetlinkMessageUnion) Type

func (m *NetlinkMessageUnion) Type() uint16

type NetlinkNeighHandler

type NetlinkNeighHandler interface {
	NetlinkNeigh(*NetlinkMessage, *Neigh)
}

type NetlinkNodeHandler

type NetlinkNodeHandler interface {
	NetlinkNode(*NetlinkMessage, *Node)
}

type NetlinkRouteHandler

type NetlinkRouteHandler interface {
	NetlinkRoute(*NetlinkMessage, *Route)
}

type NetlinkVpnHandler

type NetlinkVpnHandler interface {
	NetlinkVpn(*NetlinkMessage, *Vpn)
}

type NlMsgSrc

type NlMsgSrc int32
const (
	SRC_NOP NlMsgSrc = 0
	SRC_KNL NlMsgSrc = 1
	SRC_API NlMsgSrc = 2
)

func (NlMsgSrc) String

func (n NlMsgSrc) String() string

type Node

type Node struct {
	*nlalink.Node
	NId uint8
	Ch  chan *NetlinkMessageUnion
}

Node

func NewNode

func NewNode(node *nlalink.Node, nid uint8) *Node

func NodeDeserialize

func NodeDeserialize(nlmsg *NetlinkMessage) (*Node, error)

func (*Node) Close

func (n *Node) Close()

func (*Node) Copy

func (n *Node) Copy() *Node

func (*Node) Open

func (n *Node) Open()

func (*Node) Recv

func (n *Node) Recv() <-chan *NetlinkMessageUnion

func (*Node) Send

func (n *Node) Send(msg *NetlinkMessageUnion) error

func (*Node) String

func (n *Node) String() string

type Route

type Route struct {
	*netlink.Route
	RtId  uint32 // auto increment
	NId   uint8
	VpnGw net.IP
	EnIds []uint32
}

Route

func NewRoute

func NewRoute(route *netlink.Route, nid uint8, id uint32, vpnGw net.IP, enIds []uint32) *Route

func RouteDeserialize

func RouteDeserialize(nlmsg *NetlinkMessage) (*Route, error)

func (*Route) Copy

func (r *Route) Copy() *Route

func (*Route) GetDst

func (r *Route) GetDst() *net.IPNet

func (*Route) GetEncap

func (r *Route) GetEncap() netlink.Encap

func (*Route) GetGw

func (r *Route) GetGw() net.IP

func (*Route) GetLinkIndex

func (r *Route) GetLinkIndex() int

func (*Route) GetMPLSEncap

func (r *Route) GetMPLSEncap() *netlink.MPLSEncap

func (*Route) GetMPLSNewDst

func (r *Route) GetMPLSNewDst() *netlink.MPLSDestination

func (*Route) MultiPathIndex

func (r *Route) MultiPathIndex() int

func (*Route) String

func (r *Route) String() string

type Vpn

type Vpn struct {
	*nlalink.Vpn
	VpnId uint32 // auto increment
	NId   uint8
}

Vpn

func NewVpn

func NewVpn(vpn *nlalink.Vpn, nid uint8, id uint32) *Vpn

func VpnDeserialize

func VpnDeserialize(nlmsg *NetlinkMessage) (*Vpn, error)

func (*Vpn) Copy

func (v *Vpn) Copy() *Vpn

func (*Vpn) String

func (v *Vpn) String() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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