Wireless Daemon for Linux
 help / color / mirror / Atom feed
From: Andrew Zaborowski <andrew.zaborowski@intel.com>
To: iwd@lists.01.org
Subject: [PATCH 16/18] p2p: Add ConnectedInterface and ConnectedIP Peer properties
Date: Sat, 11 Jul 2020 03:00:51 +0200	[thread overview]
Message-ID: <20200711010053.224223-16-andrew.zaborowski@intel.com> (raw)
In-Reply-To: <20200711010053.224223-1-andrew.zaborowski@intel.com>

[-- Attachment #1: Type: text/plain, Size: 3969 bytes --]

The are useful for P2P service implementations to know unambiguously
which network interface a new P2P connection is on and the peer's IPv4
address if they need to initiate an IP connection or validate an
incoming connection's address from the peer.
---
 src/p2p.c | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 60 insertions(+), 1 deletion(-)

diff --git a/src/p2p.c b/src/p2p.c
index 03dc3b8b..aae633fb 100644
--- a/src/p2p.c
+++ b/src/p2p.c
@@ -617,6 +617,14 @@ static void p2p_netconfig_event_handler(enum netconfig_event event,
 		l_dbus_property_changed(dbus_get_bus(),
 					p2p_peer_get_path(dev->conn_peer),
 					IWD_P2P_PEER_INTERFACE, "Connected");
+		l_dbus_property_changed(dbus_get_bus(),
+					p2p_peer_get_path(dev->conn_peer),
+					IWD_P2P_PEER_INTERFACE,
+					"ConnectedInterface");
+		l_dbus_property_changed(dbus_get_bus(),
+					p2p_peer_get_path(dev->conn_peer),
+					IWD_P2P_PEER_INTERFACE,
+					"ConnectedIP");
 
 		break;
 	default:
@@ -733,6 +741,14 @@ static void p2p_netdev_event(struct netdev *netdev, enum netdev_event event,
 		l_dbus_property_changed(dbus_get_bus(),
 					p2p_peer_get_path(dev->conn_peer),
 					IWD_P2P_PEER_INTERFACE, "Connected");
+		l_dbus_property_changed(dbus_get_bus(),
+					p2p_peer_get_path(dev->conn_peer),
+					IWD_P2P_PEER_INTERFACE,
+					"ConnectedInterface");
+		l_dbus_property_changed(dbus_get_bus(),
+					p2p_peer_get_path(dev->conn_peer),
+					IWD_P2P_PEER_INTERFACE,
+					"ConnectedIP");
 		p2p_connection_reset(dev);
 		break;
 	default:
@@ -2438,9 +2454,16 @@ static void p2p_peer_disconnect(struct p2p_peer *peer)
 		dbus_pending_reply(&peer->wsc.pending_connect,
 				dbus_error_aborted(peer->wsc.pending_connect));
 
-	if (p2p_peer_operational(peer))
+	if (p2p_peer_operational(peer)) {
 		l_dbus_property_changed(dbus_get_bus(), p2p_peer_get_path(peer),
 					IWD_P2P_PEER_INTERFACE, "Connected");
+		l_dbus_property_changed(dbus_get_bus(), p2p_peer_get_path(peer),
+					IWD_P2P_PEER_INTERFACE,
+					"ConnectedInterface");
+		l_dbus_property_changed(dbus_get_bus(), p2p_peer_get_path(peer),
+					IWD_P2P_PEER_INTERFACE,
+					"ConnectedIP");
+	}
 
 	dev->disconnecting = true;
 
@@ -3968,6 +3991,38 @@ static bool p2p_peer_get_connected(struct l_dbus *dbus,
 	return true;
 }
 
+static bool p2p_peer_get_connected_if(struct l_dbus *dbus,
+					struct l_dbus_message *message,
+					struct l_dbus_message_builder *builder,
+					void *user_data)
+{
+	struct p2p_peer *peer = user_data;
+	const char *ifname = netdev_get_name(peer->dev->conn_netdev);
+
+	if (!p2p_peer_operational(peer))
+		return false;
+
+	l_dbus_message_builder_append_basic(builder, 's', ifname);
+	return true;
+}
+
+static bool p2p_peer_get_connected_ip(struct l_dbus *dbus,
+					struct l_dbus_message *message,
+					struct l_dbus_message_builder *builder,
+					void *user_data)
+{
+	struct p2p_peer *peer = user_data;
+	char *server_ip;
+
+	if (!p2p_peer_operational(peer))
+		return false;
+
+	server_ip = netconfig_get_dhcp_server_ipv4(peer->dev->conn_netconfig);
+	l_dbus_message_builder_append_basic(builder, 's', server_ip);
+	l_free(server_ip);
+	return true;
+}
+
 static struct l_dbus_message *p2p_peer_dbus_disconnect(struct l_dbus *dbus,
 						struct l_dbus_message *message,
 						void *user_data)
@@ -3999,6 +4054,10 @@ static void p2p_peer_interface_setup(struct l_dbus_interface *interface)
 					p2p_peer_get_subcategory, NULL);
 	l_dbus_interface_property(interface, "Connected", 0, "b",
 					p2p_peer_get_connected, NULL);
+	l_dbus_interface_property(interface, "ConnectedInterface", 0, "s",
+					p2p_peer_get_connected_if, NULL);
+	l_dbus_interface_property(interface, "ConnectedIP", 0, "s",
+					p2p_peer_get_connected_ip, NULL);
 	l_dbus_interface_method(interface, "Disconnect", 0,
 				p2p_peer_dbus_disconnect, "", "");
 }
-- 
2.25.1

  parent reply	other threads:[~2020-07-11  1:00 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-11  1:00 [PATCH 01/18] p2p: Stop discovery after GO Negotiation Req error Andrew Zaborowski
2020-07-11  1:00 ` [PATCH 02/18] p2p: Update peer->device_addr when updating peer->bss Andrew Zaborowski
2020-07-11  1:00 ` [PATCH 03/18] p2p: Initialize dev->discovery_users in p2p_device_request_discovery Andrew Zaborowski
2020-07-11  1:00 ` [PATCH 04/18] p2p: Use nl80211_parse_attrs Andrew Zaborowski
2020-07-11  1:00 ` [PATCH 05/18] p2p: Implement the Peer.Device property Andrew Zaborowski
2020-07-11  1:00 ` [PATCH 06/18] man iwd.debug: Document IWD_GENL_DEBUG Andrew Zaborowski
2020-07-11  1:00 ` [PATCH 07/18] test: Set WSC.PushButton call timeout to 120s Andrew Zaborowski
2020-07-11  1:00 ` [PATCH 08/18] scan: Extract WFD IE payload into struct bss Andrew Zaborowski
2020-07-11  1:00 ` [PATCH 09/18] p2putil: Extract WFD IE payloads from P2P Action frames Andrew Zaborowski
2020-07-11  1:00 ` [PATCH 10/18] p2putil: Add WFD IEs when building " Andrew Zaborowski
2020-07-11  1:00 ` [PATCH 11/18] p2p: Implement the p2p.ServiceManager interface Andrew Zaborowski
2020-07-13 19:47   ` Denis Kenzior
2020-07-15 14:25     ` Andrew Zaborowski
2020-07-11  1:00 ` [PATCH 12/18] p2p: Add the p2p.Display interface on WFD-capable peers Andrew Zaborowski
2020-07-11  1:00 ` [PATCH 13/18] p2p: Add WFD IEs in GO Negotiation and association Andrew Zaborowski
2020-07-11  1:00 ` [PATCH 14/18] doc: Wi-Fi Display DBus API doc Andrew Zaborowski
2020-07-13 19:51   ` Denis Kenzior
2020-07-11  1:00 ` [PATCH 15/18] netconfig: Implement netconfig_get_dhcp_server_ipv4 Andrew Zaborowski
2020-07-13 19:53   ` Denis Kenzior
2020-07-11  1:00 ` Andrew Zaborowski [this message]
2020-07-13 19:54   ` [PATCH 16/18] p2p: Add ConnectedInterface and ConnectedIP Peer properties Denis Kenzior
2020-07-11  1:00 ` [PATCH 17/18] doc: Document Peer.ConnectedInterface and ConnectedIP Andrew Zaborowski
2020-07-11  1:00 ` [PATCH 18/18] test: Add a sample Wi-Fi Display source app Andrew Zaborowski
2020-07-13 19:25 ` [PATCH 01/18] p2p: Stop discovery after GO Negotiation Req error Denis Kenzior

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200711010053.224223-16-andrew.zaborowski@intel.com \
    --to=andrew.zaborowski@intel.com \
    --cc=iwd@lists.01.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox