1 /* 2 * Common driver-related functions 3 * Copyright (c) 2003-2011, Jouni Malinen <j (at) w1.fi> 4 * 5 * This software may be distributed under the terms of the BSD license. 6 * See README for more details. 7 */ 8 9 #include "includes.h" 10 #include "utils/common.h" 11 #include "driver.h" 12 13 void wpa_scan_results_free(struct wpa_scan_results *res) 14 { 15 size_t i; 16 17 if (res == NULL) 18 return; 19 20 for (i = 0; i < res->num; i++) 21 os_free(res->res[i]); 22 os_free(res->res); 23 os_free(res); 24 } 25 26 27 const char * event_to_string(enum wpa_event_type event) 28 { 29 #define E2S(n) case EVENT_ ## n: return #n 30 switch (event) { 31 E2S(ASSOC); 32 E2S(DISASSOC); 33 E2S(MICHAEL_MIC_FAILURE); 34 E2S(SCAN_RESULTS); 35 E2S(ASSOCINFO); 36 E2S(INTERFACE_STATUS); 37 E2S(PMKID_CANDIDATE); 38 E2S(STKSTART); 39 E2S(TDLS); 40 E2S(FT_RESPONSE); 41 E2S(IBSS_RSN_START); 42 E2S(AUTH); 43 E2S(DEAUTH); 44 E2S(ASSOC_REJECT); 45 E2S(AUTH_TIMED_OUT); 46 E2S(ASSOC_TIMED_OUT); 47 E2S(FT_RRB_RX); 48 E2S(WPS_BUTTON_PUSHED); 49 E2S(TX_STATUS); 50 E2S(RX_FROM_UNKNOWN); 51 E2S(RX_MGMT); 52 E2S(REMAIN_ON_CHANNEL); 53 E2S(CANCEL_REMAIN_ON_CHANNEL); 54 E2S(MLME_RX); 55 E2S(RX_PROBE_REQ); 56 E2S(NEW_STA); 57 E2S(EAPOL_RX); 58 E2S(SIGNAL_CHANGE); 59 E2S(INTERFACE_ENABLED); 60 E2S(INTERFACE_DISABLED); 61 E2S(CHANNEL_LIST_CHANGED); 62 E2S(INTERFACE_UNAVAILABLE); 63 E2S(BEST_CHANNEL); 64 E2S(UNPROT_DEAUTH); 65 E2S(UNPROT_DISASSOC); 66 E2S(STATION_LOW_ACK); 67 E2S(IBSS_PEER_LOST); 68 E2S(DRIVER_GTK_REKEY); 69 E2S(SCHED_SCAN_STOPPED); 70 E2S(DRIVER_CLIENT_POLL_OK); 71 E2S(EAPOL_TX_STATUS); 72 E2S(CH_SWITCH); 73 E2S(WNM); 74 E2S(CONNECT_FAILED_REASON); 75 E2S(DFS_RADAR_DETECTED); 76 E2S(DFS_CAC_FINISHED); 77 E2S(DFS_CAC_ABORTED); 78 E2S(DFS_NOP_FINISHED); 79 E2S(SURVEY); 80 E2S(SCAN_STARTED); 81 E2S(AVOID_FREQUENCIES); 82 } 83 84 return "UNKNOWN"; 85 #undef E2S 86 } 87 88 89 const char * channel_width_to_string(enum chan_width width) 90 { 91 switch (width) { 92 case CHAN_WIDTH_20_NOHT: 93 return "20 MHz (no HT)"; 94 case CHAN_WIDTH_20: 95 return "20 MHz"; 96 case CHAN_WIDTH_40: 97 return "40 MHz"; 98 case CHAN_WIDTH_80: 99 return "80 MHz"; 100 case CHAN_WIDTH_80P80: 101 return "80+80 MHz"; 102 case CHAN_WIDTH_160: 103 return "160 MHz"; 104 default: 105 return "unknown"; 106 } 107 } 108