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 struct nl_cb;
00022 struct nl_handle;
00023 struct nl_msg;
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036 typedef int (*nl_recvmsg_msg_cb_t)(struct nl_msg *msg, void *arg);
00037
00038
00039
00040
00041
00042
00043
00044
00045 typedef int (*nl_recvmsg_err_cb_t)(struct sockaddr_nl *nla,
00046 struct nlmsgerr *nlerr, void *arg);
00047
00048
00049
00050
00051
00052
00053
00054 enum nl_cb_action {
00055
00056 NL_PROCEED,
00057
00058 NL_SKIP,
00059
00060 NL_EXIT,
00061 };
00062
00063
00064
00065
00066
00067 enum nl_cb_kind {
00068
00069 NL_CB_DEFAULT,
00070
00071 NL_CB_VERBOSE,
00072
00073 NL_CB_DEBUG,
00074
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
00083
00084
00085 enum nl_cb_type {
00086
00087 NL_CB_VALID,
00088
00089 NL_CB_FINISH,
00090
00091 NL_CB_OVERRUN,
00092
00093 NL_CB_SKIPPED,
00094
00095 NL_CB_ACK,
00096
00097 NL_CB_MSG_IN,
00098
00099 NL_CB_MSG_OUT,
00100
00101 NL_CB_INVALID,
00102
00103 NL_CB_SEQ_CHECK,
00104
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