On Thu, 2011-11-10 at 17:34 +0100, Thomas Graf wrote:
> Based on a patch for iw by Johannes Berg <[email protected]>
> 
> This simplifies the code quite a bit since we don't need
> an nl_cache or nl_family anymore.
> 
> genl_ctrl_resolve() is available in libnl1.1, libnl2 and libnl3.

Pushed, thanks.

Dan

> Cc: Johannes Berg <[email protected]>
> Signed-off-by: Thomas Graf <[email protected]>
> ---
>  src/nm-netlink-compat.h  |   12 ------------
>  src/wifi-utils-nl80211.c |   17 ++++-------------
>  2 files changed, 4 insertions(+), 25 deletions(-)
> 
> diff --git a/src/nm-netlink-compat.h b/src/nm-netlink-compat.h
> index 478bc8b..af21fb9 100644
> --- a/src/nm-netlink-compat.h
> +++ b/src/nm-netlink-compat.h
> @@ -172,18 +172,6 @@ __nl_cache_include (struct nl_cache *cache, struct 
> nl_object *obj, change_func_t
>  }
>  #define nl_cache_include __nl_cache_include
>  
> -#include <netlink/genl/ctrl.h>
> -
> -static inline int __genl_ctrl_alloc_cache(struct nl_sock *h, struct nl_cache 
> **cache)
> -{
> -     struct nl_cache *tmp = genl_ctrl_alloc_cache(h);
> -     if (!tmp)
> -             return -ENOMEM;
> -     *cache = tmp;
> -     return 0;
> -}
> -#define genl_ctrl_alloc_cache __genl_ctrl_alloc_cache
> -
>  #define NLE_SUCCESS             0
>  #define NLE_FAILURE             1
>  #define NLE_INTR                2
> diff --git a/src/wifi-utils-nl80211.c b/src/wifi-utils-nl80211.c
> index 614abd3..48c7656 100644
> --- a/src/wifi-utils-nl80211.c
> +++ b/src/wifi-utils-nl80211.c
> @@ -45,8 +45,7 @@
>  typedef struct {
>       WifiData parent;
>       struct nl_sock *nl_sock;
> -     struct nl_cache *nl_cache;
> -     struct genl_family *nl_family;
> +     int id;
>       struct nl_cb *nl_cb;
>       guint32 *freqs;
>       int num_freqs;
> @@ -81,8 +80,7 @@ static struct nl_msg *nl80211_alloc_msg (WifiDataNl80211 
> *nl80211,
>       if (!msg)
>               return NULL;
>  
> -     genlmsg_put (msg, 0, 0, genl_family_get_id (nl80211->nl_family), 0,
> -                  flags, cmd, 0);
> +     genlmsg_put (msg, 0, 0, nl80211->id, 0, flags, cmd, 0);
>  
>       NLA_PUT_U32 (msg, NL80211_ATTR_IFINDEX, nl80211->parent.ifindex);
>  
> @@ -137,10 +135,6 @@ wifi_nl80211_deinit (WifiData *parent)
>  {
>       WifiDataNl80211 *nl80211 = (WifiDataNl80211 *) parent;
>  
> -     if (nl80211->nl_family)
> -             genl_family_put (nl80211->nl_family);
> -     if (nl80211->nl_cache)
> -             nl_cache_free (nl80211->nl_cache);
>       if (nl80211->nl_sock)
>               nl_socket_free (nl80211->nl_sock);
>       if (nl80211->nl_cb)
> @@ -672,11 +666,8 @@ wifi_nl80211_init (const char *iface, int ifindex)
>       if (genl_connect (nl80211->nl_sock))
>               goto error;
>  
> -     if (genl_ctrl_alloc_cache (nl80211->nl_sock, &nl80211->nl_cache))
> -             goto error;
> -
> -     nl80211->nl_family = genl_ctrl_search_by_name (nl80211->nl_cache, 
> "nl80211");
> -     if (nl80211->nl_family == NULL)
> +     nl80211->id = genl_ctrl_resolve (nl80211->nl_sock, "nl80211");
> +     if (nl80211->id < 0)
>               goto error;
>  
>       nl80211->nl_cb = nl_cb_alloc (NL_CB_DEFAULT);


_______________________________________________
networkmanager-list mailing list
[email protected]
http://mail.gnome.org/mailman/listinfo/networkmanager-list

Reply via email to