summaryrefslogtreecommitdiff
path: root/src/platform/nm-netlink.h
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2018-02-16 17:05:32 +0100
committerThomas Haller <thaller@redhat.com>2018-02-21 12:08:46 +0100
commita7bda2ed12b958fd605e78a2512aa7246046983a (patch)
treeb25da10ed9139b2ca8a4f9bfaf30c1d1b427454b /src/platform/nm-netlink.h
parent9071e8cc050cef531420534f470347d2d9616143 (diff)
downloadNetworkManager-a7bda2ed12b958fd605e78a2512aa7246046983a.tar.gz
netlink: simplify netlink callback handling
With libnl3, each socket has it's own callback structure. One would often take that callback structure, clone it, modify it and invoke a receive operation with it. We don't need this complexity. We got rid of all default handlers, hence, by default all callbacks are unset. The only callbacks that are set, are those that we specify immediately before invoking the receive operation. Just pass the callback structure at that point. Also, no more ref-counting, and cloning of the callback structure. It is so simple, just stack allocate one if you need it.
Diffstat (limited to 'src/platform/nm-netlink.h')
-rw-r--r--src/platform/nm-netlink.h49
1 files changed, 12 insertions, 37 deletions
diff --git a/src/platform/nm-netlink.h b/src/platform/nm-netlink.h
index 2e0af4bc57..9c89748009 100644
--- a/src/platform/nm-netlink.h
+++ b/src/platform/nm-netlink.h
@@ -450,8 +450,6 @@ int nl_send_auto (struct nl_sock *sk, struct nl_msg *msg);
/*****************************************************************************/
-struct nl_cb;
-
enum nl_cb_action {
/* Proceed with wathever would come next */
NL_OK,
@@ -461,48 +459,24 @@ enum nl_cb_action {
NL_STOP,
};
-enum nl_cb_kind {
- /* Default handlers (quiet) */
- NL_CB_DEFAULT,
- /* Customized handler specified by the user */
- NL_CB_CUSTOM,
- __NL_CB_KIND_MAX,
-};
-
-#define NL_CB_KIND_MAX (__NL_CB_KIND_MAX - 1)
-
-enum nl_cb_type {
- /* Message is valid */
- NL_CB_VALID,
- /* Last message in a series of multi part messages received */
- NL_CB_FINISH,
- /* Message is an acknowledge */
- NL_CB_ACK,
- __NL_CB_TYPE_MAX,
-};
-
-#define NL_CB_TYPE_MAX (__NL_CB_TYPE_MAX - 1)
-
typedef int (*nl_recvmsg_msg_cb_t) (struct nl_msg *msg, void *arg);
typedef int (*nl_recvmsg_err_cb_t) (struct sockaddr_nl *nla,
struct nlmsgerr *nlerr, void *arg);
-struct nl_cb *nl_cb_alloc (enum nl_cb_kind kind);
-
-struct nl_cb *nl_cb_clone (struct nl_cb *orig);
-
-struct nl_cb *nl_cb_get (struct nl_cb *cb);
+struct nl_cb {
+ nl_recvmsg_msg_cb_t valid_cb;
+ void * valid_arg;
-void nl_cb_put (struct nl_cb *cb);
+ nl_recvmsg_msg_cb_t finish_cb;
+ void * finish_arg;
-int nl_cb_set (struct nl_cb *cb, enum nl_cb_type type, enum nl_cb_kind kind,
- nl_recvmsg_msg_cb_t func, void *arg);
+ nl_recvmsg_msg_cb_t ack_cb;
+ void * ack_arg;
-int nl_cb_err (struct nl_cb *cb, enum nl_cb_kind kind,
- nl_recvmsg_err_cb_t func, void *arg);
-
-struct nl_cb *nl_socket_get_cb (const struct nl_sock *sk);
+ nl_recvmsg_err_cb_t err_cb;
+ void * err_arg;
+};
int nl_sendmsg (struct nl_sock *sk, struct nl_msg *msg, struct msghdr *hdr);
@@ -512,7 +486,8 @@ void nl_complete_msg (struct nl_sock *sk, struct nl_msg *msg);
int nl_recvmsgs (struct nl_sock *sk, const struct nl_cb *cb);
-int nl_wait_for_ack (struct nl_sock *sk);
+int nl_wait_for_ack (struct nl_sock *sk,
+ const struct nl_cb *cb);
/*****************************************************************************/