2 * netlink/handlers.c default netlink message handlers
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation version 2.1
9 * Copyright (c) 2003-2006 Thomas Graf <tgraf@suug.ch>
12 #ifndef NETLINK_HANDLERS_H_
13 #define NETLINK_HANDLERS_H_
17 #include <sys/types.h>
18 #include <netlink/netlink-compat.h>
19 #include <netlink/netlink-kernel.h>
26 * @name Callback Typedefs
31 * nl_recvmsgs() callback for message processing customization
33 * @arg msg netlink message being processed
34 * @arg arg argument passwd on through caller
36 typedef int (*nl_recvmsg_msg_cb_t)(struct nl_msg *msg, void *arg);
39 * nl_recvmsgs() callback for error message processing customization
41 * @arg nla netlink address of the peer
42 * @arg nlerr netlink error message being processed
43 * @arg arg argument passed on through caller
45 typedef int (*nl_recvmsg_err_cb_t)(struct sockaddr_nl *nla,
46 struct nlmsgerr *nlerr, void *arg);
55 /** Proceed with wathever would come next */
57 /** Skip this message */
59 /** Stop parsing altogether and discard remaining messages */
68 /** Default handlers (quiet) */
70 /** Verbose default handlers (error messages printed) */
72 /** Debug handlers for debugging */
74 /** Customized handler specified by the user */
79 #define NL_CB_KIND_MAX (__NL_CB_KIND_MAX - 1)
86 /** Message is valid */
88 /** Last message in a series of multi part messages received */
90 /** Report received that data was lost */
92 /** Message wants to be skipped */
94 /** Message is an acknowledge */
96 /** Called for every message received */
98 /** Called for every message sent out except for nl_sendto() */
100 /** Message is malformed and invalid */
102 /** Called instead of internal sequence number checking */
104 /** Sending of an acknowledge message has been requested */
109 #define NL_CB_TYPE_MAX (__NL_CB_TYPE_MAX - 1)
111 extern struct nl_cb * nl_cb_new(enum nl_cb_kind);
112 extern void nl_cb_destroy(struct nl_cb *);
113 extern struct nl_cb * nl_cb_clone(struct nl_cb *);
115 extern int nl_cb_set(struct nl_cb *, enum nl_cb_type, enum nl_cb_kind,
116 nl_recvmsg_msg_cb_t, void *);
117 extern int nl_cb_set_all(struct nl_cb *, enum nl_cb_kind,
118 nl_recvmsg_msg_cb_t, void *);
119 extern int nl_cb_err(struct nl_cb *, enum nl_cb_kind, nl_recvmsg_err_cb_t,
122 extern void nl_cb_overwrite_recvmsgs(struct nl_cb *,
123 int (*func)(struct nl_handle *,
125 extern void nl_cb_overwrite_recv(struct nl_cb *,
126 int (*func)(struct nl_handle *,
127 struct sockaddr_nl *,
130 extern void nl_cb_overwrite_send(struct nl_cb *,
131 int (*func)(struct nl_handle *,