libnl: Inet Diag library (libnl-idiag)

libnl 3.12.0

Inet Diag library (libnl-idiag)

## Topics
| 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.
#define | IDIAGNL_SS_ALL (((1<<12)-1))
| Macro to represent all socket states.

## 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.
int | idiagnl_str2state (const char *name)
| Convert inet diag socket state string to int.
char * | idiagnl_timer2str (int timer, char *buf, size_t len)
| Convert inet diag timer types to strings.
int | idiagnl_str2timer (const char *name)
| Convert inet diag timer string to int.
char * | idiagnl_attrs2str (int attrs, char *buf, size_t len)
| Convert inet diag extension type to a string.
char * | idiagnl_exts2str (uint8_t attrs, char *buf, size_t len)
| Convert inet diag extension flags to a string.
char * | idiagnl_tcpstate2str (uint8_t state, char *buf, size_t len)
| Convert inetdiag tcp states to strings.
char * | idiagnl_tcpopts2str (uint8_t attrs, char *buf, size_t len)
| Convert TCP option attributes to string.
char * | idiagnl_shutdown2str (uint8_t shutdown, char *buf, size_t len)
| Convert shutdown state to string.

## Socket Creation
int | idiagnl_connect (struct nl_sock *sk)
| Create and connect idiag netlink socket.

## 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.

## 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

  sk | Netlink 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 38 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

  sk | Netlink socket.
  flags | Message flags
  family | Address family
  states | Socket states to query
  ext | Inet 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 62 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

  state | inetdiag socket state (e.g., TCP_ESTABLISHED)
  buf | output buffer which will hold string result
  len | length in bytes of the output buffer

Returns
  string representation of the inetdiag socket state or an empty string.

Definition at line 107 of file idiag.c.

## ◆ idiagnl_str2state()

int idiagnl_str2state | ( | const char * | name | ) |

Convert inet diag socket state string to int.

Parameters

  name | inetdiag socket state string

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

Definition at line 120 of file idiag.c.

## ◆ idiagnl_timer2str()

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

Convert inet diag timer types to strings.

Parameters

  timer | inetdiag timer (e.g., IDIAGNL_TIMER_ON)
  buf | output buffer which will hold string result
  len | length in bytes of the output buffer

Returns
  string representation of the inetdiag timer type or an empty string.

Definition at line 142 of file idiag.c.

## ◆ idiagnl_str2timer()

int idiagnl_str2timer | ( | const char * | name | ) |

Convert inet diag timer string to int.

Parameters

  name | inetdiag timer string

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

Definition at line 154 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

  attrs | inet diag extension type (e.g. INET_DIAG_MEMINFO)
  buf | output buffer which will hold string result
  len | length 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 181 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

  attrs | inet diag extension flags (e.g. ( (1<<(INET_DIAG_MEMINFO-1)) | (1<<(INET_DIAG_CONG-1)) | (1<<(INET_DIAG_TOS-1)) ) )
  buf | Output buffer to hold string representation
  len | length in bytes of the output buffer

Definition at line 204 of file idiag.c.

## ◆ idiagnl_tcpstate2str()

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

Convert inetdiag tcp states to strings.

Parameters

  state | TCP state (e.g., TCP_CA_Open)
  buf | output buffer which will hold string result
  len | length in bytes of the output buffer

Definition at line 223 of file idiag.c.

## ◆ idiagnl_tcpopts2str()

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

Convert TCP option attributes to string.

Parameters

  attrs | TCP option attributes to convert (e.g., TCPI_OPT_SACK | TCPI_OPT_WSCALE)
  buf | Output buffer for string
  len | Length in bytes of output buffer

Returns
  buffer with string representation or empty string

Definition at line 245 of file idiag.c.

## ◆ idiagnl_shutdown2str()

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

Convert shutdown state to string.

Parameters

  shutdown | Shutdown state (e.g., idiag_msg->shutdown)
  buf | Ouput buffer to hold string representation
  len | Length in bytes of output buffer

Returns
  string representation of shutdown state or NULL

Definition at line 259 of file idiag.c.