00001 00028 #include "top_defs.h" 00029 #include "wl_util.h" 00030 #include <stdio.h> 00031 #include <errno.h> 00032 #include <string.h> 00033 00034 int equal_ssid(const struct wl_ssid_t* ssid1, 00035 const struct wl_ssid_t* ssid2) { 00036 if (ssid1->len == ssid2->len && 00037 (memcmp(ssid1->ssid, ssid2->ssid, ssid1->len) == 0)) { 00038 return 1; 00039 } 00040 return 0; 00041 } 00042 00043 int equal_bssid(const struct wl_mac_addr_t* bssid1, 00044 const struct wl_mac_addr_t* bssid2) { 00045 if (memcmp(bssid1, bssid2, sizeof *bssid1) == 0) { 00046 return 1; 00047 } 00048 return 0; 00049 } 00050 00051 const char* ssid2str(struct wl_ssid_t *ssid) { 00052 static char buf[WL_SSID_MAX_LENGTH + 1]; 00053 00054 memset(buf, 0, sizeof buf); 00055 memcpy(buf, ssid->ssid, ssid->len); 00056 00057 return buf; 00058 } 00059 00060 00061 const char* mac2str(uint8_t* mac) 00062 { 00063 static char buf[18] ALIGN; 00064 sniprintf(buf, sizeof(buf), "%02x-%02x-%02x-%02x-%02x-%02x", 00065 mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]); 00066 return buf; 00067 } 00068 00069 00070 char* enc_type2str(enum wl_enc_type enc_type) 00071 { 00072 switch(enc_type) { 00073 case ENC_TYPE_WEP: 00074 return "WEP"; 00075 case ENC_TYPE_CCMP: 00076 return "CCMP"; 00077 case ENC_TYPE_TKIP: 00078 return "TKIP"; 00079 default: 00080 return ""; 00081 }; 00082 }