Documentation ¶
Overview ¶
Package netlink contains the bare minimum needed to partially parse netlink messages.
Index ¶
Constants ¶
const ( RTA_ALIGNTO = 4 SizeofNlMsghdr = 0x10 SizeofNlAttr = 0x4 SizeofRtAttr = 0x4 EINVAL = syscall.Errno(0x16) )
TODO - get these from sys/unix or syscall
Variables ¶
var ( ErrNotType20 = errors.New("NetlinkMessage wrong type") ErrParseFailed = errors.New("Unable to parse InetDiagMsg") )
Error types.
Functions ¶
func Parse ¶
func Parse(raw inetdiag.RawInetDiagMsg) (*inetdiag.InetDiagMsg, error)
Parse returns the InetDiagMsg itself Modified from original to also return attribute data array.
Types ¶
type NetlinkMessage ¶
type NetlinkMessage = syscall.NetlinkMessage
type NetlinkRouteAttr ¶
type NetlinkRouteAttr = syscall.NetlinkRouteAttr
func ParseRouteAttr ¶
func ParseRouteAttr(b []byte) ([]NetlinkRouteAttr, error)
ParseRouteAttr parses a byte array into slice of NetlinkRouteAttr struct. Derived from "github.com/vishvananda/netlink/nl/nl_linux.go"
type RouteAttrValue ¶
type RouteAttrValue []byte
RouteAttrValue is the type of RouteAttr.Value
func (RouteAttrValue) CongestionAlgorithm ¶
func (raw RouteAttrValue) CongestionAlgorithm() (string, bool)
CongestionAlgorithm returns the congestion algorithm string INET_DIAG_CONG
type Snapshot ¶
type Snapshot struct { // Timestamp of batch of messages containing this message. Timestamp time.Time // Bit field indicating whether each message type was observed. Observed uint32 // Bit field indicating whether any message type was NOT fully parsed. // TODO - populate this field if any message is ignored, or not fully parsed. NotFullyParsed uint32 // Info from struct inet_diag_msg, including socket_id; InetDiagMsg *inetdiag.InetDiagMsg SockInfo *inetdiag.SockID // From INET_DIAG_CONG message. CongestionAlgorithm string // See https://tools.ietf.org/html/rfc3168 // TODO Do we need to record whether these are present and zero, vs absent? TOS uint8 TClass uint8 ClassID uint8 // TODO Do we need to record present and zero, vs absent? Shutdown uint8 // From INET_DIAG_PROTOCOL message. // TODO Do we need to record present and zero, vs absent? Protocol inetdiag.Protocol Mark uint32 // TCPInfo contains data from struct tcp_info. TCPInfo *tcp.LinuxTCPInfo // Data obtained from INET_DIAG_MEMINFO. MemInfo *inetdiag.MemInfo // Data obtained from INET_DIAG_SKMEMINFO. SocketMem *inetdiag.SocketMemInfo VegasInfo *inetdiag.VegasInfo DCTCPInfo *inetdiag.DCTCPInfo BBRInfo *inetdiag.BBRInfo }
Snapshot contains all info gathered through netlink library.
func MakeSnapShot ¶
func MakeSnapShot(msg *NetlinkMessage, skipLocal bool) (*Snapshot, error)
MakeArchivalRecord parses the NetlinkMessage into a ArchivalRecord. If skipLocal is true, it will return nil for loopback, local unicast, multicast, and unspecified connections. Note that Parse does not populate the Timestamp field, so caller should do so.