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 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 #define NL_PROCEED NL_OK
00070 #define NL_EXIT NL_STOP
00071
00072
00073
00074
00075
00076 enum nl_cb_kind {
00077
00078 NL_CB_DEFAULT,
00079
00080 NL_CB_VERBOSE,
00081
00082 NL_CB_DEBUG,
00083
00084 NL_CB_CUSTOM,
00085 __NL_CB_KIND_MAX,
00086 };
00087
00088 #define NL_CB_KIND_MAX (__NL_CB_KIND_MAX - 1)
00089
00090
00091
00092
00093
00094 enum nl_cb_type {
00095
00096 NL_CB_VALID,
00097
00098 NL_CB_FINISH,
00099
00100 NL_CB_OVERRUN,
00101
00102 NL_CB_SKIPPED,
00103
00104 NL_CB_ACK,
00105
00106 NL_CB_MSG_IN,
00107
00108 NL_CB_MSG_OUT,
00109
00110 NL_CB_INVALID,
00111
00112 NL_CB_SEQ_CHECK,
00113
00114 NL_CB_SEND_ACK,
00115 __NL_CB_TYPE_MAX,
00116 };
00117
00118 #define NL_CB_TYPE_MAX (__NL_CB_TYPE_MAX - 1)
00119
00120 extern struct nl_cb * nl_cb_alloc(enum nl_cb_kind);
00121 extern struct nl_cb * nl_cb_clone(struct nl_cb *);
00122 extern struct nl_cb * nl_cb_get(struct nl_cb *);
00123 extern void nl_cb_put(struct nl_cb *);
00124
00125 extern int nl_cb_set(struct nl_cb *, enum nl_cb_type, enum nl_cb_kind,
00126 nl_recvmsg_msg_cb_t, void *);
00127 extern int nl_cb_set_all(struct nl_cb *, enum nl_cb_kind,
00128 nl_recvmsg_msg_cb_t, void *);
00129 extern int nl_cb_err(struct nl_cb *, enum nl_cb_kind, nl_recvmsg_err_cb_t,
00130 void *);
00131
00132 extern void nl_cb_overwrite_recvmsgs(struct nl_cb *,
00133 int (*func)(struct nl_handle *,
00134 struct nl_cb *));
00135 extern void nl_cb_overwrite_recv(struct nl_cb *,
00136 int (*func)(struct nl_handle *,
00137 struct sockaddr_nl *,
00138 unsigned char **,
00139 struct ucred **));
00140 extern void nl_cb_overwrite_send(struct nl_cb *,
00141 int (*func)(struct nl_handle *,
00142 struct nl_msg *));
00143
00144 #ifdef __cplusplus
00145 }
00146 #endif
00147
00148 #endif