ip

package
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: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ICMPV6_ROUTER_PREF_LOW     = 0x3
	ICMPV6_ROUTER_PREF_MEDIUM  = 0x0
	ICMPV6_ROUTER_PREF_HIGH    = 0x1
	ICMPV6_ROUTER_PREF_INVALID = 0x2
)
View Source
const (
	RTM_F_OFFLOAD_FAILED = 0x20000000 /* route offload failed, this value
	 * is chosen to avoid conflicts with
	 * other flags defined in
	 * include/uapi/linux/ipv6_route.h
	 */
)

Variables

View Source
var AddrFlagDatas []AddrFlagData

Functions

This section is empty.

Types

type AddrEntry

type AddrEntry struct {
	Family        int
	PrefixLen     int
	Flags         AddrFlag
	Scope         AddrScope
	Ifindex       int
	Name          string
	Label         string
	InterfaceAddr net.IP
	LocalAddr     net.IP
	BroadcastAddr net.IP
	AnycastAddr   net.IP
	MulticastAddr net.IP
	AddrFlags     AddrFlag
	AddrInfo      *iproute2.IfaCacheinfo
}

type AddrFlag

type AddrFlag int

func (AddrFlag) String

func (f AddrFlag) String() string

type AddrFlagData

type AddrFlagData struct {
	Name     string
	Mask     int
	ReadOnly bool
	V6Only   bool
}

type AddrFlagV6

type AddrFlagV6 int

func (AddrFlagV6) String

func (f AddrFlagV6) String() string

type AddrScope

type AddrScope int

func (AddrScope) String

func (s AddrScope) String() string

type Client

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

A Client can manipulate ip netlink interface.

func New

func New() (*Client, error)

New creates a Client which can issue ip commands.

func NewWithConn

func NewWithConn(conn *netlink.Conn) *Client

NewWithConn creates a Client which can issue ip commands with the given netlink connection.

func (*Client) ListAddresses

func (c *Client) ListAddresses() (map[int][]*AddrEntry, error)

ListAddresses gets all addresses information of links from kernel by netlink interface. Firstly, send a getting address request, and receive all netlink response messages. Secondly, parse address information from every netlink response messages one by one.

func (c *Client) ListLinks() ([]*LinkEntry, error)

ListLinks gets all links information from kernel by netlink interface. Firstly, send a getting link request, and receive all netlink response messages. Secondly, parse link information from every netlink response messages one by one.

func (*Client) ListNeighbours

func (c *Client) ListNeighbours() ([]*NeighEntry, error)

ListNeighbours dumps arp table from kernel. Firstly, send a getting neighbour request, and receive all netlink response messages. Secondly, parse neighbour information from every netlink response messages one by one.

func (*Client) ListRoutes

func (c *Client) ListRoutes() ([]*RouteEntry, error)

func (*Client) ListRoutesV4

func (c *Client) ListRoutesV4() ([]*RouteEntry, error)

func (*Client) ListRoutesV6

func (c *Client) ListRoutesV6() ([]*RouteEntry, error)

type LinkEntry

type LinkEntry struct {
	DeviceType       LinkType
	DeviceFlags      LinkFlags
	Ifindex          int
	Name             string
	Master           int
	Link             int
	Namespace        int
	TxQueueCount     int
	TxQueue          int
	RxQueueCount     int
	MTU              int
	MinMTU           int
	MaxMTU           int
	OperState        LinkOperState
	Mode             LinkMode
	Group            LinkGroup
	Promiscuity      int
	MaxGSOSegs       int
	MaxGSOSize       int
	Carrier          uint8
	CarrierChanges   int
	CarrierUpCount   int
	CarrierDownCount int
	QDisc            string
	ProtoDown        uint8
	Map              []byte
	Addr             []byte
	Broadcast        []byte
	Stat             []byte
	Stat64           []byte
	XDP              uint64
	AFSpec           []byte
}

A LinkEntry contains information for the link from kernel, like ifindex, name, link state, link type and so on. It should includes all information from executing command `ip link list`.

type LinkFlags

type LinkFlags uint32

LinkFlags is the type of link flag.

func (LinkFlags) String

func (f LinkFlags) String() string

String returns the string description of the LinkStat.

type LinkGroup

type LinkGroup int

LinkGroup is the type of link group.

func (LinkGroup) String

func (g LinkGroup) String() string

String returns the string description of the LinkGroup. The group information is from */etc/iproute2/group*.

type LinkMode

type LinkMode uint8

LinkMode is the type of link mode.

func (LinkMode) String

func (m LinkMode) String() string

String returns the string description of the LinkMode.

type LinkOperState

type LinkOperState int

LinkOperState is the type of link operstate.

func (LinkOperState) String

func (s LinkOperState) String() string

String returns the string description of the LinkOperState.

type LinkRxErrors

type LinkRxErrors struct {
	Length             uint64
	RingBufferOverflow uint64
	CRC                uint64
	FrameAlign         uint64
	FifoOverrun        uint64
	MissedPacket       uint64
}

LinkRxErrors is the rx error statistics of the link.

type LinkStat

type LinkStat struct {
	RxPackets   uint64
	TxPackets   uint64
	RxBytes     uint64
	TxBytes     uint64
	RxErrors    uint64
	TxErrors    uint64
	RxDropped   uint64
	TxDropped   uint64
	MulticastRx uint64
	Collisions  uint64
	LinkRxErrors
	LinkTxErrors
}

LinkStat is the packet statistis of the link, including rx error statistics and tx error statistics.

func (*LinkStat) UnmarshalBinary

func (s *LinkStat) UnmarshalBinary(data []byte) error

UnmarshalBinary gets a LinkStat from a byte slice.

type LinkTxErrors

type LinkTxErrors struct {
	Abort     uint64
	Carrier   uint64
	Fifo      uint64
	Heartbeat uint64
	Window    uint64
}

LinkTxErrors is the tx error statistics of the link.

type LinkType

type LinkType int

LinkType is the type of link type.

func (LinkType) String

func (t LinkType) String() string

String returns the string description of the LinkType.

type NeighEntry

type NeighEntry struct {
	Ifindex int
	Addr    net.IP
	Lladdr  net.HardwareAddr
	State   iproute2.NudState
}

A NeighEntry contains information for the arp records from kernel.

type RouteEntry

type RouteEntry struct {
	Family   int
	DstLen   int
	SrcLen   int
	Tos      int
	TableID  RouteTable
	Protocol RouteProtocol
	Scope    RouteScope
	Type     RouteType
	Flags    RouteFlags

	Daddr      net.IP
	Saddr      net.IP
	InIfindex  int
	OutIfindex int
	Gateway    net.IP
	Table      RouteTable
	Priority   int
	PrefSrc    net.IP
	Metric     int
	Pref       RoutePref
}

type RouteFlags

type RouteFlags int

func (RouteFlags) String

func (f RouteFlags) String() string

type RoutePref

type RoutePref int

func (RoutePref) String

func (p RoutePref) String() string

type RouteProtocol

type RouteProtocol int

func (RouteProtocol) String

func (p RouteProtocol) String() string

type RouteScope

type RouteScope int

func (RouteScope) String

func (s RouteScope) String() string

type RouteTable

type RouteTable int

func (RouteTable) String

func (t RouteTable) String() string

type RouteType

type RouteType int

func (RouteType) String

func (typ RouteType) String() string

Jump to

Keyboard shortcuts

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