/build/buildd/libnl-1.0~pre6/include/netlink/handlers.h

00001 /*
00002  * netlink/handlers.c   default netlink message handlers
00003  *
00004  *      This library is free software; you can redistribute it and/or
00005  *      modify it under the terms of the GNU Lesser General Public
00006  *      License as published by the Free Software Foundation version 2.1
00007  *      of the License.
00008  *
00009  * Copyright (c) 2003-2006 Thomas Graf <tgraf@suug.ch>
00010  */
00011 
00012 #ifndef NETLINK_HANDLERS_H_
00013 #define NETLINK_HANDLERS_H_
00014 
00015 #include <stdio.h>
00016 #include <stdint.h>
00017 #include <sys/types.h>
00018 #include <netlink/netlink-compat.h>
00019 #include <netlink/netlink-kernel.h>
00020 
00021 struct nl_cb;
00022 struct nl_handle;
00023 struct nl_msg;
00024 
00025 /**
00026  * @name Callback Typedefs
00027  * @{
00028  */
00029 
00030 /**
00031  * nl_recvmsgs() callback for message processing customization
00032  * @ingroup cb
00033  * @arg msg             netlink message being processed
00034  * @arg arg             argument passwd on through caller
00035  */
00036 typedef int (*nl_recvmsg_msg_cb_t)(struct nl_msg *msg, void *arg);
00037 
00038 /**
00039  * nl_recvmsgs() callback for error message processing customization
00040  * @ingroup cb
00041  * @arg nla             netlink address of the peer
00042  * @arg nlerr           netlink error message being processed
00043  * @arg arg             argument passed on through caller
00044  */
00045 typedef int (*nl_recvmsg_err_cb_t)(struct sockaddr_nl *nla,
00046                                    struct nlmsgerr *nlerr, void *arg);
00047 
00048 /** @} */
00049 
00050 /**
00051  * Callback actions
00052  * @ingroup cb
00053  */
00054 enum nl_cb_action {
00055         /** Proceed with wathever would come next */
00056         NL_PROCEED,
00057         /** Skip this message */
00058         NL_SKIP,
00059         /** Stop parsing altogether and discard remaining messages */
00060         NL_EXIT,
00061 };
00062 
00063 /**
00064  * Callback kinds
00065  * @ingroup cb
00066  */
00067 enum nl_cb_kind {
00068         /** Default handlers (quiet) */
00069         NL_CB_DEFAULT,
00070         /** Verbose default handlers (error messages printed) */
00071         NL_CB_VERBOSE,
00072         /** Debug handlers for debugging */
00073         NL_CB_DEBUG,
00074         /** Customized handler specified by the user */
00075         NL_CB_CUSTOM,
00076         __NL_CB_KIND_MAX,
00077 };
00078 
00079 #define NL_CB_KIND_MAX (__NL_CB_KIND_MAX - 1)
00080 
00081 /**
00082  * Callback types
00083  * @ingroup cb
00084  */
00085 enum nl_cb_type {
00086         /** Message is valid */
00087         NL_CB_VALID,
00088         /** Last message in a series of multi part messages received */
00089         NL_CB_FINISH,
00090         /** Report received that data was lost */
00091         NL_CB_OVERRUN,
00092         /** Message wants to be skipped */
00093         NL_CB_SKIPPED,
00094         /** Message is an acknowledge */
00095         NL_CB_ACK,
00096         /** Called for every message received */
00097         NL_CB_MSG_IN,
00098         /** Called for every message sent out except for nl_sendto() */
00099         NL_CB_MSG_OUT,
00100         /** Message is malformed and invalid */
00101         NL_CB_INVALID,
00102         /** Called instead of internal sequence number checking */
00103         NL_CB_SEQ_CHECK,
00104         /** Sending of an acknowledge message has been requested */
00105         NL_CB_SEND_ACK,
00106         __NL_CB_TYPE_MAX,
00107 };
00108 
00109 #define NL_CB_TYPE_MAX (__NL_CB_TYPE_MAX - 1)
00110 
00111 extern struct nl_cb *   nl_cb_new(enum nl_cb_kind);
00112 extern void             nl_cb_destroy(struct nl_cb *);
00113 extern struct nl_cb *   nl_cb_clone(struct nl_cb *);
00114 
00115 extern int  nl_cb_set(struct nl_cb *, enum nl_cb_type, enum nl_cb_kind,
00116                       nl_recvmsg_msg_cb_t, void *);
00117 extern int  nl_cb_set_all(struct nl_cb *, enum nl_cb_kind,
00118                           nl_recvmsg_msg_cb_t, void *);
00119 extern int  nl_cb_err(struct nl_cb *, enum nl_cb_kind, nl_recvmsg_err_cb_t,
00120                       void *);
00121 
00122 extern void nl_cb_overwrite_recvmsgs(struct nl_cb *,
00123                                      int (*func)(struct nl_handle *,
00124                                                  struct nl_cb *));
00125 extern void nl_cb_overwrite_recv(struct nl_cb *,
00126                                  int (*func)(struct nl_handle *,
00127                                              struct sockaddr_nl *,
00128                                              unsigned char **,
00129                                              struct ucred **));
00130 extern void nl_cb_overwrite_send(struct nl_cb *,
00131                                  int (*func)(struct nl_handle *,
00132                                              struct nl_msg *));
00133 
00134 #endif

Generated on Fri Apr 27 14:14:07 2007 for libnl by  doxygen 1.5.1