nl

package
v0.0.0-...-2e893ec Latest Latest
Warning

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

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

Documentation

Overview

Package nl has low level primitives for making Netlink calls.

Index

Constants

View Source
const (
	DEFAULT_CHANGE = 0xFFFFFFFF
	// doesn't exist in syscall
	IFLA_VFINFO_LIST = 0x16
)
View Source
const (
	IFLA_INFO_UNSPEC = iota
	IFLA_INFO_KIND
	IFLA_INFO_DATA
	IFLA_INFO_XSTATS
	IFLA_INFO_MAX = IFLA_INFO_XSTATS
)
View Source
const (
	IFLA_VLAN_UNSPEC = iota
	IFLA_VLAN_ID
	IFLA_VLAN_FLAGS
	IFLA_VLAN_EGRESS_QOS
	IFLA_VLAN_INGRESS_QOS
	IFLA_VLAN_PROTOCOL
	IFLA_VLAN_MAX = IFLA_VLAN_PROTOCOL
)
View Source
const (
	VETH_INFO_UNSPEC = iota
	VETH_INFO_PEER
	VETH_INFO_MAX = VETH_INFO_PEER
)
View Source
const (
	IFLA_VXLAN_UNSPEC = iota
	IFLA_VXLAN_ID
	IFLA_VXLAN_GROUP
	IFLA_VXLAN_LINK
	IFLA_VXLAN_LOCAL
	IFLA_VXLAN_TTL
	IFLA_VXLAN_TOS
	IFLA_VXLAN_LEARNING
	IFLA_VXLAN_AGEING
	IFLA_VXLAN_LIMIT
	IFLA_VXLAN_PORT_RANGE
	IFLA_VXLAN_PROXY
	IFLA_VXLAN_RSC
	IFLA_VXLAN_L2MISS
	IFLA_VXLAN_L3MISS
	IFLA_VXLAN_PORT
	IFLA_VXLAN_GROUP6
	IFLA_VXLAN_LOCAL6
	IFLA_VXLAN_UDP_CSUM
	IFLA_VXLAN_UDP_ZERO_CSUM6_TX
	IFLA_VXLAN_UDP_ZERO_CSUM6_RX
	IFLA_VXLAN_REMCSUM_TX
	IFLA_VXLAN_REMCSUM_RX
	IFLA_VXLAN_GBP
	IFLA_VXLAN_REMCSUM_NOPARTIAL
	IFLA_VXLAN_FLOWBASED
	IFLA_VXLAN_MAX = IFLA_VXLAN_FLOWBASED
)
View Source
const (
	BRIDGE_MODE_UNSPEC = iota
	BRIDGE_MODE_HAIRPIN
)
View Source
const (
	IFLA_BRPORT_UNSPEC = iota
	IFLA_BRPORT_STATE
	IFLA_BRPORT_PRIORITY
	IFLA_BRPORT_COST
	IFLA_BRPORT_MODE
	IFLA_BRPORT_GUARD
	IFLA_BRPORT_PROTECT
	IFLA_BRPORT_FAST_LEAVE
	IFLA_BRPORT_LEARNING
	IFLA_BRPORT_UNICAST_FLOOD
	IFLA_BRPORT_MAX = IFLA_BRPORT_UNICAST_FLOOD
)
View Source
const (
	IFLA_IPVLAN_UNSPEC = iota
	IFLA_IPVLAN_MODE
	IFLA_IPVLAN_MAX = IFLA_IPVLAN_MODE
)
View Source
const (
	IFLA_MACVLAN_UNSPEC = iota
	IFLA_MACVLAN_MODE
	IFLA_MACVLAN_FLAGS
	IFLA_MACVLAN_MAX = IFLA_MACVLAN_FLAGS
)
View Source
const (
	MACVLAN_MODE_PRIVATE  = 1
	MACVLAN_MODE_VEPA     = 2
	MACVLAN_MODE_BRIDGE   = 4
	MACVLAN_MODE_PASSTHRU = 8
	MACVLAN_MODE_SOURCE   = 16
)
View Source
const (
	IFLA_BOND_UNSPEC = iota
	IFLA_BOND_MODE
	IFLA_BOND_ACTIVE_SLAVE
	IFLA_BOND_MIIMON
	IFLA_BOND_UPDELAY
	IFLA_BOND_DOWNDELAY
	IFLA_BOND_USE_CARRIER
	IFLA_BOND_ARP_INTERVAL
	IFLA_BOND_ARP_IP_TARGET
	IFLA_BOND_ARP_VALIDATE
	IFLA_BOND_ARP_ALL_TARGETS
	IFLA_BOND_PRIMARY
	IFLA_BOND_PRIMARY_RESELECT
	IFLA_BOND_FAIL_OVER_MAC
	IFLA_BOND_XMIT_HASH_POLICY
	IFLA_BOND_RESEND_IGMP
	IFLA_BOND_NUM_PEER_NOTIF
	IFLA_BOND_ALL_SLAVES_ACTIVE
	IFLA_BOND_MIN_LINKS
	IFLA_BOND_LP_INTERVAL
	IFLA_BOND_PACKETS_PER_SLAVE
	IFLA_BOND_AD_LACP_RATE
	IFLA_BOND_AD_SELECT
	IFLA_BOND_AD_INFO
)
View Source
const (
	IFLA_BOND_AD_INFO_UNSPEC = iota
	IFLA_BOND_AD_INFO_AGGREGATOR
	IFLA_BOND_AD_INFO_NUM_PORTS
	IFLA_BOND_AD_INFO_ACTOR_KEY
	IFLA_BOND_AD_INFO_PARTNER_KEY
	IFLA_BOND_AD_INFO_PARTNER_MAC
)
View Source
const (
	IFLA_BOND_SLAVE_UNSPEC = iota
	IFLA_BOND_SLAVE_STATE
	IFLA_BOND_SLAVE_MII_STATUS
	IFLA_BOND_SLAVE_LINK_FAILURE_COUNT
	IFLA_BOND_SLAVE_PERM_HWADDR
	IFLA_BOND_SLAVE_QUEUE_ID
	IFLA_BOND_SLAVE_AD_AGGREGATOR_ID
)
View Source
const (
	IFLA_GRE_UNSPEC = iota
	IFLA_GRE_LINK
	IFLA_GRE_IFLAGS
	IFLA_GRE_OFLAGS
	IFLA_GRE_IKEY
	IFLA_GRE_OKEY
	IFLA_GRE_LOCAL
	IFLA_GRE_REMOTE
	IFLA_GRE_TTL
	IFLA_GRE_TOS
	IFLA_GRE_PMTUDISC
	IFLA_GRE_ENCAP_LIMIT
	IFLA_GRE_FLOWINFO
	IFLA_GRE_FLAGS
	IFLA_GRE_ENCAP_TYPE
	IFLA_GRE_ENCAP_FLAGS
	IFLA_GRE_ENCAP_SPORT
	IFLA_GRE_ENCAP_DPORT
	IFLA_GRE_COLLECT_METADATA
	IFLA_GRE_MAX = IFLA_GRE_COLLECT_METADATA
)
View Source
const (
	GRE_CSUM    = 0x8000
	GRE_ROUTING = 0x4000
	GRE_KEY     = 0x2000
	GRE_SEQ     = 0x1000
	GRE_STRICT  = 0x0800
	GRE_REC     = 0x0700
	GRE_FLAGS   = 0x00F8
	GRE_VERSION = 0x0007
)
View Source
const (
	IFLA_VF_INFO_UNSPEC = iota
	IFLA_VF_INFO
	IFLA_VF_INFO_MAX = IFLA_VF_INFO
)
View Source
const (
	IFLA_VF_UNSPEC = iota
	IFLA_VF_MAC    /* Hardware queue specific attributes */
	IFLA_VF_VLAN
	IFLA_VF_TX_RATE      /* Max TX Bandwidth Allocation */
	IFLA_VF_SPOOFCHK     /* Spoof Checking on/off switch */
	IFLA_VF_LINK_STATE   /* link state enable/disable/auto switch */
	IFLA_VF_RATE         /* Min and Max TX Bandwidth Allocation */
	IFLA_VF_RSS_QUERY_EN /* RSS Redirection Table and Hash Key query
	 * on/off switch
	 */
	IFLA_VF_STATS /* network device statistics */
	IFLA_VF_MAX   = IFLA_VF_STATS
)
View Source
const (
	IFLA_VF_LINK_STATE_AUTO    = iota /* link state of the uplink */
	IFLA_VF_LINK_STATE_ENABLE         /* link always up */
	IFLA_VF_LINK_STATE_DISABLE        /* link always down */
	IFLA_VF_LINK_STATE_MAX     = IFLA_VF_LINK_STATE_DISABLE
)
View Source
const (
	IFLA_VF_STATS_RX_PACKETS = iota
	IFLA_VF_STATS_TX_PACKETS
	IFLA_VF_STATS_RX_BYTES
	IFLA_VF_STATS_TX_BYTES
	IFLA_VF_STATS_BROADCAST
	IFLA_VF_STATS_MULTICAST
	IFLA_VF_STATS_MAX = IFLA_VF_STATS_MULTICAST
)
View Source
const (
	SizeofVfMac        = 0x24
	SizeofVfVlan       = 0x0c
	SizeofVfTxRate     = 0x08
	SizeofVfRate       = 0x0c
	SizeofVfSpoofchk   = 0x08
	SizeofVfLinkState  = 0x08
	SizeofVfRssQueryEn = 0x08
)
View Source
const (
	// Family type definitions
	FAMILY_ALL = syscall.AF_UNSPEC
	FAMILY_V4  = syscall.AF_INET
	FAMILY_V6  = syscall.AF_INET6
)
View Source
const (
	FRA_UNSPEC  = iota
	FRA_DST     /* destination address */
	FRA_SRC     /* source address */
	FRA_IIFNAME /* interface name */
	FRA_GOTO    /* target to jump to (FR_ACT_GOTO) */
	FRA_UNUSED2
	FRA_PRIORITY /* priority/preference */
	FRA_UNUSED3
	FRA_UNUSED4
	FRA_UNUSED5
	FRA_FWMARK /* mark */
	FRA_FLOW   /* flow/class id */
	FRA_TUN_ID
	FRA_SUPPRESS_IFGROUP
	FRA_SUPPRESS_PREFIXLEN
	FRA_TABLE  /* Extended table id */
	FRA_FWMASK /* mask for netfilter mark */
	FRA_OIFNAME
)

syscall package lack of rule atributes type. Thus there are defined below

View Source
const (
	FR_ACT_UNSPEC = iota
	FR_ACT_TO_TBL /* Pass to fixed table */
	FR_ACT_GOTO   /* Jump to another rule */
	FR_ACT_NOP    /* No operation */
	FR_ACT_RES3
	FR_ACT_RES4
	FR_ACT_BLACKHOLE   /* Drop without notification */
	FR_ACT_UNREACHABLE /* Drop with ENETUNREACH */
	FR_ACT_PROHIBIT    /* Drop with EACCES */
)

ip rule netlink request types

View Source
const (
	LINKLAYER_UNSPEC = iota
	LINKLAYER_ETHERNET
	LINKLAYER_ATM
)

LinkLayer

View Source
const (
	ATM_CELL_PAYLOAD = 48
	ATM_CELL_SIZE    = 53
)

ATM

View Source
const (
	TCA_POLICE_UNSPEC = iota
	TCA_POLICE_TBF
	TCA_POLICE_RATE
	TCA_POLICE_PEAKRATE
	TCA_POLICE_AVRATE
	TCA_POLICE_RESULT
	TCA_POLICE_MAX = TCA_POLICE_RESULT
)

Police

View Source
const (
	TCA_UNSPEC = iota
	TCA_KIND
	TCA_OPTIONS
	TCA_STATS
	TCA_XSTATS
	TCA_RATE
	TCA_FCNT
	TCA_STATS2
	TCA_STAB
	TCA_MAX = TCA_STAB
)

Message types

View Source
const (
	TCA_ACT_TAB = 1
	TCAA_MAX    = 1
)
View Source
const (
	TCA_ACT_UNSPEC = iota
	TCA_ACT_KIND
	TCA_ACT_OPTIONS
	TCA_ACT_INDEX
	TCA_ACT_STATS
	TCA_ACT_MAX
)
View Source
const (
	TCA_PRIO_UNSPEC = iota
	TCA_PRIO_MQ
	TCA_PRIO_MAX = TCA_PRIO_MQ
)
View Source
const (
	SizeofTcMsg          = 0x14
	SizeofTcActionMsg    = 0x04
	SizeofTcPrioMap      = 0x14
	SizeofTcRateSpec     = 0x0c
	SizeofTcNetemQopt    = 0x18
	SizeofTcNetemCorr    = 0x0c
	SizeofTcNetemReorder = 0x08
	SizeofTcNetemCorrupt = 0x08
	SizeofTcTbfQopt      = 2*SizeofTcRateSpec + 0x0c
	SizeofTcHtbCopt      = 2*SizeofTcRateSpec + 0x14
	SizeofTcHtbGlob      = 0x14
	SizeofTcU32Key       = 0x10
	SizeofTcU32Sel       = 0x10 // without keys
	SizeofTcActBpf       = 0x14
	SizeofTcMirred       = 0x1c
	SizeofTcPolice       = 2*SizeofTcRateSpec + 0x20
)
View Source
const (
	TCA_TBF_UNSPEC = iota
	TCA_TBF_PARMS
	TCA_TBF_RTAB
	TCA_TBF_PTAB
	TCA_TBF_RATE64
	TCA_TBF_PRATE64
	TCA_TBF_BURST
	TCA_TBF_PBURST
	TCA_TBF_MAX = TCA_TBF_PBURST
)
View Source
const (
	TCA_NETEM_UNSPEC = iota
	TCA_NETEM_CORR
	TCA_NETEM_DELAY_DIST
	TCA_NETEM_REORDER
	TCA_NETEM_CORRUPT
	TCA_NETEM_LOSS
	TCA_NETEM_RATE
	TCA_NETEM_ECN
	TCA_NETEM_RATE64
	TCA_NETEM_MAX = TCA_NETEM_RATE64
)
View Source
const (
	TCA_HTB_UNSPEC = iota
	TCA_HTB_PARMS
	TCA_HTB_INIT
	TCA_HTB_CTAB
	TCA_HTB_RTAB
	TCA_HTB_DIRECT_QLEN
	TCA_HTB_RATE64
	TCA_HTB_CEIL64
	TCA_HTB_MAX = TCA_HTB_CEIL64
)
View Source
const (
	TCA_U32_UNSPEC = iota
	TCA_U32_CLASSID
	TCA_U32_HASH
	TCA_U32_LINK
	TCA_U32_DIVISOR
	TCA_U32_SEL
	TCA_U32_POLICE
	TCA_U32_ACT
	TCA_U32_INDEV
	TCA_U32_PCNT
	TCA_U32_MARK
	TCA_U32_MAX = TCA_U32_MARK
)
View Source
const (
	TC_U32_TERMINAL  = 1 << iota
	TC_U32_OFFSET    = 1 << iota
	TC_U32_VAROFFSET = 1 << iota
	TC_U32_EAT       = 1 << iota
)
View Source
const (
	TCA_MIRRED_UNSPEC = iota
	TCA_MIRRED_TM
	TCA_MIRRED_PARMS
	TCA_MIRRED_MAX = TCA_MIRRED_PARMS
)
View Source
const (
	TCA_EGRESS_REDIR   = 1 /* packet redirect to EGRESS*/
	TCA_EGRESS_MIRROR  = 2 /* mirror packet to EGRESS */
	TCA_INGRESS_REDIR  = 3 /* packet redirect to INGRESS*/
	TCA_INGRESS_MIRROR = 4 /* mirror packet to INGRESS */
)
View Source
const (
	TC_ACT_UNSPEC     = int32(-1)
	TC_ACT_OK         = 0
	TC_ACT_RECLASSIFY = 1
	TC_ACT_SHOT       = 2
	TC_ACT_PIPE       = 3
	TC_ACT_STOLEN     = 4
	TC_ACT_QUEUED     = 5
	TC_ACT_REPEAT     = 6
	TC_ACT_REDIRECT   = 7
	TC_ACT_JUMP       = 0x10000000
)
View Source
const (
	TC_POLICE_UNSPEC     = TC_ACT_UNSPEC
	TC_POLICE_OK         = TC_ACT_OK
	TC_POLICE_RECLASSIFY = TC_ACT_RECLASSIFY
	TC_POLICE_SHOT       = TC_ACT_SHOT
	TC_POLICE_PIPE       = TC_ACT_PIPE
)
View Source
const (
	TCA_FW_UNSPEC = iota
	TCA_FW_CLASSID
	TCA_FW_POLICE
	TCA_FW_INDEV
	TCA_FW_ACT
	TCA_FW_MASK
	TCA_FW_MAX = TCA_FW_MASK
)
View Source
const (
	TCA_BPF_UNSPEC = iota
	TCA_BPF_ACT
	TCA_BPF_POLICE
	TCA_BPF_CLASSID
	TCA_BPF_OPS_LEN
	TCA_BPF_OPS
	TCA_BPF_FD
	TCA_BPF_NAME
	TCA_BPF_FLAGS
	TCA_BPF_MAX = TCA_BPF_FLAGS
)
View Source
const (
	TCA_ACT_BPF_UNSPEC = iota
	TCA_ACT_BPF_TM
	TCA_ACT_BPF_PARMS
	TCA_ACT_BPF_OPS_LEN
	TCA_ACT_BPF_OPS
	TCA_ACT_BPF_FD
	TCA_ACT_BPF_NAME
	TCA_ACT_BPF_MAX = TCA_ACT_BPF_NAME
)
View Source
const (
	XFRM_MSG_BASE        = 0x10
	XFRM_MSG_NEWSA       = 0x10
	XFRM_MSG_DELSA       = 0x11
	XFRM_MSG_GETSA       = 0x12
	XFRM_MSG_NEWPOLICY   = 0x13
	XFRM_MSG_DELPOLICY   = 0x14
	XFRM_MSG_GETPOLICY   = 0x15
	XFRM_MSG_ALLOCSPI    = 0x16
	XFRM_MSG_ACQUIRE     = 0x17
	XFRM_MSG_EXPIRE      = 0x18
	XFRM_MSG_UPDPOLICY   = 0x19
	XFRM_MSG_UPDSA       = 0x1a
	XFRM_MSG_POLEXPIRE   = 0x1b
	XFRM_MSG_FLUSHSA     = 0x1c
	XFRM_MSG_FLUSHPOLICY = 0x1d
	XFRM_MSG_NEWAE       = 0x1e
	XFRM_MSG_GETAE       = 0x1f
	XFRM_MSG_REPORT      = 0x20
	XFRM_MSG_MIGRATE     = 0x21
	XFRM_MSG_NEWSADINFO  = 0x22
	XFRM_MSG_GETSADINFO  = 0x23
	XFRM_MSG_NEWSPDINFO  = 0x24
	XFRM_MSG_GETSPDINFO  = 0x25
	XFRM_MSG_MAPPING     = 0x26
	XFRM_MSG_MAX         = 0x26
	XFRM_NR_MSGTYPES     = 0x17
)

Message Types

View Source
const (
	/* Netlink message attributes.  */
	XFRMA_UNSPEC         = 0x00
	XFRMA_ALG_AUTH       = 0x01 /* struct xfrm_algo */
	XFRMA_ALG_CRYPT      = 0x02 /* struct xfrm_algo */
	XFRMA_ALG_COMP       = 0x03 /* struct xfrm_algo */
	XFRMA_ENCAP          = 0x04 /* struct xfrm_algo + struct xfrm_encap_tmpl */
	XFRMA_TMPL           = 0x05 /* 1 or more struct xfrm_user_tmpl */
	XFRMA_SA             = 0x06 /* struct xfrm_usersa_info  */
	XFRMA_POLICY         = 0x07 /* struct xfrm_userpolicy_info */
	XFRMA_SEC_CTX        = 0x08 /* struct xfrm_sec_ctx */
	XFRMA_LTIME_VAL      = 0x09
	XFRMA_REPLAY_VAL     = 0x0a
	XFRMA_REPLAY_THRESH  = 0x0b
	XFRMA_ETIMER_THRESH  = 0x0c
	XFRMA_SRCADDR        = 0x0d /* xfrm_address_t */
	XFRMA_COADDR         = 0x0e /* xfrm_address_t */
	XFRMA_LASTUSED       = 0x0f /* unsigned long  */
	XFRMA_POLICY_TYPE    = 0x10 /* struct xfrm_userpolicy_type */
	XFRMA_MIGRATE        = 0x11
	XFRMA_ALG_AEAD       = 0x12 /* struct xfrm_algo_aead */
	XFRMA_KMADDRESS      = 0x13 /* struct xfrm_user_kmaddress */
	XFRMA_ALG_AUTH_TRUNC = 0x14 /* struct xfrm_algo_auth */
	XFRMA_MARK           = 0x15 /* struct xfrm_mark */
	XFRMA_TFCPAD         = 0x16 /* __u32 */
	XFRMA_REPLAY_ESN_VAL = 0x17 /* struct xfrm_replay_esn */
	XFRMA_SA_EXTRA_FLAGS = 0x18 /* __u32 */
	XFRMA_MAX            = 0x18
)

Attribute types

View Source
const (
	SizeofXfrmAddress     = 0x10
	SizeofXfrmSelector    = 0x38
	SizeofXfrmLifetimeCfg = 0x40
	SizeofXfrmLifetimeCur = 0x20
	SizeofXfrmId          = 0x18
)
View Source
const (
	SizeofXfrmUserpolicyId   = 0x40
	SizeofXfrmUserpolicyInfo = 0xa8
	SizeofXfrmUserTmpl       = 0x40
)
View Source
const (
	SizeofXfrmUsersaId   = 0x18
	SizeofXfrmStats      = 0x0c
	SizeofXfrmUsersaInfo = 0xe0
	SizeofXfrmAlgo       = 0x44
	SizeofXfrmAlgoAuth   = 0x48
	SizeofXfrmEncapTmpl  = 0x18
)
View Source
const (
	// not defined in syscall
	IFLA_NET_NS_FD = 28
)
View Source
const (
	TCA_ACT_MIRRED = 8
)
View Source
const (
	TCA_BPF_FLAG_ACT_DIRECT uint32 = 1 << iota
)
View Source
const TC_LINKLAYER_MASK = 0x0F
View Source
const (
	TC_PRIO_MAX = 15
)
View Source
const (
	XFRM_INF = ^uint64(0)
)

Infinity for packet and byte counts

Variables

This section is empty.

Functions

func BytesToString

func BytesToString(b []byte) string

func GetIPFamily

func GetIPFamily(ip net.IP) int

GetIPFamily returns the family type of a net.IP.

func NativeEndian

func NativeEndian() binary.ByteOrder

Get native endianness for the system

func NonZeroTerminated

func NonZeroTerminated(s string) []byte

func ParseRouteAttr

func ParseRouteAttr(b []byte) ([]syscall.NetlinkRouteAttr, error)

func Swap16

func Swap16(i uint16) uint16

Byte swap a 16 bit value if we aren't big endian

func Swap32

func Swap32(i uint32) uint32

Byte swap a 32 bit value if aren't big endian

func Uint16Attr

func Uint16Attr(v uint16) []byte

func Uint32Attr

func Uint32Attr(v uint32) []byte

func Uint8Attr

func Uint8Attr(v uint8) []byte

func ZeroTerminated

func ZeroTerminated(s string) []byte

Types

type IfAddrmsg

type IfAddrmsg struct {
	syscall.IfAddrmsg
}

func DeserializeIfAddrmsg

func DeserializeIfAddrmsg(b []byte) *IfAddrmsg

func NewIfAddrmsg

func NewIfAddrmsg(family int) *IfAddrmsg

func (*IfAddrmsg) Len

func (msg *IfAddrmsg) Len() int

func (*IfAddrmsg) Serialize

func (msg *IfAddrmsg) Serialize() []byte

type IfInfomsg

type IfInfomsg struct {
	syscall.IfInfomsg
}

IfInfomsg is related to links, but it is used for list requests as well

func DeserializeIfInfomsg

func DeserializeIfInfomsg(b []byte) *IfInfomsg

func NewIfInfomsg

func NewIfInfomsg(family int) *IfInfomsg

Create an IfInfomsg with family specified

func NewIfInfomsgChild

func NewIfInfomsgChild(parent *RtAttr, family int) *IfInfomsg

func (*IfInfomsg) Len

func (msg *IfInfomsg) Len() int

func (*IfInfomsg) Serialize

func (msg *IfInfomsg) Serialize() []byte

type NetlinkRequest

type NetlinkRequest struct {
	syscall.NlMsghdr
	Data []NetlinkRequestData
}

func NewNetlinkRequest

func NewNetlinkRequest(proto, flags int) *NetlinkRequest

Create a new netlink request from proto and flags Note the Len value will be inaccurate once data is added until the message is serialized

func (*NetlinkRequest) AddData

func (req *NetlinkRequest) AddData(data NetlinkRequestData)

func (*NetlinkRequest) Execute

func (req *NetlinkRequest) Execute(sockType int, resType uint16) ([][]byte, error)

Execute the request against a the given sockType. Returns a list of netlink messages in seriaized format, optionally filtered by resType.

func (*NetlinkRequest) Serialize

func (req *NetlinkRequest) Serialize() []byte

Serialize the Netlink Request into a byte array

type NetlinkRequestData

type NetlinkRequestData interface {
	Len() int
	Serialize() []byte
}

type NetlinkSocket

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

func Subscribe

func Subscribe(protocol int, groups ...uint) (*NetlinkSocket, error)

Create a netlink socket with a given protocol (e.g. NETLINK_ROUTE) and subscribe it to multicast groups passed in variable argument list. Returns the netlink socket on which Receive() method can be called to retrieve the messages from the kernel.

func (*NetlinkSocket) Close

func (s *NetlinkSocket) Close()

func (*NetlinkSocket) GetFd

func (s *NetlinkSocket) GetFd() int

func (*NetlinkSocket) GetPid

func (s *NetlinkSocket) GetPid() (uint32, error)

func (*NetlinkSocket) Receive

func (s *NetlinkSocket) Receive() ([]syscall.NetlinkMessage, error)

func (*NetlinkSocket) Send

func (s *NetlinkSocket) Send(request *NetlinkRequest) error

type RtAttr

type RtAttr struct {
	syscall.RtAttr
	Data []byte
	// contains filtered or unexported fields
}

Extend RtAttr to handle data and children

func NewRtAttr

func NewRtAttr(attrType int, data []byte) *RtAttr

Create a new Extended RtAttr object

func NewRtAttrChild

func NewRtAttrChild(parent *RtAttr, attrType int, data []byte) *RtAttr

Create a new RtAttr obj anc add it as a child of an existing object

func (*RtAttr) Len

func (a *RtAttr) Len() int

func (*RtAttr) Serialize

func (a *RtAttr) Serialize() []byte

Serialize the RtAttr into a byte array This can't just unsafe.cast because it must iterate through children.

type RtMsg

type RtMsg struct {
	syscall.RtMsg
}

func DeserializeRtMsg

func DeserializeRtMsg(b []byte) *RtMsg

func NewRtDelMsg

func NewRtDelMsg() *RtMsg

func NewRtMsg

func NewRtMsg() *RtMsg

func (*RtMsg) Len

func (msg *RtMsg) Len() int

func (*RtMsg) Serialize

func (msg *RtMsg) Serialize() []byte

type TcActBpf

type TcActBpf struct {
	TcGen
}

func DeserializeTcActBpf

func DeserializeTcActBpf(b []byte) *TcActBpf

func (*TcActBpf) Len

func (msg *TcActBpf) Len() int

func (*TcActBpf) Serialize

func (x *TcActBpf) Serialize() []byte

type TcActionMsg

type TcActionMsg struct {
	Family uint8
	Pad    [3]byte
}

func DeserializeTcActionMsg

func DeserializeTcActionMsg(b []byte) *TcActionMsg

func (*TcActionMsg) Len

func (msg *TcActionMsg) Len() int

func (*TcActionMsg) Serialize

func (x *TcActionMsg) Serialize() []byte

type TcGen

type TcGen struct {
	Index   uint32
	Capab   uint32
	Action  int32
	Refcnt  int32
	Bindcnt int32
}

type TcHtbCopt

type TcHtbCopt struct {
	Rate    TcRateSpec
	Ceil    TcRateSpec
	Buffer  uint32
	Cbuffer uint32
	Quantum uint32
	Level   uint32
	Prio    uint32
}

func DeserializeTcHtbCopt

func DeserializeTcHtbCopt(b []byte) *TcHtbCopt

func (*TcHtbCopt) Len

func (msg *TcHtbCopt) Len() int

func (*TcHtbCopt) Serialize

func (x *TcHtbCopt) Serialize() []byte

type TcHtbGlob

type TcHtbGlob struct {
	Version      uint32
	Rate2Quantum uint32
	Defcls       uint32
	Debug        uint32
	DirectPkts   uint32
}

func DeserializeTcHtbGlob

func DeserializeTcHtbGlob(b []byte) *TcHtbGlob

func (*TcHtbGlob) Len

func (msg *TcHtbGlob) Len() int

func (*TcHtbGlob) Serialize

func (x *TcHtbGlob) Serialize() []byte

type TcMirred

type TcMirred struct {
	TcGen
	Eaction int32
	Ifindex uint32
}

func DeserializeTcMirred

func DeserializeTcMirred(b []byte) *TcMirred

func (*TcMirred) Len

func (msg *TcMirred) Len() int

func (*TcMirred) Serialize

func (x *TcMirred) Serialize() []byte

type TcMsg

type TcMsg struct {
	Family  uint8
	Pad     [3]byte
	Ifindex int32
	Handle  uint32
	Parent  uint32
	Info    uint32
}

func DeserializeTcMsg

func DeserializeTcMsg(b []byte) *TcMsg

func (*TcMsg) Len

func (msg *TcMsg) Len() int

func (*TcMsg) Serialize

func (x *TcMsg) Serialize() []byte

type TcNetemCorr

type TcNetemCorr struct {
	DelayCorr uint32
	LossCorr  uint32
	DupCorr   uint32
}

func DeserializeTcNetemCorr

func DeserializeTcNetemCorr(b []byte) *TcNetemCorr

func (*TcNetemCorr) Len

func (msg *TcNetemCorr) Len() int

func (*TcNetemCorr) Serialize

func (x *TcNetemCorr) Serialize() []byte

type TcNetemCorrupt

type TcNetemCorrupt struct {
	Probability uint32
	Correlation uint32
}

func DeserializeTcNetemCorrupt

func DeserializeTcNetemCorrupt(b []byte) *TcNetemCorrupt

func (*TcNetemCorrupt) Len

func (msg *TcNetemCorrupt) Len() int

func (*TcNetemCorrupt) Serialize

func (x *TcNetemCorrupt) Serialize() []byte

type TcNetemQopt

type TcNetemQopt struct {
	Latency   uint32
	Limit     uint32
	Loss      uint32
	Gap       uint32
	Duplicate uint32
	Jitter    uint32
}

func DeserializeTcNetemQopt

func DeserializeTcNetemQopt(b []byte) *TcNetemQopt

func (*TcNetemQopt) Len

func (msg *TcNetemQopt) Len() int

func (*TcNetemQopt) Serialize

func (x *TcNetemQopt) Serialize() []byte

type TcNetemReorder

type TcNetemReorder struct {
	Probability uint32
	Correlation uint32
}

func DeserializeTcNetemReorder

func DeserializeTcNetemReorder(b []byte) *TcNetemReorder

func (*TcNetemReorder) Len

func (msg *TcNetemReorder) Len() int

func (*TcNetemReorder) Serialize

func (x *TcNetemReorder) Serialize() []byte

type TcPolice

type TcPolice struct {
	Index    uint32
	Action   int32
	Limit    uint32
	Burst    uint32
	Mtu      uint32
	Rate     TcRateSpec
	PeakRate TcRateSpec
	Refcnt   int32
	Bindcnt  int32
	Capab    uint32
}

func DeserializeTcPolice

func DeserializeTcPolice(b []byte) *TcPolice

func (*TcPolice) Len

func (msg *TcPolice) Len() int

func (*TcPolice) Serialize

func (x *TcPolice) Serialize() []byte

type TcPrioMap

type TcPrioMap struct {
	Bands   int32
	Priomap [TC_PRIO_MAX + 1]uint8
}

func DeserializeTcPrioMap

func DeserializeTcPrioMap(b []byte) *TcPrioMap

func (*TcPrioMap) Len

func (msg *TcPrioMap) Len() int

func (*TcPrioMap) Serialize

func (x *TcPrioMap) Serialize() []byte

type TcRateSpec

type TcRateSpec struct {
	CellLog   uint8
	Linklayer uint8
	Overhead  uint16
	CellAlign int16
	Mpu       uint16
	Rate      uint32
}

func DeserializeTcRateSpec

func DeserializeTcRateSpec(b []byte) *TcRateSpec

func (*TcRateSpec) Len

func (msg *TcRateSpec) Len() int

func (*TcRateSpec) Serialize

func (x *TcRateSpec) Serialize() []byte

type TcTbfQopt

type TcTbfQopt struct {
	Rate     TcRateSpec
	Peakrate TcRateSpec
	Limit    uint32
	Buffer   uint32
	Mtu      uint32
}

func DeserializeTcTbfQopt

func DeserializeTcTbfQopt(b []byte) *TcTbfQopt

func (*TcTbfQopt) Len

func (msg *TcTbfQopt) Len() int

func (*TcTbfQopt) Serialize

func (x *TcTbfQopt) Serialize() []byte

type TcU32Key

type TcU32Key struct {
	Mask    uint32 // big endian
	Val     uint32 // big endian
	Off     int32
	OffMask int32
}

func DeserializeTcU32Key

func DeserializeTcU32Key(b []byte) *TcU32Key

func (*TcU32Key) Len

func (msg *TcU32Key) Len() int

func (*TcU32Key) Serialize

func (x *TcU32Key) Serialize() []byte

type TcU32Sel

type TcU32Sel struct {
	Flags    uint8
	Offshift uint8
	Nkeys    uint8
	Pad      uint8
	Offmask  uint16 // big endian
	Off      uint16
	Offoff   int16
	Hoff     int16
	Hmask    uint32 // big endian
	Keys     []TcU32Key
}

func DeserializeTcU32Sel

func DeserializeTcU32Sel(b []byte) *TcU32Sel

func (*TcU32Sel) Len

func (msg *TcU32Sel) Len() int

func (*TcU32Sel) Serialize

func (x *TcU32Sel) Serialize() []byte

type VfLinkState

type VfLinkState struct {
	Vf        uint32
	LinkState uint32
}

func DeserializeVfLinkState

func DeserializeVfLinkState(b []byte) *VfLinkState

func (*VfLinkState) Len

func (msg *VfLinkState) Len() int

func (*VfLinkState) Serialize

func (msg *VfLinkState) Serialize() []byte

type VfMac

type VfMac struct {
	Vf  uint32
	Mac [32]byte
}

func DeserializeVfMac

func DeserializeVfMac(b []byte) *VfMac

func (*VfMac) Len

func (msg *VfMac) Len() int

func (*VfMac) Serialize

func (msg *VfMac) Serialize() []byte

type VfRate

type VfRate struct {
	Vf        uint32
	MinTxRate uint32
	MaxTxRate uint32
}

func DeserializeVfRate

func DeserializeVfRate(b []byte) *VfRate

func (*VfRate) Len

func (msg *VfRate) Len() int

func (*VfRate) Serialize

func (msg *VfRate) Serialize() []byte

type VfRssQueryEn

type VfRssQueryEn struct {
	Vf      uint32
	Setting uint32
}

func DeserializeVfRssQueryEn

func DeserializeVfRssQueryEn(b []byte) *VfRssQueryEn

func (*VfRssQueryEn) Len

func (msg *VfRssQueryEn) Len() int

func (*VfRssQueryEn) Serialize

func (msg *VfRssQueryEn) Serialize() []byte

type VfSpoofchk

type VfSpoofchk struct {
	Vf      uint32
	Setting uint32
}

func DeserializeVfSpoofchk

func DeserializeVfSpoofchk(b []byte) *VfSpoofchk

func (*VfSpoofchk) Len

func (msg *VfSpoofchk) Len() int

func (*VfSpoofchk) Serialize

func (msg *VfSpoofchk) Serialize() []byte

type VfTxRate

type VfTxRate struct {
	Vf   uint32
	Rate uint32
}

func DeserializeVfTxRate

func DeserializeVfTxRate(b []byte) *VfTxRate

func (*VfTxRate) Len

func (msg *VfTxRate) Len() int

func (*VfTxRate) Serialize

func (msg *VfTxRate) Serialize() []byte

type VfVlan

type VfVlan struct {
	Vf   uint32
	Vlan uint32
	Qos  uint32
}

func DeserializeVfVlan

func DeserializeVfVlan(b []byte) *VfVlan

func (*VfVlan) Len

func (msg *VfVlan) Len() int

func (*VfVlan) Serialize

func (msg *VfVlan) Serialize() []byte

type XfrmAddress

type XfrmAddress [SizeofXfrmAddress]byte

func DeserializeXfrmAddress

func DeserializeXfrmAddress(b []byte) *XfrmAddress

func (*XfrmAddress) FromIP

func (x *XfrmAddress) FromIP(ip net.IP)

func (*XfrmAddress) Serialize

func (x *XfrmAddress) Serialize() []byte

func (*XfrmAddress) ToIP

func (x *XfrmAddress) ToIP() net.IP

func (*XfrmAddress) ToIPNet

func (x *XfrmAddress) ToIPNet(prefixlen uint8) *net.IPNet

type XfrmAlgo

type XfrmAlgo struct {
	AlgName   [64]byte
	AlgKeyLen uint32
	AlgKey    []byte
}

func DeserializeXfrmAlgo

func DeserializeXfrmAlgo(b []byte) *XfrmAlgo

func (*XfrmAlgo) Len

func (msg *XfrmAlgo) Len() int

func (*XfrmAlgo) Serialize

func (msg *XfrmAlgo) Serialize() []byte

type XfrmAlgoAuth

type XfrmAlgoAuth struct {
	AlgName     [64]byte
	AlgKeyLen   uint32
	AlgTruncLen uint32
	AlgKey      []byte
}

func DeserializeXfrmAlgoAuth

func DeserializeXfrmAlgoAuth(b []byte) *XfrmAlgoAuth

func (*XfrmAlgoAuth) Len

func (msg *XfrmAlgoAuth) Len() int

func (*XfrmAlgoAuth) Serialize

func (msg *XfrmAlgoAuth) Serialize() []byte

type XfrmEncapTmpl

type XfrmEncapTmpl struct {
	EncapType  uint16
	EncapSport uint16 // big endian
	EncapDport uint16 // big endian
	Pad        [2]byte
	EncapOa    XfrmAddress
}

func DeserializeXfrmEncapTmpl

func DeserializeXfrmEncapTmpl(b []byte) *XfrmEncapTmpl

func (*XfrmEncapTmpl) Len

func (msg *XfrmEncapTmpl) Len() int

func (*XfrmEncapTmpl) Serialize

func (msg *XfrmEncapTmpl) Serialize() []byte

type XfrmId

type XfrmId struct {
	Daddr XfrmAddress
	Spi   uint32 // big endian
	Proto uint8
	Pad   [3]byte
}

func DeserializeXfrmId

func DeserializeXfrmId(b []byte) *XfrmId

func (*XfrmId) Len

func (msg *XfrmId) Len() int

func (*XfrmId) Serialize

func (msg *XfrmId) Serialize() []byte

type XfrmLifetimeCfg

type XfrmLifetimeCfg struct {
	SoftByteLimit         uint64
	HardByteLimit         uint64
	SoftPacketLimit       uint64
	HardPacketLimit       uint64
	SoftAddExpiresSeconds uint64
	HardAddExpiresSeconds uint64
	SoftUseExpiresSeconds uint64
	HardUseExpiresSeconds uint64
}

func DeserializeXfrmLifetimeCfg

func DeserializeXfrmLifetimeCfg(b []byte) *XfrmLifetimeCfg

func (*XfrmLifetimeCfg) Len

func (msg *XfrmLifetimeCfg) Len() int

func (*XfrmLifetimeCfg) Serialize

func (msg *XfrmLifetimeCfg) Serialize() []byte

type XfrmLifetimeCur

type XfrmLifetimeCur struct {
	Bytes   uint64
	Packets uint64
	AddTime uint64
	UseTime uint64
}

func DeserializeXfrmLifetimeCur

func DeserializeXfrmLifetimeCur(b []byte) *XfrmLifetimeCur

func (*XfrmLifetimeCur) Len

func (msg *XfrmLifetimeCur) Len() int

func (*XfrmLifetimeCur) Serialize

func (msg *XfrmLifetimeCur) Serialize() []byte

type XfrmSelector

type XfrmSelector struct {
	Daddr      XfrmAddress
	Saddr      XfrmAddress
	Dport      uint16 // big endian
	DportMask  uint16 // big endian
	Sport      uint16 // big endian
	SportMask  uint16 // big endian
	Family     uint16
	PrefixlenD uint8
	PrefixlenS uint8
	Proto      uint8
	Pad        [3]byte
	Ifindex    int32
	User       uint32
}

func DeserializeXfrmSelector

func DeserializeXfrmSelector(b []byte) *XfrmSelector

func (*XfrmSelector) Len

func (msg *XfrmSelector) Len() int

func (*XfrmSelector) Serialize

func (msg *XfrmSelector) Serialize() []byte

type XfrmStats

type XfrmStats struct {
	ReplayWindow    uint32
	Replay          uint32
	IntegrityFailed uint32
}

func DeserializeXfrmStats

func DeserializeXfrmStats(b []byte) *XfrmStats

func (*XfrmStats) Len

func (msg *XfrmStats) Len() int

func (*XfrmStats) Serialize

func (msg *XfrmStats) Serialize() []byte

type XfrmUserTmpl

type XfrmUserTmpl struct {
	XfrmId   XfrmId
	Family   uint16
	Pad1     [2]byte
	Saddr    XfrmAddress
	Reqid    uint32
	Mode     uint8
	Share    uint8
	Optional uint8
	Pad2     byte
	Aalgos   uint32
	Ealgos   uint32
	Calgos   uint32
}

func DeserializeXfrmUserTmpl

func DeserializeXfrmUserTmpl(b []byte) *XfrmUserTmpl

func (*XfrmUserTmpl) Len

func (msg *XfrmUserTmpl) Len() int

func (*XfrmUserTmpl) Serialize

func (msg *XfrmUserTmpl) Serialize() []byte

type XfrmUserpolicyId

type XfrmUserpolicyId struct {
	Sel   XfrmSelector
	Index uint32
	Dir   uint8
	Pad   [3]byte
}

func DeserializeXfrmUserpolicyId

func DeserializeXfrmUserpolicyId(b []byte) *XfrmUserpolicyId

func (*XfrmUserpolicyId) Len

func (msg *XfrmUserpolicyId) Len() int

func (*XfrmUserpolicyId) Serialize

func (msg *XfrmUserpolicyId) Serialize() []byte

type XfrmUserpolicyInfo

type XfrmUserpolicyInfo struct {
	Sel      XfrmSelector
	Lft      XfrmLifetimeCfg
	Curlft   XfrmLifetimeCur
	Priority uint32
	Index    uint32
	Dir      uint8
	Action   uint8
	Flags    uint8
	Share    uint8
	Pad      [4]byte
}

func DeserializeXfrmUserpolicyInfo

func DeserializeXfrmUserpolicyInfo(b []byte) *XfrmUserpolicyInfo

func (*XfrmUserpolicyInfo) Len

func (msg *XfrmUserpolicyInfo) Len() int

func (*XfrmUserpolicyInfo) Serialize

func (msg *XfrmUserpolicyInfo) Serialize() []byte

type XfrmUsersaId

type XfrmUsersaId struct {
	Daddr  XfrmAddress
	Spi    uint32 // big endian
	Family uint16
	Proto  uint8
	Pad    byte
}

func DeserializeXfrmUsersaId

func DeserializeXfrmUsersaId(b []byte) *XfrmUsersaId

func (*XfrmUsersaId) Len

func (msg *XfrmUsersaId) Len() int

func (*XfrmUsersaId) Serialize

func (msg *XfrmUsersaId) Serialize() []byte

type XfrmUsersaInfo

type XfrmUsersaInfo struct {
	Sel          XfrmSelector
	Id           XfrmId
	Saddr        XfrmAddress
	Lft          XfrmLifetimeCfg
	Curlft       XfrmLifetimeCur
	Stats        XfrmStats
	Seq          uint32
	Reqid        uint32
	Family       uint16
	Mode         uint8
	ReplayWindow uint8
	Flags        uint8
	Pad          [7]byte
}

func DeserializeXfrmUsersaInfo

func DeserializeXfrmUsersaInfo(b []byte) *XfrmUsersaInfo

func (*XfrmUsersaInfo) Len

func (msg *XfrmUsersaInfo) Len() int

func (*XfrmUsersaInfo) Serialize

func (msg *XfrmUsersaInfo) Serialize() []byte

Jump to

Keyboard shortcuts

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