libnl: Callbacks/Customization

libnl 3.10.0

Enumerations
Callbacks/Customization
Core Library (libnl)

## Enumerations
enum | nl_cb_action { NL_OK , NL_SKIP , NL_STOP }
| Callback actions. More...
enum | nl_cb_kind { NL_CB_DEFAULT , NL_CB_VERBOSE , NL_CB_DEBUG , NL_CB_CUSTOM , __NL_CB_KIND_MAX }
| Callback kinds. More...
enum | nl_cb_type { NL_CB_VALID , NL_CB_FINISH , NL_CB_OVERRUN , NL_CB_SKIPPED , NL_CB_ACK , NL_CB_MSG_IN , NL_CB_MSG_OUT , NL_CB_INVALID , NL_CB_SEQ_CHECK , NL_CB_SEND_ACK , NL_CB_DUMP_INTR , __NL_CB_TYPE_MAX }
| Callback types. More...

## Callback Typedefs
typedef int(* | nl_recvmsg_msg_cb_t) (struct nl_msg *msg, void *arg)
| nl_recvmsgs() callback for message processing customization
typedef int(* | nl_recvmsg_err_cb_t) (struct sockaddr_nl *nla, struct nlmsgerr *nlerr, void *arg)
| nl_recvmsgs() callback for error message processing customization

## Callback Handle Management
struct nl_cb * | nl_cb_alloc (enum nl_cb_kind kind)
| Allocate a new callback handle.
struct nl_cb * | nl_cb_clone (struct nl_cb *orig)
| Clone an existing callback handle.
struct nl_cb * | nl_cb_get (struct nl_cb *cb)
void | nl_cb_put (struct nl_cb *cb)
enum nl_cb_type | nl_cb_active_type (struct nl_cb *cb)
| Obtain type of current active callback.

## Callback Setup
int | nl_cb_set (struct nl_cb *cb, enum nl_cb_type type, enum nl_cb_kind kind, nl_recvmsg_msg_cb_t func, void *arg)
| Set up a callback.
int | nl_cb_set_all (struct nl_cb *cb, enum nl_cb_kind kind, nl_recvmsg_msg_cb_t func, void *arg)
| Set up a all callbacks.
int | nl_cb_err (struct nl_cb *cb, enum nl_cb_kind kind, nl_recvmsg_err_cb_t func, void *arg)
| Set up an error callback.

## Overwriting
void | nl_cb_overwrite_recvmsgs (struct nl_cb *cb, int(*func)(struct nl_sock *, struct nl_cb *))
| Overwrite internal calls to nl_recvmsgs()
void | nl_cb_overwrite_recv (struct nl_cb *cb, int(*func)(struct nl_sock *, struct sockaddr_nl *, unsigned char **, struct ucred **))
| Overwrite internal calls to nl_recv()
void | nl_cb_overwrite_send (struct nl_cb *cb, int(*func)(struct nl_sock *, struct nl_msg *))
| Overwrite internal calls to nl_send()

## Detailed Description

Related sections in the development guide:

- Callback Configuration (Netlink Core Library Development Guide)

## Header

#include <netlink/handlers.h>

## Typedef Documentation

## ◆ nl_recvmsg_msg_cb_t

typedef int(* nl_recvmsg_msg_cb_t) (struct nl_msg *msg, void *arg)

nl_recvmsgs() callback for message processing customization

Parameters

  msg | netlink message being processed
  arg | argument passed on through caller

Definition at line 38 of file handlers.h.

## ◆ nl_recvmsg_err_cb_t

typedef int(* nl_recvmsg_err_cb_t) (struct sockaddr_nl *nla, struct nlmsgerr *nlerr, void *arg)

nl_recvmsgs() callback for error message processing customization

Parameters

  nla | netlink address of the peer
  nlerr | netlink error message being processed
  arg | argument passed on through caller

Definition at line 47 of file handlers.h.

## Enumeration Type Documentation

## ◆ nl_cb_action

enum nl_cb_action

Callback actions.

Enumerator
NL_OK | Proceed with whatever would come next.
NL_SKIP | Skip this message.
NL_STOP | Stop parsing altogether and discard remaining messages.

Definition at line 56 of file handlers.h.

## ◆ nl_cb_kind

enum nl_cb_kind

Callback kinds.

Enumerator
NL_CB_DEFAULT | Default handlers (quiet)
NL_CB_VERBOSE | Verbose default handlers (error messages printed)
NL_CB_DEBUG | Debug handlers for debugging.
NL_CB_CUSTOM | Customized handler specified by the user.

Definition at line 69 of file handlers.h.

## ◆ nl_cb_type

enum nl_cb_type

Callback types.

Enumerator
NL_CB_VALID | Message is valid.
NL_CB_FINISH | Last message in a series of multi part messages received.
NL_CB_OVERRUN | Report received that data was lost.
NL_CB_SKIPPED | Message wants to be skipped.
NL_CB_ACK | Message is an acknowledgement.
NL_CB_MSG_IN | Called for every message received.
NL_CB_MSG_OUT | Called for every message sent out except for nl_sendto()
NL_CB_INVALID | Message is malformed and invalid.
NL_CB_SEQ_CHECK | Called instead of internal sequence number checking.
NL_CB_SEND_ACK | Sending of an acknowledge message has been requested.
NL_CB_DUMP_INTR | Flag NLM_F_DUMP_INTR is set in message.

Definition at line 87 of file handlers.h.

## Function Documentation

## ◆ nl_cb_alloc()

struct nl_cb * nl_cb_alloc | ( | enum nl_cb_kind | kind | ) |

Allocate a new callback handle.

Parameters

  kind | callback kind to be used for initialization

Returns
  Newly allocated callback handle or NULL

Definition at line 198 of file handlers.c.

References nl_cb::cb_active, nl_cb_err(), and nl_cb_set().

Referenced by nl_cb_clone(), and nl_socket_alloc().

Here is the call graph for this function:
Here is the caller graph for this function:

## ◆ nl_cb_clone()

struct nl_cb * nl_cb_clone | ( | struct nl_cb * | orig | ) |

Clone an existing callback handle.

Parameters

  orig | original callback handle

Returns
  Newly allocated callback handle being a duplicate of orig or NULL

Definition at line 227 of file handlers.c.

References nl_cb_alloc(), and NL_CB_DEFAULT.

Referenced by nl_cache_mngr_data_ready(), nl_pickup_keep_syserr(), and nl_wait_for_ack().

Here is the call graph for this function:
Here is the caller graph for this function:

## ◆ nl_cb_get()

struct nl_cb * nl_cb_get | ( | struct nl_cb * | cb | ) |

Definition at line 241 of file handlers.c.

## ◆ nl_cb_put()

void nl_cb_put | ( | struct nl_cb * | cb | ) |

Definition at line 248 of file handlers.c.

## ◆ nl_cb_active_type()

enum nl_cb_type nl_cb_active_type | ( | struct nl_cb * | cb | ) |

Obtain type of current active callback.

Parameters

  cb | callback to query

Returns
  type or __NL_CB_TYPE_MAX if none active

Definition at line 268 of file handlers.c.

References nl_cb::cb_active.

## ◆ nl_cb_set()

int nl_cb_set | ( | struct nl_cb * | cb,
|  | enum nl_cb_type | type,
|  | enum nl_cb_kind | kind,
|  | nl_recvmsg_msg_cb_t | func,
|  | void * | arg )

Set up a callback.

Parameters

  cb | callback set
  type | callback to modify
  kind | kind of implementation
  func | callback function (NL_CB_CUSTOM)
  arg | argument passed to callback

Returns
  0 on success or a negative error code

Definition at line 290 of file handlers.c.

References NL_CB_CUSTOM.

Referenced by nl_cache_mngr_data_ready(), nl_cb_alloc(), nl_cb_set_all(), nl_pickup_keep_syserr(), nl_socket_disable_seq_check(), nl_socket_modify_cb(), and nl_wait_for_ack().

Here is the caller graph for this function:

## ◆ nl_cb_set_all()

int nl_cb_set_all | ( | struct nl_cb * | cb,
|  | enum nl_cb_kind | kind,
|  | nl_recvmsg_msg_cb_t | func,
|  | void * | arg )

Set up a all callbacks.

Parameters

  cb | callback set
  kind | kind of callback
  func | callback function
  arg | argument to be passwd to callback function

Returns
  0 on success or a negative error code

Definition at line 319 of file handlers.c.

References nl_cb_set().

Here is the call graph for this function:

## ◆ nl_cb_err()

int nl_cb_err | ( | struct nl_cb * | cb,
|  | enum nl_cb_kind | kind,
|  | nl_recvmsg_err_cb_t | func,
|  | void * | arg )

Set up an error callback.

Parameters

  cb | callback set
  kind | kind of callback
  func | callback function
  arg | argument to be passed to callback function

Definition at line 340 of file handlers.c.

References NL_CB_CUSTOM.

Referenced by nl_cb_alloc(), nl_pickup_keep_syserr(), and nl_socket_modify_err_cb().

Here is the caller graph for this function:

## ◆ nl_cb_overwrite_recvmsgs()

void nl_cb_overwrite_recvmsgs | ( | struct nl_cb * | cb,
|  | int(*)(struct nl_sock *, struct nl_cb *) | func )

Overwrite internal calls to nl_recvmsgs()

Parameters

  cb | callback set
  func | replacement callback for nl_recvmsgs()

Definition at line 369 of file handlers.c.

References nl_cb::cb_recvmsgs_ow.

## ◆ nl_cb_overwrite_recv()

void nl_cb_overwrite_recv | ( | struct nl_cb * | cb,
|  | int(*)(struct nl_sock *, struct sockaddr_nl *, unsigned char **, struct ucred **) | func )

Overwrite internal calls to nl_recv()

Parameters

  cb | callback set
  func | replacement callback for nl_recv()

Definition at line 380 of file handlers.c.

References nl_cb::cb_recv_ow.

## ◆ nl_cb_overwrite_send()

void nl_cb_overwrite_send | ( | struct nl_cb * | cb,
|  | int(*)(struct nl_sock *, struct nl_msg *) | func )

Overwrite internal calls to nl_send()

Parameters

  cb | callback set
  func | replacement callback for nl_send()

Definition at line 392 of file handlers.c.

References nl_cb::cb_send_ow.