Documentation
¶
Index ¶
- func Ntohs(in uint16) uint16
- func ToNetipAddr(in [4]uint32) netip.Addr
- func ToNetipAddrWithFamily(family uint8, in [4]uint32) (netip.Addr, error)
- type BBRInfo
- type Config
- type DCTCPInfo
- type Diag
- func (d *Diag) Close() error
- func (d *Diag) NetDump(opt *NetOption) ([]NetObject, error)
- func (d *Diag) SetOption(o netlink.ConnOption, enable bool) error
- func (d *Diag) TCPDump() ([]NetObject, error)
- func (d *Diag) UDPDump() ([]NetObject, error)
- func (d *Diag) UnixDump(opt *UnixOption) ([]UnixObject, error)
- type DiagMsg
- type InetDiagReqV2
- type KernelSockaddrStorage
- type MemInfo
- type NetAttribute
- type NetObject
- type NetOption
- type SctpInfo
- type SockID
- type SockOpt
- type TcpInfo
- type UnixAttribute
- type UnixDiagMsg
- type UnixDiagReq
- type UnixDiagRqLen
- type UnixDiagVfs
- type UnixObject
- type UnixOption
- type VegasInfo
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ToNetipAddr ¶
ToNetipAddr converts an IP in [4]uint32 representation to netip.Addr.
For the special case 0.0.0.0 or :: it can return an unspecified address. For details, see netip.IsUnspecified.
Types ¶
type Config ¶
type Config struct { // NetNS defines the network namespace NetNS int }
Config contains options for NETLINK_SOCK_DIAG
type Diag ¶
type Diag struct {
// contains filtered or unexported fields
}
Diag represents a netlink wrapper
func (*Diag) SetOption ¶
func (d *Diag) SetOption(o netlink.ConnOption, enable bool) error
SetOption allows to enable or disable netlink socket options.
func (*Diag) TCPDump ¶
Dump returns all TCP connections. It is a wrapper around (*Diag).NetDump(..) for IPPROTO_TCP and the families AF_INET and AF_INET6 for all TCP states.
func (*Diag) UDPDump ¶
Dump returns all TCP connections. It is a wrapper around (*Diag).NetDump(..) for IPPROTO_UDP and the families AF_INET and AF_INET6 for all UDP states.
func (*Diag) UnixDump ¶
func (d *Diag) UnixDump(opt *UnixOption) ([]UnixObject, error)
UnixDump returns Unix socket information.
type DiagMsg ¶
type DiagMsg struct { Family uint8 State uint8 Timer uint8 Retrans uint8 ID SockID Expires uint32 RQueue uint32 WQueue uint32 UID uint32 INode uint32 }
Based on inet_diag_msg
type InetDiagReqV2 ¶
type InetDiagReqV2 struct { Family uint8 Protocol uint8 Ext uint8 Pad uint8 States uint32 ID SockID }
Based on inet_diag_req_v2
type KernelSockaddrStorage ¶
Based on __kernel_sockaddr_storage in include/uapi/linux/socket.h
type NetAttribute ¶
type NetAttribute struct { MemInfo *MemInfo VegasInfo *VegasInfo Cong *string TOS *uint8 TClass *uint8 Shutdown *uint8 DCTCPInfo *DCTCPInfo Protocol *uint8 SKV6Only *uint8 Mark *uint32 BBRInfo *BBRInfo ClassID *uint32 CGroupID *uint64 SockOpt *SockOpt TcpInfo *TcpInfo SctpInfo *SctpInfo }
NetAttribute contains various elements
type NetObject ¶
type NetObject struct { DiagMsg NetAttribute }
NetObject represents a network response
type SctpInfo ¶
type SctpInfo struct { Tag uint32 State uint32 Rwnd uint32 Unackdata uint16 Penddata uint16 Instrms uint16 Outstrms uint16 FragmentationPoint uint32 Inqueue uint32 Outqueue uint32 OverallError uint32 MaxBurst uint32 Maxseg uint32 PeerRwnd uint32 PeerTag uint32 PeerCapable uint8 PeerSack uint8 Reserved1 uint16 Isacks uint64 Osacks uint64 Opackets uint64 Ipackets uint64 Rtxchunks uint64 Outofseqtsns uint64 Idupchunks uint64 Gapcnt uint64 Ouodchunks uint64 Iuodchunks uint64 Oodchunks uint64 Iodchunks uint64 Octrlchunks uint64 Ictrlchunks uint64 SockaddrStorage KernelSockaddrStorage PState int32 PCwnd uint32 PSrtt uint32 PRto uint32 PHbinterval uint32 PPathmaxrxt uint32 PSackdelay uint32 PSackfreq uint32 PSsthresh uint32 PPartial_bytes_acked uint32 PFlight_size uint32 PError uint16 Reserved2 uint16 SAutoclose uint32 SAdaptation_ind uint32 SPdPoint uint32 SNodelay uint8 SDisableFragments uint8 Sv4mapped uint8 SFragInterleave uint8 SType uint32 Reserved3 uint32 }
type SockID ¶
type SockID struct { SPort uint16 // in network byte order, use Ntohs() for host byte order DPort uint16 // in network byte order, use Ntohs() for host byte order Src [4]uint32 // use ToNetipAddr() for netip.Addr representation Dst [4]uint32 // use ToNetipAddr() for netip.Addr representation If uint32 Cookie [2]uint32 }
Based on inet_diag_sockid
type SockOpt ¶
Based on inet_diag_sockopt Bitfield1 and Bitfield2 are the Go representations for the following bit fields:
__u8 recverr:1, is_icsk:1, freebind:1, hdrincl:1, mc_loop:1, transparent:1, mc_all:1, nodefrag:1; __u8 bind_address_no_port:1, recverr_rfc4884:1, defer_connect:1, unused:5;
type TcpInfo ¶
type TcpInfo struct { State uint8 CaState uint8 Retransmits uint8 Probes uint8 Backoff uint8 Options uint8 Wscale uint8 // snd: 4, rcv : 4; ClientInfo uint8 // DeliveryRateAppLimited:1, FastopenClientFail:2; Rto uint32 Ato uint32 SndMss uint32 RcvMss uint32 Unacked uint32 Sacked uint32 Lost uint32 Retrans uint32 Fackets uint32 LastDataSent uint32 LastAckSent uint32 LastDataRecv uint32 LastAckRecv uint32 Pmtu uint32 RcvSsthresh uint32 Rtt uint32 Rttvar uint32 SndSsthresh uint32 SndCwnd uint32 Advmss uint32 Reordering uint32 RcvRtt uint32 RcvSpace uint32 RotalRetrans uint32 PacingRate uint64 MaxPacingRate uint64 BytesAcked uint64 BytesReceived uint64 SegsOut uint32 SegsIn uint32 NotsentBytes uint32 MinRtt uint32 DataSegsIn uint32 DataSegsOut uint32 DeliveryRate uint64 BusyTime uint64 RwndLimited uint64 SndbufLimited uint64 Delivered uint32 DeliveredCe uint32 BytesSent uint64 BytesRetrans uint64 DsackDups uint32 ReordSeen uint32 RcvOoopack uint32 SndWnd uint32 RcvWnd uint32 Rehash uint32 TotalRto uint16 TotalRtoRecoveries uint16 TotalRtoTime uint32 }
TcpInfo based on tcp_info in include/uapi/linux/tcp.h
type UnixAttribute ¶
type UnixAttribute struct { Name *string Vfs *UnixDiagVfs RQLen *UnixDiagRqLen MemInfo *MemInfo Shutdown *uint8 UID *uint32 Peer *uint32 Icons []uint32 }
UnixAttribute contains various elements
type UnixDiagMsg ¶
type UnixDiagMsg struct { Family uint8 Type uint8 State uint8 Pad uint8 Ino uint32 Cookie [2]uint32 }
Based on unix_diag_msg
type UnixDiagReq ¶
type UnixDiagReq struct { Family uint8 Protocol uint8 Pad uint16 States uint32 Ino uint32 Show uint32 Cookie [2]uint32 }
Based on unix_diag_req
type UnixDiagRqLen ¶
Based on unix_diag_rqlen
type UnixObject ¶
type UnixObject struct { UnixDiagMsg UnixAttribute }
type UnixOption ¶
UnixOption defines a query to Unix sockets.