00001 00016 #include "includes.h" 00017 00018 #include "hostapd.h" 00019 #include "ieee802_1x.h" 00020 #include "wpa.h" 00021 #include "ieee802_11.h" 00022 #include "sta_info.h" 00023 #include "wps_hostapd.h" 00024 #include "ctrl_iface_ap.h" 00025 00026 00027 static int hostapd_ctrl_iface_sta_mib(struct hostapd_data *hapd, 00028 struct sta_info *sta, 00029 char *buf, size_t buflen) 00030 { 00031 int len, res, ret; 00032 00033 if (sta == NULL) { 00034 ret = os_snprintf(buf, buflen, "FAIL\n"); 00035 if (ret < 0 || (size_t) ret >= buflen) 00036 return 0; 00037 return ret; 00038 } 00039 00040 len = 0; 00041 ret = os_snprintf(buf + len, buflen - len, MACSTR "\n", 00042 MAC2STR(sta->addr)); 00043 if (ret < 0 || (size_t) ret >= buflen - len) 00044 return len; 00045 len += ret; 00046 00047 res = ieee802_11_get_mib_sta(hapd, sta, buf + len, buflen - len); 00048 if (res >= 0) 00049 len += res; 00050 res = wpa_get_mib_sta(sta->wpa_sm, buf + len, buflen - len); 00051 if (res >= 0) 00052 len += res; 00053 res = ieee802_1x_get_mib_sta(hapd, sta, buf + len, buflen - len); 00054 if (res >= 0) 00055 len += res; 00056 res = hostapd_wps_get_mib_sta(hapd, sta->addr, buf + len, 00057 buflen - len); 00058 if (res >= 0) 00059 len += res; 00060 00061 return len; 00062 } 00063 00064 00065 int hostapd_ctrl_iface_sta_first(struct hostapd_data *hapd, 00066 char *buf, size_t buflen) 00067 { 00068 return hostapd_ctrl_iface_sta_mib(hapd, hapd->sta_list, buf, buflen); 00069 } 00070 00071 00072 int hostapd_ctrl_iface_sta(struct hostapd_data *hapd, const char *txtaddr, 00073 char *buf, size_t buflen) 00074 { 00075 u8 addr[ETH_ALEN]; 00076 int ret; 00077 00078 if (hwaddr_aton(txtaddr, addr)) { 00079 ret = os_snprintf(buf, buflen, "FAIL\n"); 00080 if (ret < 0 || (size_t) ret >= buflen) 00081 return 0; 00082 return ret; 00083 } 00084 return hostapd_ctrl_iface_sta_mib(hapd, ap_get_sta(hapd, addr), 00085 buf, buflen); 00086 } 00087 00088 00089 int hostapd_ctrl_iface_sta_next(struct hostapd_data *hapd, const char *txtaddr, 00090 char *buf, size_t buflen) 00091 { 00092 u8 addr[ETH_ALEN]; 00093 struct sta_info *sta; 00094 int ret; 00095 00096 if (hwaddr_aton(txtaddr, addr) || 00097 (sta = ap_get_sta(hapd, addr)) == NULL) { 00098 ret = os_snprintf(buf, buflen, "FAIL\n"); 00099 if (ret < 0 || (size_t) ret >= buflen) 00100 return 0; 00101 return ret; 00102 } 00103 return hostapd_ctrl_iface_sta_mib(hapd, sta->next, buf, buflen); 00104 } 00105