summaryrefslogtreecommitdiff
path: root/libnm
diff options
context:
space:
mode:
authorBenjamin Berg <bberg@redhat.com>2018-10-18 11:36:54 +0200
committerThomas Haller <thaller@redhat.com>2019-01-27 23:45:12 +0100
commit6420a2c1fdb55b43fcf662ef1d53001f3835c9e6 (patch)
tree91999980565c948539e4caa36cc19203172495c8 /libnm
parentadb8338408cd3d9696bc9dad7206f7848cef5ef4 (diff)
downloadNetworkManager-6420a2c1fdb55b43fcf662ef1d53001f3835c9e6.tar.gz
libnm: Add NMDeviceP2PWifi
Diffstat (limited to 'libnm')
-rw-r--r--libnm/NetworkManager.h1
-rw-r--r--libnm/libnm.ver4
-rw-r--r--libnm/meson.build2
-rw-r--r--libnm/nm-client.c6
-rw-r--r--libnm/nm-device-p2p-wifi.c467
-rw-r--r--libnm/nm-device-p2p-wifi.h79
-rw-r--r--libnm/nm-types.h1
7 files changed, 560 insertions, 0 deletions
diff --git a/libnm/NetworkManager.h b/libnm/NetworkManager.h
index 8c5f3c782c..1f98e50b11 100644
--- a/libnm/NetworkManager.h
+++ b/libnm/NetworkManager.h
@@ -46,6 +46,7 @@
#include "nm-device-ovs-interface.h"
#include "nm-device-ovs-port.h"
#include "nm-device-ovs-bridge.h"
+#include "nm-device-p2p-wifi.h"
#include "nm-device-ppp.h"
#include "nm-device-team.h"
#include "nm-device-tun.h"
diff --git a/libnm/libnm.ver b/libnm/libnm.ver
index 66bf8d6e08..e2ff5f37fe 100644
--- a/libnm/libnm.ver
+++ b/libnm/libnm.ver
@@ -1450,6 +1450,10 @@ global:
nm_client_add_and_activate_connection2;
nm_client_add_and_activate_connection2_finish;
nm_device_get_connectivity;
+ nm_device_p2p_wifi_get_group_owner;
+ nm_device_p2p_wifi_get_hw_address;
+ nm_device_p2p_wifi_get_peers;
+ nm_device_p2p_wifi_get_type;
nm_p2p_peer_connection_valid;
nm_p2p_peer_filter_connections;
nm_p2p_peer_get_flags;
diff --git a/libnm/meson.build b/libnm/meson.build
index dc674447b5..dee4e36bdf 100644
--- a/libnm/meson.build
+++ b/libnm/meson.build
@@ -50,6 +50,7 @@ libnm_headers = files(
'nm-device-ovs-interface.h',
'nm-device-ovs-port.h',
'nm-device-ovs-bridge.h',
+ 'nm-device-p2p-wifi.h',
'nm-device-ppp.h',
'nm-device-team.h',
'nm-device-tun.h',
@@ -115,6 +116,7 @@ libnm_sources = files(
'nm-device-ovs-interface.c',
'nm-device-ovs-port.c',
'nm-device-ovs-bridge.c',
+ 'nm-device-p2p-wifi.c',
'nm-device-ppp.c',
'nm-device-team.c',
'nm-device-tun.c',
diff --git a/libnm/nm-client.c b/libnm/nm-client.c
index c9f919d412..e5902ad051 100644
--- a/libnm/nm-client.c
+++ b/libnm/nm-client.c
@@ -41,6 +41,7 @@
#include "introspection/org.freedesktop.NetworkManager.h"
#include "introspection/org.freedesktop.NetworkManager.Device.Wireless.h"
+#include "introspection/org.freedesktop.NetworkManager.Device.P2PWireless.h"
#include "introspection/org.freedesktop.NetworkManager.Device.h"
#include "introspection/org.freedesktop.NetworkManager.DnsManager.h"
#include "introspection/org.freedesktop.NetworkManager.Settings.h"
@@ -68,6 +69,7 @@
#include "nm-device-ovs-interface.h"
#include "nm-device-ovs-port.h"
#include "nm-device-ovs-bridge.h"
+#include "nm-device-p2p-wifi.h"
#include "nm-device-ppp.h"
#include "nm-device-team.h"
#include "nm-device-tun.h"
@@ -2612,6 +2614,8 @@ proxy_type (GDBusObjectManagerClient *manager,
return NMDBUS_TYPE_MANAGER_PROXY;
else if (strcmp (interface_name, NM_DBUS_INTERFACE_DEVICE_WIRELESS) == 0)
return NMDBUS_TYPE_DEVICE_WIFI_PROXY;
+ else if (strcmp (interface_name, NM_DBUS_INTERFACE_DEVICE_P2P_WIRELESS) == 0)
+ return NMDBUS_TYPE_DEVICE_P2P_WIFI_PROXY;
else if (strcmp (interface_name, NM_DBUS_INTERFACE_DEVICE) == 0)
return NMDBUS_TYPE_DEVICE_PROXY;
else if (strcmp (interface_name, NM_DBUS_INTERFACE_SETTINGS_CONNECTION) == 0)
@@ -2690,6 +2694,8 @@ obj_nm_for_gdbus_object (NMClient *self, GDBusObject *object, GDBusObjectManager
type = NM_TYPE_DEVICE_OVS_PORT;
else if (strcmp (ifname, NM_DBUS_INTERFACE_DEVICE_OVS_BRIDGE) == 0)
type = NM_TYPE_DEVICE_OVS_BRIDGE;
+ else if (strcmp (ifname, NM_DBUS_INTERFACE_DEVICE_P2P_WIRELESS) == 0)
+ type = NM_TYPE_DEVICE_P2P_WIFI;
else if (strcmp (ifname, NM_DBUS_INTERFACE_DEVICE_PPP) == 0)
type = NM_TYPE_DEVICE_PPP;
else if (strcmp (ifname, NM_DBUS_INTERFACE_DEVICE_TEAM) == 0)
diff --git a/libnm/nm-device-p2p-wifi.c b/libnm/nm-device-p2p-wifi.c
new file mode 100644
index 0000000000..d4f54335eb
--- /dev/null
+++ b/libnm/nm-device-p2p-wifi.c
@@ -0,0 +1,467 @@
+/*
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA.
+ *
+ * Copyright 2007 - 2008 Novell, Inc.
+ * Copyright 2007 - 2018 Red Hat, Inc.
+ */
+
+#include "nm-default.h"
+
+#include "nm-device-p2p-wifi.h"
+
+#include <string.h>
+
+#include "nm-setting-connection.h"
+#include "nm-setting-p2p-wireless.h"
+#include "nm-utils.h"
+
+#include "nm-p2p-peer.h"
+#include "nm-object-private.h"
+#include "nm-core-internal.h"
+#include "nm-dbus-helpers.h"
+
+#include "introspection/org.freedesktop.NetworkManager.Device.P2PWireless.h"
+
+G_DEFINE_TYPE (NMDeviceP2PWifi, nm_device_p2p_wifi, NM_TYPE_DEVICE)
+
+#define NM_DEVICE_P2P_WIFI_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_DEVICE_P2P_WIFI, NMDeviceP2PWifiPrivate))
+
+void _nm_device_p2p_wifi_set_p2p_wireless_enabled (NMDeviceP2PWifi *device, gboolean enabled);
+static void state_changed_cb (NMDevice *device, GParamSpec *pspec, gpointer user_data);
+
+typedef struct {
+ NMDeviceP2PWifi *device;
+ GSimpleAsyncResult *simple;
+} RequestScanInfo;
+
+typedef struct {
+ NMDBusDeviceP2PWifi *proxy;
+
+ char *hw_address;
+
+ gboolean group_owner;
+ GByteArray *wfd_ies;
+ GPtrArray *peers;
+} NMDeviceP2PWifiPrivate;
+
+enum {
+ PROP_0,
+ PROP_HW_ADDRESS,
+ PROP_GROUP_OWNER,
+ PROP_WFDIES,
+ PROP_PEERS,
+
+ LAST_PROP
+};
+
+enum {
+ PEER_ADDED,
+ PEER_REMOVED,
+
+ LAST_SIGNAL
+};
+static guint signals[LAST_SIGNAL] = { 0 };
+
+/**
+ * nm_device_p2p_wifi_get_hw_address:
+ * @device: a #NMDeviceP2PWifi
+ *
+ * Gets the actual hardware (MAC) address of the #NMDeviceP2PWifi
+ *
+ * Returns: the actual hardware address. This is the internal string used by the
+ * device, and must not be modified.
+ *
+ * Since: 1.16
+ **/
+const char *
+nm_device_p2p_wifi_get_hw_address (NMDeviceP2PWifi *device)
+{
+ g_return_val_if_fail (NM_IS_DEVICE_P2P_WIFI (device), NULL);
+
+ return nm_str_not_empty (NM_DEVICE_P2P_WIFI_GET_PRIVATE (device)->hw_address);
+}
+
+/**
+ * nm_device_p2p_wifi_get_group_owner:
+ * @device: a #NMDeviceP2PWifi
+ *
+ * Gets whether the device is currently the P2P group owner. This is only
+ * valid when a connection is established.
+ *
+ * Returns: Whether the device is the P2P group owner.
+ *
+ * Since: 1.16
+ **/
+gboolean
+nm_device_p2p_wifi_get_group_owner (NMDeviceP2PWifi *device)
+{
+ g_return_val_if_fail (NM_IS_DEVICE_P2P_WIFI (device), FALSE);
+
+ return NM_DEVICE_P2P_WIFI_GET_PRIVATE (device)->group_owner;
+}
+
+/**
+ * nm_device_p2p_wifi_get_peers:
+ * @device: a #NMDeviceP2PWifi
+ *
+ * Gets all the found peers of the #NMDeviceP2PWifi.
+ *
+ * Returns: (element-type NMP2PPeer): a #GPtrArray containing all the
+ * found #NMP2PPeers.
+ * The returned array is owned by the client and should not be modified.
+ *
+ * Since: 1.16
+ **/
+const GPtrArray *
+nm_device_p2p_wifi_get_peers (NMDeviceP2PWifi *device)
+{
+ g_return_val_if_fail (NM_IS_DEVICE_P2P_WIFI (device), NULL);
+
+ return NM_DEVICE_P2P_WIFI_GET_PRIVATE (device)->peers;
+}
+
+/**
+ * nm_device_p2p_wifi_get_peer_by_path:
+ * @device: a #NMDeviceP2PWifi
+ * @path: the object path of the peer
+ *
+ * Gets a #NMP2PPeer by path.
+ *
+ * Returns: (transfer none): the peer or %NULL if none is found.
+ *
+ * Since: 1.16
+ **/
+NMP2PPeer *
+nm_device_p2p_wifi_get_peer_by_path (NMDeviceP2PWifi *device,
+ const char *path)
+{
+ const GPtrArray *peers;
+ int i;
+ NMP2PPeer *peer = NULL;
+
+ g_return_val_if_fail (NM_IS_DEVICE_P2P_WIFI (device), NULL);
+ g_return_val_if_fail (path != NULL, NULL);
+
+ peers = nm_device_p2p_wifi_get_peers (device);
+ if (!peers)
+ return NULL;
+
+ for (i = 0; i < peers->len; i++) {
+ NMP2PPeer *candidate = g_ptr_array_index (peers, i);
+ if (!strcmp (nm_object_get_path (NM_OBJECT (candidate)), path)) {
+ peer = candidate;
+ break;
+ }
+ }
+
+ return peer;
+}
+
+static void
+clean_up_peers (NMDeviceP2PWifi *self, gboolean in_dispose)
+{
+ NMDeviceP2PWifiPrivate *priv;
+ GPtrArray *peers;
+ int i;
+
+ g_return_if_fail (NM_IS_DEVICE_P2P_WIFI (self));
+
+ priv = NM_DEVICE_P2P_WIFI_GET_PRIVATE (self);
+
+ peers = priv->peers;
+
+ if (in_dispose)
+ priv->peers = NULL;
+ else {
+ priv->peers = g_ptr_array_new ();
+
+ for (i = 0; i < peers->len; i++) {
+ NMP2PPeer *peer = NM_P2P_PEER (g_ptr_array_index (peers, i));
+
+ g_signal_emit (self, signals[PEER_REMOVED], 0, peer);
+ }
+ }
+
+ g_ptr_array_unref (peers);
+}
+
+static gboolean
+connection_compatible (NMDevice *device, NMConnection *connection, GError **error)
+{
+ if (!NM_DEVICE_CLASS (nm_device_p2p_wifi_parent_class)->connection_compatible (device, connection, error))
+ return FALSE;
+
+ if (!nm_connection_is_type (connection, NM_SETTING_P2P_WIRELESS_SETTING_NAME)) {
+ g_set_error_literal (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_INCOMPATIBLE_CONNECTION,
+ _("The connection was not a P2P Wi-Fi connection."));
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+static GType
+get_setting_type (NMDevice *device)
+{
+ return NM_TYPE_SETTING_WIRELESS;
+}
+
+static const char *
+get_hw_address (NMDevice *device)
+{
+ return nm_device_p2p_wifi_get_hw_address (NM_DEVICE_P2P_WIFI (device));
+}
+
+static GVariant *
+nm_device_p2p_wifi_get_wfdies_as_variant (const NMDeviceP2PWifi *self)
+{
+ const NMDeviceP2PWifiPrivate *priv = NM_DEVICE_P2P_WIFI_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
+get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ NMDeviceP2PWifi *self = NM_DEVICE_P2P_WIFI (object);
+
+ switch (prop_id) {
+ case PROP_HW_ADDRESS:
+ g_value_set_string (value, nm_device_p2p_wifi_get_hw_address (self));
+ break;
+ case PROP_GROUP_OWNER:
+ g_value_set_enum (value, nm_device_p2p_wifi_get_group_owner (self));
+ break;
+ case PROP_WFDIES:
+ g_value_take_variant (value, nm_device_p2p_wifi_get_wfdies_as_variant (self));
+ break;
+ case PROP_PEERS:
+ g_value_take_boxed (value, _nm_utils_copy_object_array (nm_device_p2p_wifi_get_peers (self)));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+nm_device_p2p_wifi_init (NMDeviceP2PWifi *device)
+{
+ NMDeviceP2PWifiPrivate *priv = NM_DEVICE_P2P_WIFI_GET_PRIVATE (device);
+
+ g_signal_connect (device,
+ "notify::" NM_DEVICE_STATE,
+ G_CALLBACK (state_changed_cb),
+ NULL);
+
+ priv->peers = g_ptr_array_new ();
+}
+
+static void
+state_changed_cb (NMDevice *device, GParamSpec *pspec, gpointer user_data)
+{
+#if 0
+ NMDeviceP2PWifi *self = NM_DEVICE_P2P_WIFI (device);
+
+ switch (nm_device_get_state (device)) {
+ case NM_DEVICE_STATE_UNKNOWN:
+ case NM_DEVICE_STATE_UNMANAGED:
+ case NM_DEVICE_STATE_UNAVAILABLE:
+ case NM_DEVICE_STATE_DISCONNECTED:
+ case NM_DEVICE_STATE_FAILED:
+ /* TODO: Do something? */
+ break;
+ default:
+ break;
+ }
+#endif
+}
+
+static void
+init_dbus (NMObject *object)
+{
+ NMDeviceP2PWifiPrivate *priv = NM_DEVICE_P2P_WIFI_GET_PRIVATE (object);
+ const NMPropertiesInfo property_info[] = {
+ { NM_DEVICE_P2P_WIFI_HW_ADDRESS, &priv->hw_address },
+ { NM_DEVICE_P2P_WIFI_GROUP_OWNER, &priv->group_owner },
+ { NM_DEVICE_P2P_WIFI_WFDIES, &priv->wfd_ies },
+ { NM_DEVICE_P2P_WIFI_PEERS, &priv->peers, NULL, NM_TYPE_P2P_PEER, "peer" },
+ { NULL },
+ };
+
+ NM_OBJECT_CLASS (nm_device_p2p_wifi_parent_class)->init_dbus (object);
+
+ priv->proxy = NMDBUS_DEVICE_P2P_WIFI (_nm_object_get_proxy (object, NM_DBUS_INTERFACE_DEVICE_P2P_WIRELESS));
+ _nm_object_register_properties (object,
+ NM_DBUS_INTERFACE_DEVICE_P2P_WIRELESS,
+ property_info);
+}
+
+static void
+dispose (GObject *object)
+{
+ NMDeviceP2PWifiPrivate *priv = NM_DEVICE_P2P_WIFI_GET_PRIVATE (object);
+
+ if (priv->peers)
+ clean_up_peers (NM_DEVICE_P2P_WIFI (object), TRUE);
+
+ g_clear_object (&priv->proxy);
+ if (priv->wfd_ies)
+ g_byte_array_unref (priv->wfd_ies);
+ priv->wfd_ies = NULL;
+
+ G_OBJECT_CLASS (nm_device_p2p_wifi_parent_class)->dispose (object);
+}
+
+static void
+finalize (GObject *object)
+{
+ NMDeviceP2PWifiPrivate *priv = NM_DEVICE_P2P_WIFI_GET_PRIVATE (object);
+
+ g_free (priv->hw_address);
+
+ G_OBJECT_CLASS (nm_device_p2p_wifi_parent_class)->finalize (object);
+}
+
+static void
+nm_device_p2p_wifi_class_init (NMDeviceP2PWifiClass *wifi_class)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (wifi_class);
+ NMObjectClass *nm_object_class = NM_OBJECT_CLASS (wifi_class);
+ NMDeviceClass *device_class = NM_DEVICE_CLASS (wifi_class);
+
+ g_type_class_add_private (wifi_class, sizeof (NMDeviceP2PWifiPrivate));
+
+ /* virtual methods */
+ object_class->get_property = get_property;
+ object_class->dispose = dispose;
+ object_class->finalize = finalize;
+
+ nm_object_class->init_dbus = init_dbus;
+
+ device_class->connection_compatible = connection_compatible;
+ device_class->get_setting_type = get_setting_type;
+ device_class->get_hw_address = get_hw_address;
+
+ /* properties */
+
+ /**
+ * NMDeviceP2PWifi:hw-address:
+ *
+ * The hardware (MAC) address of the device.
+ *
+ * Since: 1.16
+ **/
+ g_object_class_install_property
+ (object_class, PROP_HW_ADDRESS,
+ g_param_spec_string (NM_DEVICE_P2P_WIFI_HW_ADDRESS, "", "",
+ NULL,
+ G_PARAM_READABLE |
+ G_PARAM_STATIC_STRINGS));
+
+
+ /**
+ * NMDeviceP2PWifi:group-owner:
+ *
+ * Whether the device is currently the group owner.
+ *
+ * Since: 1.16
+ **/
+ g_object_class_install_property
+ (object_class, PROP_GROUP_OWNER,
+ g_param_spec_boolean (NM_DEVICE_P2P_WIFI_GROUP_OWNER, "", "",
+ FALSE,
+ G_PARAM_READABLE |
+ G_PARAM_STATIC_STRINGS));
+
+ /**
+ * NMDeviceP2PWifi:wfd-ies:
+ *
+ * Whether the device is currently the group owner.
+ *
+ * Since: 1.16
+ **/
+ g_object_class_install_property
+ (object_class, PROP_WFDIES,
+ g_param_spec_variant (NM_DEVICE_P2P_WIFI_WFDIES, "", "",
+ G_VARIANT_TYPE ("ay"),
+ NULL,
+ G_PARAM_READABLE |
+ G_PARAM_STATIC_STRINGS));
+
+ /**
+ * NMDeviceP2PWifi:peers: (type GPtrArray(NMP2PPeer))
+ *
+ * List of all P2P Wi-Fi peers the device can see.
+ *
+ * Since: 1.16
+ **/
+ g_object_class_install_property
+ (object_class, PROP_PEERS,
+ g_param_spec_boxed (NM_DEVICE_P2P_WIFI_PEERS, "", "",
+ G_TYPE_PTR_ARRAY,
+ G_PARAM_READABLE |
+ G_PARAM_STATIC_STRINGS));
+
+ /* signals */
+
+ /**
+ * NMDeviceP2PWifi::peer-added:
+ * @device: the P2P Wi-Fi device that received the signal
+ * @peer: the new access point
+ *
+ * Notifies that a #NMP2PPeer is added to the P2P Wi-Fi device.
+ *
+ * Since: 1.16
+ **/
+ signals[PEER_ADDED] =
+ g_signal_new ("peer-added",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_FIRST,
+ G_STRUCT_OFFSET (NMDeviceP2PWifiClass, peer_added),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__OBJECT,
+ G_TYPE_NONE, 1,
+ G_TYPE_OBJECT);
+
+ /**
+ * NMDeviceP2PWifi::peer-removed:
+ * @device: the P2P Wi-Fi device that received the signal
+ * @peer: the removed access point
+ *
+ * Notifies that a #NMP2PPeer is removed from the P2P Wi-Fi device.
+ *
+ * Since: 1.16
+ **/
+ signals[PEER_REMOVED] =
+ g_signal_new ("peer-removed",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_FIRST,
+ G_STRUCT_OFFSET (NMDeviceP2PWifiClass, peer_removed),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__OBJECT,
+ G_TYPE_NONE, 1,
+ G_TYPE_OBJECT);
+}
diff --git a/libnm/nm-device-p2p-wifi.h b/libnm/nm-device-p2p-wifi.h
new file mode 100644
index 0000000000..74779f2097
--- /dev/null
+++ b/libnm/nm-device-p2p-wifi.h
@@ -0,0 +1,79 @@
+/*
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA.
+ *
+ * Copyright 2007 - 2008 Novell, Inc.
+ * Copyright 2007 - 2018 Red Hat, Inc.
+ */
+
+#ifndef __NM_DEVICE_P2P_WIFI_H__
+#define __NM_DEVICE_P2P_WIFI_H__
+
+#if !defined (__NETWORKMANAGER_H_INSIDE__) && !defined (NETWORKMANAGER_COMPILATION)
+#error "Only <NetworkManager.h> can be included directly."
+#endif
+
+#include "nm-device.h"
+
+G_BEGIN_DECLS
+
+#define NM_TYPE_DEVICE_P2P_WIFI (nm_device_p2p_wifi_get_type ())
+#define NM_DEVICE_P2P_WIFI(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_DEVICE_P2P_WIFI, NMDeviceP2PWifi))
+#define NM_DEVICE_P2P_WIFI_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_DEVICE_P2P_WIFI, NMDeviceP2PWifiClass))
+#define NM_IS_DEVICE_P2P_WIFI(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_DEVICE_P2P_WIFI))
+#define NM_IS_DEVICE_P2P_WIFI_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_DEVICE_P2P_WIFI))
+#define NM_DEVICE_P2P_WIFI_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_DEVICE_P2P_WIFI, NMDeviceP2PWifiClass))
+
+#define NM_DEVICE_P2P_WIFI_HW_ADDRESS "hw-address"
+#define NM_DEVICE_P2P_WIFI_GROUP_OWNER "group-owner"
+#define NM_DEVICE_P2P_WIFI_PEERS "peers"
+#define NM_DEVICE_P2P_WIFI_WFDIES "wfdies"
+
+/**
+ * NMDeviceP2PWifi:
+ */
+struct _NMDeviceP2PWifi {
+ NMDevice parent;
+};
+
+typedef struct {
+ NMDeviceClass parent;
+
+ /* Signals */
+ void (*peer_added) (NMDeviceP2PWifi *device, NMP2PPeer *peer);
+ void (*peer_removed) (NMDeviceP2PWifi *device, NMP2PPeer *peer);
+
+ /*< private >*/
+ gpointer padding[4];
+} NMDeviceP2PWifiClass;
+
+GType nm_device_p2p_wifi_get_type (void);
+
+const char * nm_device_p2p_wifi_get_hw_address (NMDeviceP2PWifi *device);
+gboolean nm_device_p2p_wifi_get_group_owner (NMDeviceP2PWifi *device);
+
+#if 0
+gboolean nm_device_p2p_wifi_get_wfdies (NMDeviceP2PWifi *device);
+#endif
+
+NMP2PPeer * nm_device_p2p_wifi_get_peer_by_path (NMDeviceP2PWifi *device,
+ const char *path);
+
+const GPtrArray * nm_device_p2p_wifi_get_peers (NMDeviceP2PWifi *device);
+
+
+G_END_DECLS
+
+#endif /* __NM_DEVICE_P2P_WIFI_H__ */
diff --git a/libnm/nm-types.h b/libnm/nm-types.h
index 97415cbf3f..0cf8186f5c 100644
--- a/libnm/nm-types.h
+++ b/libnm/nm-types.h
@@ -54,6 +54,7 @@ typedef struct _NMDeviceTun NMDeviceTun;
typedef struct _NMDeviceVlan NMDeviceVlan;
typedef struct _NMDeviceVxlan NMDeviceVxlan;
typedef struct _NMDeviceWifi NMDeviceWifi;
+typedef struct _NMDeviceP2PWifi NMDeviceP2PWifi;
typedef struct _NMDeviceWimax NMDeviceWimax;
typedef struct _NMDeviceWireGuard NMDeviceWireGuard;
typedef struct _NMDeviceWpan NMDeviceWpan;