wpa_supplicant: Use common functions for ctrl_iface
Use the common functions, structures when UNIX socket ctrl_iface used. Signed-off-by: Janusz Dziedzic <janusz.dziedzic@tieto.com>
This commit is contained in:
parent
ca974ae53f
commit
1a2124c650
3 changed files with 6 additions and 71 deletions
|
@ -1291,6 +1291,7 @@ endif
|
|||
L_CFLAGS += -DCONFIG_CTRL_IFACE
|
||||
ifeq ($(CONFIG_CTRL_IFACE), unix)
|
||||
L_CFLAGS += -DCONFIG_CTRL_IFACE_UNIX
|
||||
OBJS += src/common/ctrl_iface_common.c
|
||||
endif
|
||||
ifeq ($(CONFIG_CTRL_IFACE), udp)
|
||||
L_CFLAGS += -DCONFIG_CTRL_IFACE_UDP
|
||||
|
|
|
@ -1335,6 +1335,7 @@ endif
|
|||
CFLAGS += -DCONFIG_CTRL_IFACE
|
||||
ifeq ($(CONFIG_CTRL_IFACE), unix)
|
||||
CFLAGS += -DCONFIG_CTRL_IFACE_UNIX
|
||||
OBJS += ../src/common/ctrl_iface_common.o
|
||||
endif
|
||||
ifeq ($(CONFIG_CTRL_IFACE), udp)
|
||||
CFLAGS += -DCONFIG_CTRL_IFACE_UDP
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#include "utils/common.h"
|
||||
#include "utils/eloop.h"
|
||||
#include "utils/list.h"
|
||||
#include "common/ctrl_iface_common.h"
|
||||
#include "eapol_supp/eapol_supp_sm.h"
|
||||
#include "config.h"
|
||||
#include "wpa_supplicant_i.h"
|
||||
|
@ -31,22 +32,6 @@
|
|||
|
||||
/* Per-interface ctrl_iface */
|
||||
|
||||
/**
|
||||
* struct wpa_ctrl_dst - Internal data structure of control interface monitors
|
||||
*
|
||||
* This structure is used to store information about registered control
|
||||
* interface monitors into struct wpa_supplicant. This data is private to
|
||||
* ctrl_iface_unix.c and should not be touched directly from other files.
|
||||
*/
|
||||
struct wpa_ctrl_dst {
|
||||
struct dl_list list;
|
||||
struct sockaddr_un addr;
|
||||
socklen_t addrlen;
|
||||
int debug_level;
|
||||
int errors;
|
||||
};
|
||||
|
||||
|
||||
struct ctrl_iface_priv {
|
||||
struct wpa_supplicant *wpa_s;
|
||||
int sock;
|
||||
|
@ -119,22 +104,7 @@ static int wpa_supplicant_ctrl_iface_attach(struct dl_list *ctrl_dst,
|
|||
struct sockaddr_un *from,
|
||||
socklen_t fromlen, int global)
|
||||
{
|
||||
struct wpa_ctrl_dst *dst;
|
||||
char addr_txt[200];
|
||||
|
||||
dst = os_zalloc(sizeof(*dst));
|
||||
if (dst == NULL)
|
||||
return -1;
|
||||
os_memcpy(&dst->addr, from, sizeof(struct sockaddr_un));
|
||||
dst->addrlen = fromlen;
|
||||
dst->debug_level = MSG_INFO;
|
||||
dl_list_add(ctrl_dst, &dst->list);
|
||||
printf_encode(addr_txt, sizeof(addr_txt),
|
||||
(u8 *) from->sun_path,
|
||||
fromlen - offsetof(struct sockaddr_un, sun_path));
|
||||
wpa_printf(MSG_DEBUG, "CTRL_IFACE %smonitor attached %s",
|
||||
global ? "global " : "", addr_txt);
|
||||
return 0;
|
||||
return ctrl_iface_attach(ctrl_dst, from, fromlen);
|
||||
}
|
||||
|
||||
|
||||
|
@ -142,26 +112,7 @@ static int wpa_supplicant_ctrl_iface_detach(struct dl_list *ctrl_dst,
|
|||
struct sockaddr_un *from,
|
||||
socklen_t fromlen)
|
||||
{
|
||||
struct wpa_ctrl_dst *dst;
|
||||
|
||||
dl_list_for_each(dst, ctrl_dst, struct wpa_ctrl_dst, list) {
|
||||
if (fromlen == dst->addrlen &&
|
||||
os_memcmp(from->sun_path, dst->addr.sun_path,
|
||||
fromlen - offsetof(struct sockaddr_un, sun_path))
|
||||
== 0) {
|
||||
char addr_txt[200];
|
||||
printf_encode(addr_txt, sizeof(addr_txt),
|
||||
(u8 *) from->sun_path,
|
||||
fromlen -
|
||||
offsetof(struct sockaddr_un, sun_path));
|
||||
wpa_printf(MSG_DEBUG, "CTRL_IFACE monitor detached %s",
|
||||
addr_txt);
|
||||
dl_list_del(&dst->list);
|
||||
os_free(dst);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
return ctrl_iface_detach(ctrl_dst, from, fromlen);
|
||||
}
|
||||
|
||||
|
||||
|
@ -170,27 +121,9 @@ static int wpa_supplicant_ctrl_iface_level(struct ctrl_iface_priv *priv,
|
|||
socklen_t fromlen,
|
||||
char *level)
|
||||
{
|
||||
struct wpa_ctrl_dst *dst;
|
||||
|
||||
wpa_printf(MSG_DEBUG, "CTRL_IFACE LEVEL %s", level);
|
||||
|
||||
dl_list_for_each(dst, &priv->ctrl_dst, struct wpa_ctrl_dst, list) {
|
||||
if (fromlen == dst->addrlen &&
|
||||
os_memcmp(from->sun_path, dst->addr.sun_path,
|
||||
fromlen - offsetof(struct sockaddr_un, sun_path))
|
||||
== 0) {
|
||||
char addr_txt[200];
|
||||
dst->debug_level = atoi(level);
|
||||
printf_encode(addr_txt, sizeof(addr_txt),
|
||||
(u8 *) from->sun_path, fromlen -
|
||||
offsetof(struct sockaddr_un, sun_path));
|
||||
wpa_printf(MSG_DEBUG, "CTRL_IFACE changed monitor level to %d for %s",
|
||||
dst->debug_level, addr_txt);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
return ctrl_iface_level(&priv->ctrl_dst, from, fromlen, level);
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue