2 * Control interface for shared AP commands
3 * Copyright (c) 2004-2009, Jouni Malinen <j@w1.fi>
5 * This software may be distributed under the terms of the BSD license.
6 * See README for more details.
9 #include "utils/includes.h"
11 #include "utils/common.h"
13 #include "ieee802_1x.h"
15 #include "ieee802_11.h"
17 #include "wps_hostapd.h"
18 #include "p2p_hostapd.h"
19 #include "ctrl_iface_ap.h"
22 static int hostapd_ctrl_iface_sta_mib(struct hostapd_data *hapd,
24 char *buf, size_t buflen)
29 ret = os_snprintf(buf, buflen, "FAIL\n");
30 if (ret < 0 || (size_t) ret >= buflen)
36 ret = os_snprintf(buf + len, buflen - len, MACSTR "\n",
38 if (ret < 0 || (size_t) ret >= buflen - len)
42 res = ieee802_11_get_mib_sta(hapd, sta, buf + len, buflen - len);
45 res = wpa_get_mib_sta(sta->wpa_sm, buf + len, buflen - len);
48 res = ieee802_1x_get_mib_sta(hapd, sta, buf + len, buflen - len);
51 res = hostapd_wps_get_mib_sta(hapd, sta->addr, buf + len,
55 res = hostapd_p2p_get_mib_sta(hapd, sta, buf + len, buflen - len);
63 int hostapd_ctrl_iface_sta_first(struct hostapd_data *hapd,
64 char *buf, size_t buflen)
66 return hostapd_ctrl_iface_sta_mib(hapd, hapd->sta_list, buf, buflen);
70 int hostapd_ctrl_iface_sta(struct hostapd_data *hapd, const char *txtaddr,
71 char *buf, size_t buflen)
76 if (hwaddr_aton(txtaddr, addr)) {
77 ret = os_snprintf(buf, buflen, "FAIL\n");
78 if (ret < 0 || (size_t) ret >= buflen)
82 return hostapd_ctrl_iface_sta_mib(hapd, ap_get_sta(hapd, addr),
87 int hostapd_ctrl_iface_sta_next(struct hostapd_data *hapd, const char *txtaddr,
88 char *buf, size_t buflen)
94 if (hwaddr_aton(txtaddr, addr) ||
95 (sta = ap_get_sta(hapd, addr)) == NULL) {
96 ret = os_snprintf(buf, buflen, "FAIL\n");
97 if (ret < 0 || (size_t) ret >= buflen)
101 return hostapd_ctrl_iface_sta_mib(hapd, sta->next, buf, buflen);