aboutsummaryrefslogtreecommitdiffstats
path: root/package/libnl-tiny/src/include
diff options
context:
space:
mode:
authorFelix Fietkau <nbd@openwrt.org>2011-01-31 19:57:28 +0000
committerFelix Fietkau <nbd@openwrt.org>2011-01-31 19:57:28 +0000
commit6c6588ff7384ea9be1d4e97c641b8035a354b5e4 (patch)
tree55d0efb4eeb8b4daf3df1061b8b912428497ce3d /package/libnl-tiny/src/include
parentec635ea26815d4afe7d3cb5ca4aa30282367f08a (diff)
downloadmaster-187ad058-6c6588ff7384ea9be1d4e97c641b8035a354b5e4.tar.gz
master-187ad058-6c6588ff7384ea9be1d4e97c641b8035a354b5e4.tar.bz2
master-187ad058-6c6588ff7384ea9be1d4e97c641b8035a354b5e4.zip
libnl-tiny: add unl a convenience wrapper around the libnl api
git-svn-id: svn://svn.openwrt.org/openwrt/trunk@25263 3c298f89-4303-0410-b956-a3cf2f4a3e73
Diffstat (limited to 'package/libnl-tiny/src/include')
-rw-r--r--package/libnl-tiny/src/include/unl.h46
1 files changed, 46 insertions, 0 deletions
diff --git a/package/libnl-tiny/src/include/unl.h b/package/libnl-tiny/src/include/unl.h
new file mode 100644
index 0000000000..57e348ae1d
--- /dev/null
+++ b/package/libnl-tiny/src/include/unl.h
@@ -0,0 +1,46 @@
+#ifndef __UNL_H
+#define __UNL_H
+
+#include <netlink/netlink.h>
+#include <netlink/genl/genl.h>
+#include <netlink/genl/family.h>
+#include <stdbool.h>
+
+struct unl {
+ struct nl_sock *sock;
+ struct nl_cache *cache;
+ struct genl_family *family;
+ char *family_name;
+ int hdrlen;
+ bool loop_done;
+};
+
+int unl_genl_init(struct unl *unl, const char *family);
+void unl_free(struct unl *unl);
+
+typedef int (*unl_cb)(struct nl_msg *, void *);
+
+struct nl_msg *unl_genl_msg(struct unl *unl, int cmd, bool dump);
+int unl_genl_request(struct unl *unl, struct nl_msg *msg, unl_cb handler, void *arg);
+int unl_genl_request_single(struct unl *unl, struct nl_msg *msg, struct nl_msg **dest);
+void unl_genl_loop(struct unl *unl, unl_cb handler, void *arg);
+
+int unl_genl_subscribe(struct unl *unl, const char *name);
+int unl_genl_unsubscribe(struct unl *unl, const char *name);
+
+int unl_nl80211_phy_lookup(const char *name);
+int unl_nl80211_wdev_to_phy(struct unl *unl, int wdev);
+struct nl_msg *unl_nl80211_phy_msg(struct unl *unl, int phy, int cmd, bool dump);
+struct nl_msg *unl_nl80211_vif_msg(struct unl *unl, int dev, int cmd, bool dump);
+
+static inline void unl_loop_done(struct unl *unl)
+{
+ unl->loop_done = true;
+}
+
+static inline struct nlattr *unl_find_attr(struct unl *unl, struct nl_msg *msg, int attr)
+{
+ return nlmsg_find_attr(nlmsg_hdr(msg), unl->hdrlen, attr);
+}
+
+#endif