#include <ctype.h>
#include "cmd_wl.h"
#include "wl_cm.h"
#include "console.h"
#include "wl_util.h"
#include "util.h"
#include "lwip/netif.h"
Go to the source code of this file.
Defines | |
#define | MAX_KEY_LEN 64 |
Functions | |
static uint8_t | ascii_to_key (char *outp, const char *inp) |
cmd_state_t | cmd_connect (int argc, char *argv[], void *ctx) |
cmd_state_t | cmd_power (int argc, char *argv[], void *ctx) |
cmd_state_t | cmd_psconf (int argc, char *argv[], void *ctx) |
cmd_state_t | cmd_scan (int argc, char *argv[], void *ctx) |
cmd_state_t | cmd_setkey (int argc, char *argv[], void *ctx) |
cmd_state_t | cmd_status (int argc, char *argv[], void *ctx) |
#define MAX_KEY_LEN 64 |
static uint8_t ascii_to_key | ( | char * | outp, | |
const char * | inp | |||
) | [static] |
Definition at line 256 of file cmd_wl.c.
References MAX_KEY_LEN, and printk().
Referenced by cmd_setkey(), and gui_connect_cb().
00256 { 00257 char buf[3]; 00258 int len; 00259 buf[2] = '\0'; 00260 len = strlen(inp); 00261 if (len % 2) { 00262 printk("Invalid length\n"); 00263 } 00264 len = 0; 00265 while (*inp) { 00266 if (! isxdigit(*inp) || ! isxdigit(*(inp+1)) || 00267 len > MAX_KEY_LEN) { 00268 return 0; 00269 } 00270 buf[0] = *inp++; 00271 buf[1] = *inp++; 00272 *outp++ = strtol(buf, NULL, 16); 00273 len++; 00274 } 00275 return len; 00276 }
cmd_state_t cmd_connect | ( | int | argc, | |
char * | argv[], | |||
void * | ctx | |||
) |
Definition at line 57 of file cmd_wl.c.
References CMD_DONE, printk(), and wl_cm_set_network().
Referenced by wl_init_complete_cb().
00058 { 00059 struct wl_ssid_t ssid; 00060 char* desired_ssid; 00061 00062 if (argc < 2) { 00063 printk("usage: connect <ssid>\n"); 00064 return CMD_DONE; 00065 } 00066 00067 desired_ssid = argv[1]; 00068 00069 if (strlen(desired_ssid) > WL_SSID_MAX_LENGTH) { 00070 printk("ssid too long (max 32)\n"); 00071 return CMD_DONE; 00072 } 00073 00074 memcpy(ssid.ssid, desired_ssid, WL_SSID_MAX_LENGTH); 00075 ssid.len = strlen(desired_ssid); 00076 wl_cm_set_network(&ssid, NULL); 00077 return CMD_DONE; 00078 }
cmd_state_t cmd_power | ( | int | argc, | |
char * | argv[], | |||
void * | ctx | |||
) |
Definition at line 187 of file cmd_wl.c.
References CMD_DONE, and printk().
Referenced by wl_init_complete_cb().
00188 { 00189 const char *usage = "usage: powersave <on|off>\n"; 00190 00191 if (argc < 2) { 00192 printk(usage); 00193 return CMD_DONE; 00194 } 00195 00196 if (!strcmp(argv[1], "on")) { 00197 if (wl_enable_ps() != WL_SUCCESS) { 00198 printk("could not enable power save\n"); 00199 return CMD_DONE; 00200 } 00201 return CMD_DONE; 00202 } 00203 else if(!strcmp(argv[1], "off")) { 00204 if (wl_disable_ps() != WL_SUCCESS) { 00205 printk("could not disable power save\n"); 00206 return CMD_DONE; 00207 } 00208 return CMD_DONE; 00209 } 00210 00211 printk(usage); 00212 return CMD_DONE; 00213 }
cmd_state_t cmd_psconf | ( | int | argc, | |
char * | argv[], | |||
void * | ctx | |||
) |
Definition at line 220 of file cmd_wl.c.
References CMD_DONE, and printk().
Referenced by wl_init_complete_cb().
00221 { 00222 const char *usage = 00223 "usage: psconf <use_ps_poll> (0/1 default 0)\n" \ 00224 " <traffic_timeout> ([ms] default 10)\n" \ 00225 " <ps_delay> ([ms] default 5000)\n"; 00226 00227 uint8_t use_ps_poll; 00228 uint32_t traffic_timeout; 00229 uint32_t ps_delay; 00230 00231 if (argc < 4) { 00232 printk(usage); 00233 return CMD_DONE; 00234 } 00235 00236 use_ps_poll = atoi(argv[1]); 00237 traffic_timeout = atoi(argv[2]); 00238 ps_delay = atoi(argv[3]); 00239 00240 if (use_ps_poll > 1) { 00241 printk(usage); 00242 return CMD_DONE; 00243 } 00244 00245 if (wl_conf_ps(use_ps_poll, traffic_timeout, ps_delay) != WL_SUCCESS) 00246 printk("configuration failed\n"); 00247 00248 return CMD_DONE; 00249 }
cmd_state_t cmd_scan | ( | int | argc, | |
char * | argv[], | |||
void * | ctx | |||
) |
Definition at line 42 of file cmd_wl.c.
References CMD_DONE, and print_network_list().
Referenced by wl_init_complete_cb().
00043 { 00044 /* Note that the scan results presented will 00045 * be from the last scan, not this one. 00046 */ 00047 wl_scan(); 00048 print_network_list(); 00049 return CMD_DONE; 00050 }
cmd_state_t cmd_setkey | ( | int | argc, | |
char * | argv[], | |||
void * | ctx | |||
) |
Definition at line 283 of file cmd_wl.c.
References ascii_to_key(), CMD_DONE, and printk().
Referenced by wl_init_complete_cb().
00284 { 00285 int idx, len; 00286 char key[13]; 00287 struct wl_mac_addr_t bssid; 00288 const char *usage = "usage: setkey <key_idx (0-3)> <key in hex>\n\t "\ 00289 "or: setkey none\n"; 00290 00291 memset(&bssid.octet, 0xff, sizeof bssid.octet); 00292 if (argc == 2 && strcmp(argv[1], "none") == 0) { 00293 printk("Deleting WEP keys\n"); 00294 wl_set_auth_mode(AUTH_MODE_OPEN_SYSTEM); 00295 wl_delete_wep_key(0, &bssid); 00296 wl_delete_wep_key(1, &bssid); 00297 wl_delete_wep_key(2, &bssid); 00298 wl_delete_wep_key(3, &bssid); 00299 return CMD_DONE; 00300 } 00301 if (argc < 3) { 00302 printk(usage); 00303 return CMD_DONE; 00304 } 00305 idx = atoi(argv[1]); 00306 len = ascii_to_key(key, argv[2]); 00307 if (0 == len || idx > 3 || idx < 0 || (idx == 0 && *argv[1] != '0')) { 00308 printk(usage); 00309 return CMD_DONE; 00310 } 00311 if (len != 5 && len != 13) { 00312 printk(" WEP key must be 10 (WEP-40) or 26 (WEP-104) digits\n"); 00313 return CMD_DONE; 00314 } 00315 wl_add_wep_key(idx, len, key, &bssid); 00316 wl_set_auth_mode(AUTH_MODE_SHARED_KEY); 00317 wl_set_default_wep_key(idx); 00318 00319 return CMD_DONE; 00320 }
cmd_state_t cmd_status | ( | int | argc, | |
char * | argv[], | |||
void * | ctx | |||
) |
Definition at line 151 of file cmd_wl.c.
References CMD_DONE, ip2str(), mac2str(), print_network(), and printk().
Referenced by wl_init_complete_cb().
00152 { 00153 struct wl_network_t* net; 00154 uint8_t mac[WL_MAC_ADDR_LENGTH]; 00155 00156 printk("wl_api version " WL_API_RELEASE_NAME "\n"); 00157 /* print mac address */ 00158 if (wl_get_mac_addr(mac) != WL_SUCCESS) { 00159 printk("failed to get mac address\n"); 00160 return CMD_DONE; 00161 } 00162 printk("hw addr: %s\n", mac2str(mac)); 00163 00164 /* print network info */ 00165 net = wl_get_current_network(); 00166 printk("link status: "); 00167 if (!net) { 00168 printk("down\n"); 00169 return CMD_DONE; 00170 } 00171 print_network(net); 00172 00173 /* print ip address */ 00174 if (netif_is_up(netif_default)) 00175 printk("ip addr: %s\n", ip2str(netif_default->ip_addr)); 00176 else 00177 printk("ip addr: none\n"); 00178 00179 return CMD_DONE; 00180 }