wifi: merge branch 'bb/supplicant-wifi-p2p-support'

Partially merge [1].

[1] https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/24
This commit is contained in:
Thomas Haller 2018-12-13 09:50:11 +01:00
commit 4d88334d23
4 changed files with 1012 additions and 53 deletions

File diff suppressed because it is too large Load diff

View file

@ -55,33 +55,48 @@ typedef enum {
/* Properties */
#define NM_SUPPLICANT_INTERFACE_IFACE "iface"
#define NM_SUPPLICANT_INTERFACE_OBJECT_PATH "object-path"
#define NM_SUPPLICANT_INTERFACE_SCANNING "scanning"
#define NM_SUPPLICANT_INTERFACE_CURRENT_BSS "current-bss"
#define NM_SUPPLICANT_INTERFACE_P2P_GROUP_JOINED "p2p-group-joined"
#define NM_SUPPLICANT_INTERFACE_P2P_GROUP_PATH "p2p-group-path"
#define NM_SUPPLICANT_INTERFACE_P2P_GROUP_OWNER "p2p-group-owner"
#define NM_SUPPLICANT_INTERFACE_DRIVER "driver"
#define NM_SUPPLICANT_INTERFACE_P2P_AVAILABLE "p2p-available"
#define NM_SUPPLICANT_INTERFACE_FAST_SUPPORT "fast-support"
#define NM_SUPPLICANT_INTERFACE_AP_SUPPORT "ap-support"
#define NM_SUPPLICANT_INTERFACE_PMF_SUPPORT "pmf-support"
#define NM_SUPPLICANT_INTERFACE_FILS_SUPPORT "fils-support"
#define NM_SUPPLICANT_INTERFACE_P2P_SUPPORT "p2p-support"
#define NM_SUPPLICANT_INTERFACE_WFD_SUPPORT "wfd-support"
/* Signals */
#define NM_SUPPLICANT_INTERFACE_STATE "state"
#define NM_SUPPLICANT_INTERFACE_REMOVED "removed"
#define NM_SUPPLICANT_INTERFACE_BSS_UPDATED "bss-updated"
#define NM_SUPPLICANT_INTERFACE_BSS_REMOVED "bss-removed"
#define NM_SUPPLICANT_INTERFACE_PEER_UPDATED "peer-updated"
#define NM_SUPPLICANT_INTERFACE_PEER_REMOVED "peer-removed"
#define NM_SUPPLICANT_INTERFACE_SCAN_DONE "scan-done"
#define NM_SUPPLICANT_INTERFACE_CREDENTIALS_REQUEST "credentials-request"
#define NM_SUPPLICANT_INTERFACE_WPS_CREDENTIALS "wps-credentials"
#define NM_SUPPLICANT_INTERFACE_GROUP_STARTED "group-started"
#define NM_SUPPLICANT_INTERFACE_GROUP_FINISHED "group-finished"
#define NM_SUPPLICANT_INTERFACE_GROUP_FORMATION_FAILURE "group-formation-failure"
typedef struct _NMSupplicantInterfaceClass NMSupplicantInterfaceClass;
GType nm_supplicant_interface_get_type (void);
NMSupplicantInterface * nm_supplicant_interface_new (const char *ifname,
const char *object_path,
NMSupplicantDriver driver,
NMSupplicantFeature fast_support,
NMSupplicantFeature ap_support,
NMSupplicantFeature pmf_support,
NMSupplicantFeature fils_support);
NMSupplicantFeature fils_support,
NMSupplicantFeature p2p_support,
NMSupplicantFeature wfd_support);
void nm_supplicant_interface_set_supplicant_available (NMSupplicantInterface *self,
gboolean available);
@ -120,14 +135,33 @@ guint nm_supplicant_interface_get_max_scan_ssids (NMSupplicantInterface *self);
gboolean nm_supplicant_interface_get_has_credentials_request (NMSupplicantInterface *self);
gboolean nm_supplicant_interface_get_p2p_group_joined (NMSupplicantInterface *self);
const char* nm_supplicant_interface_get_p2p_group_path (NMSupplicantInterface *self);
gboolean nm_supplicant_interface_get_p2p_group_owner (NMSupplicantInterface *self);
gboolean nm_supplicant_interface_credentials_reply (NMSupplicantInterface *self,
const char *field,
const char *value,
GError **error);
void nm_supplicant_interface_p2p_start_find (NMSupplicantInterface *self,
guint timeout);
void nm_supplicant_interface_p2p_stop_find (NMSupplicantInterface *self);
void nm_supplicant_interface_p2p_connect (NMSupplicantInterface * self,
const char * peer,
const char * wps_method,
const char * wps_pin);
void nm_supplicant_interface_p2p_cancel_connect (NMSupplicantInterface * self);
void nm_supplicant_interface_p2p_disconnect (NMSupplicantInterface * self);
NMSupplicantFeature nm_supplicant_interface_get_ap_support (NMSupplicantInterface *self);
NMSupplicantFeature nm_supplicant_interface_get_pmf_support (NMSupplicantInterface *self);
NMSupplicantFeature nm_supplicant_interface_get_fils_support (NMSupplicantInterface *self);
NMSupplicantFeature nm_supplicant_interface_get_p2p_support (NMSupplicantInterface *self);
NMSupplicantFeature nm_supplicant_interface_get_wfd_support (NMSupplicantInterface *self);
void nm_supplicant_interface_set_ap_support (NMSupplicantInterface *self,
NMSupplicantFeature apmode);
@ -141,6 +175,12 @@ void nm_supplicant_interface_set_pmf_support (NMSupplicantInterface *self,
void nm_supplicant_interface_set_fils_support (NMSupplicantInterface *self,
NMSupplicantFeature fils_support);
void nm_supplicant_interface_set_p2p_support (NMSupplicantInterface *self,
NMSupplicantFeature p2p_support);
void nm_supplicant_interface_set_wfd_support (NMSupplicantInterface *self,
NMSupplicantFeature wfd_support);
void nm_supplicant_interface_enroll_wps (NMSupplicantInterface *self,
const char *const type,
const char *bssid,

View file

@ -41,6 +41,8 @@ typedef struct {
NMSupplicantFeature ap_support;
NMSupplicantFeature pmf_support;
NMSupplicantFeature fils_support;
NMSupplicantFeature p2p_support;
NMSupplicantFeature wfd_support;
guint die_count_reset_id;
guint die_count;
} NMSupplicantManagerPrivate;
@ -159,11 +161,71 @@ nm_supplicant_manager_create_interface (NMSupplicantManager *self,
}
iface = nm_supplicant_interface_new (ifname,
NULL,
driver,
priv->fast_support,
priv->ap_support,
priv->pmf_support,
priv->fils_support);
priv->fils_support,
priv->p2p_support,
priv->wfd_support);
priv->ifaces = g_slist_prepend (priv->ifaces, iface);
g_object_add_toggle_ref ((GObject *) iface, _sup_iface_last_ref, self);
/* If we're making the supplicant take a time out for a bit, don't
* let the supplicant interface start immediately, just let it hang
* around in INIT state until we're ready to talk to the supplicant
* again.
*/
if (is_available (self))
nm_supplicant_interface_set_supplicant_available (iface, TRUE);
return iface;
}
/**
* nm_supplicant_manager_create_interface_from_path:
* @self: the #NMSupplicantManager
* @object_path: the DBus object path for which to obtain the supplicant interface
*
* Note: the manager owns a reference to the instance and the only way to
* get the manager to release it, is by dropping all other references
* to the supplicant-interface (or destroying the manager).
*
* Returns: (transfer full): returns a #NMSupplicantInterface or %NULL.
* Must be unrefed at the end.
* */
NMSupplicantInterface *
nm_supplicant_manager_create_interface_from_path (NMSupplicantManager *self,
const char *object_path)
{
NMSupplicantManagerPrivate *priv;
NMSupplicantInterface *iface;
GSList *ifaces;
g_return_val_if_fail (NM_IS_SUPPLICANT_MANAGER (self), NULL);
g_return_val_if_fail (object_path != NULL, NULL);
priv = NM_SUPPLICANT_MANAGER_GET_PRIVATE (self);
_LOGD ("creating new supplicant interface for dbus path %s", object_path);
/* assert against not requesting duplicate interfaces. */
for (ifaces = priv->ifaces; ifaces; ifaces = ifaces->next) {
if (g_strcmp0 (nm_supplicant_interface_get_object_path (ifaces->data), object_path) == 0)
g_return_val_if_reached (NULL);
}
iface = nm_supplicant_interface_new (NULL,
object_path,
NM_SUPPLICANT_DRIVER_WIRELESS,
priv->fast_support,
priv->ap_support,
priv->pmf_support,
priv->fils_support,
priv->p2p_support,
priv->wfd_support);
priv->ifaces = g_slist_prepend (priv->ifaces, iface);
g_object_add_toggle_ref ((GObject *) iface, _sup_iface_last_ref, self);
@ -199,6 +261,8 @@ update_capabilities (NMSupplicantManager *self)
priv->ap_support = NM_SUPPLICANT_FEATURE_UNKNOWN;
priv->pmf_support = NM_SUPPLICANT_FEATURE_UNKNOWN;
priv->fils_support = NM_SUPPLICANT_FEATURE_UNKNOWN;
/* P2P support is newer than the capabilities property */
priv->p2p_support = NM_SUPPLICANT_FEATURE_NO;
value = g_dbus_proxy_get_cached_property (priv->proxy, "Capabilities");
if (value) {
@ -207,6 +271,7 @@ update_capabilities (NMSupplicantManager *self)
priv->ap_support = NM_SUPPLICANT_FEATURE_NO;
priv->pmf_support = NM_SUPPLICANT_FEATURE_NO;
priv->fils_support = NM_SUPPLICANT_FEATURE_NO;
priv->p2p_support = NM_SUPPLICANT_FEATURE_NO;
if (array) {
if (g_strv_contains (array, "ap"))
priv->ap_support = NM_SUPPLICANT_FEATURE_YES;
@ -214,17 +279,20 @@ update_capabilities (NMSupplicantManager *self)
priv->pmf_support = NM_SUPPLICANT_FEATURE_YES;
if (g_strv_contains (array, "fils"))
priv->fils_support = NM_SUPPLICANT_FEATURE_YES;
if (g_strv_contains (array, "p2p"))
priv->p2p_support = NM_SUPPLICANT_FEATURE_YES;
g_free (array);
}
}
g_variant_unref (value);
}
/* Tell all interfaces about results of the AP/PMF/FILS check */
/* Tell all interfaces about results of the AP/PMF/FILS/P2P check */
for (ifaces = priv->ifaces; ifaces; ifaces = ifaces->next) {
nm_supplicant_interface_set_ap_support (ifaces->data, priv->ap_support);
nm_supplicant_interface_set_pmf_support (ifaces->data, priv->pmf_support);
nm_supplicant_interface_set_fils_support (ifaces->data, priv->fils_support);
nm_supplicant_interface_set_p2p_support (ifaces->data, priv->p2p_support);
}
_LOGD ("AP mode is %ssupported",
@ -236,6 +304,9 @@ update_capabilities (NMSupplicantManager *self)
_LOGD ("FILS is %ssupported",
(priv->fils_support == NM_SUPPLICANT_FEATURE_YES) ? "" :
(priv->fils_support == NM_SUPPLICANT_FEATURE_NO) ? "not " : "possibly ");
_LOGD ("P2P is %ssupported",
(priv->p2p_support == NM_SUPPLICANT_FEATURE_YES) ? "" :
(priv->p2p_support == NM_SUPPLICANT_FEATURE_NO) ? "not " : "possibly ");
/* EAP-FAST */
priv->fast_support = NM_SUPPLICANT_FEATURE_NO;
@ -264,6 +335,20 @@ update_capabilities (NMSupplicantManager *self)
_LOGD ("EAP-FAST is %ssupported",
(priv->fast_support == NM_SUPPLICANT_FEATURE_YES) ? "" :
(priv->fast_support == NM_SUPPLICANT_FEATURE_NO) ? "not " : "possibly ");
priv->wfd_support = NM_SUPPLICANT_FEATURE_NO;
value = g_dbus_proxy_get_cached_property (priv->proxy, "WFDIEs");
if (value) {
priv->wfd_support = NM_SUPPLICANT_FEATURE_YES;
g_variant_unref (value);
}
for (ifaces = priv->ifaces; ifaces; ifaces = ifaces->next)
nm_supplicant_interface_set_wfd_support (ifaces->data, priv->fast_support);
_LOGD ("WFD is %ssupported",
(priv->wfd_support == NM_SUPPLICANT_FEATURE_YES) ? "" :
(priv->wfd_support == NM_SUPPLICANT_FEATURE_NO) ? "not " : "possibly ");
}
static void

View file

@ -41,5 +41,7 @@ NMSupplicantManager *nm_supplicant_manager_get (void);
NMSupplicantInterface *nm_supplicant_manager_create_interface (NMSupplicantManager *mgr,
const char *ifname,
NMSupplicantDriver driver);
NMSupplicantInterface *nm_supplicant_manager_create_interface_from_path (NMSupplicantManager *self,
const char *object_path);
#endif /* __NETWORKMANAGER_SUPPLICANT_MANAGER_H__ */