1 #ifndef __UNL_H 2 #define __UNL_H 3 4 #include <netlink/netlink.h> 5 #include <netlink/genl/genl.h> 6 #include <netlink/genl/family.h> 7 #include <stdbool.h> 8 9 struct unl { 10 struct nl_sock *sock; 11 struct nl_cache *cache; 12 struct genl_family *family; 13 char *family_name; 14 int hdrlen; 15 bool loop_done; 16 }; 17 18 int unl_genl_init(struct unl *unl, const char *family); 19 int unl_rtnl_init(struct unl *unl); 20 void unl_free(struct unl *unl); 21 22 typedef int (*unl_cb)(struct nl_msg *, void *); 23 24 struct nl_msg *unl_genl_msg(struct unl *unl, int cmd, bool dump); 25 struct nl_msg *unl_rtnl_msg(struct unl *unl, int cmd, bool dump); 26 27 int unl_request(struct unl *unl, struct nl_msg *msg, unl_cb handler, void *arg); 28 int unl_request_single(struct unl *unl, struct nl_msg *msg, struct nl_msg **dest); 29 void unl_loop(struct unl *unl, unl_cb handler, void *arg); 30 31 /* compat */ 32 #define unl_genl_request unl_request 33 #define unl_genl_request_single unl_request_single 34 #define unl_genl_loop unl_loop 35 36 int unl_genl_multicast_id(struct unl *unl, const char *name); 37 int unl_genl_subscribe(struct unl *unl, const char *name); 38 int unl_genl_unsubscribe(struct unl *unl, const char *name); 39 40 int unl_nl80211_phy_lookup(const char *name); 41 int unl_nl80211_wdev_to_phy(struct unl *unl, int wdev); 42 struct nl_msg *unl_nl80211_phy_msg(struct unl *unl, int phy, int cmd, bool dump); 43 struct nl_msg *unl_nl80211_vif_msg(struct unl *unl, int dev, int cmd, bool dump); 44 45 static inline void unl_loop_done(struct unl *unl) 46 { 47 unl->loop_done = true; 48 } 49 50 static inline struct nlattr *unl_find_attr(struct unl *unl, struct nl_msg *msg, int attr) 51 { 52 return nlmsg_find_attr(nlmsg_hdr(msg), unl->hdrlen, attr); 53 } 54 55 #endif 56
This page was automatically generated by LXR 0.3.1. • OpenWrt