diff mbox

[5/9] wpa_supplicant: change attach/detach ctrl UDP functions

Message ID 1443009859-15327-6-git-send-email-janusz.dziedzic@tieto.com
State Changes Requested
Headers show

Commit Message

Janusz.Dziedzic@tieto.com Sept. 23, 2015, 12:04 p.m. UTC
Make ctrl UDP iface funtions (attach/detach) common for
ctrl and global interfaces.

Signed-off-by: Janusz Dziedzic <janusz.dziedzic@tieto.com>
---
 wpa_supplicant/ctrl_iface_udp.c | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)
diff mbox

Patch

diff --git a/wpa_supplicant/ctrl_iface_udp.c b/wpa_supplicant/ctrl_iface_udp.c
index c5ba92d..8c5c038 100644
--- a/wpa_supplicant/ctrl_iface_udp.c
+++ b/wpa_supplicant/ctrl_iface_udp.c
@@ -83,7 +83,7 @@  static int sockaddr_compare(struct sockaddr *a, struct sockaddr *b)
 	return 0;
 }
 
-static int wpa_supplicant_ctrl_iface_attach(struct ctrl_iface_priv *priv,
+static int wpa_supplicant_ctrl_iface_attach(struct wpa_ctrl_dst **head,
 					    struct sockaddr_storage *from,
 					    socklen_t fromlen)
 {
@@ -97,8 +97,8 @@  static int wpa_supplicant_ctrl_iface_attach(struct ctrl_iface_priv *priv,
 	os_memcpy(&dst->addr, from, fromlen);
 	dst->addrlen = fromlen;
 	dst->debug_level = MSG_INFO;
-	dst->next = priv->ctrl_dst;
-	priv->ctrl_dst = dst;
+	dst->next = *head;
+	*head = dst;
 
 	getnameinfo((struct sockaddr *) from, fromlen,
 		    host, sizeof(host),
@@ -111,7 +111,7 @@  static int wpa_supplicant_ctrl_iface_attach(struct ctrl_iface_priv *priv,
 }
 
 
-static int wpa_supplicant_ctrl_iface_detach(struct ctrl_iface_priv *priv,
+static int wpa_supplicant_ctrl_iface_detach(struct wpa_ctrl_dst **head,
 					    struct sockaddr_storage *from,
 					    socklen_t fromlen)
 {
@@ -119,7 +119,7 @@  static int wpa_supplicant_ctrl_iface_detach(struct ctrl_iface_priv *priv,
 	char host[NI_MAXHOST] = {0};
 	char service[NI_MAXSERV] = {0};
 
-	dst = priv->ctrl_dst;
+	dst = *head;
 	while (dst) {
 		if (!sockaddr_compare((struct sockaddr *) from, (struct sockaddr *) &dst->addr)) {
 			getnameinfo((struct sockaddr *) from, fromlen,
@@ -131,7 +131,7 @@  static int wpa_supplicant_ctrl_iface_detach(struct ctrl_iface_priv *priv,
 				   host, service);
 
 			if (prev == NULL)
-				priv->ctrl_dst = dst->next;
+				*head = dst->next;
 			else
 				prev->next = dst->next;
 			os_free(dst);
@@ -254,14 +254,14 @@  static void wpa_supplicant_ctrl_iface_receive(int sock, void *eloop_ctx,
 		pos++;
 
 	if (os_strcmp(pos, "ATTACH") == 0) {
-		if (wpa_supplicant_ctrl_iface_attach(priv, (struct sockaddr_storage *) &from, fromlen))
+		if (wpa_supplicant_ctrl_iface_attach(&priv->ctrl_dst, (struct sockaddr_storage *) &from, fromlen))
 			reply_len = 1;
 		else {
 			new_attached = 1;
 			reply_len = 2;
 		}
 	} else if (os_strcmp(pos, "DETACH") == 0) {
-		if (wpa_supplicant_ctrl_iface_detach(priv, (struct sockaddr_storage *)&from, fromlen))
+		if (wpa_supplicant_ctrl_iface_detach(&priv->ctrl_dst, (struct sockaddr_storage *)&from, fromlen))
 			reply_len = 1;
 		else
 			reply_len = 2;
@@ -455,7 +455,7 @@  static void wpa_supplicant_ctrl_iface_send(struct ctrl_iface_priv *priv,
 				dst->errors++;
 				if (dst->errors > 10) {
 					wpa_supplicant_ctrl_iface_detach(
-						priv, &dst->addr,
+						&priv->ctrl_dst, &dst->addr,
 						dst->addrlen);
 				}
 			} else