summaryrefslogtreecommitdiffhomepage
path: root/system-linux.c
diff options
context:
space:
mode:
authorFelix Fietkau <nbd@openwrt.org>2011-10-23 16:04:50 +0200
committerFelix Fietkau <nbd@openwrt.org>2011-10-23 16:04:50 +0200
commite284f0d534d5caccebdb2c898e593fb5b13a9d39 (patch)
treeb0db5315e04d95a9a1efee27d3219e8b2a2f219d /system-linux.c
parente19e9800b93dbaec566c43d752b9cf1a3c7c913b (diff)
add a function for creating a raw event socket that does not use genl or rtnl
Diffstat (limited to 'system-linux.c')
-rw-r--r--system-linux.c23
1 files changed, 15 insertions, 8 deletions
diff --git a/system-linux.c b/system-linux.c
index 0308e6f..57a4617 100644
--- a/system-linux.c
+++ b/system-linux.c
@@ -58,6 +58,20 @@ create_socket(int protocol)
}
static bool
+create_raw_event_socket(struct event_socket *ev, int protocol,
+ uloop_fd_handler cb)
+{
+ ev->sock = create_socket(protocol);
+ if (!ev->sock)
+ 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;
+}
+
+static bool
create_event_socket(struct event_socket *ev, int protocol,
int (*cb)(struct nl_msg *msg, void *arg))
{
@@ -68,14 +82,7 @@ create_event_socket(struct event_socket *ev, int protocol,
nl_cb_set(ev->cb, NL_CB_VALID, NL_CB_CUSTOM, cb, NULL);
- ev->sock = create_socket(protocol);
- if (!ev->sock)
- 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;
+ return create_raw_event_socket(ev, protocol, handler_nl_event);
}
int system_init(void)