aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJouni Malinen <jouni.malinen@atheros.com>2009-01-21 09:45:56 (GMT)
committerJouni Malinen <j@w1.fi>2009-02-08 10:10:48 (GMT)
commitd2e7a70f088dd3cedfea01f22ab7bb646a328d0b (patch)
tree828dd8478eea955580cb189e19df5a53f0fedeb4
parentd025b338ba25540680baa244f79b6ebf7ae8e938 (diff)
downloadhostap-06-d2e7a70f088dd3cedfea01f22ab7bb646a328d0b.zip
hostap-06-d2e7a70f088dd3cedfea01f22ab7bb646a328d0b.tar.gz
hostap-06-d2e7a70f088dd3cedfea01f22ab7bb646a328d0b.tar.bz2
Enable wpa_msg() for hostapd
Use wpa_msg() like wpa_supplicant in order to avoid having to use direct hostapd_ctrl_iface_send() calls. (cherry picked from commit 42d16805c9fbf27614861f69aad1f5dfacaaf361) Conflicts: hostapd/ctrl_iface.h
-rw-r--r--hostapd/ctrl_iface.c21
-rw-r--r--hostapd/ctrl_iface.h2
-rw-r--r--hostapd/wps_hostapd.c6
3 files changed, 20 insertions, 9 deletions
diff --git a/hostapd/ctrl_iface.c b/hostapd/ctrl_iface.c
index 7afd859..fe63e7c 100644
--- a/hostapd/ctrl_iface.c
+++ b/hostapd/ctrl_iface.c
@@ -41,6 +41,10 @@ struct wpa_ctrl_dst {
};
+static void hostapd_ctrl_iface_send(struct hostapd_data *hapd, int level,
+ const char *buf, size_t len);
+
+
static int hostapd_ctrl_iface_attach(struct hostapd_data *hapd,
struct sockaddr_un *from,
socklen_t fromlen)
@@ -381,6 +385,16 @@ static char * hostapd_ctrl_iface_path(struct hostapd_data *hapd)
}
+static void hostapd_ctrl_iface_msg_cb(void *ctx, int level,
+ const char *txt, size_t len)
+{
+ struct hostapd_data *hapd = ctx;
+ if (hapd == NULL)
+ return;
+ hostapd_ctrl_iface_send(hapd, level, txt, len);
+}
+
+
int hostapd_ctrl_iface_init(struct hostapd_data *hapd)
{
struct sockaddr_un addr;
@@ -445,6 +459,7 @@ int hostapd_ctrl_iface_init(struct hostapd_data *hapd)
hapd->ctrl_sock = s;
eloop_register_read_sock(s, hostapd_ctrl_iface_receive, hapd,
NULL);
+ wpa_msg_register_cb(hostapd_ctrl_iface_msg_cb);
return 0;
@@ -494,8 +509,8 @@ void hostapd_ctrl_iface_deinit(struct hostapd_data *hapd)
}
-void hostapd_ctrl_iface_send(struct hostapd_data *hapd, int level,
- char *buf, size_t len)
+static void hostapd_ctrl_iface_send(struct hostapd_data *hapd, int level,
+ const char *buf, size_t len)
{
struct wpa_ctrl_dst *dst, *next;
struct msghdr msg;
@@ -510,7 +525,7 @@ void hostapd_ctrl_iface_send(struct hostapd_data *hapd, int level,
os_snprintf(levelstr, sizeof(levelstr), "<%d>", level);
io[0].iov_base = levelstr;
io[0].iov_len = os_strlen(levelstr);
- io[1].iov_base = buf;
+ io[1].iov_base = (char *) buf;
io[1].iov_len = len;
os_memset(&msg, 0, sizeof(msg));
msg.msg_iov = io;
diff --git a/hostapd/ctrl_iface.h b/hostapd/ctrl_iface.h
index 2ac2f3b..d86de8c 100644
--- a/hostapd/ctrl_iface.h
+++ b/hostapd/ctrl_iface.h
@@ -17,7 +17,5 @@
int hostapd_ctrl_iface_init(struct hostapd_data *hapd);
void hostapd_ctrl_iface_deinit(struct hostapd_data *hapd);
-void hostapd_ctrl_iface_send(struct hostapd_data *hapd, int level,
- char *buf, size_t len);
#endif /* CTRL_IFACE_H */
diff --git a/hostapd/wps_hostapd.c b/hostapd/wps_hostapd.c
index 8e6645d..f4c1b0e 100644
--- a/hostapd/wps_hostapd.c
+++ b/hostapd/wps_hostapd.c
@@ -19,7 +19,6 @@
#include "eloop.h"
#include "uuid.h"
#include "wpa_ctrl.h"
-#include "ctrl_iface.h"
#include "ieee802_11_defs.h"
#include "wps/wps.h"
#include "wps/wps_defs.h"
@@ -133,7 +132,7 @@ static void hostapd_wps_pin_needed_cb(void *ctx, const u8 *uuid_e,
dev->model_number, dev->serial_number,
dev->categ, dev->oui, dev->sub_categ);
if (len > 0 && len < (int) sizeof(txt))
- hostapd_ctrl_iface_send(hapd, MSG_INFO, txt, len);
+ wpa_msg(hapd, MSG_INFO, "%s", txt);
if (hapd->conf->wps_pin_requests) {
FILE *f;
@@ -195,8 +194,7 @@ static int hostapd_wps_cred_cb(void *ctx, const struct wps_credential *cred)
wpa_printf(MSG_DEBUG, "WPS: MAC Address " MACSTR,
MAC2STR(cred->mac_addr));
- hostapd_ctrl_iface_send(hapd, MSG_INFO, WPS_EVENT_NEW_AP_SETTINGS,
- os_strlen(WPS_EVENT_NEW_AP_SETTINGS));
+ wpa_msg(hapd, MSG_INFO, WPS_EVENT_NEW_AP_SETTINGS);
len = os_strlen(hapd->iface->config_fname) + 5;
tmp_fname = os_malloc(len);