2 * Control interface for shared AP commands
3 * Copyright (c) 2004-2009, Jouni Malinen <j@w1.fi>
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation.
9 * Alternatively, this software may be distributed under the terms of BSD
12 * See README and COPYING for more details.
15 #include "utils/includes.h"
17 #include "utils/common.h"
19 #include "ieee802_1x.h"
21 #include "ieee802_11.h"
23 #include "wps_hostapd.h"
24 #include "ctrl_iface_ap.h"
27 static int hostapd_ctrl_iface_sta_mib(struct hostapd_data *hapd,
29 char *buf, size_t buflen)
34 ret = os_snprintf(buf, buflen, "FAIL\n");
35 if (ret < 0 || (size_t) ret >= buflen)
41 ret = os_snprintf(buf + len, buflen - len, MACSTR "\n",
43 if (ret < 0 || (size_t) ret >= buflen - len)
47 res = ieee802_11_get_mib_sta(hapd, sta, buf + len, buflen - len);
50 res = wpa_get_mib_sta(sta->wpa_sm, buf + len, buflen - len);
53 res = ieee802_1x_get_mib_sta(hapd, sta, buf + len, buflen - len);
56 res = hostapd_wps_get_mib_sta(hapd, sta->addr, buf + len,
65 int hostapd_ctrl_iface_sta_first(struct hostapd_data *hapd,
66 char *buf, size_t buflen)
68 return hostapd_ctrl_iface_sta_mib(hapd, hapd->sta_list, buf, buflen);
72 int hostapd_ctrl_iface_sta(struct hostapd_data *hapd, const char *txtaddr,
73 char *buf, size_t buflen)
78 if (hwaddr_aton(txtaddr, addr)) {
79 ret = os_snprintf(buf, buflen, "FAIL\n");
80 if (ret < 0 || (size_t) ret >= buflen)
84 return hostapd_ctrl_iface_sta_mib(hapd, ap_get_sta(hapd, addr),
89 int hostapd_ctrl_iface_sta_next(struct hostapd_data *hapd, const char *txtaddr,
90 char *buf, size_t buflen)
96 if (hwaddr_aton(txtaddr, addr) ||
97 (sta = ap_get_sta(hapd, addr)) == NULL) {
98 ret = os_snprintf(buf, buflen, "FAIL\n");
99 if (ret < 0 || (size_t) ret >= buflen)
103 return hostapd_ctrl_iface_sta_mib(hapd, sta->next, buf, buflen);