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 "p2p_hostapd.h"
25 #include "ctrl_iface_ap.h"
28 static int hostapd_ctrl_iface_sta_mib(struct hostapd_data *hapd,
30 char *buf, size_t buflen)
35 ret = os_snprintf(buf, buflen, "FAIL\n");
36 if (ret < 0 || (size_t) ret >= buflen)
42 ret = os_snprintf(buf + len, buflen - len, MACSTR "\n",
44 if (ret < 0 || (size_t) ret >= buflen - len)
48 res = ieee802_11_get_mib_sta(hapd, sta, buf + len, buflen - len);
51 res = wpa_get_mib_sta(sta->wpa_sm, buf + len, buflen - len);
54 res = ieee802_1x_get_mib_sta(hapd, sta, buf + len, buflen - len);
57 res = hostapd_wps_get_mib_sta(hapd, sta->addr, buf + len,
61 res = hostapd_p2p_get_mib_sta(hapd, sta, buf + len, buflen - len);
69 int hostapd_ctrl_iface_sta_first(struct hostapd_data *hapd,
70 char *buf, size_t buflen)
72 return hostapd_ctrl_iface_sta_mib(hapd, hapd->sta_list, buf, buflen);
76 int hostapd_ctrl_iface_sta(struct hostapd_data *hapd, const char *txtaddr,
77 char *buf, size_t buflen)
82 if (hwaddr_aton(txtaddr, addr)) {
83 ret = os_snprintf(buf, buflen, "FAIL\n");
84 if (ret < 0 || (size_t) ret >= buflen)
88 return hostapd_ctrl_iface_sta_mib(hapd, ap_get_sta(hapd, addr),
93 int hostapd_ctrl_iface_sta_next(struct hostapd_data *hapd, const char *txtaddr,
94 char *buf, size_t buflen)
100 if (hwaddr_aton(txtaddr, addr) ||
101 (sta = ap_get_sta(hapd, addr)) == NULL) {
102 ret = os_snprintf(buf, buflen, "FAIL\n");
103 if (ret < 0 || (size_t) ret >= buflen)
107 return hostapd_ctrl_iface_sta_mib(hapd, sta->next, buf, buflen);