libnl 3.7.0
Inet Diag library (libnl-idiag)

Modules

 Inet Diag Memory Info
 
 Inet Diag Messages
 
 Inet Diag Requests
 
 Inet Diag TCP Vegas Info
 

Macros

#define IDIAG_SS_ALL   IDIAGNL_SS_ALL
 Macro to represent all socket states. More...
 
#define IDIAGNL_SS_ALL   (((1<<12)-1))
 Macro to represent all socket states. More...
 

Enumerations

enum  {
  IDIAG_SS_UNKNOWN = 0 ,
  IDIAG_SS_ESTABLISHED = 1 ,
  IDIAG_SS_SYN_SENT = 2 ,
  IDIAG_SS_SYN_RECV = 3 ,
  IDIAG_SS_FIN_WAIT1 = 4 ,
  IDIAG_SS_FIN_WAIT2 = 5 ,
  IDIAG_SS_TIME_WAIT = 6 ,
  IDIAG_SS_CLOSE = 7 ,
  IDIAG_SS_CLOSE_WAIT = 8 ,
  IDIAG_SS_LAST_ACK = 9 ,
  IDIAG_SS_LISTEN = 10 ,
  IDIAG_SS_CLOSING = 11 ,
  IDIAG_SS_MAX = 12
}
 Socket state identifiers. More...
 
enum  {
  IDIAG_ATTR_NONE = 0 ,
  IDIAG_ATTR_MEMINFO = 1 ,
  IDIAG_ATTR_INFO = 2 ,
  IDIAG_ATTR_VEGASINFO = 3 ,
  IDIAG_ATTR_CONG = 4 ,
  IDIAG_ATTR_TOS = 5 ,
  IDIAG_ATTR_TCLASS = 6 ,
  IDIAG_ATTR_SKMEMINFO = 7 ,
  IDIAG_ATTR_SHUTDOWN = 8 ,
  IDIAG_ATTR_MAX = 9 ,
  IDIAG_ATTR_ALL = (1<<IDIAG_ATTR_MAX) - 1
}
 Inet Diag extended attributes. More...
 

Inet Diag flag and attribute conversions

char * idiagnl_state2str (int state, char *buf, size_t len)
 Convert inet diag socket states to strings. More...
 
int idiagnl_str2state (const char *name)
 Convert inet diag socket state string to int. More...
 
char * idiagnl_timer2str (int timer, char *buf, size_t len)
 Convert inet diag timer types to strings. More...
 
int idiagnl_str2timer (const char *name)
 Convert inet diag timer string to int. More...
 
char * idiagnl_attrs2str (int attrs, char *buf, size_t len)
 Convert inet diag extension type to a string. More...
 
char * idiagnl_exts2str (uint8_t attrs, char *buf, size_t len)
 Convert inet diag extension flags to a string. More...
 
char * idiagnl_tcpstate2str (uint8_t state, char *buf, size_t len)
 Convert inetdiag tcp states to strings. More...
 
char * idiagnl_tcpopts2str (uint8_t attrs, char *buf, size_t len)
 Convert TCP option attributes to string. More...
 
char * idiagnl_shutdown2str (uint8_t shutdown, char *buf, size_t len)
 Convert shutdown state to string. More...
 

Socket Creation

int idiagnl_connect (struct nl_sock *sk)
 Create and connect idiag netlink socket. More...
 

Sending

int idiagnl_send_simple (struct nl_sock *sk, int flags, uint8_t family, uint16_t states, uint16_t ext)
 Send trivial idiag netlink message. More...
 

Detailed Description

Macro Definition Documentation

◆ IDIAG_SS_ALL

#define IDIAG_SS_ALL   IDIAGNL_SS_ALL

Macro to represent all socket states.

Deprecated:

Definition at line 59 of file idiagnl.h.

◆ IDIAGNL_SS_ALL

#define IDIAGNL_SS_ALL   (((1<<12)-1))

Macro to represent all socket states.

Definition at line 111 of file idiagnl.h.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum

Socket state identifiers.

Deprecated:
: use instead the TCP_* defines from netinet/tcp.h.

Definition at line 36 of file idiagnl.h.

◆ anonymous enum

anonymous enum

Inet Diag extended attributes.

Deprecated:
These attributes should not be used. They mirror the INET_DIAG_* extension flags from kernel headers. Use those instead.

Definition at line 67 of file idiagnl.h.

Function Documentation

◆ idiagnl_connect()

int idiagnl_connect ( struct nl_sock *  sk)

Create and connect idiag netlink socket.

Parameters
skNetlink socket.

Creates a NETLINK_INET_DIAG socket, binds the socket, and issues a connection attemp.

See also
nl_connect()
Returns
0 on success or a negative error code.

Definition at line 34 of file idiag.c.

References nl_connect().

+ Here is the call graph for this function:

◆ idiagnl_send_simple()

int idiagnl_send_simple ( struct nl_sock *  sk,
int  flags,
uint8_t  family,
uint16_t  states,
uint16_t  ext 
)

Send trivial idiag netlink message.

Parameters
skNetlink socket.
flagsMessage flags
familyAddress family
statesSocket states to query
extInet Diag attribute extensions to query. Note that this only supports 8 bit arguments. Flags outside uint8_t range are silently ignored.
Returns
0 on success or a negative error code. Due to a bug, this function returns the number of bytes sent. Treat any non-negative number as success.

Definition at line 58 of file idiag.c.

References nl_send_simple().

+ Here is the call graph for this function:

◆ idiagnl_state2str()

char * idiagnl_state2str ( int  state,
char *  buf,
size_t  len 
)

Convert inet diag socket states to strings.

Parameters
stateinetdiag socket state (e.g., TCP_ESTABLISHED)
bufoutput buffer which will hold string result
lenlength in bytes of the output buffer
Returns
string representation of the inetdiag socket state or an empty string.

Definition at line 103 of file idiag.c.

◆ idiagnl_str2state()

int idiagnl_str2state ( const char *  name)

Convert inet diag socket state string to int.

Parameters
nameinetdiag socket state string
Returns
the int representation of the socket state strign or a negative error code.

Definition at line 116 of file idiag.c.

◆ idiagnl_timer2str()

char * idiagnl_timer2str ( int  timer,
char *  buf,
size_t  len 
)

Convert inet diag timer types to strings.

Parameters
timerinetdiag timer (e.g., IDIAGNL_TIMER_ON)
bufoutput buffer which will hold string result
lenlength in bytes of the output buffer
Returns
string representation of the inetdiag timer type or an empty string.

Definition at line 138 of file idiag.c.

◆ idiagnl_str2timer()

int idiagnl_str2timer ( const char *  name)

Convert inet diag timer string to int.

Parameters
nameinetdiag timer string
Returns
the int representation of the timer string or a negative error code.

Definition at line 150 of file idiag.c.

◆ idiagnl_attrs2str()

char * idiagnl_attrs2str ( int  attrs,
char *  buf,
size_t  len 
)

Convert inet diag extension type to a string.

Parameters
attrsinet diag extension type (e.g. INET_DIAG_MEMINFO)
bufoutput buffer which will hold string result
lenlength in bytes of the output buffer
Returns
string representation of inet diag extension type or an empty string.
Deprecated:
: don't use this function. It is not very useful and should never have been exposed as public API.

Definition at line 177 of file idiag.c.

◆ idiagnl_exts2str()

char * idiagnl_exts2str ( uint8_t  attrs,
char *  buf,
size_t  len 
)

Convert inet diag extension flags to a string.

Parameters
attrsinet diag extension flags (e.g. ( (1<<(INET_DIAG_MEMINFO-1)) | (1<<(INET_DIAG_CONG-1)) | (1<<(INET_DIAG_TOS-1)) ) )
bufOutput buffer to hold string representation
lenlength in bytes of the output buffer

Definition at line 200 of file idiag.c.

◆ idiagnl_tcpstate2str()

char * idiagnl_tcpstate2str ( uint8_t  state,
char *  buf,
size_t  len 
)

Convert inetdiag tcp states to strings.

Parameters
stateTCP state (e.g., TCP_CA_Open)
bufoutput buffer which will hold string result
lenlength in bytes of the output buffer

Definition at line 219 of file idiag.c.

◆ idiagnl_tcpopts2str()

char * idiagnl_tcpopts2str ( uint8_t  attrs,
char *  buf,
size_t  len 
)

Convert TCP option attributes to string.

Parameters
attrsTCP option attributes to convert (e.g., TCPI_OPT_SACK | TCPI_OPT_WSCALE)
bufOutput buffer for string
lenLength in bytes of output buffer
Returns
buffer with string representation or empty string

Definition at line 241 of file idiag.c.

◆ idiagnl_shutdown2str()

char * idiagnl_shutdown2str ( uint8_t  shutdown,
char *  buf,
size_t  len 
)

Convert shutdown state to string.

Parameters
shutdownShutdown state (e.g., idiag_msg->shutdown)
bufOuput buffer to hold string representation
lenLength in bytes of output buffer
Returns
string representation of shutdown state or NULL

Definition at line 255 of file idiag.c.