netlink

package
v0.0.0-...-c9b7238 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2018 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// NetlinkRoute return socket descriptor.
	NetlinkRoute = 0

	// RtmGrpLink Rtnetlink multicast group.
	RtmGrpLink = 0x1
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Conn

type Conn struct {
	Family     int
	Groups     uint32
	FileDescr  int
	SocketAddr *unix.SockaddrNetlink
	Pid        uint32
}

Conn provides an interface for connecting to netlink socket.

func Dial

func Dial(family int, groups uint32) (*Conn, error)

Dial netlink socket.

func (*Conn) Bind

func (c *Conn) Bind() error

Bind to netlink socket.

func (*Conn) Close

func (c *Conn) Close() error

Close netlink socket.

func (*Conn) Receive

func (c *Conn) Receive() ([]syscall.NetlinkMessage, error)

Receive messages from netlink socket.

type Flags

type Flags uint

Flags type for network interface state.

const (
	// FlagUp interface is up (administratively).
	FlagUp Flags = 1 << iota

	// FlagBroadcast broadcast address valid.
	FlagBroadcast

	// FlagDebug turn on debugging.
	FlagDebug

	// FlagLoopback is a loopback net.
	FlagLoopback

	// FlagPointToPoint interface is has p-p link.
	FlagPointToPoint

	// FlagNoTrailers avoid use of trailers.
	FlagNoTrailers

	// FlagRunning interface RFC2863 OPER_UP.
	FlagRunning

	// FlagNoArp no ARP protocol.
	FlagNoArp

	// FlagPromisc receive all packets.
	FlagPromisc

	// FlagAllMulti receive all multicast packets.
	FlagAllMulti

	// FlagMaster master of a load balancer.
	FlagMaster

	// FlagSlave slave of a load balancer.
	FlagSlave

	// FlagMulticast supports multicast.
	FlagMulticast

	// FlagPortSel can set media type.
	FlagPortSel

	// FlagAutoMedia auto media select active.
	FlagAutoMedia

	// FlagDynamic dialup device with changing addresses.
	FlagDynamic

	// FlagLowerUp driver signals L1 up.
	FlagLowerUp

	// FlagDormant driver signals dormant.
	FlagDormant

	// FlagEcho echo sent packets.
	FlagEcho
)

func (Flags) MarshalJSON

func (f Flags) MarshalJSON() ([]byte, error)

MarshalJSON marshal flags into JSON.

func (Flags) Slice

func (f Flags) Slice() []string

Slice return a list of all flags.

func (Flags) String

func (f Flags) String() string

String return a string of all flags.

type HwAddr

type HwAddr []byte

HwAddr hardware address type.

func (HwAddr) MarshalJSON

func (a HwAddr) MarshalJSON() ([]byte, error)

MarshalJSON marshal hardware address into JSON.

func (HwAddr) String

func (a HwAddr) String() string

type Interface

type Interface struct {
	Index        int            `json:"index"`
	MTU          int            `json:"mtu"`
	Name         string         `json:"name"`
	HwAddr       HwAddr         `json:"hwaddr,omitempty"`
	Flags        Flags          `json:"flags"`
	NetInterface *net.Interface `json:"-"`
}

Interface provides information about a network interface.

func Interfaces

func Interfaces() ([]Interface, error)

Interfaces connect using rtnetlink and retrieve all network interfaces.

func ParseNewLink(ifim *syscall.IfInfomsg, attrs []syscall.NetlinkRouteAttr) *Interface

ParseNewLink parse interface info message.

Jump to

Keyboard shortcuts

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