netfilter
firewalling, NAT, and packet mangling for linux
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
Callbacks/Customization
Collaboration diagram for Callbacks/Customization:

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_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 More...
 
typedef int(* nl_recvmsg_err_cb_t )(struct sockaddr_nl *nla, struct nlmsgerr *nlerr, void *arg)
 nl_recvmsgs() callback for error message processing customization More...
 

Callback Handle Management

struct nl_cbnl_cb_alloc (enum nl_cb_kind kind)
 Allocate a new callback handle. More...
 
struct nl_cbnl_cb_clone (struct nl_cb *orig)
 Clone an existing callback handle. More...
 
struct nl_cbnl_cb_get (struct nl_cb *cb)
 
void nl_cb_put (struct nl_cb *cb)
 

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

Overwriting

void nl_cb_overwrite_recvmsgs (struct nl_cb *cb, int(*func)(struct nl_sock *, struct nl_cb *))
 Overwrite internal calls to nl_recvmsgs() More...
 
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() More...
 
void nl_cb_overwrite_send (struct nl_cb *cb, int(*func)(struct nl_sock *, struct nl_msg *))
 Overwrite internal calls to nl_send() More...
 

Detailed Description

1) Setting up a callback set
// Allocate a callback set and initialize it to the verbose default set
// Modify the set to call my_func() for all valid messages
// Set the error message handler to the verbose default implementation
// and direct it to print all errors to the given file descriptor.
FILE *file = fopen(...);

Typedef Documentation

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

nl_recvmsgs() callback for error message processing customization

  • nla netlink address of the peer
  • nlerr netlink error message being processed
  • arg argument passed on through caller
typedef int(* nl_recvmsg_msg_cb_t)(struct nl_msg *msg, void *arg)

nl_recvmsgs() callback for message processing customization

  • msg netlink message being processed
  • arg argument passwd on through caller

Enumeration Type Documentation

Callback actions.

Enumerator
NL_OK 

Proceed with wathever would come next.

NL_SKIP 

Skip this message.

NL_STOP 

Stop parsing altogether and discard remaining messages.

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.

__NL_CB_KIND_MAX 
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 acknowledge.

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_TYPE_MAX 

Function Documentation

struct nl_cb* nl_cb_alloc ( enum nl_cb_kind  kind)

Allocate a new callback handle.

  • kind callback kind to be used for initialization
    Returns
    Newly allocated callback handle or NULL

References nl_cb::cb_refcnt, nl_cb_err(), NL_CB_KIND_MAX, nl_cb_set(), NL_CB_TYPE_MAX, and NULL.

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:

struct nl_cb* nl_cb_clone ( struct nl_cb orig)

Clone an existing callback handle.

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

References nl_cb::cb_refcnt, nl_cb_alloc(), NL_CB_DEFAULT, and NULL.

Referenced by __cache_pickup(), and nl_wait_for_ack().

Here is the call graph for this function:

Here is the caller graph for this function:

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.

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

References nl_cb::cb_err, nl_cb::cb_err_arg, NL_CB_CUSTOM, NL_CB_KIND_MAX, and NLE_RANGE.

Referenced by nl_cb_alloc().

Here is the caller graph for this function:

struct nl_cb* nl_cb_get ( struct nl_cb cb)

References nl_cb::cb_refcnt.

Referenced by nl_socket_alloc_cb(), nl_socket_get_cb(), and nl_socket_set_cb().

Here is the caller graph for this function:

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()

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

References nl_cb::cb_recv_ow.

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

Overwrite internal calls to nl_recvmsgs()

References nl_cb::cb_recvmsgs_ow.

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

Overwrite internal calls to nl_send()

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

References nl_cb::cb_send_ow.

void nl_cb_put ( struct nl_cb cb)

References BUG, and nl_cb::cb_refcnt.

Referenced by __cache_pickup(), nl_socket_free(), nl_socket_set_cb(), and nl_wait_for_ack().

Here is the caller graph for this function:

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.

  • 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

References nl_cb::cb_args, nl_cb::cb_set, NL_CB_CUSTOM, NL_CB_KIND_MAX, NL_CB_TYPE_MAX, NLE_RANGE, and type.

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

Here is the caller graph for this function:

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.

  • 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

References nl_cb_set(), and NL_CB_TYPE_MAX.

Here is the call graph for this function: