Logo Search packages:      
Sourcecode: libnl version File versions  Download package

handlers.h

/*
 * netlink/handlers.c   default netlink message handlers
 *
 *          This program is free software; you can redistribute it and/or
 *          modify it under the terms of the GNU General Public License
 *          as published by the Free Software Foundation; either version
 *          2 of the License, or (at your option) any later version.
 *
 * Copyright (c) 2003-2005 Thomas Graf <tgraf@suug.ch>
 */

#ifndef NETLINK_HANDLERS_H_
#define NETLINK_HANDLERS_H_

#include <stdio.h>
#include <stdint.h>
#include <sys/types.h>
#include <linux/types.h>
#include <netlink/netlink-compat.h>
#include <netlink/netlink-kernel.h>

struct nl_cb;
struct nl_handle;
struct nl_msg;

/**
 * @name Callback Typedefs
 * @{
 */

/**
 * nl_recvmsgs() callback for message processing customization
 * @ingroup cb
 * @arg msg       netlink message being processed
 * @arg arg       argument passwd on through caller
 */
00037 typedef int (*nl_recvmsg_msg_cb_t)(struct nl_msg *msg, void *arg);

/**
 * nl_recvmsgs() callback for error message processing customization
 * @ingroup cb
 * @arg nla       netlink address of the peer
 * @arg nlerr           netlink error message being processed
 * @arg arg       argument passed on through caller
 */
00046 typedef int (*nl_recvmsg_err_cb_t)(struct sockaddr_nl *nla,
                           struct nlmsgerr *nlerr, void *arg);

/** @} */

/**
 * Callback actions
 * @ingroup cb
 */
00055 enum nl_cb_action {
      /** Proceed with wathever would come next */
00057       NL_PROCEED,
      /** Skip this message */
00059       NL_SKIP,
      /** Stop parsing altogether and discard remaining messages */
00061       NL_EXIT,
};

/**
 * Callback kinds
 * @ingroup cb
 */
00068 enum nl_cb_kind {
      /** Default handlers (quiet) */
00070       NL_CB_DEFAULT,
      /** Verbose default handlers (error messages printed) */
00072       NL_CB_VERBOSE,
      /** Debug handlers for debugging */
00074       NL_CB_DEBUG,
      /** Customized handler specified by the user */
00076       NL_CB_CUSTOM,
      __NL_CB_KIND_MAX,
};

#define NL_CB_KIND_MAX (__NL_CB_KIND_MAX - 1)

/**
 * Callback types
 * @ingroup cb
 */
00086 enum nl_cb_type {
      /** Message is valid */
00088       NL_CB_VALID,
      /** Last message in a series of multi part messages received */
00090       NL_CB_FINISH,
      /** Report received that data was lost */
00092       NL_CB_OVERRUN,
      /** Message wants to be skipped */
00094       NL_CB_SKIPPED,
      /** Message is an acknowledge */
00096       NL_CB_ACK,
      /** Called for every message received */
00098       NL_CB_MSG_IN,
      /** Called for every message sent out except for nl_sendto() */
00100       NL_CB_MSG_OUT,
      /** Message is malformed and invalid */
00102       NL_CB_INVALID,
      /** Called instead of internal sequence number checking */
00104       NL_CB_SEQ_CHECK,
      /** Sending of an acknowledge message has been requested */
00106       NL_CB_SEND_ACK,
      __NL_CB_TYPE_MAX,
};

#define NL_CB_TYPE_MAX (__NL_CB_TYPE_MAX - 1)

extern struct nl_cb *   nl_cb_new(enum nl_cb_kind);
extern void       nl_cb_destroy(struct nl_cb *);
extern struct nl_cb *   nl_cb_clone(struct nl_cb *);

extern int  nl_cb_set(struct nl_cb *, enum nl_cb_type, enum nl_cb_kind,
                  nl_recvmsg_msg_cb_t, void *);
extern int  nl_cb_set_all(struct nl_cb *, enum nl_cb_kind,
                    nl_recvmsg_msg_cb_t, void *);
extern int  nl_cb_err(struct nl_cb *, enum nl_cb_kind, nl_recvmsg_err_cb_t,
                  void *);

extern void nl_cb_overwrite_recvmsgs(struct nl_cb *,
                             int (*func)(struct nl_handle *,
                                     struct nl_cb *));
extern void nl_cb_overwrite_recv(struct nl_cb *,
                         int (*func)(struct nl_handle *,
                                   struct sockaddr_nl *,
                                   unsigned char **));
extern void nl_cb_overwrite_send(struct nl_cb *,
                         int (*func)(struct nl_handle *,
                                   struct nl_msg *));

#endif

Generated by  Doxygen 1.6.0   Back to index