mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-01-06 15:30:14 +01:00
wifi-p2p: merge branch 'benzea/WFDIEs'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/issues/125 https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/84
This commit is contained in:
commit
229b4fdd81
9 changed files with 129 additions and 69 deletions
|
|
@ -27,20 +27,6 @@
|
|||
-->
|
||||
<property name="GroupOwner" type="b" access="read"/>
|
||||
|
||||
<!--
|
||||
WFDIEs:
|
||||
|
||||
The Wi-Fi Display information elements.
|
||||
|
||||
Since: 1.16
|
||||
-->
|
||||
<property name="WFDIEs" type="ay" access="read">
|
||||
<!-- gdbus-codegen assumes that "ay" means "non-UTF-8 string" and
|
||||
won't deal with '\0' bytes correctly.
|
||||
-->
|
||||
<annotation name="org.gtk.GDBus.C.ForceGVariant" value="1"/>
|
||||
</property>
|
||||
|
||||
<!--
|
||||
Peers:
|
||||
|
||||
|
|
|
|||
|
|
@ -49,10 +49,12 @@
|
|||
NM_GOBJECT_PROPERTIES_DEFINE_BASE (
|
||||
PROP_PEER,
|
||||
PROP_WPS_METHOD,
|
||||
PROP_WFD_IES,
|
||||
);
|
||||
|
||||
typedef struct {
|
||||
char *peer_mac_address;
|
||||
GBytes *wfd_ies;
|
||||
|
||||
NMSettingWirelessSecurityWpsMethod wps_method;
|
||||
} NMSettingWifiP2PPrivate;
|
||||
|
|
@ -104,6 +106,22 @@ nm_setting_wifi_p2p_get_wps_method (NMSettingWifiP2P *setting)
|
|||
return NM_SETTING_WIFI_P2P_GET_PRIVATE (setting)->wps_method;
|
||||
}
|
||||
|
||||
/**
|
||||
* nm_setting_wifi_p2p_get_wfd_ies:
|
||||
* @setting: the #NMSettingWiFiP2P
|
||||
*
|
||||
* Returns: (transfer none): the #NMSettingWiFiP2P:wfd-ies property of the setting
|
||||
*
|
||||
* Since: 1.16
|
||||
**/
|
||||
GBytes *
|
||||
nm_setting_wifi_p2p_get_wfd_ies (NMSettingWifiP2P *setting)
|
||||
{
|
||||
g_return_val_if_fail (NM_IS_SETTING_WIFI_P2P (setting), NULL);
|
||||
|
||||
return NM_SETTING_WIFI_P2P_GET_PRIVATE (setting)->wfd_ies;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static gboolean
|
||||
|
|
@ -154,6 +172,9 @@ get_property (GObject *object, guint prop_id,
|
|||
case PROP_WPS_METHOD:
|
||||
g_value_set_uint (value, nm_setting_wifi_p2p_get_wps_method (setting));
|
||||
break;
|
||||
case PROP_WFD_IES:
|
||||
g_value_set_boxed (value, nm_setting_wifi_p2p_get_wfd_ies (setting));
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
|
|
@ -175,6 +196,10 @@ set_property (GObject *object, guint prop_id,
|
|||
case PROP_WPS_METHOD:
|
||||
priv->wps_method = g_value_get_uint (value);
|
||||
break;
|
||||
case PROP_WFD_IES:
|
||||
g_clear_pointer (&priv->wfd_ies, g_bytes_unref);
|
||||
priv->wfd_ies = g_value_dup_boxed (value);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
|
|
@ -209,6 +234,7 @@ finalize (GObject *object)
|
|||
NMSettingWifiP2PPrivate *priv = NM_SETTING_WIFI_P2P_GET_PRIVATE (object);
|
||||
|
||||
g_free (priv->peer_mac_address);
|
||||
g_bytes_unref (priv->wfd_ies);
|
||||
|
||||
G_OBJECT_CLASS (nm_setting_wifi_p2p_parent_class)->finalize (object);
|
||||
}
|
||||
|
|
@ -258,7 +284,7 @@ nm_setting_wifi_p2p_class_init (NMSettingWifiP2PClass *setting_wifi_p2p_class)
|
|||
* Since: 1.16
|
||||
*/
|
||||
obj_properties[PROP_WPS_METHOD] =
|
||||
g_param_spec_uint (NM_SETTING_WIRELESS_SECURITY_WPS_METHOD, "", "",
|
||||
g_param_spec_uint (NM_SETTING_WIFI_P2P_WPS_METHOD, "", "",
|
||||
0,
|
||||
G_MAXUINT32,
|
||||
NM_SETTING_WIRELESS_SECURITY_WPS_METHOD_DEFAULT,
|
||||
|
|
@ -266,6 +292,25 @@ nm_setting_wifi_p2p_class_init (NMSettingWifiP2PClass *setting_wifi_p2p_class)
|
|||
NM_SETTING_PARAM_FUZZY_IGNORE |
|
||||
G_PARAM_STATIC_STRINGS);
|
||||
|
||||
/**
|
||||
* NMSettingWifiP2P:wfd-ies:
|
||||
*
|
||||
* The Wi-Fi Display (WFD) Information Elements (IEs) to set.
|
||||
*
|
||||
* Wi-Fi Display requires a protocol specific information element to be
|
||||
* set in certain Wi-Fi frames. These can be specified here for the
|
||||
* purpose of establishing a connection.
|
||||
* This setting is only useful when implementing a Wi-Fi Display client.
|
||||
*
|
||||
* Since: 1.16
|
||||
*/
|
||||
obj_properties[PROP_WFD_IES] =
|
||||
g_param_spec_boxed (NM_SETTING_WIFI_P2P_WFD_IES, "", "",
|
||||
G_TYPE_BYTES,
|
||||
G_PARAM_READWRITE |
|
||||
NM_SETTING_PARAM_FUZZY_IGNORE |
|
||||
G_PARAM_STATIC_STRINGS);
|
||||
|
||||
g_object_class_install_properties (object_class, _PROPERTY_ENUMS_LAST, obj_properties);
|
||||
|
||||
_nm_setting_class_commit (setting_class, NM_META_SETTING_TYPE_WIFI_P2P);
|
||||
|
|
|
|||
|
|
@ -45,6 +45,7 @@ G_BEGIN_DECLS
|
|||
*/
|
||||
#define NM_SETTING_WIFI_P2P_PEER "peer"
|
||||
#define NM_SETTING_WIFI_P2P_WPS_METHOD "wps-method"
|
||||
#define NM_SETTING_WIFI_P2P_WFD_IES "wfd-ies"
|
||||
|
||||
typedef struct _NMSettingWifiP2PClass NMSettingWifiP2PClass;
|
||||
|
||||
|
|
@ -60,6 +61,9 @@ const char *nm_setting_wifi_p2p_get_peer (NMSettingWifiP2P *setting);
|
|||
NM_AVAILABLE_IN_1_16
|
||||
NMSettingWirelessSecurityWpsMethod nm_setting_wifi_p2p_get_wps_method (NMSettingWifiP2P *setting);
|
||||
|
||||
NM_AVAILABLE_IN_1_16
|
||||
GBytes *nm_setting_wifi_p2p_get_wfd_ies (NMSettingWifiP2P *setting);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __NM_SETTING_WIFI_P2P_H__ */
|
||||
|
|
|
|||
|
|
@ -1460,6 +1460,7 @@ global:
|
|||
nm_device_wifi_p2p_stop_find_finish;
|
||||
nm_setting_wifi_p2p_get_peer;
|
||||
nm_setting_wifi_p2p_get_type;
|
||||
nm_setting_wifi_p2p_get_wfd_ies;
|
||||
nm_setting_wifi_p2p_get_wps_method;
|
||||
nm_setting_wifi_p2p_new;
|
||||
nm_team_link_watcher_get_vlanid;
|
||||
|
|
|
|||
|
|
@ -41,7 +41,6 @@ typedef struct {
|
|||
NM_GOBJECT_PROPERTIES_DEFINE_BASE (
|
||||
PROP_HW_ADDRESS,
|
||||
PROP_GROUP_OWNER,
|
||||
PROP_WFDIES,
|
||||
PROP_PEERS,
|
||||
);
|
||||
|
||||
|
|
@ -59,7 +58,6 @@ typedef struct {
|
|||
|
||||
char *hw_address;
|
||||
|
||||
GByteArray *wfd_ies;
|
||||
GPtrArray *peers;
|
||||
|
||||
gboolean group_owner;
|
||||
|
|
@ -366,18 +364,6 @@ get_hw_address (NMDevice *device)
|
|||
return nm_device_wifi_p2p_get_hw_address (NM_DEVICE_WIFI_P2P (device));
|
||||
}
|
||||
|
||||
static GVariant *
|
||||
nm_device_wifi_p2p_get_wfdies_as_variant (const NMDeviceWifiP2P *self)
|
||||
{
|
||||
const NMDeviceWifiP2PPrivate *priv = NM_DEVICE_WIFI_P2P_GET_PRIVATE (self);
|
||||
|
||||
if (priv->wfd_ies) {
|
||||
return g_variant_new_fixed_array (G_VARIANT_TYPE_BYTE,
|
||||
priv->wfd_ies->data, priv->wfd_ies->len, 1);
|
||||
} else
|
||||
return g_variant_new_array (G_VARIANT_TYPE_BYTE, NULL, 0);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static void
|
||||
|
|
@ -395,9 +381,6 @@ get_property (GObject *object,
|
|||
case PROP_GROUP_OWNER:
|
||||
g_value_set_enum (value, nm_device_wifi_p2p_get_group_owner (self));
|
||||
break;
|
||||
case PROP_WFDIES:
|
||||
g_value_take_variant (value, nm_device_wifi_p2p_get_wfdies_as_variant (self));
|
||||
break;
|
||||
case PROP_PEERS:
|
||||
g_value_take_boxed (value, _nm_utils_copy_object_array (nm_device_wifi_p2p_get_peers (self)));
|
||||
break;
|
||||
|
|
@ -422,7 +405,6 @@ init_dbus (NMObject *object)
|
|||
const NMPropertiesInfo property_info[] = {
|
||||
{ NM_DEVICE_WIFI_P2P_HW_ADDRESS, &priv->hw_address },
|
||||
{ NM_DEVICE_WIFI_P2P_GROUP_OWNER, &priv->group_owner },
|
||||
{ NM_DEVICE_WIFI_P2P_WFDIES, &priv->wfd_ies },
|
||||
{ NM_DEVICE_WIFI_P2P_PEERS, &priv->peers, NULL, NM_TYPE_WIFI_P2P_PEER, "peer" },
|
||||
{ NULL },
|
||||
};
|
||||
|
|
@ -450,8 +432,6 @@ finalize (GObject *object)
|
|||
|
||||
g_clear_object (&priv->proxy);
|
||||
g_free (priv->hw_address);
|
||||
if (priv->wfd_ies)
|
||||
g_byte_array_unref (priv->wfd_ies);
|
||||
if (priv->peers)
|
||||
g_ptr_array_unref (priv->peers);
|
||||
|
||||
|
|
@ -502,20 +482,6 @@ nm_device_wifi_p2p_class_init (NMDeviceWifiP2PClass *wifi_class)
|
|||
G_PARAM_READABLE |
|
||||
G_PARAM_STATIC_STRINGS);
|
||||
|
||||
/**
|
||||
* NMDeviceWifiP2P:wfd-ies:
|
||||
*
|
||||
* Whether the device is currently the group owner.
|
||||
*
|
||||
* Since: 1.16
|
||||
**/
|
||||
obj_properties[PROP_WFDIES] =
|
||||
g_param_spec_variant (NM_DEVICE_WIFI_P2P_WFDIES, "", "",
|
||||
G_VARIANT_TYPE ("ay"),
|
||||
NULL,
|
||||
G_PARAM_READABLE |
|
||||
G_PARAM_STATIC_STRINGS);
|
||||
|
||||
/**
|
||||
* NMDeviceWifiP2P:peers: (type GPtrArray(NMWifiP2PPeer))
|
||||
*
|
||||
|
|
|
|||
|
|
@ -49,9 +49,6 @@ _LOG_DECLARE_SELF(NMDeviceWifiP2P);
|
|||
NM_GOBJECT_PROPERTIES_DEFINE (NMDeviceWifiP2P,
|
||||
PROP_GROUP_OWNER,
|
||||
PROP_PEERS,
|
||||
PROP_WFDIES, /* TODO: Make this a property of the setting and Find feature
|
||||
* making the device stateless.
|
||||
*/
|
||||
);
|
||||
|
||||
typedef struct {
|
||||
|
|
@ -66,7 +63,6 @@ typedef struct {
|
|||
NMSupplicantInterface *group_iface;
|
||||
|
||||
CList peers_lst_head;
|
||||
GBytes *wfd_ies;
|
||||
|
||||
guint sup_timeout_id;
|
||||
guint peer_dump_id;
|
||||
|
|
@ -413,8 +409,6 @@ act_stage1_prepare (NMDevice *device, NMDeviceStateReason *out_failure_reason)
|
|||
return NM_ACT_STAGE_RETURN_POSTPONE;
|
||||
}
|
||||
|
||||
/* TODO: Set WFD IEs on supplicant manager here! */
|
||||
|
||||
return NM_ACT_STAGE_RETURN_SUCCESS;
|
||||
}
|
||||
|
||||
|
|
@ -466,7 +460,9 @@ act_stage2_config (NMDevice *device, NMDeviceStateReason *out_failure_reason)
|
|||
NMDeviceWifiP2P *self = NM_DEVICE_WIFI_P2P (device);
|
||||
NMDeviceWifiP2PPrivate *priv = NM_DEVICE_WIFI_P2P_GET_PRIVATE (self);
|
||||
NMConnection *connection;
|
||||
NMSettingWifiP2P *s_wifi_p2p;
|
||||
NMWifiP2PPeer *peer;
|
||||
GBytes *wfd_ies;
|
||||
|
||||
nm_clear_g_source (&priv->sup_timeout_id);
|
||||
|
||||
|
|
@ -482,6 +478,11 @@ act_stage2_config (NMDevice *device, NMDeviceStateReason *out_failure_reason)
|
|||
return NM_ACT_STAGE_RETURN_FAILURE;
|
||||
}
|
||||
|
||||
/* Set the WFD IEs before trying to establish the connection. */
|
||||
s_wifi_p2p = NM_SETTING_WIFI_P2P (nm_connection_get_setting (connection, NM_TYPE_SETTING_WIFI_P2P));
|
||||
wfd_ies = nm_setting_wifi_p2p_get_wfd_ies (s_wifi_p2p);
|
||||
nm_supplicant_manager_set_wfd_ies (priv->sup_mgr, wfd_ies);
|
||||
|
||||
/* TODO: Grab secrets if we don't have them yet! */
|
||||
|
||||
/* TODO: Fix "pbc" being hardcoded here! */
|
||||
|
|
@ -938,6 +939,8 @@ supplicant_interfaces_release (NMDeviceWifiP2P *self, gboolean set_is_waiting)
|
|||
if (priv->mgmt_iface) {
|
||||
_LOGD (LOGD_DEVICE | LOGD_WIFI, "P2P: Releasing WPA supplicant interface.");
|
||||
|
||||
nm_supplicant_manager_set_wfd_ies (priv->sup_mgr, NULL);
|
||||
|
||||
g_signal_handlers_disconnect_by_data (priv->mgmt_iface, self);
|
||||
|
||||
g_clear_object (&priv->mgmt_iface);
|
||||
|
|
@ -999,10 +1002,12 @@ device_state_changed (NMDevice *device,
|
|||
case NM_DEVICE_STATE_FAILED:
|
||||
/* Clear any critical protocol notification in the wifi stack.
|
||||
* At this point the IP device may have been removed already. */
|
||||
nm_supplicant_manager_set_wfd_ies (priv->sup_mgr, NULL);
|
||||
if (nm_device_get_ip_ifindex (device) > 0)
|
||||
nm_platform_wifi_indicate_addressing_running (nm_device_get_platform (device), nm_device_get_ip_ifindex (device), FALSE);
|
||||
break;
|
||||
case NM_DEVICE_STATE_DISCONNECTED:
|
||||
nm_supplicant_manager_set_wfd_ies (priv->sup_mgr, NULL);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
|
@ -1198,7 +1203,6 @@ static const NMDBusInterfaceInfoExtended interface_info_device_wifi_p2p = {
|
|||
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE ("HwAddress", "s", NM_DEVICE_HW_ADDRESS),
|
||||
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE ("GroupOwner", "b", NM_DEVICE_WIFI_P2P_GROUP_OWNER),
|
||||
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE ("Peers", "ao", NM_DEVICE_WIFI_P2P_PEERS),
|
||||
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE ("WFDIEs", "ay", NM_DEVICE_WIFI_P2P_WFDIES),
|
||||
),
|
||||
),
|
||||
.legacy_property_changed = FALSE,
|
||||
|
|
@ -1222,9 +1226,6 @@ get_property (GObject *object, guint prop_id,
|
|||
list = nm_wifi_p2p_peers_get_paths (&priv->peers_lst_head);
|
||||
g_value_take_boxed (value, nm_utils_strv_make_deep_copied (list));
|
||||
break;
|
||||
case PROP_WFDIES:
|
||||
g_value_take_variant (value, nm_utils_gbytes_to_variant_ay (priv->wfd_ies));
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
|
|
@ -1286,8 +1287,6 @@ finalize (GObject *object)
|
|||
|
||||
nm_assert (c_list_is_empty (&priv->peers_lst_head));
|
||||
|
||||
g_bytes_unref (priv->wfd_ies);
|
||||
|
||||
G_OBJECT_CLASS (nm_device_wifi_p2p_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
|
|
@ -1338,12 +1337,5 @@ nm_device_wifi_p2p_class_init (NMDeviceWifiP2PClass *klass)
|
|||
G_PARAM_READABLE |
|
||||
G_PARAM_STATIC_STRINGS);
|
||||
|
||||
obj_properties[PROP_WFDIES] =
|
||||
g_param_spec_variant (NM_DEVICE_WIFI_P2P_WFDIES, "", "",
|
||||
G_VARIANT_TYPE ("ay"),
|
||||
NULL,
|
||||
G_PARAM_READABLE |
|
||||
G_PARAM_STATIC_STRINGS);
|
||||
|
||||
g_object_class_install_properties (object_class, _PROPERTY_ENUMS_LAST, obj_properties);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,7 +34,6 @@
|
|||
#define NM_DEVICE_WIFI_P2P_GROUP_OWNER "group-owner"
|
||||
#define NM_DEVICE_WIFI_P2P_PEERS "peers"
|
||||
#define NM_DEVICE_WIFI_P2P_GROUPS "groups"
|
||||
#define NM_DEVICE_WIFI_P2P_WFDIES "WFDIEs"
|
||||
|
||||
typedef struct _NMDeviceWifiP2P NMDeviceWifiP2P;
|
||||
typedef struct _NMDeviceWifiP2PClass NMDeviceWifiP2PClass;
|
||||
|
|
|
|||
|
|
@ -123,6 +123,70 @@ _sup_iface_last_ref (gpointer data,
|
|||
g_object_remove_toggle_ref ((GObject *) sup_iface, _sup_iface_last_ref, self);
|
||||
}
|
||||
|
||||
static void
|
||||
on_supplicant_wfd_ies_set (GObject *source_object,
|
||||
GAsyncResult *res,
|
||||
gpointer user_data)
|
||||
{
|
||||
gs_unref_variant GVariant *result = NULL;
|
||||
gs_free_error GError *error = NULL;
|
||||
|
||||
result = g_dbus_connection_call_finish (G_DBUS_CONNECTION (source_object), res, &error);
|
||||
|
||||
if (!result)
|
||||
_LOGW ("failed to set WFD IEs on wpa_supplicant: %s", error->message);
|
||||
}
|
||||
|
||||
/**
|
||||
* nm_supplicant_manager_set_wfd_ies:
|
||||
* @self: the #NMSupplicantManager
|
||||
* @wfd_ies: a #GBytes with the WFD IEs or %NULL
|
||||
*
|
||||
* This function sets the global WFD IEs on wpa_supplicant. Note that
|
||||
* it would make more sense if this was per-device, but wpa_supplicant
|
||||
* simply does not work that way.
|
||||
* */
|
||||
void
|
||||
nm_supplicant_manager_set_wfd_ies (NMSupplicantManager *self,
|
||||
GBytes *wfd_ies)
|
||||
{
|
||||
NMSupplicantManagerPrivate *priv;
|
||||
GVariantBuilder params = G_VARIANT_BUILDER_INIT(G_VARIANT_TYPE ("(ssv)"));
|
||||
GVariant *val;
|
||||
|
||||
g_return_if_fail (NM_IS_SUPPLICANT_MANAGER (self));
|
||||
|
||||
priv = NM_SUPPLICANT_MANAGER_GET_PRIVATE (self);
|
||||
|
||||
_LOGD ("setting WFD IEs for P2P operation");
|
||||
|
||||
if (wfd_ies)
|
||||
val = g_variant_new_fixed_array (G_VARIANT_TYPE_BYTE,
|
||||
g_bytes_get_data (wfd_ies, NULL),
|
||||
g_bytes_get_size (wfd_ies),
|
||||
sizeof (guint8));
|
||||
else
|
||||
val = g_variant_new_fixed_array (G_VARIANT_TYPE_BYTE,
|
||||
NULL, 0, sizeof (guint8));
|
||||
|
||||
g_variant_builder_add (¶ms, "s", g_dbus_proxy_get_interface_name (priv->proxy));
|
||||
g_variant_builder_add (¶ms, "s", "WFDIEs");
|
||||
g_variant_builder_add_value (¶ms, g_variant_new_variant (val));
|
||||
|
||||
g_dbus_connection_call (g_dbus_proxy_get_connection (priv->proxy),
|
||||
g_dbus_proxy_get_name (priv->proxy),
|
||||
g_dbus_proxy_get_object_path (priv->proxy),
|
||||
"org.freedesktop.DBus.Properties",
|
||||
"Set",
|
||||
g_variant_builder_end (¶ms),
|
||||
G_VARIANT_TYPE_UNIT,
|
||||
G_DBUS_CALL_FLAGS_NO_AUTO_START,
|
||||
1000,
|
||||
NULL,
|
||||
on_supplicant_wfd_ies_set,
|
||||
NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
* nm_supplicant_manager_create_interface:
|
||||
* @self: the #NMSupplicantManager
|
||||
|
|
|
|||
|
|
@ -38,6 +38,9 @@ GType nm_supplicant_manager_get_type (void);
|
|||
|
||||
NMSupplicantManager *nm_supplicant_manager_get (void);
|
||||
|
||||
void nm_supplicant_manager_set_wfd_ies (NMSupplicantManager *self,
|
||||
GBytes *wfd_ies);
|
||||
|
||||
NMSupplicantInterface *nm_supplicant_manager_create_interface (NMSupplicantManager *mgr,
|
||||
const char *ifname,
|
||||
NMSupplicantDriver driver);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue