aboutsummaryrefslogtreecommitdiffstats
path: root/hostapd
diff options
context:
space:
mode:
authorJouni Malinen <j@w1.fi>2008-01-06 19:41:33 (GMT)
committerJouni Malinen <j@w1.fi>2008-01-06 19:41:33 (GMT)
commitfab779533a86230b9957853b03d09ecc81b8e4b8 (patch)
tree6b01b8e7f54d15d9d1b92bb1fc0daad6bad44dc9 /hostapd
parent9964ef2b6aeff0d82c749cabb11c67f10df3e0e7 (diff)
downloadhostap-history-fab779533a86230b9957853b03d09ecc81b8e4b8.zip
hostap-history-fab779533a86230b9957853b03d09ecc81b8e4b8.tar.gz
hostap-history-fab779533a86230b9957853b03d09ecc81b8e4b8.tar.bz2
WPS: Added support for configuring Device Password using hostapd ctrl_iface
The hardcoded PIN value was replaced with a WPS Registrar function, wps_registrar_add_pin(), and hostapd ctrl_iface was extended with a new WPS_PIN <uuid> <pin> (hostapd_cli wps_pin <uuid> <pin>) command that adds a new UUID,PIN pair to the WPS Registrar.
Diffstat (limited to 'hostapd')
-rw-r--r--hostapd/ctrl_iface.c20
-rw-r--r--hostapd/hostapd_cli.c26
-rw-r--r--hostapd/wps_hostapd.c12
-rw-r--r--hostapd/wps_hostapd.h2
4 files changed, 57 insertions, 3 deletions
diff --git a/hostapd/ctrl_iface.c b/hostapd/ctrl_iface.c
index e2df04f..6452952 100644
--- a/hostapd/ctrl_iface.c
+++ b/hostapd/ctrl_iface.c
@@ -1,6 +1,6 @@
/*
* hostapd / UNIX domain socket -based control interface
- * Copyright (c) 2004-2007, Jouni Malinen <j@w1.fi>
+ * Copyright (c) 2004-2008, Jouni Malinen <j@w1.fi>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
@@ -29,6 +29,7 @@
#include "ctrl_iface.h"
#include "sta_info.h"
#include "accounting.h"
+#include "wps_hostapd.h"
struct wpa_ctrl_dst {
@@ -218,6 +219,18 @@ static int hostapd_ctrl_iface_new_sta(struct hostapd_data *hapd,
}
+#ifdef CONFIG_WPS
+static int hostapd_ctrl_iface_wps_pin(struct hostapd_data *hapd, char *txt)
+{
+ char *pin = os_strchr(txt, ' ');
+ if (pin == NULL)
+ return -1;
+ *pin++ = '\0';
+ return hostapd_wps_add_pin(hapd, txt, pin);
+}
+#endif /* CONFIG_WPS */
+
+
static void hostapd_ctrl_iface_receive(int sock, void *eloop_ctx,
void *sock_ctx)
{
@@ -301,6 +314,11 @@ static void hostapd_ctrl_iface_receive(int sock, void *eloop_ctx,
} else if (os_strncmp(buf, "NEW_STA ", 8) == 0) {
if (hostapd_ctrl_iface_new_sta(hapd, buf + 8))
reply_len = -1;
+#ifdef CONFIG_WPS
+ } else if (os_strncmp(buf, "WPS_PIN ", 8) == 0) {
+ if (hostapd_ctrl_iface_wps_pin(hapd, buf + 8))
+ reply_len = -1;
+#endif /* CONFIG_WPS */
} else {
os_memcpy(reply, "UNKNOWN COMMAND\n", 16);
reply_len = 16;
diff --git a/hostapd/hostapd_cli.c b/hostapd/hostapd_cli.c
index ca68352..bd85513 100644
--- a/hostapd/hostapd_cli.c
+++ b/hostapd/hostapd_cli.c
@@ -1,6 +1,6 @@
/*
* hostapd - command line interface for hostapd daemon
- * Copyright (c) 2004-2007, Jouni Malinen <j@w1.fi>
+ * Copyright (c) 2004-2008, Jouni Malinen <j@w1.fi>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
@@ -22,7 +22,7 @@
static const char *hostapd_cli_version =
"hostapd_cli v" VERSION_STR "\n"
-"Copyright (c) 2004-2007, Jouni Malinen <j@w1.fi> and contributors";
+"Copyright (c) 2004-2008, Jouni Malinen <j@w1.fi> and contributors";
static const char *hostapd_cli_license =
@@ -83,6 +83,9 @@ static const char *commands_help =
" sta <addr> get MIB variables for one station\n"
" all_sta get MIB variables for all stations\n"
" new_sta <addr> add a new station\n"
+#ifdef CONFIG_WPS
+" wps_pin <uuid> <pin> add WPS Enrollee PIN (Device Password)\n"
+#endif /* CONFIG_WPS */
" help show this usage help\n"
" interface [ifname] show interfaces/select interface\n"
" level <debug level> change debug level\n"
@@ -230,6 +233,22 @@ static int hostapd_cli_cmd_new_sta(struct wpa_ctrl *ctrl, int argc,
}
+#ifdef CONFIG_WPS
+static int hostapd_cli_cmd_wps_pin(struct wpa_ctrl *ctrl, int argc,
+ char *argv[])
+{
+ char buf[64];
+ if (argc != 2) {
+ printf("Invalid 'wps_pin' command - exactly two arguments, "
+ "UUID and PIN, are required.\n");
+ return -1;
+ }
+ snprintf(buf, sizeof(buf), "WPS_PIN %s %s", argv[0], argv[1]);
+ return wpa_ctrl_command(ctrl, buf);
+}
+#endif /* CONFIG_WPS */
+
+
static int wpa_ctrl_command_sta(struct wpa_ctrl *ctrl, char *cmd,
char *addr, size_t addr_len)
{
@@ -378,6 +397,9 @@ static struct hostapd_cli_cmd hostapd_cli_commands[] = {
{ "sta", hostapd_cli_cmd_sta },
{ "all_sta", hostapd_cli_cmd_all_sta },
{ "new_sta", hostapd_cli_cmd_new_sta },
+#ifdef CONFIG_WPS
+ { "wps_pin", hostapd_cli_cmd_wps_pin },
+#endif /* CONFIG_WPS */
{ "help", hostapd_cli_cmd_help },
{ "interface", hostapd_cli_cmd_interface },
{ "level", hostapd_cli_cmd_level },
diff --git a/hostapd/wps_hostapd.c b/hostapd/wps_hostapd.c
index 5d6b2a9..9c64ffa 100644
--- a/hostapd/wps_hostapd.c
+++ b/hostapd/wps_hostapd.c
@@ -15,6 +15,7 @@
#include "includes.h"
#include "hostapd.h"
+#include "uuid.h"
#include "wps/wps.h"
#include "wps/wps_defs.h"
#include "wps_hostapd.h"
@@ -148,3 +149,14 @@ void hostapd_deinit_wps(struct hostapd_data *hapd)
{
wps_registrar_deinit(hapd->wps_registrar);
}
+
+
+int hostapd_wps_add_pin(struct hostapd_data *hapd, const char *uuid,
+ const char *pin)
+{
+ u8 u[UUID_LEN];
+ if (uuid_str2bin(uuid, u))
+ return -1;
+ return wps_registrar_add_pin(hapd->wps_registrar, u,
+ (const u8 *) pin, os_strlen(pin));
+}
diff --git a/hostapd/wps_hostapd.h b/hostapd/wps_hostapd.h
index 02d8a70..6497c75 100644
--- a/hostapd/wps_hostapd.h
+++ b/hostapd/wps_hostapd.h
@@ -20,6 +20,8 @@
int hostapd_init_wps(struct hostapd_data *hapd,
struct hostapd_bss_config *conf);
void hostapd_deinit_wps(struct hostapd_data *hapd);
+int hostapd_wps_add_pin(struct hostapd_data *hapd, const char *uuid,
+ const char *pin);
#else /* CONFIG_WPS */