aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJouni Malinen <j@w1.fi>2006-07-23 17:15:04 (GMT)
committerJouni Malinen <j@w1.fi>2006-07-23 17:15:04 (GMT)
commitb592b6a397ae8c282386e6ab2c9f3d265916a99e (patch)
tree96fe365723c9aab21a44a4166a85e6df708da7d9
parent2105f2c4688e39f5c2c2f4ed9e29cb5c4caac51c (diff)
downloadhostap-history-b592b6a397ae8c282386e6ab2c9f3d265916a99e.zip
hostap-history-b592b6a397ae8c282386e6ab2c9f3d265916a99e.tar.gz
hostap-history-b592b6a397ae8c282386e6ab2c9f3d265916a99e.tar.bz2
Added 'hostapd_cli new_sta <addr>' command for adding a new STA into
hostapd (e.g., to initialize wired network authentication based on an external signal). This is based on the ideas from the patch sent by Alexandre Fenyo <fenyo@fenyo.net>.
-rw-r--r--hostapd/ChangeLog5
-rw-r--r--hostapd/ctrl_iface.c31
-rw-r--r--hostapd/hostapd_cli.c18
3 files changed, 53 insertions, 1 deletions
diff --git a/hostapd/ChangeLog b/hostapd/ChangeLog
index 1410384..e132de0 100644
--- a/hostapd/ChangeLog
+++ b/hostapd/ChangeLog
@@ -1,5 +1,10 @@
ChangeLog for hostapd
+????-??-?? - v0.5.5
+ * added 'hostapd_cli new_sta <addr>' command for adding a new STA into
+ hostapd (e.g., to initialize wired network authentication based on an
+ external signal)
+
2006-06-20 - v0.5.4
* fixed nt_password_hash build [Bug 144]
* added PeerKey handshake implementation for IEEE 802.11e
diff --git a/hostapd/ctrl_iface.c b/hostapd/ctrl_iface.c
index 7439b92..9a4810e 100644
--- a/hostapd/ctrl_iface.c
+++ b/hostapd/ctrl_iface.c
@@ -29,6 +29,7 @@
#include "ieee802_11.h"
#include "ctrl_iface.h"
#include "sta_info.h"
+#include "accounting.h"
struct wpa_ctrl_dst {
@@ -173,6 +174,33 @@ static int hostapd_ctrl_iface_sta_next(struct hostapd_data *hapd,
}
+static int hostapd_ctrl_iface_new_sta(struct hostapd_data *hapd,
+ const char *txtaddr)
+{
+ u8 addr[ETH_ALEN];
+ struct sta_info *sta;
+
+ wpa_printf(MSG_DEBUG, "CTRL_IFACE NEW_STA %s", txtaddr);
+
+ if (hwaddr_aton(txtaddr, addr))
+ return -1;
+
+ sta = ap_get_sta(hapd, addr);
+ if (sta)
+ return 0;
+
+ wpa_printf(MSG_DEBUG, "Add new STA " MACSTR " based on ctrl_iface "
+ "notification", MAC2STR(addr));
+ sta = ap_sta_add(hapd, addr);
+ if (sta == NULL)
+ return -1;
+
+ hostapd_new_assoc_sta(hapd, sta, 0);
+ accounting_sta_get_id(hapd, sta);
+ return 0;
+}
+
+
static void hostapd_ctrl_iface_receive(int sock, void *eloop_ctx,
void *sock_ctx)
{
@@ -253,6 +281,9 @@ static void hostapd_ctrl_iface_receive(int sock, void *eloop_ctx,
if (hostapd_ctrl_iface_level(hapd, &from, fromlen,
buf + 6))
reply_len = -1;
+ } else if (strncmp(buf, "NEW_STA ", 8) == 0) {
+ if (hostapd_ctrl_iface_new_sta(hapd, buf + 8))
+ reply_len = -1;
} else {
memcpy(reply, "UNKNOWN COMMAND\n", 16);
reply_len = 16;
diff --git a/hostapd/hostapd_cli.c b/hostapd/hostapd_cli.c
index cbb99a9..a523d37 100644
--- a/hostapd/hostapd_cli.c
+++ b/hostapd/hostapd_cli.c
@@ -79,8 +79,9 @@ static const char *hostapd_cli_full_license =
static const char *commands_help =
"Commands:\n"
" mib get MIB variables (dot1x, dot11, radius)\n"
-" sta <addr> get MIB vatiables for one station\n"
+" 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"
" help show this usage help\n"
" interface [ifname] show interfaces/select interface\n"
" level <debug level> change debug level\n"
@@ -214,6 +215,20 @@ static int hostapd_cli_cmd_sta(struct wpa_ctrl *ctrl, int argc, char *argv[])
}
+static int hostapd_cli_cmd_new_sta(struct wpa_ctrl *ctrl, int argc,
+ char *argv[])
+{
+ char buf[64];
+ if (argc != 1) {
+ printf("Invalid 'new_sta' command - exactly one argument, STA "
+ "address, is required.\n");
+ return -1;
+ }
+ snprintf(buf, sizeof(buf), "NEW_STA %s", argv[0]);
+ return wpa_ctrl_command(ctrl, buf);
+}
+
+
static int wpa_ctrl_command_sta(struct wpa_ctrl *ctrl, char *cmd,
char *addr, size_t addr_len)
{
@@ -361,6 +376,7 @@ static struct hostapd_cli_cmd hostapd_cli_commands[] = {
{ "mib", hostapd_cli_cmd_mib },
{ "sta", hostapd_cli_cmd_sta },
{ "all_sta", hostapd_cli_cmd_all_sta },
+ { "new_sta", hostapd_cli_cmd_new_sta },
{ "help", hostapd_cli_cmd_help },
{ "interface", hostapd_cli_cmd_interface },
{ "level", hostapd_cli_cmd_level },