static int32_t Shell_ipconfig_task (uint32_t enet_device, uint32_t index, int32_t argc, char *argv[]) { uint32_t error; uint32_t priority; uint32_t period; if (argc > ++index) { if (strcmp (argv[index], "start") == 0) { if (argc > ++index) { if (! Shell_parse_number(argv[index], &priority)) { printf ("Error in task command, invalid priority parameter!\n"); return SHELL_EXIT_ERROR; } } else { printf ("Error in task command, missing priority parameter!\n"); return SHELL_EXIT_ERROR; } if (argc > ++index) { if (! Shell_parse_number(argv[index], &period)) { printf ("Error in task command, invalid priority parameter!\n"); return SHELL_EXIT_ERROR; } } else { printf ("Error in task command, missing period parameter!\n"); return SHELL_EXIT_ERROR; } error = ipcfg_task_create (priority, period); if (error != 0) { printf ("Error in task command, create failed!\n", enet_device, error); return SHELL_EXIT_ERROR; } } else if (strcmp (argv[index], "stop") == 0) { ipcfg_task_destroy (TRUE); } else { printf ("Error in task command, invalid parameter!\n"); return SHELL_EXIT_ERROR; } } printf ("Link status task %s\n", ipcfg_task_status () ? "running" : "stopped"); return SHELL_EXIT_SUCCESS; }
int32_t Shell_ipconfig(int32_t argc, char *argv[] ) { /* Body */ bool print_usage, shorthelp = FALSE; int32_t return_code = SHELL_EXIT_SUCCESS; uint32_t enet_device = BSP_DEFAULT_ENET_DEVICE; uint32_t index = 1; print_usage = Shell_check_help_request (argc, argv, &shorthelp); if (!print_usage) { if (argc > index) { if (Shell_parse_number (argv[index], &enet_device)) { index++; } } if (enet_device >= BSP_ENET_DEVICE_COUNT) { printf ("Wrong number of ethernet device (%d)!\n", enet_device); return_code = SHELL_EXIT_ERROR; } else { if (argc > index) { if (strcmp (argv[index], "init") == 0) { return_code = Shell_ipconfig_init (enet_device, index, argc, argv); } else if (strcmp (argv[index], "release") == 0) { return_code = Shell_ipconfig_release (enet_device, index, argc, argv); } else if (strcmp (argv[index], "task") == 0) { return_code = Shell_ipconfig_task (enet_device, index, argc, argv); } #if RTCSCFG_IPCFG_ENABLE_DNS else if (strcmp (argv[index], "dns") == 0) { return_code = Shell_ipconfig_dns (enet_device, index, argc, argv); } #endif else if (strcmp (argv[index], "ip") == 0) { return_code = Shell_ipconfig_staticip (enet_device, index, argc, argv); } #if RTCSCFG_IPCFG_ENABLE_DHCP else if (strcmp (argv[index], "dhcp") == 0) { return_code = Shell_ipconfig_dhcp (enet_device, index, argc, argv); } #endif #if RTCSCFG_IPCFG_ENABLE_BOOT else if (strcmp (argv[index], "boot") == 0) { return_code = Shell_ipconfig_boot (enet_device); } #endif else if (strcmp (argv[index], "unbind") == 0) { #if RTCSCFG_ENABLE_IP6 #if RTCSCFG_ENABLE_IP4 if(argc > 2) { #endif return_code = Shell_ipconfig_unbind6 (enet_device, index, argc, argv); #if RTCSCFG_ENABLE_IP4 } else { #endif #endif #if RTCSCFG_ENABLE_IP4 return_code = Shell_ipconfig_unbind (enet_device); #endif #if RTCSCFG_ENABLE_IP6 #if RTCSCFG_ENABLE_IP4 } #endif #endif } else if (strcmp (argv[index], "phyinfo") == 0) { return_code = Shell_ipcfg_phy_registers (enet_device); } else { printf ("Unknown ipconfig command!\n"); return_code = SHELL_EXIT_ERROR; } } else { return_code = Shell_ipconfig_status (enet_device); } } } if ((print_usage) || (return_code != SHELL_EXIT_SUCCESS)) { if (shorthelp) { printf ("%s [<device>] [<command>]\n", argv[0]); } else { printf ("Usage: %s [<device>] [<command>]\n", argv[0]); printf (" Commands:\n"); printf (" init [<mac>]\n"); printf (" Initialize ethernet device (once).\n"); printf (" release\n"); printf (" Release ethernet device (once).\n"); printf (" task [start <priority> <period> | stop]\n"); printf (" Manage link status checking task.\n"); #if RTCSCFG_IPCFG_ENABLE_DNS printf (" dns [add <ip> | del <ip>]\n"); printf (" Manage dns ip list.\n"); #endif printf (" ip <ip> <mask> [<gateway>]\n"); printf (" Bind with ip for IPv4. For IPv6 you should put ipv6 address only.\n"); printf (" Like \'ip <ipv6>\' to bind IPv6 address manually.\n"); #if RTCSCFG_IPCFG_ENABLE_DHCP printf (" dhcp [<ipv4> <mask> [<gateway>]]\n"); printf (" Bind with dhcp [use <ip> & <mask> in case dhcp fails].\n"); printf (" Support IPv4 only.\n"); #endif #if RTCSCFG_IPCFG_ENABLE_BOOT printf (" boot\n"); printf (" Bind with boot protocol.\n"); #endif printf (" unbind [<ipv6>]\n"); printf (" Unbind network interface. Using \'unbind\' without parameter\n"); printf (" will unbind IPv4 address from interface. In case IPv6 you should\n"); printf (" use ipv6 address like parameter to unbind it from interface.\n"); printf (" Parameters:\n"); printf (" <device> = Ethernet device number (default %d).\n", BSP_DEFAULT_ENET_DEVICE); printf (" <mac> = Ethernet MAC address.\n" ); printf (" <priority> = Link status task MQX priority.\n"); printf (" <period> = Link status task check period (ms).\n"); printf (" <ip> = IP address to use both familys. \n"); printf (" <ipv4> = IPv4 address to use. \n"); printf (" <ipv6> = IPv6 address to use. \n"); printf (" <mask> = Network mask to use. \n"); printf (" <gateway> = Network gateway to use.\n"); } } return return_code; } /* Endbody */
int32_t Shell_iwconfig(int32_t argc, char *argv[] ) { /* Body */ bool print_usage, shorthelp = FALSE; int32_t return_code = SHELL_EXIT_SUCCESS; uint32_t enet_device = BSP_DEFAULT_ENET_DEVICE, index = 1; SHELL_CONTEXT_PTR shell_ptr = Shell_get_context(argv); print_usage = Shell_check_help_request (argc, argv, &shorthelp); if (!print_usage) { if (argc > index) { if (Shell_parse_number (argv[index], &enet_device)) { index++; } } if (enet_device >= BSP_ENET_DEVICE_COUNT) { fprintf(shell_ptr->STDOUT, "Wrong number of ethernet device (%d)!\n", enet_device); return_code = SHELL_EXIT_ERROR; } else { if (argc > index) { if (strcmp (argv[index], "ssid") == 0) { return_code = Shell_iwconfig_set_ssid(shell_ptr->STDOUT, enet_device,argv[index+1]); } else if (strcmp (argv[index], "mode") == 0) { return_code = Shell_iwconfig_set_mode(shell_ptr->STDOUT, enet_device,argv[index+1]); } else if (strcmp (argv[index], "commit") == 0) { return_code = Shell_iwconfig_commit(shell_ptr->STDOUT, enet_device); } else if (strcmp (argv[index], "key") == 0) { return_code = Shell_iwconfig_set_wep_key(shell_ptr->STDOUT, enet_device,index,argc,argv); } else if (strcmp (argv[index], "sectype") == 0) { return_code = Shell_iwconfig_set_sec_type(shell_ptr->STDOUT, enet_device,argv[index+1]); } else if (strcmp (argv[index], "passphrase") == 0) { return_code = Shell_iwconfig_set_passphrase(shell_ptr->STDOUT, enet_device,argv[index+1]); } else if (strcmp (argv[index], "power") == 0) { return_code = Shell_iwconfig_set_power(shell_ptr->STDOUT, enet_device,index,argc,argv); } else if (strcmp (argv[index], "scan") == 0) { return_code = Shell_iwconfig_set_scan(shell_ptr->STDOUT, enet_device,index,argc,argv); } else if (strcmp (argv[index], "help") == 0) { return_code = SHELL_EXIT_ERROR; } else { fprintf(shell_ptr->STDOUT, "Unknown iwconfig command!\n"); return_code = SHELL_EXIT_ERROR; } } else if (argc == 1) { char data[32]; uint32_t error; error = iwcfg_get_essid (enet_device,(char *)data); if (error != 0) return_code = SHELL_EXIT_ERROR; fprintf(shell_ptr->STDOUT, "ssid=%s\n",data); iwcfg_get_mode (enet_device,(char *)data); fprintf(shell_ptr->STDOUT, "mode=%s\n",data); iwcfg_get_sectype (enet_device,(char *)data); fprintf(shell_ptr->STDOUT, "security type=%s\n",data); if (strcmp(data,"wep") == 0) { uint32_t def_key_index; iwcfg_get_wep_key(enet_device,(char *)data,&def_key_index); fprintf(shell_ptr->STDOUT, "wep key=%s\n",data); fprintf(shell_ptr->STDOUT, "default key index=%d\n",def_key_index); } if (strcmp(data,"wpa") == 0) { unsigned char p_phrase[65]; iwcfg_get_passphrase(enet_device,(char *)p_phrase); fprintf(shell_ptr->STDOUT, " passphrase=%s\n",p_phrase); } if (strcmp(data,"wpa2") == 0) { unsigned char p_phrase[65]; iwcfg_get_passphrase(enet_device,(char *)p_phrase); fprintf(shell_ptr->STDOUT, " passphrase=%s\n",p_phrase); } } } } else { return_code = SHELL_EXIT_ERROR; } if ((print_usage) || (return_code != SHELL_EXIT_SUCCESS)) { if (shorthelp) { fprintf(shell_ptr->STDOUT, "%s [<device>] [<command>]\n", argv[0]); } else { fprintf(shell_ptr->STDOUT, "Use iwconfig commands if Wifi device is initialized\n"); fprintf(shell_ptr->STDOUT, "Usage: %s [<command>]\n", argv[0]); fprintf(shell_ptr->STDOUT, " Commands:\n"); fprintf(shell_ptr->STDOUT, " ssid [<network id>] = Set SSID on device to associate with AP\n"); fprintf(shell_ptr->STDOUT, " mode [<network mode>] = Set network mode on device\n"); fprintf(shell_ptr->STDOUT, " commit = Forces the card to apply all pending changes.\n"); fprintf(shell_ptr->STDOUT, " key [<WEP Key>],[<key index>] = Sets WEP Keys and enables WEP security\n"); fprintf(shell_ptr->STDOUT, " passphrase [<passphrase string>] = Enables WPA2 security and sets the passphrase\n"); fprintf(shell_ptr->STDOUT, " sectype [<security type>]= Sets the Security for WiFi Device \n"); fprintf(shell_ptr->STDOUT, " power [<on>] [<off>] [period] [<value>] = Enables or disables the power mode and sets the sleep duration.\n"); fprintf(shell_ptr->STDOUT, " scan = Scan for Access Points and display there infrmation\n"); fprintf(shell_ptr->STDOUT, " help = Display commands list and parameters.\n"); fprintf(shell_ptr->STDOUT, " Parameters:\n"); fprintf(shell_ptr->STDOUT, " <network id> = name of the wireless network\n"); fprintf(shell_ptr->STDOUT, " <network mode> = type of Wireless network. Possible values: managed or adhoc\n"); fprintf(shell_ptr->STDOUT, " <WEP Key> = WEP Security Key. If set to none, WEP security is disabled.\n"); fprintf(shell_ptr->STDOUT, " <key index> = Four keys can be set as WEP keys.Set index as [1],[2],[3],[4]\n"); fprintf(shell_ptr->STDOUT, " = To change which key is the currently active key, just enter [index]\n"); fprintf(shell_ptr->STDOUT, " = (without entering any key value).\n"); fprintf(shell_ptr->STDOUT, " <security type>= wep,wpa,wpa2 or none\n"); fprintf(shell_ptr->STDOUT, " <passphrase string> = pass phrase string\n"); fprintf(shell_ptr->STDOUT, " <on> = enables power mode\n"); fprintf(shell_ptr->STDOUT, " <off> = disables power mode\n"); fprintf(shell_ptr->STDOUT, " <value> = sleep duration\n"); } } return return_code; } /* Endbody */