+static bool
+create_event_socket(struct event_socket *ev, int protocol,
+ int (*cb)(struct nl_msg *msg, void *arg))
+{
+ // Prepare socket for link events
+ ev->cb = nl_cb_alloc(NL_CB_DEFAULT);
+ if (!ev->cb)
+ return false;
+
+ nl_cb_set(ev->cb, NL_CB_VALID, NL_CB_CUSTOM, cb, NULL);
+
+ ev->sock = nl_socket_alloc();
+ if (!ev->sock)
+ return false;
+
+ if (nl_connect(ev->sock, protocol))
+ return false;
+
+ ev->uloop.fd = nl_socket_get_fd(ev->sock);
+ ev->uloop.cb = handler_nl_event;
+ uloop_fd_add(&ev->uloop, ULOOP_READ | ULOOP_EDGE_TRIGGER);
+ return true;
+}
+