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