mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-01-05 02:10:17 +01:00
platform: use new platform API to get genl family id for nl80211/Wi-Fi
This commit is contained in:
parent
f40dcd65f7
commit
36e6ac5450
5 changed files with 20 additions and 20 deletions
|
|
@ -3296,10 +3296,11 @@ _new_from_nl_link(NMPlatform *platform,
|
|||
switch (obj->link.type) {
|
||||
case NM_LINK_TYPE_WIFI:
|
||||
case NM_LINK_TYPE_OLPC_MESH:
|
||||
obj->_link.ext_data =
|
||||
(GObject *) nm_wifi_utils_new(ifi->ifi_index,
|
||||
NM_LINUX_PLATFORM_GET_PRIVATE(platform)->sk_genl_sync,
|
||||
TRUE);
|
||||
obj->_link.ext_data = (GObject *) nm_wifi_utils_new(
|
||||
NM_LINUX_PLATFORM_GET_PRIVATE(platform)->sk_genl_sync,
|
||||
nm_platform_genl_get_family_id(platform, NMP_GENL_FAMILY_TYPE_NL80211),
|
||||
ifi->ifi_index,
|
||||
TRUE);
|
||||
break;
|
||||
case NM_LINK_TYPE_WPAN:
|
||||
obj->_link.ext_data =
|
||||
|
|
|
|||
|
|
@ -46,9 +46,9 @@ typedef struct {
|
|||
NMWifiUtils parent;
|
||||
struct nl_sock *nl_sock;
|
||||
guint32 *freqs;
|
||||
int id;
|
||||
int num_freqs;
|
||||
int phy;
|
||||
guint16 genl_family_id;
|
||||
bool can_wowlan : 1;
|
||||
} NMWifiUtilsNl80211;
|
||||
|
||||
|
|
@ -83,12 +83,12 @@ error_handler(struct sockaddr_nl *nla, struct nlmsgerr *err, void *arg)
|
|||
}
|
||||
|
||||
static struct nl_msg *
|
||||
_nl80211_alloc_msg(int id, int ifindex, int phy, guint32 cmd, guint32 flags)
|
||||
_nl80211_alloc_msg(guint16 genl_family_id, int ifindex, int phy, guint32 cmd, guint32 flags)
|
||||
{
|
||||
nm_auto_nlmsg struct nl_msg *msg = NULL;
|
||||
|
||||
msg = nlmsg_alloc();
|
||||
genlmsg_put(msg, 0, 0, id, 0, flags, cmd, 0);
|
||||
genlmsg_put(msg, 0, 0, genl_family_id, 0, flags, cmd, 0);
|
||||
NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, ifindex);
|
||||
if (phy != -1)
|
||||
NLA_PUT_U32(msg, NL80211_ATTR_WIPHY, phy);
|
||||
|
|
@ -101,7 +101,7 @@ nla_put_failure:
|
|||
static struct nl_msg *
|
||||
nl80211_alloc_msg(NMWifiUtilsNl80211 *self, guint32 cmd, guint32 flags)
|
||||
{
|
||||
return _nl80211_alloc_msg(self->id, self->parent.ifindex, self->phy, cmd, flags);
|
||||
return _nl80211_alloc_msg(self->genl_family_id, self->parent.ifindex, self->phy, cmd, flags);
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -945,7 +945,7 @@ nm_wifi_utils_nl80211_class_init(NMWifiUtilsNl80211Class *klass)
|
|||
}
|
||||
|
||||
NMWifiUtils *
|
||||
nm_wifi_utils_nl80211_new(int ifindex, struct nl_sock *genl)
|
||||
nm_wifi_utils_nl80211_new(struct nl_sock *genl, guint16 genl_family_id, int ifindex)
|
||||
{
|
||||
gs_unref_object NMWifiUtilsNl80211 *self = NULL;
|
||||
nm_auto_nlmsg struct nl_msg *msg = NULL;
|
||||
|
|
@ -954,16 +954,14 @@ nm_wifi_utils_nl80211_new(int ifindex, struct nl_sock *genl)
|
|||
if (!genl)
|
||||
return NULL;
|
||||
|
||||
if (genl_family_id == 0)
|
||||
return NULL;
|
||||
|
||||
self = g_object_new(NM_TYPE_WIFI_UTILS_NL80211, NULL);
|
||||
|
||||
self->parent.ifindex = ifindex;
|
||||
self->nl_sock = genl;
|
||||
|
||||
self->id = genl_ctrl_resolve(self->nl_sock, "nl80211");
|
||||
if (self->id < 0) {
|
||||
_LOGD("genl_ctrl_resolve: failed to resolve \"nl80211\"");
|
||||
return NULL;
|
||||
}
|
||||
self->genl_family_id = genl_family_id;
|
||||
|
||||
self->phy = -1;
|
||||
|
||||
|
|
|
|||
|
|
@ -24,6 +24,6 @@
|
|||
|
||||
GType nm_wifi_utils_nl80211_get_type(void);
|
||||
|
||||
NMWifiUtils *nm_wifi_utils_nl80211_new(int ifindex, struct nl_sock *genl);
|
||||
NMWifiUtils *nm_wifi_utils_nl80211_new(struct nl_sock *genl, guint16 genl_family_id, int ifindex);
|
||||
|
||||
#endif /* __WIFI_UTILS_NL80211_H__ */
|
||||
|
|
|
|||
|
|
@ -32,16 +32,16 @@ nm_wifi_utils_class_init(NMWifiUtilsClass *klass)
|
|||
{}
|
||||
|
||||
NMWifiUtils *
|
||||
nm_wifi_utils_new(int ifindex, struct nl_sock *genl, gboolean check_scan)
|
||||
nm_wifi_utils_new(struct nl_sock *genl, guint16 genl_family_id, int ifindex, gboolean check_scan)
|
||||
{
|
||||
NMWifiUtils *ret;
|
||||
|
||||
g_return_val_if_fail(ifindex > 0, NULL);
|
||||
|
||||
ret = nm_wifi_utils_nl80211_new(ifindex, genl);
|
||||
ret = nm_wifi_utils_nl80211_new(genl, genl_family_id, ifindex);
|
||||
|
||||
#if HAVE_WEXT
|
||||
if (ret == NULL)
|
||||
if (!ret)
|
||||
ret = nm_wifi_utils_wext_new(ifindex, check_scan);
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -27,7 +27,8 @@ GType nm_wifi_utils_get_type(void);
|
|||
|
||||
gboolean nm_wifi_utils_is_wifi(int dirfd, const char *ifname);
|
||||
|
||||
NMWifiUtils *nm_wifi_utils_new(int ifindex, struct nl_sock *genl, gboolean check_scan);
|
||||
NMWifiUtils *
|
||||
nm_wifi_utils_new(struct nl_sock *genl, guint16 genl_family_id, int ifindex, gboolean check_scan);
|
||||
|
||||
_NMDeviceWifiCapabilities nm_wifi_utils_get_caps(NMWifiUtils *data);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue