iproute2

package module
v0.0.0-...-2854774 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2022 License: Apache-2.0 Imports: 6 Imported by: 0

README

go-iproute2

Some net tools of iproute2 implement with Go.

Completions

ip
  1. ip neigh list
  2. ip link list
  3. ip addr list
  4. ip rourte list
bridge
  1. bridge monitor fdb
  2. bridge fdb list
ss
  1. ss -s: print summary of socket stat
  2. ss -l: list all udp and tcp listening sockets
  3. ss -t: list all tcp connections
  4. ss -lt: list all tcp listeners
  5. ss -u: list all udp sockets, excluding the listening ones
  6. ss -lu: list all udp listening sockets

All the above listings support IPv4 and IPv6 version.

TO-DO

  • ip
  • bridge
  • ss (basically complete)

Maybe more tools, like dcb, devlink, nstat, tc, will be implemented in some day.

Documentation

Index

Constants

View Source
const (
	SizeofInetDiagReq  = int(unsafe.Sizeof(InetDiagReq{}))
	SizeofInetDiagMsg  = int(unsafe.Sizeof(InetDiagMsg{}))
	SizeofIfInfoMsg    = unix.SizeofIfInfomsg
	SizeofIfAddrMsg    = unix.SizeofIfAddrmsg
	SizeofIfaCacheinfo = unix.SizeofIfaCacheinfo
	SizeofNdMsg        = unix.SizeofNdMsg
	SizeofRtMsg        = unix.SizeofRtMsg
)

size of some structures.

View Source
const (
	AF_BRIDGE = 0x7
	PF_BRIDGE = AF_BRIDGE
)

copied from syscall

View Source
const (
	NETLINK_ROUTE = 0x0

	RTM_NEWNEIGH = 0x1c
	RTM_DELNEIGH = 0x1d
	RTM_GETNEIGH = 0x1e

	RTNLGRP_NEIGH = 0x3
)

copied from golang.org/x/sys/unix

View Source
const (
	FamilySocketMonitoring = 0x0004
)

families for netlink socket

View Source
const (
	IFLA_EXT_MASK = 0x1d
)

copied from src/cmd/vendor/golang.org/x/sys/unix/ztypes_linux.go TODO(Asphaltt): use ztypes_linux.go instead

View Source
const (
	MsgTypeSockDiagByFamily = 0x0014
)

message types for netlink message

Variables

This section is empty.

Functions

This section is empty.

Types

type IfAddrMsg

type IfAddrMsg unix.IfAddrmsg

IfAddrMsg is an interface address message, that's an alias of golang.org/x/sys/unix.IfAddrmsg

func (*IfAddrMsg) MarshalBinary

func (m *IfAddrMsg) MarshalBinary() ([]byte, error)

MarshalBinary marshals an interface address message to byte slice.

func (*IfAddrMsg) UnmarshalBinary

func (m *IfAddrMsg) UnmarshalBinary(data []byte) error

UnmarshalBinary unmarshals an interface address message from byte slice.

type IfInfoMsg

type IfInfoMsg unix.IfInfomsg

IfInfoMsg is an interface information message, that's an alias of golang.org/x/sys/unix.IfInfomsg

func (*IfInfoMsg) MarshalBinary

func (m *IfInfoMsg) MarshalBinary() ([]byte, error)

MarshalBinary marshals an interface information message to byte slice.

func (*IfInfoMsg) UnmarshalBinary

func (m *IfInfoMsg) UnmarshalBinary(data []byte) error

UnmarshalBinary unmarshals an interface information message from byte slice.

type IfaCacheinfo

type IfaCacheinfo unix.IfaCacheinfo

IfaCacheinfo is an interface address information, that's an alias of golang.org/x/sys/unix.IfaCacheinfo

func (*IfaCacheinfo) MarshalBinary

func (m *IfaCacheinfo) MarshalBinary() ([]byte, error)

MarshalBinary marshals an interface address information to byte slice.

func (*IfaCacheinfo) UnmarshalBinary

func (m *IfaCacheinfo) UnmarshalBinary(data []byte) error

UnmarshalBinary unmarshals an interface address information from byte slice.

type InetDiagMsg

type InetDiagMsg struct {
	Family  uint8
	State   uint8
	Timer   uint8
	Retrans uint8

	InetDiagSockID

	Expires uint32
	RQueue  uint32
	WQueue  uint32
	UID     uint32
	Inode   uint32
}

An InetDiagMsg is a response message for sock diag netlink.

func (*InetDiagMsg) UnmarshalBinary

func (msg *InetDiagMsg) UnmarshalBinary(data []byte) error

UnmarshalBinary unmarshals an inet diag response message from byte slice.

type InetDiagReq

type InetDiagReq struct {
	Family   uint8
	Protocol uint8
	Ext      uint8
	Pad      uint8
	States   uint32
	InetDiagSockID
}

An InetDiagReq is a request message for sock diag netlink.

func (*InetDiagReq) MarshalBinary

func (req *InetDiagReq) MarshalBinary() (data []byte, err error)

MarshalBinary marshals an inet diag request message to byte slice.

type InetDiagSockID

type InetDiagSockID struct {
	Sport   uint16 // big endian
	Dport   uint16 // big endian
	Saddr   [16]byte
	Daddr   [16]byte
	Ifindex uint32
	Cookie  [2]uint32
}

An InetDiagSockID contains some info about a socket.

type NdAttrCacheInfo

type NdAttrCacheInfo struct {
	Confirmed uint32
	Used      uint32
	Updated   uint32
	RefCount  uint32
}

A NdAttrCacheInfo is the cache info in the neighbour/fdb message.

func (*NdAttrCacheInfo) UnmarshalBinary

func (c *NdAttrCacheInfo) UnmarshalBinary(data []byte) error

UnmarshalBinary unmarshals a neighbour attribute's cache info from byte slice.

type NdAttrType

type NdAttrType uint16
const (
	NdaUnspec NdAttrType = iota
	NdaDst
	NdaLladdr
	NdaCacheInfo
	NdaProbes
	NdaVlan
	NdaPort
	NdaVNI
	NdaIfindex
	NdaMaster
	NdaLinkNetNSID
	NdaSrcVNI
	NdaProtocol
	NdaNhID
	NdaFdbExtAttrs
)

types for error message attribute

type NdMsg

type NdMsg unix.NdMsg

NdMsg is a neighbour message, that's an alias of golang.org/x/sys/unix.NdMsg

func (*NdMsg) MarshalBinary

func (m *NdMsg) MarshalBinary() ([]byte, error)

MarshalBinary marshals a neighbour message to byte slice.

type NtfFlag

type NtfFlag uint8
const (
	NtfUse NtfFlag = 1 << iota
	NtfSelf
	NtfMaster
	NtfProxy
	NtfExtLearned
	NtfOffloaded
	NtfSticky
	NtfRouter
)

func (NtfFlag) String

func (f NtfFlag) String() string

type NudState

type NudState uint16
const (
	NudIncomplete NudState = 1 << iota
	NudReachable
	NudStale
	NudDelay
	NudProbe
	NudFailed
	NudNoArp
	NudPermanent
	NudNone NudState = 0
)

func (NudState) String

func (s NudState) String() string

type RtMsg

type RtMsg unix.RtMsg

RtMsg is a route message, that's an alias of golang.org/x/sys/unix.RtMsg

func (*RtMsg) MarshalBinary

func (m *RtMsg) MarshalBinary() ([]byte, error)

MarshalBinary marshals a route message to byte slice.

func (*RtMsg) UnmarshalBinary

func (m *RtMsg) UnmarshalBinary(data []byte) error

UnmarshalBinary unmarshals a route message from byte slice.

type RtTextFilterType

type RtTextFilterType int

New extended info filters for IFLA_EXT_MASK

const (
	RTEXT_FILTER_VF RtTextFilterType = 1 << iota
	RTEXT_FILTER_BRVLAN
	RTEXT_FILTER_BRVLAN_COMPRESSED
	RTEXT_FILTER_SKIP_STATS
	RTEXT_FILTER_MRP
	RTEXT_FILTER_CFM_CONFIG
	RTEXT_FILTER_CFM_STATUS
)

type SockDiagAttrType

type SockDiagAttrType int

SockDiagAttrType is the type for sock diag's attribute.

const (
	InetDiagNone SockDiagAttrType = iota
	InetDiagMemInfo
	InetDiagInfo
	InetDiagVegaInfo
	InetDiagCong
	InetDiagTOS
	InetDiagTclass
	InetDiagSkMemInfo
	InetDiagShutdown

	InetDiagDctcpInfo /* request as INET_DIAG_VEGASINFO */
	InetDiagProtocol  /* response attribute only */
	InetDiagSkV6Only
	InetDiagLocals
	InetDiagPeers
	InetDiagPad
	InetDiagMark    /* only with CAP_NET_ADMIN */
	InetDiagBbrInfo /* request as INET_DIAG_VEGASINFO */
	InetDiagClassID /* request as INET_DIAG_TCLASS */
	InetDiagMD5Sig
	InetDiagUlpInfo
	InetDiagSkBpfStorages
	InetDiagCgroupID
	InetDiagSockOpt
)

attribute types for sock diag message

type SockStateType

type SockStateType int

SockStateType is the type for socket's state.

const (
	Unknown SockStateType = iota
	Established
	SynSent
	SynRecv
	FinWait1
	FinWait2
	TimeWait
	Close
	CloseWait
	LastAck
	Listen
	Closing

	All  SockStateType = 1<<(_Max) - 1
	Conn SockStateType = All & ^((1 << Listen) | (1 << Close) | (1 << TimeWait) | (1 << SynRecv))
)

states for socket

func (SockStateType) String

func (s SockStateType) String() string

String gets the description string of the state.

Directories

Path Synopsis
cmd
ip
ss
internal
etc

Jump to

Keyboard shortcuts

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