wpa_supplicant support multiple WiFi Direct Groups [GO (2.4 GHz) + GO (5 GHz)]

Shanbhag, Sandeep Sandeep.Shanbhag2 at harman.com
Mon Oct 5 07:23:16 EDT 2015


> There is no such functionality. Each P2P GO instance on a device shares a single P2P Device instance and with it a single P2P Device Address.

>That's not true. A single P2P Device Address is used even when operating two groups on different chips. This combination is not really supported well today in wpa_supplicant, but in any case, the protocol requires there to be a single P2P Device Address (and with it, a single P2P Device instance within wpa_supplicant).

	=> This might hold good for a device with a single WiFi chip. One single P2P Device instance restricts a device to a single device name.
	   But there might be devices with 2 or more WiFi chips or single chip with Dual MAC+ Dual Radio capabilities which might want to host multiple groups with different device name and different P2P Device configurations.
	   Such devices can have multiple Universally Unique MAC addresses that can be used as P2P Device Addresses.
	   Specification cannot/should not restrict such possibilities, it cannot/should not restrict a device to have a single device name irrespective of its capabilities (chips)
	   For such a device it should be possible to run 2 supplicant instance to satisfy the requirements, is this invalid and violation of specification?

	   If running 2 supplicants one for each chip and each supplicant creating a group with its own device name is not a violation of the specification then the question is does it help to modify the supplicant to satisfy such needs.


-----Original Message-----
From: hostap-bounces at lists.shmoo.com [mailto:hostap-bounces at lists.shmoo.com] On Behalf Of hostap-request at lists.shmoo.com
Sent: Wednesday, September 23, 2015 5:35 PM
To: hostap at lists.shmoo.com
Subject: HostAP Digest, Vol 149, Issue 29

Send HostAP mailing list submissions to
	hostap at lists.shmoo.com

To subscribe or unsubscribe via the World Wide Web, visit
	http://lists.shmoo.com/mailman/listinfo/hostap
or, via email, send a message with subject or body 'help' to
	hostap-request at lists.shmoo.com

You can reach the person managing the list at
	hostap-owner at lists.shmoo.com

When replying, please edit your Subject line so it is more specific than "Re: Contents of HostAP digest..."


Today's Topics:

   1. Re: wpa_supplicant support multiple WiFi Direct Groups [GO
      (2.4 GHz)	+	GO (5 GHz)] (Jouni Malinen)
   2. Re: Portability fixes for OSX (Alan DeKok)
   3. [PATCH 1/9] wpa_supplicant: use getaddrinfo() when UDP ctrl
      interface (Janusz Dziedzic)
   4. [PATCH 0/9] Refactor CTRL UDP (remote) path (Janusz Dziedzic)
   5. [PATCH 2/9] wpa_supplicant: use getnameinfo() for UDP ctrl
      iface (Janusz Dziedzic)


----------------------------------------------------------------------

Message: 1
Date: Tue, 22 Sep 2015 19:04:59 +0300
From: Jouni Malinen <j at w1.fi>
To: hostap at lists.shmoo.com
Subject: Re: wpa_supplicant support multiple WiFi Direct Groups [GO
	(2.4 GHz)	+	GO (5 GHz)]
Message-ID: <20150922160459.GA24426 at w1.fi>
Content-Type: text/plain; charset=us-ascii

On Tue, Sep 22, 2015 at 03:12:59PM +0000, Shanbhag, Sandeep wrote:

> This was more from the perspective that if each GO is supposed to have an associated unique Device entity.

There is no such functionality. Each P2P GO instance on a device shares a single P2P Device instance and with it a single P2P Device Address.

> IMHO, this behavior beats the whole purpose of somebody trying to create multiple groups using a single supplicant. The reason somebody wants to create more than one group is so that the remote device sees these multiple groups as different groups and should be able to connect to whichever it chooses to connect. But with this single device entity it does not become possible due to the reasons mentioned above.

If you want to find operating P2P groups, use normal scan results for that.

> For Ex: If there are 2 groups created using a single supplicant say: Group-A (on 2.4 GHz Channel) and Group-B (on 5 GHz Channel).
> Now a dual band mobile phone should be able to see both the groups in its WiFi Direct Discovery Screen and then should be able to make a choice of whether to connect to Group-A or Group-B.
> But due to the same P2P-Device Address used by both the groups the remote device can at a time either see Group-A or Group-B.

That's not accurate. When looking at the list of peer devices, sure, you'll see a single entry as expected since there is a single P2P Device Address. However, when looking at scan results, you'll see both of the groups separately if that peer is indeed operating two groups concurrently as the GO.

> Also consider a case when there are 2 WiFi chips and a single supplicant needs to create one group on each of the chip then at least 2 P2P Device Entities are required.

That's not true. A single P2P Device Address is used even when operating two groups on different chips. This combination is not really supported well today in wpa_supplicant, but in any case, the protocol requires there to be a single P2P Device Address (and with it, a single P2P Device instance within wpa_supplicant).

> So this problem can be solved by either bringing P2P structure out of global and making it part of wpa_s structure or by changing the logic of peer addition based not only on Device Address but some also may be the group's interface address.

I cannot really agree with either of those. The former is against the specification and would not really help either unless you could force every deployed devices to update to such design.. The latter is not accurate description of how a peer should be identified. P2P Device Address is the unique identifier of each P2P Device.

It sounds like you are searching for means to receive more information on the groups in which a given peer is currently connected (either as a GO or as a P2P Client). That's something that could be extended in the P2P Peer information in wpa_supplicant.

-- 
Jouni Malinen                                            PGP id EFC895FA


------------------------------

Message: 2
Date: Tue, 22 Sep 2015 12:45:56 -0400
From: Alan DeKok <aland at deployingradius.com>
To: Johannes Berg <johannes at sipsolutions.net>
Cc: hostap at lists.shmoo.com
Subject: Re: Portability fixes for OSX
Message-ID: <C1BC712E-5408-4B93-8694-912223A7E734 at deployingradius.com>
Content-Type: text/plain; charset="us-ascii"

On Sep 22, 2015, at 11:14 AM, Johannes Berg <johannes at sipsolutions.net> wrote:
> Seems like you could consider caching the result of 
> mach_timebase_info()?

  Sure.  Updated patch attached.

  Alan DeKok.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Portability-fixes-for-OS-X.patch
Type: application/octet-stream
Size: 1904 bytes
Desc: not available
URL: <http://lists.shmoo.com/pipermail/hostap/attachments/20150922/5cf9f6b0/attachment-0001.obj>

------------------------------

Message: 3
Date: Wed, 23 Sep 2015 14:04:11 +0200
From: Janusz Dziedzic <janusz.dziedzic at tieto.com>
To: hostap at lists.shmoo.com
Cc: j at w1.fi
Subject: [PATCH 1/9] wpa_supplicant: use getaddrinfo() when UDP ctrl
	interface
Message-ID:
	<1443009859-15327-2-git-send-email-janusz.dziedzic at tieto.com>

Kill not needed #ifdefs and make code common for IPv4/IPv6 when registering UDP server for ctrl interface.

Signed-off-by: Janusz Dziedzic <janusz.dziedzic at tieto.com>
---
 wpa_supplicant/ctrl_iface_udp.c | 113 +++++++++++++++++++---------------------
 1 file changed, 55 insertions(+), 58 deletions(-)

diff --git a/wpa_supplicant/ctrl_iface_udp.c b/wpa_supplicant/ctrl_iface_udp.c index 76f69f2..12b4d45 100644
--- a/wpa_supplicant/ctrl_iface_udp.c
+++ b/wpa_supplicant/ctrl_iface_udp.c
@@ -15,7 +15,7 @@
 #include "wpa_supplicant_i.h"
 #include "ctrl_iface.h"
 #include "common/wpa_ctrl.h"
-
+#include <netdb.h>
 
 #define COOKIE_LEN 8
 
@@ -338,13 +338,9 @@ wpa_supplicant_ctrl_iface_init(struct wpa_supplicant *wpa_s)  {
 	struct ctrl_iface_priv *priv;
 	int port = WPA_CTRL_IFACE_PORT;
-#ifdef CONFIG_CTRL_IFACE_UDP_IPV6
-	struct sockaddr_in6 addr;
-	int domain = PF_INET6;
-#else /* CONFIG_CTRL_IFACE_UDP_IPV6 */
-	struct sockaddr_in addr;
-	int domain = PF_INET;
-#endif /* CONFIG_CTRL_IFACE_UDP_IPV6 */
+	char p[32]={0};
+	struct addrinfo hints = { 0 }, *res, *saveres;
+	int n;
 
 	priv = os_zalloc(sizeof(*priv));
 	if (priv == NULL)
@@ -356,35 +352,33 @@ wpa_supplicant_ctrl_iface_init(struct wpa_supplicant *wpa_s)
 	if (wpa_s->conf->ctrl_interface == NULL)
 		return priv;
 
-	priv->sock = socket(domain, SOCK_DGRAM, 0);
+#ifdef CONFIG_CTRL_IFACE_UDP_REMOTE
+	hints.ai_flags = AI_PASSIVE;
+#endif
+
+#ifdef CONFIG_CTRL_IFACE_UDP_IPV6
+	hints.ai_family = AF_INET6;
+#else
+	hints.ai_family = AF_INET;
+#endif
+	hints.ai_socktype = SOCK_DGRAM;
+
+try_again:
+	os_snprintf(p, sizeof(p), "%d", port);
+	n = getaddrinfo(NULL, p, &hints, &res);
+	if (n) {
+		wpa_printf(MSG_ERROR, "getaddrinfo(): %s", gai_strerror(n));
+		goto fail;
+	}
+
+	saveres = res;
+	priv->sock = socket(res->ai_family, res->ai_socktype, 
+res->ai_protocol);
 	if (priv->sock < 0) {
 		wpa_printf(MSG_ERROR, "socket(PF_INET): %s", strerror(errno));
 		goto fail;
 	}
 
-	os_memset(&addr, 0, sizeof(addr));
-#ifdef CONFIG_CTRL_IFACE_UDP_IPV6
-	addr.sin6_family = AF_INET6;
-#ifdef CONFIG_CTRL_IFACE_UDP_REMOTE
-	addr.sin6_addr = in6addr_any;
-#else /* CONFIG_CTRL_IFACE_UDP_REMOTE */
-	inet_pton(AF_INET6, "::1", &addr.sin6_addr);
-#endif /* CONFIG_CTRL_IFACE_UDP_REMOTE */ -#else /* CONFIG_CTRL_IFACE_UDP_IPV6 */
-	addr.sin_family = AF_INET;
-#ifdef CONFIG_CTRL_IFACE_UDP_REMOTE
-	addr.sin_addr.s_addr = INADDR_ANY;
-#else /* CONFIG_CTRL_IFACE_UDP_REMOTE */
-	addr.sin_addr.s_addr = htonl((127 << 24) | 1);
-#endif /* CONFIG_CTRL_IFACE_UDP_REMOTE */ -#endif /* CONFIG_CTRL_IFACE_UDP_IPV6 */
-try_again:
-#ifdef CONFIG_CTRL_IFACE_UDP_IPV6
-	addr.sin6_port = htons(port);
-#else /* CONFIG_CTRL_IFACE_UDP_IPV6 */
-	addr.sin_port = htons(port);
-#endif /* CONFIG_CTRL_IFACE_UDP_IPV6 */
-	if (bind(priv->sock, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
+	if (bind(priv->sock, res->ai_addr, res->ai_addrlen) < 0) {
 		port--;
 		if ((WPA_CTRL_IFACE_PORT - port) < WPA_CTRL_IFACE_PORT_LIMIT)
 			goto try_again;
@@ -392,6 +386,8 @@ try_again:
 		goto fail;
 	}
 
+	freeaddrinfo(saveres);
+
 #ifdef CONFIG_CTRL_IFACE_UDP_REMOTE
 	wpa_msg(wpa_s, MSG_DEBUG, "ctrl_iface_init UDP port: %d", port);  #endif /* CONFIG_CTRL_IFACE_UDP_REMOTE */ @@ -560,20 +556,6 @@ static void wpa_supplicant_global_ctrl_iface_receive(int sock, void *eloop_ctx,
 		return;
 	}
 
-#ifndef CONFIG_CTRL_IFACE_UDP_REMOTE
-	if (from.sin_addr.s_addr != htonl((127 << 24) | 1)) {
-		/*
-		 * The OS networking stack is expected to drop this kind of
-		 * frames since the socket is bound to only localhost address.
-		 * Just in case, drop the frame if it is coming from any other
-		 * address.
-		 */
-		wpa_printf(MSG_DEBUG, "CTRL: Drop packet from unexpected "
-			   "source %s", inet_ntoa(from.sin_addr));
-		return;
-	}
-#endif /* CONFIG_CTRL_IFACE_UDP_REMOTE */
-
 	buf[res] = '\0';
 
 	if (os_strcmp(buf, "GET_COOKIE") == 0) { @@ -622,8 +604,10 @@ struct ctrl_iface_global_priv *  wpa_supplicant_global_ctrl_iface_init(struct wpa_global *global)  {
 	struct ctrl_iface_global_priv *priv;
-	struct sockaddr_in addr;
 	int port = WPA_GLOBAL_CTRL_IFACE_PORT;
+	char p[32]={0};
+	struct addrinfo hints = { 0 }, *res, *saveres;
+	int n;
 
 	priv = os_zalloc(sizeof(*priv));
 	if (priv == NULL)
@@ -637,22 +621,33 @@ wpa_supplicant_global_ctrl_iface_init(struct wpa_global *global)
 	wpa_printf(MSG_DEBUG, "Global control interface '%s'",
 		   global->params.ctrl_interface);
 
-	priv->sock = socket(PF_INET, SOCK_DGRAM, 0);
+#ifdef CONFIG_CTRL_IFACE_UDP_REMOTE
+	hints.ai_flags = AI_PASSIVE;
+#endif
+
+#ifdef CONFIG_CTRL_IFACE_UDP_IPV6
+	hints.ai_family = AF_INET6;
+#else
+	hints.ai_family = AF_INET;
+#endif
+	hints.ai_socktype = SOCK_DGRAM;
+
+try_again:
+	os_snprintf(p, sizeof(p), "%d", port);
+	n = getaddrinfo(NULL, p, &hints, &res);
+	if (n) {
+		wpa_printf(MSG_ERROR, "getaddrinfo(): %s", gai_strerror(n));
+		goto fail;
+	}
+
+	saveres = res;
+	priv->sock = socket(res->ai_family, res->ai_socktype, 
+res->ai_protocol);
 	if (priv->sock < 0) {
 		wpa_printf(MSG_ERROR, "socket(PF_INET): %s", strerror(errno));
 		goto fail;
 	}
 
-	os_memset(&addr, 0, sizeof(addr));
-	addr.sin_family = AF_INET;
-#ifdef CONFIG_CTRL_IFACE_UDP_REMOTE
-	addr.sin_addr.s_addr = INADDR_ANY;
-#else /* CONFIG_CTRL_IFACE_UDP_REMOTE */
-	addr.sin_addr.s_addr = htonl((127 << 24) | 1);
-#endif /* CONFIG_CTRL_IFACE_UDP_REMOTE */
-try_again:
-	addr.sin_port = htons(port);
-	if (bind(priv->sock, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
+	if (bind(priv->sock, res->ai_addr, res->ai_addrlen) < 0) {
 		port++;
 		if ((port - WPA_GLOBAL_CTRL_IFACE_PORT) <
 		    WPA_GLOBAL_CTRL_IFACE_PORT_LIMIT) @@ -661,6 +656,8 @@ try_again:
 		goto fail;
 	}
 
+	freeaddrinfo(saveres);
+
 #ifdef CONFIG_CTRL_IFACE_UDP_REMOTE
 	wpa_printf(MSG_DEBUG, "global_ctrl_iface_init UDP port: %d", port);  #endif /* CONFIG_CTRL_IFACE_UDP_REMOTE */
--
1.9.1



------------------------------

Message: 4
Date: Wed, 23 Sep 2015 14:04:10 +0200
From: Janusz Dziedzic <janusz.dziedzic at tieto.com>
To: hostap at lists.shmoo.com
Cc: j at w1.fi
Subject: [PATCH 0/9] Refactor CTRL UDP (remote) path
Message-ID:
	<1443009859-15327-1-git-send-email-janusz.dziedzic at tieto.com>

Kill #ifdefs hell used for client and server. Use common
code for IPv4/IPv6. Simplify supplicant/cli UDP code.
Add monitor support for CTRL UDP also.

Please review.

Janusz Dziedzic (9):
  wpa_supplicant: use getaddrinfo() when UDP ctrl interface
  wpa_supplicant: use getnameinfo() for UDP ctrl iface
  wpa_supplicant: add helper function sockaddr_compare
  wpa_supplicant: use sockaddr_storage for ctrl UDP iface
  wpa_supplicant: change attach/detach ctrl UDP functions
  wpa_supplicant: monitor support for global ctrl UDP iface
  wpa_ctrl: use common separator for IPv4/IPv6
  wpa_cli: simplify ctrl UDP path
  wpa_cli: don't send IFNAME when remote UDP and global iface

 src/common/wpa_ctrl.c           | 168 +++++-----------
 wpa_supplicant/ctrl_iface_udp.c | 418 +++++++++++++++++++++-------------------
 2 files changed, 267 insertions(+), 319 deletions(-)

-- 
1.9.1



------------------------------

Message: 5
Date: Wed, 23 Sep 2015 14:04:12 +0200
From: Janusz Dziedzic <janusz.dziedzic at tieto.com>
To: hostap at lists.shmoo.com
Cc: j at w1.fi
Subject: [PATCH 2/9] wpa_supplicant: use getnameinfo() for UDP ctrl
	iface
Message-ID:
	<1443009859-15327-3-git-send-email-janusz.dziedzic at tieto.com>

Kill not needed #ifdefs and use getnameinfo() that
will work for both IPv4 and IPv6.

Signed-off-by: Janusz Dziedzic <janusz.dziedzic at tieto.com>
---
 wpa_supplicant/ctrl_iface_udp.c | 111 +++++++++++++++-------------------------
 1 file changed, 41 insertions(+), 70 deletions(-)

diff --git a/wpa_supplicant/ctrl_iface_udp.c b/wpa_supplicant/ctrl_iface_udp.c
index 12b4d45..26fb3aa 100644
--- a/wpa_supplicant/ctrl_iface_udp.c
+++ b/wpa_supplicant/ctrl_iface_udp.c
@@ -63,9 +63,8 @@ static int wpa_supplicant_ctrl_iface_attach(struct ctrl_iface_priv *priv,
 					    socklen_t fromlen)
 {
 	struct wpa_ctrl_dst *dst;
-#ifdef CONFIG_CTRL_IFACE_UDP_IPV6
-	char addr[INET6_ADDRSTRLEN];
-#endif /* CONFIG_UDP_IPV6 */
+	char host[NI_MAXHOST] = {0};
+	char service[NI_MAXSERV] = {0};
 
 	dst = os_zalloc(sizeof(*dst));
 	if (dst == NULL)
@@ -75,14 +74,14 @@ static int wpa_supplicant_ctrl_iface_attach(struct ctrl_iface_priv *priv,
 	dst->debug_level = MSG_INFO;
 	dst->next = priv->ctrl_dst;
 	priv->ctrl_dst = dst;
-#ifdef CONFIG_CTRL_IFACE_UDP_IPV6
-	wpa_printf(MSG_DEBUG, "CTRL_IFACE monitor attached %s:%d",
-		   inet_ntop(AF_INET6, &from->sin6_addr, addr, sizeof(*from)),
-		   ntohs(from->sin6_port));
-#else /* CONFIG_CTRL_IFACE_UDP_IPV6 */
-	wpa_printf(MSG_DEBUG, "CTRL_IFACE monitor attached %s:%d",
-		   inet_ntoa(from->sin_addr), ntohs(from->sin_port));
-#endif /* CONFIG_CTRL_IFACE_UDP_IPV6 */
+
+	getnameinfo((struct sockaddr *) from, fromlen,
+		    host, sizeof(host),
+		    service, sizeof(service),
+		    NI_NUMERICHOST);
+
+	wpa_printf(MSG_DEBUG, "CTRL_IFACE monitor attached %s:%s",
+		   host, service);
 	return 0;
 }
 
@@ -96,9 +95,8 @@ static int wpa_supplicant_ctrl_iface_detach(struct ctrl_iface_priv *priv,
 					    socklen_t fromlen)
 {
 	struct wpa_ctrl_dst *dst, *prev = NULL;
-#ifdef CONFIG_CTRL_IFACE_UDP_IPV6
-	char addr[INET6_ADDRSTRLEN];
-#endif /* CONFIG_CTRL_IFACE_UDP_IPV6 */
+	char host[NI_MAXHOST] = {0};
+	char service[NI_MAXSERV] = {0};
 
 	dst = priv->ctrl_dst;
 	while (dst) {
@@ -106,17 +104,19 @@ static int wpa_supplicant_ctrl_iface_detach(struct ctrl_iface_priv *priv,
 		if (from->sin6_port == dst->addr.sin6_port &&
 		    !os_memcmp(&from->sin6_addr, &dst->addr.sin6_addr,
 			       sizeof(from->sin6_addr))) {
-			wpa_printf(MSG_DEBUG, "CTRL_IFACE monitor detached %s:%d",
-				   inet_ntop(AF_INET6, &from->sin6_addr, addr,
-					     sizeof(*from)),
-				   ntohs(from->sin6_port));
 #else /* CONFIG_CTRL_IFACE_UDP_IPV6 */
 		if (from->sin_addr.s_addr == dst->addr.sin_addr.s_addr &&
 		    from->sin_port == dst->addr.sin_port) {
-			wpa_printf(MSG_DEBUG, "CTRL_IFACE monitor detached "
-				   "%s:%d", inet_ntoa(from->sin_addr),
-				   ntohs(from->sin_port));
 #endif /* CONFIG_CTRL_IFACE_UDP_IPV6 */
+
+			getnameinfo((struct sockaddr *) from, fromlen,
+				    host, sizeof(host),
+				    service, sizeof(service),
+				    NI_NUMERICHOST);
+
+			wpa_printf(MSG_DEBUG, "CTRL_IFACE monitor detached %s:%s",
+				   host, service);
+
 			if (prev == NULL)
 				priv->ctrl_dst = dst->next;
 			else
@@ -141,9 +141,8 @@ static int wpa_supplicant_ctrl_iface_level(struct ctrl_iface_priv *priv,
 					   char *level)
 {
 	struct wpa_ctrl_dst *dst;
-#ifdef CONFIG_CTRL_IFACE_UDP_IPV6
-	char addr[INET6_ADDRSTRLEN];
-#endif /* CONFIG_CTRL_IFACE_UDP_IPV6 */
+	char host[NI_MAXHOST] = {0};
+	char service[NI_MAXSERV] = {0};
 
 	wpa_printf(MSG_DEBUG, "CTRL_IFACE LEVEL %s", level);
 
@@ -153,17 +152,17 @@ static int wpa_supplicant_ctrl_iface_level(struct ctrl_iface_priv *priv,
 		if (from->sin6_port == dst->addr.sin6_port &&
 		    !os_memcmp(&from->sin6_addr, &dst->addr.sin6_addr,
 			       sizeof(from->sin6_addr))) {
-			wpa_printf(MSG_DEBUG, "CTRL_IFACE changed monitor level %s:%d",
-				   inet_ntop(AF_INET6, &from->sin6_addr, addr,
-					     sizeof(*from)),
-				   ntohs(from->sin6_port));
 #else /* CONFIG_CTRL_IFACE_UDP_IPV6 */
 		if (from->sin_addr.s_addr == dst->addr.sin_addr.s_addr &&
 		    from->sin_port == dst->addr.sin_port) {
-			wpa_printf(MSG_DEBUG, "CTRL_IFACE changed monitor "
-				   "level %s:%d", inet_ntoa(from->sin_addr),
-				   ntohs(from->sin_port));
 #endif /* CONFIG_CTRL_IFACE_UDP_IPV6 */
+			getnameinfo((struct sockaddr *) from, fromlen,
+				    host, sizeof(host),
+				    service, sizeof(service),
+				    NI_NUMERICHOST);
+
+			wpa_printf(MSG_DEBUG, "CTRL_IFACE changed monitor level %s:%s",
+				   host, service);
 			dst->debug_level = atoi(level);
 			return 0;
 		}
@@ -203,9 +202,6 @@ static void wpa_supplicant_ctrl_iface_receive(int sock, void *eloop_ctx,
 	int res;
 #ifdef CONFIG_CTRL_IFACE_UDP_IPV6
 	struct sockaddr_in6 from;
-#ifndef CONFIG_CTRL_IFACE_UDP_REMOTE
-	char addr[INET6_ADDRSTRLEN];
-#endif /* CONFIG_CTRL_IFACE_UDP_REMOTE */
 #else /* CONFIG_CTRL_IFACE_UDP_IPV6 */
 	struct sockaddr_in from;
 #endif /* CONFIG_CTRL_IFACE_UDP_IPV6 */
@@ -223,28 +219,6 @@ static void wpa_supplicant_ctrl_iface_receive(int sock, void *eloop_ctx,
 		return;
 	}
 
-#ifndef CONFIG_CTRL_IFACE_UDP_REMOTE
-#ifdef CONFIG_CTRL_IFACE_UDP_IPV6
-	inet_ntop(AF_INET6, &from.sin6_addr, addr, sizeof(from));
-	if (os_strcmp(addr, "::1")) {
-		wpa_printf(MSG_DEBUG, "CTRL: Drop packet from unexpected source %s",
-			   addr);
-	}
-#else /* CONFIG_CTRL_IFACE_UDP_IPV6 */
-	if (from.sin_addr.s_addr != htonl((127 << 24) | 1)) {
-		/*
-		 * The OS networking stack is expected to drop this kind of
-		 * frames since the socket is bound to only localhost address.
-		 * Just in case, drop the frame if it is coming from any other
-		 * address.
-		 */
-		wpa_printf(MSG_DEBUG, "CTRL: Drop packet from unexpected "
-			   "source %s", inet_ntoa(from.sin_addr));
-		return;
-	}
-#endif /* CONFIG_CTRL_IFACE_UDP_IPV6 */
-#endif /* CONFIG_CTRL_IFACE_UDP_REMOTE */
-
 	buf[res] = '\0';
 
 	if (os_strcmp(buf, "GET_COOKIE") == 0) {
@@ -441,13 +415,12 @@ static void wpa_supplicant_ctrl_iface_send(struct ctrl_iface_priv *priv,
 					   size_t len)
 {
 	struct wpa_ctrl_dst *dst, *next;
+	char host[NI_MAXHOST] = {0};
+	char service[NI_MAXSERV] = {0};
 	char levelstr[10];
 	int idx;
 	char *sbuf;
 	int llen;
-#ifdef CONFIG_CTRL_IFACE_UDP_IPV6
-	char addr[INET6_ADDRSTRLEN];
-#endif /* CONFIG_CTRL_IFACE_UDP_IPV6 */
 
 	dst = priv->ctrl_dst;
 	if (priv->sock < 0 || dst == NULL)
@@ -467,19 +440,17 @@ static void wpa_supplicant_ctrl_iface_send(struct ctrl_iface_priv *priv,
 	while (dst) {
 		next = dst->next;
 		if (level >= dst->debug_level) {
-#ifdef CONFIG_CTRL_IFACE_UDP_IPV6
-			wpa_printf(MSG_DEBUG, "CTRL_IFACE monitor send %s:%d",
-				   inet_ntop(AF_INET6, &dst->addr.sin6_addr,
-					     addr, sizeof(dst->addr)),
-				   ntohs(dst->addr.sin6_port));
-#else /* CONFIG_CTRL_IFACE_UDP_IPV6 */
-			wpa_printf(MSG_DEBUG, "CTRL_IFACE monitor send %s:%d",
-				   inet_ntoa(dst->addr.sin_addr),
-				   ntohs(dst->addr.sin_port));
-#endif /* CONFIG_CTRL_IFACE_UDP_IPV6 */
+			getnameinfo((struct sockaddr *) &dst->addr, dst->addrlen,
+				    host, sizeof(host),
+				    service, sizeof(service),
+				    NI_NUMERICHOST);
+
+			wpa_printf(MSG_DEBUG, "CTRL_IFACE monitor send %s:%s",
+				   host, service);
+
 			if (sendto(priv->sock, sbuf, llen + len, 0,
 				   (struct sockaddr *) &dst->addr,
-				   sizeof(dst->addr)) < 0) {
+				   dst->addrlen) < 0) {
 				wpa_printf(MSG_ERROR,
 					   "sendto(CTRL_IFACE monitor): %s",
 					   strerror(errno));
-- 
1.9.1



------------------------------

_______________________________________________
HostAP mailing list
HostAP at lists.shmoo.com
http://lists.shmoo.com/mailman/listinfo/hostap


End of HostAP Digest, Vol 149, Issue 29
***************************************


More information about the HostAP mailing list