00001
00002
00003
00004
00005
00006
00007
00008
00009
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 #ifdef __cplusplus
00022 extern "C" {
00023 #endif
00024
00025 struct nl_cb;
00026 struct nl_handle;
00027 struct nl_msg;
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040 typedef int (*nl_recvmsg_msg_cb_t)(struct nl_msg *msg, void *arg);
00041
00042
00043
00044
00045
00046
00047
00048
00049 typedef int (*nl_recvmsg_err_cb_t)(struct sockaddr_nl *nla,
00050 struct nlmsgerr *nlerr, void *arg);
00051
00052
00053
00054
00055
00056
00057
00058 enum nl_cb_action {
00059
00060 NL_OK,
00061
00062 NL_SKIP,
00063
00064 NL_STOP,
00065 };
00066
00067
00068 #define NL_PROCEED NL_OK
00069 #define NL_EXIT NL_STOP
00070
00071
00072
00073
00074
00075 enum nl_cb_kind {
00076
00077 NL_CB_DEFAULT,
00078
00079 NL_CB_VERBOSE,
00080
00081 NL_CB_DEBUG,
00082
00083 NL_CB_CUSTOM,
00084 __NL_CB_KIND_MAX,
00085 };
00086
00087 #define NL_CB_KIND_MAX (__NL_CB_KIND_MAX - 1)
00088
00089
00090
00091
00092
00093 enum nl_cb_type {
00094
00095 NL_CB_VALID,
00096
00097 NL_CB_FINISH,
00098
00099 NL_CB_OVERRUN,
00100
00101 NL_CB_SKIPPED,
00102
00103 NL_CB_ACK,
00104
00105 NL_CB_MSG_IN,
00106
00107 NL_CB_MSG_OUT,
00108
00109 NL_CB_INVALID,
00110
00111 NL_CB_SEQ_CHECK,
00112
00113 NL_CB_SEND_ACK,
00114 __NL_CB_TYPE_MAX,
00115 };
00116
00117 #define NL_CB_TYPE_MAX (__NL_CB_TYPE_MAX - 1)
00118
00119 extern struct nl_cb * nl_cb_alloc(enum nl_cb_kind);
00120 extern struct nl_cb * nl_cb_clone(struct nl_cb *);
00121 extern struct nl_cb * nl_cb_get(struct nl_cb *);
00122 extern void nl_cb_put(struct nl_cb *);
00123
00124 extern int nl_cb_set(struct nl_cb *, enum nl_cb_type, enum nl_cb_kind,
00125 nl_recvmsg_msg_cb_t, void *);
00126 extern int nl_cb_set_all(struct nl_cb *, enum nl_cb_kind,
00127 nl_recvmsg_msg_cb_t, void *);
00128 extern int nl_cb_err(struct nl_cb *, enum nl_cb_kind, nl_recvmsg_err_cb_t,
00129 void *);
00130
00131 extern void nl_cb_overwrite_recvmsgs(struct nl_cb *,
00132 int (*func)(struct nl_handle *,
00133 struct nl_cb *));
00134 extern void nl_cb_overwrite_recv(struct nl_cb *,
00135 int (*func)(struct nl_handle *,
00136 struct sockaddr_nl *,
00137 unsigned char **,
00138 struct ucred **));
00139 extern void nl_cb_overwrite_send(struct nl_cb *,
00140 int (*func)(struct nl_handle *,
00141 struct nl_msg *));
00142
00143 #ifdef __cplusplus
00144 }
00145 #endif
00146
00147 #endif