/******************************************************************************* Function: void iwconfigDisplayStatus(void) Summary: Responds to the user invoking iwconfig with no parameters Description: Responds to the user invoking iwconfig with no parameters Parameters: None. Returns: None Remarks: None. *****************************************************************************/ static void iwconfigDisplayStatus(void) { UINT8 *p; UINT8 tmp; UINT8 connectionState; UINT8 cpId; #if defined(MRF24WG) char buf[6]; #endif union { struct { UINT8 List[WF_CHANNEL_LIST_LENGTH]; UINT8 Num; } Channel; UINT8 Domain; struct { UINT8 String[WF_MAX_SSID_LENGTH+1]; UINT8 Len; } Ssid; struct { UINT8 NetworkType; } Mode; struct { UINT16 Threshold; } Rts; } ws; // workspace // cpId { WFConsolePrintRomStr("\tcpid: ", FALSE); WFConsolePrintInteger(iwconfigCb.cpId, 'd'); WFConsolePrintRomStr("", TRUE); } // channel { WF_CAGetChannelList(ws.Channel.List, &ws.Channel.Num); WFConsolePrintRomStr("\tchannel: ", FALSE); p = ws.Channel.List; tmp = ws.Channel.Num; while ( --tmp > 0u ) { WFConsolePrintInteger(*p, 'd'); WFConsolePrintRomStr(",", FALSE); p++; } WFConsolePrintInteger(*p, 'd'); WFConsolePrintRomStr("", TRUE); } #if defined(MRF24WG) // domain { WF_GetRegionalDomain(&ws.Domain); WFConsolePrintRomStr("\tdomain: ", FALSE); if ( ws.Domain == WF_DOMAIN_FCC ) { WFConsolePrintRomStr("fcc", TRUE); } else if ( ws.Domain == WF_DOMAIN_ETSI ) { WFConsolePrintRomStr("etsi", TRUE); } else if ( ws.Domain == WF_DOMAIN_JAPAN ) { WFConsolePrintRomStr("japan", TRUE); } else if ( ws.Domain == WF_DOMAIN_OTHER ) { WFConsolePrintRomStr("other", TRUE); } else { WFConsolePrintRomStr("unknown", TRUE); } } #else // domain { WF_GetRegionalDomain(&ws.Domain); WFConsolePrintRomStr("\tdomain: ", FALSE); if ( ws.Domain == WF_DOMAIN_FCC ) { WFConsolePrintRomStr("fcc", TRUE); } else if ( ws.Domain == WF_DOMAIN_IC ) { WFConsolePrintRomStr("ic", TRUE); } else if ( ws.Domain == WF_DOMAIN_ETSI ) { WFConsolePrintRomStr("etsi", TRUE); } else if ( ws.Domain == WF_DOMAIN_SPAIN ) { WFConsolePrintRomStr("spain", TRUE); } else if ( ws.Domain == WF_DOMAIN_FRANCE ) { WFConsolePrintRomStr("france", TRUE); } else if ( ws.Domain == WF_DOMAIN_JAPAN_A ) { WFConsolePrintRomStr("japana", TRUE); } else if ( ws.Domain == WF_DOMAIN_JAPAN_B ) { WFConsolePrintRomStr("japanb", TRUE); } else { WFConsolePrintRomStr("unknown", TRUE); } } #endif // rts { WF_GetRtsThreshold(&ws.Rts.Threshold); WFConsolePrintRomStr("\trts: ", FALSE); WFConsolePrintInteger(ws.Rts.Threshold, 'd'); WFConsolePrintRomStr("", TRUE); } // mode { WF_CMGetConnectionState(&connectionState, &cpId); WF_CPGetNetworkType(iwconfigCb.cpId, &ws.Mode.NetworkType); WFConsolePrintRomStr("\tmode: ", FALSE); if (iwconfigCb.isIdle) { if (iwconfigCb.connState == WF_CSTATE_NOT_CONNECTED) { WFConsolePrintRomStr("idle", TRUE); } else if (iwconfigCb.connState == WF_CSTATE_CONNECTION_PERMANENTLY_LOST) { WFConsolePrintRomStr("idle (connection permanently lost)", TRUE); } else { WFConsolePrintRomStr("idle (?)", TRUE); } } else { WF_CPGetNetworkType(iwconfigCb.cpId, &ws.Mode.NetworkType); if (ws.Mode.NetworkType == WF_INFRASTRUCTURE) { if (iwconfigCb.connState == WF_CSTATE_CONNECTION_IN_PROGRESS) { WFConsolePrintRomStr("managed (connection in progress)", TRUE); } else if (iwconfigCb.connState == WF_CSTATE_CONNECTED_INFRASTRUCTURE) { WFConsolePrintRomStr("managed", TRUE); } else if (iwconfigCb.connState == WF_CSTATE_RECONNECTION_IN_PROGRESS) { WFConsolePrintRomStr("managed (reconnection in progress)", TRUE); } else { WFConsolePrintRomStr("managed (?)", TRUE); } } else if (ws.Mode.NetworkType == WF_ADHOC) { if (iwconfigCb.connState == WF_CSTATE_CONNECTION_IN_PROGRESS) { WFConsolePrintRomStr("adhoc (connection in progress)", TRUE); } else if (iwconfigCb.connState == WF_CSTATE_CONNECTED_ADHOC) { WFConsolePrintRomStr("adhoc", TRUE); } else if (iwconfigCb.connState == WF_CSTATE_RECONNECTION_IN_PROGRESS) { WFConsolePrintRomStr("adhoc (reconnection in progress)", TRUE); } else { WFConsolePrintRomStr("adhoc (?)", TRUE); } } else { WFConsolePrintRomStr("unknown", TRUE); } } } // ssid { WF_CPGetSsid(iwconfigCb.cpId, ws.Ssid.String, &ws.Ssid.Len); ws.Ssid.String[ws.Ssid.Len] = '\0'; WFConsolePrintRomStr("\tssid: ", FALSE); WFConsolePrintRamStr(ws.Ssid.String, TRUE); } // power { switch (iwconfigCb.powerSaveState) { case WF_PS_PS_POLL_DTIM_ENABLED: WFConsolePrintRomStr("\tpwrsave: enabled", TRUE); WFConsolePrintRomStr("\tdtim rx: enabled", TRUE); break; case WF_PS_PS_POLL_DTIM_DISABLED: WFConsolePrintRomStr("\tpwrsave: enabled", TRUE); WFConsolePrintRomStr("\tdtim rx: disabled", TRUE); break; case WF_PS_OFF: WFConsolePrintRomStr("\tpwrsave: disabled", TRUE); break; default: WFConsolePrintRomStr("\tpwrsave: unknown(", FALSE); WFConsolePrintInteger(iwconfigCb.powerSaveState, 'd'); WFConsolePrintRomStr(")", TRUE); break; } } #if defined(MRF24WG) // context WF_OutputConnectionContext(); // Network Type putrsUART("\tNetwork: "); #if defined(EZ_CONFIG_STORE) && !defined(WF_CONSOLE_DEMO) /* if EZConfig demo */ if (AppConfig.networkType == WF_ADHOC) { putrsUART("AdHoc\r\n"); } else { putrsUART("Infrastructure\r\n"); } #else #if (MY_DEFAULT_NETWORK_TYPE == WF_ADHOC) putrsUART("AdHoc\r\n"); #elif (MY_DEFAULT_NETWORK_TYPE == WF_P2P) putrsUART("P2P\r\n"); #elif (MY_DEFAULT_NETWORK_TYPE == WF_INFRASTRUCTURE) #if (MY_DEFAULT_WIFI_SECURITY_MODE == WF_SECURITY_WPS_PUSH_BUTTON) putrsUART("Infrastructure (using WPS Push Button)\r\n"); #elif (MY_DEFAULT_WIFI_SECURITY_MODE == WF_SECURITY_WPS_PIN) putrsUART("Infrastructure (using WPS Pin)\r\n"); #else putrsUART("Infrastructure\r\n"); #endif #endif #endif /* EZ_CONFIG_STORE */ // Retry Count putrsUART("\tRetries "); #if (MY_DEFAULT_NETWORK_TYPE == WF_ADHOC) sprintf(buf, "%d\r\n", ADHOC_RETRY_COUNT); putsUART(buf); #elif (MY_DEFAULT_NETWORK_TYPE == WF_INFRASTRUCTURE) #if (INFRASTRUCTURE_RETRY_COUNT == WF_RETRY_FOREVER) sprintf(buf, "Retry Forever\r\n"); putsUART(buf); #else sprintf(buf, "%d\r\n", INFRASTRUCTURE_RETRY_COUNT); putsUART(buf); #endif #endif /* (MY_DEFAULT_NETWORK_TYPE == WF_ADHOC) */ // Security putrsUART("\tSecurity: "); #if (MY_DEFAULT_WIFI_SECURITY_MODE == WF_SECURITY_OPEN) putrsUART("WF_SECURITY_OPEN"); #elif (MY_DEFAULT_WIFI_SECURITY_MODE == WF_SECURITY_WEP_40) putrsUART("WF_SECURITY_WEP_40"); #elif (MY_DEFAULT_WIFI_SECURITY_MODE == WF_SECURITY_WEP_104) putrsUART("WF_SECURITY_WEP_104"); #elif (MY_DEFAULT_WIFI_SECURITY_MODE == WF_SECURITY_WPA_WITH_KEY) putrsUART("WF_SECURITY_WPA_WITH_KEY"); #elif (MY_DEFAULT_WIFI_SECURITY_MODE == WF_SECURITY_WPA_WITH_PASS_PHRASE) putrsUART("WF_SECURITY_WPA_WITH_PASS_PHRASE"); #elif (MY_DEFAULT_WIFI_SECURITY_MODE == WF_SECURITY_WPA2_WITH_KEY) putrsUART("WF_SECURITY_WPA2_WITH_KEY"); #elif (MY_DEFAULT_WIFI_SECURITY_MODE == WF_SECURITY_WPA2_WITH_PASS_PHRASE) putrsUART("WF_SECURITY_WPA2_WITH_PASS_PHRASE"); #elif (MY_DEFAULT_WIFI_SECURITY_MODE == WF_SECURITY_WPA_AUTO_WITH_KEY) putrsUART("WF_SECURITY_WPA_AUTO_WITH_KEY"); #elif (MY_DEFAULT_WIFI_SECURITY_MODE == WF_SECURITY_WPA_AUTO_WITH_PASS_PHRASE) putrsUART("WF_SECURITY_WPA_AUTO_WITH_PASS_PHRASE"); #elif (MY_DEFAULT_WIFI_SECURITY_MODE == WF_SECURITY_WPS_PUSH_BUTTON) putrsUART("WF_SECURITY_WPS_PUSH_BUTTON"); #elif (MY_DEFAULT_WIFI_SECURITY_MODE == WF_SECURITY_WPS_PIN) putrsUART("WF_SECURITY_WPS_PIN"); #else putrsUART("Unknown"); #endif putrsUART("\r\n"); // scan type putrsUART("\tScan: "); #if (MY_DEFAULT_SCAN_TYPE == WF_ACTIVE_SCAN) putrsUART("Active Scan\r\n"); #else putrsUART("Passive Scan\r\n"); #endif // MAC address putrsUART("\tMAC: "); OutputMacAddress(); #endif /* MRF24WG */ }
static void notHandledParam(uint8_t index) { WFConsolePrintRomStr("Param ", false); WFConsolePrintInteger(index, 'd'); WFConsolePrintRomStr(" not handled", true); }
static void iwprivDisplayStatus(void) { UINT8 i, j; UINT8* p; // security type { WFConsolePrintRomStr("Encryption: ", FALSE); switch (iwprivCb.securityType) { case WF_SECURITY_OPEN: WFConsolePrintRomStr("none", TRUE); break; case WF_SECURITY_WEP_40: case WF_SECURITY_WEP_104: WFConsolePrintRomStr("wep", TRUE); break; case WF_SECURITY_WPA_WITH_KEY: case WF_SECURITY_WPA2_WITH_KEY: case WF_SECURITY_WPA_AUTO_WITH_KEY: WFConsolePrintRomStr("wpa-psk", TRUE); break; case WF_SECURITY_WPA_WITH_PASS_PHRASE: case WF_SECURITY_WPA2_WITH_PASS_PHRASE: case WF_SECURITY_WPA_AUTO_WITH_PASS_PHRASE: WFConsolePrintRomStr("wpa-phrase", TRUE); break; default: WFConsolePrintRomStr("unknown", TRUE); return; } } if ( iwprivCb.securityType == WF_SECURITY_WEP_40 || iwprivCb.securityType == WF_SECURITY_WEP_104 ) { UINT8 webKeyLen; if ( iwprivCb.securityKeyLength == (IWPRIV_WEB_KEY_NUM * IWPRIV_WEB_LONG_KEY_LEN) ) { webKeyLen = IWPRIV_WEB_LONG_KEY_LEN; } else if ( iwprivCb.securityKeyLength == (IWPRIV_WEB_KEY_NUM * IWPRIV_WEB_SHORT_KEY_LEN) ) { webKeyLen = IWPRIV_WEB_SHORT_KEY_LEN; } else { WFConsolePrintRomStr(" Wep key: not yet set or unknown", TRUE); return; } p = iwprivCb.securityKey; for( j=0; j < IWPRIV_WEB_KEY_NUM ; j++ ) { if ( j == iwprivCb.wepDefaultKeyId ) WFConsolePrintRomStr(" *", FALSE); else WFConsolePrintRomStr(" ", FALSE); WFConsolePrintRomStr("Wep key[", FALSE); WFConsolePrintInteger(j+1, FALSE); WFConsolePrintRomStr("]: 0x", FALSE); for ( i=0; i < webKeyLen ; i++ ) { sprintf( (char *) g_ConsoleContext.txBuf, "%.2x", *p++); WFConsolePrintRamStr( (char *) g_ConsoleContext.txBuf, FALSE); } WFConsolePrintRomStr("", TRUE); } } else if ( iwprivCb.securityType == WF_SECURITY_WPA_AUTO_WITH_KEY ) { if ( iwprivCb.securityKeyLength != WF_WPA_KEY_LENGTH ) { WFConsolePrintRomStr(" PSK: not yet set or unknown", TRUE); return; } putrsUART(" PSK: \""); p = iwprivCb.securityKey; for( j=0; j < WF_WPA_KEY_LENGTH ; j++ ) { sprintf( (char *) g_ConsoleContext.txBuf, "%.2x", *p++); WFConsolePrintRamStr( (char *) g_ConsoleContext.txBuf , FALSE ); } WFConsolePrintRomStr("", TRUE); } else if ( iwprivCb.securityType == WF_SECURITY_WPA_AUTO_WITH_PASS_PHRASE ) { if ( iwprivCb.securityKeyLength == 0 ) { WFConsolePrintRomStr(" Phrase: not yet set or unknown", TRUE); return; } WFConsolePrintRomStr(" Phrase: \"", FALSE); p = iwprivCb.securityKey; for( j=0; j < iwprivCb.securityKeyLength ; j++ ) { sprintf( (char *) g_ConsoleContext.txBuf, "%c", *p++); WFConsolePrintRamStr( (char *) g_ConsoleContext.txBuf, FALSE ); } WFConsolePrintRomStr("\"", TRUE); WFConsolePrintRomStr(" SSID: ", FALSE); WFConsolePrintRamStr(iwprivCb.ssid, TRUE); } }
static void notHandledParam(UINT8 index) { WFConsolePrintRomStr("Param ", FALSE); WFConsolePrintInteger(index, 'd'); WFConsolePrintRomStr(" not handled", TRUE); }
/***************************************************************************** * FUNCTION: iwprivDisplayStatus * * RETURNS: none * * PARAMS: none * * NOTES: Display security mode status * Valid security mode: * Open * WEP40 * WEP104 * WPA-PSK/WPA2-PSK Auto with Key * WPA-PSK/WPA2-PSK Auto with Passphrase *****************************************************************************/ static void iwprivDisplayStatus(void) { uint8_t i, j; uint8_t * p; // security type { WFConsolePrintRomStr("Encryption: ", false); switch (iwprivCb.securityType) { case WF_SECURITY_OPEN: WFConsolePrintRomStr("Open", true); break; case WF_SECURITY_WEP_40: WFConsolePrintRomStr("WEP40", true); break; case WF_SECURITY_WEP_104: WFConsolePrintRomStr("WEP104", true); break; case WF_SECURITY_WPA_AUTO_WITH_KEY: WFConsolePrintRomStr("WPA-PSK/WPA2-PSK Auto with Key", true); break; case WF_SECURITY_WPA_AUTO_WITH_PASS_PHRASE: WFConsolePrintRomStr("WPA-PSK/WPA2-PSK Auto with Passphrase", true); break; default: WFConsolePrintRomStr("Unknown", true); return; } } if ( iwprivCb.securityType == WF_SECURITY_WEP_40 || iwprivCb.securityType == WF_SECURITY_WEP_104 ) { uint8_t webKeyLen; if ( iwprivCb.securityKeyLength == (IWPRIV_WEB_KEY_NUM * IWPRIV_WEB_LONG_KEY_LEN) ) { webKeyLen = IWPRIV_WEB_LONG_KEY_LEN; } else if ( iwprivCb.securityKeyLength == (IWPRIV_WEB_KEY_NUM * IWPRIV_WEB_SHORT_KEY_LEN) ) { webKeyLen = IWPRIV_WEB_SHORT_KEY_LEN; } else { WFConsolePrintRomStr(" WEP Key: not yet set or unknown", true); return; } p = iwprivCb.securityKey; for (j = 0; j < IWPRIV_WEB_KEY_NUM; j++) { if (j == iwprivCb.wepDefaultKeyId ) WFConsolePrintRomStr(" *", false); else WFConsolePrintRomStr(" ", false); WFConsolePrintRomStr("WEP Key[", false); WFConsolePrintInteger(j + 1, false); WFConsolePrintRomStr("]: 0x", false); for (i = 0; i < webKeyLen ; i++) { sprintf( (char *) g_ConsoleContext.txBuf, "%.2x", *p++); WFConsolePrintRamStr((char *) g_ConsoleContext.txBuf, false); } WFConsolePrintRomStr("", true); } } else if ( iwprivCb.securityType == WF_SECURITY_WPA_AUTO_WITH_KEY ) { if ( iwprivCb.securityKeyLength != WF_WPA_KEY_LENGTH ) { WFConsolePrintRomStr(" PSK: not yet set or unknown", true); return; } putrsUART(" PSK: \""); p = iwprivCb.securityKey; for (j = 0; j < WF_WPA_KEY_LENGTH; j++) { sprintf( (char *) g_ConsoleContext.txBuf, "%.2x", *p++); WFConsolePrintRamStr( (char *) g_ConsoleContext.txBuf , false ); } WFConsolePrintRomStr("", true); } else if ( iwprivCb.securityType == WF_SECURITY_WPA_AUTO_WITH_PASS_PHRASE ) { if ( iwprivCb.securityKeyLength == 0 ) { WFConsolePrintRomStr(" Passphrase: not yet set or unknown", true); return; } WFConsolePrintRomStr(" Passphrase: \"", false); p = iwprivCb.securityKey; for (j = 0; j < iwprivCb.securityKeyLength; j++ ) { sprintf( (char *) g_ConsoleContext.txBuf, "%c", *p++); WFConsolePrintRamStr( (char *) g_ConsoleContext.txBuf, false ); } WFConsolePrintRomStr("\"", true); WFConsolePrintRomStr(" SSID: ", false); WFConsolePrintRamStr(iwprivCb.ssid, true); } }