Added WirelessManager, a port of wpa_supplicant.
[AROS.git] / workbench / network / WirelessManager / src / ap / ctrl_iface_ap.c
blobe50b0a70ca95d546303cc7f657f285d7c8cb9f93
1 /*
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
10 * license.
12 * See README and COPYING for more details.
15 #include "utils/includes.h"
17 #include "utils/common.h"
18 #include "hostapd.h"
19 #include "ieee802_1x.h"
20 #include "wpa_auth.h"
21 #include "ieee802_11.h"
22 #include "sta_info.h"
23 #include "wps_hostapd.h"
24 #include "ctrl_iface_ap.h"
27 static int hostapd_ctrl_iface_sta_mib(struct hostapd_data *hapd,
28 struct sta_info *sta,
29 char *buf, size_t buflen)
31 int len, res, ret;
33 if (sta == NULL) {
34 ret = os_snprintf(buf, buflen, "FAIL\n");
35 if (ret < 0 || (size_t) ret >= buflen)
36 return 0;
37 return ret;
40 len = 0;
41 ret = os_snprintf(buf + len, buflen - len, MACSTR "\n",
42 MAC2STR(sta->addr));
43 if (ret < 0 || (size_t) ret >= buflen - len)
44 return len;
45 len += ret;
47 res = ieee802_11_get_mib_sta(hapd, sta, buf + len, buflen - len);
48 if (res >= 0)
49 len += res;
50 res = wpa_get_mib_sta(sta->wpa_sm, buf + len, buflen - len);
51 if (res >= 0)
52 len += res;
53 res = ieee802_1x_get_mib_sta(hapd, sta, buf + len, buflen - len);
54 if (res >= 0)
55 len += res;
56 res = hostapd_wps_get_mib_sta(hapd, sta->addr, buf + len,
57 buflen - len);
58 if (res >= 0)
59 len += res;
61 return 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)
75 u8 addr[ETH_ALEN];
76 int ret;
78 if (hwaddr_aton(txtaddr, addr)) {
79 ret = os_snprintf(buf, buflen, "FAIL\n");
80 if (ret < 0 || (size_t) ret >= buflen)
81 return 0;
82 return ret;
84 return hostapd_ctrl_iface_sta_mib(hapd, ap_get_sta(hapd, addr),
85 buf, buflen);
89 int hostapd_ctrl_iface_sta_next(struct hostapd_data *hapd, const char *txtaddr,
90 char *buf, size_t buflen)
92 u8 addr[ETH_ALEN];
93 struct sta_info *sta;
94 int ret;
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)
100 return 0;
101 return ret;
103 return hostapd_ctrl_iface_sta_mib(hapd, sta->next, buf, buflen);