aboutsummaryrefslogtreecommitdiffstats
path: root/wlantest/monitor.c
diff options
context:
space:
mode:
authorJouni Malinen <j@w1.fi>2010-11-07 15:59:50 (GMT)
committerJouni Malinen <j@w1.fi>2010-11-07 21:29:02 (GMT)
commit3215df77eeaf4fee01d03b1a164b1329cfdcfb52 (patch)
tree2dedfedacae216eac162822702e987c33f8cf44f /wlantest/monitor.c
parent4bc82fc7ae6294c4b1ca6dc537adbd25301f793f (diff)
downloadhostap-3215df77eeaf4fee01d03b1a164b1329cfdcfb52.zip
hostap-3215df77eeaf4fee01d03b1a164b1329cfdcfb52.tar.gz
hostap-3215df77eeaf4fee01d03b1a164b1329cfdcfb52.tar.bz2
wlantest: Add capturing and parsing of RADIUS messages
Another interface (-I) or pcap file (-R) can now be specified as a source of RADIUS packets. These packets are now parsed, but the MSK is not yet derived for PMK use.
Diffstat (limited to 'wlantest/monitor.c')
-rw-r--r--wlantest/monitor.c62
1 files changed, 62 insertions, 0 deletions
diff --git a/wlantest/monitor.c b/wlantest/monitor.c
index d01d8b3..057073e 100644
--- a/wlantest/monitor.c
+++ b/wlantest/monitor.c
@@ -37,6 +37,22 @@ static void monitor_read(int sock, void *eloop_ctx, void *sock_ctx)
}
+static void monitor_read_wired(int sock, void *eloop_ctx, void *sock_ctx)
+{
+ struct wlantest *wt = eloop_ctx;
+ u8 buf[3000];
+ int len;
+
+ len = recv(sock, buf, sizeof(buf), 0);
+ if (len < 0) {
+ wpa_printf(MSG_INFO, "recv(PACKET): %s", strerror(errno));
+ return;
+ }
+
+ wlantest_process_wired(wt, buf, len);
+}
+
+
int monitor_init(struct wlantest *wt, const char *ifname)
{
struct sockaddr_ll ll;
@@ -77,6 +93,46 @@ int monitor_init(struct wlantest *wt, const char *ifname)
}
+int monitor_init_wired(struct wlantest *wt, const char *ifname)
+{
+ struct sockaddr_ll ll;
+
+ os_memset(&ll, 0, sizeof(ll));
+ ll.sll_family = AF_PACKET;
+ ll.sll_ifindex = if_nametoindex(ifname);
+ if (ll.sll_ifindex == 0) {
+ wpa_printf(MSG_ERROR, "Monitor interface '%s' does not exist",
+ ifname);
+ return -1;
+ }
+
+ wt->monitor_wired = socket(PF_PACKET, SOCK_RAW, htons(ETH_P_ALL));
+ if (wt->monitor_wired < 0) {
+ wpa_printf(MSG_ERROR, "socket(PF_PACKET,SOCK_RAW): %s",
+ strerror(errno));
+ return -1;
+ }
+
+ if (bind(wt->monitor_wired, (struct sockaddr *) &ll, sizeof(ll)) < 0) {
+ wpa_printf(MSG_ERROR, "bind(PACKET): %s", strerror(errno));
+ close(wt->monitor_wired);
+ wt->monitor_wired = -1;
+ return -1;
+ }
+
+ if (eloop_register_read_sock(wt->monitor_wired, monitor_read_wired,
+ wt, NULL)) {
+ wpa_printf(MSG_ERROR, "Could not register monitor read "
+ "socket");
+ close(wt->monitor_wired);
+ wt->monitor_wired = -1;
+ return -1;
+ }
+
+ return 0;
+}
+
+
void monitor_deinit(struct wlantest *wt)
{
if (wt->monitor_sock >= 0) {
@@ -84,4 +140,10 @@ void monitor_deinit(struct wlantest *wt)
close(wt->monitor_sock);
wt->monitor_sock = -1;
}
+
+ if (wt->monitor_wired >= 0) {
+ eloop_unregister_read_sock(wt->monitor_wired);
+ close(wt->monitor_wired);
+ wt->monitor_wired = -1;
+ }
}