util.h File Reference

#include "lwip/ip.h"

Go to the source code of this file.

Functions

char * ip2str (struct ip_addr addr)
void print_network (struct wl_network_t *wl_network)
void print_network_list (void)
struct ip_addr str2ip (const char *str)


Function Documentation

char* ip2str ( struct ip_addr  addr  ) 

Definition at line 35 of file util.c.

Referenced by cmd_ping(), cmd_status(), document_index_html_cb(), gui_status_up_cb(), ip_status_cb(), ping_recv(), and print_stats().

00036 {
00037         static char buf[16];
00038         sniprintf(buf, sizeof(buf), "%lu.%lu.%lu.%lu",
00039                  (addr.addr >> 24) & 0xff,
00040                  (addr.addr >> 16) & 0xff,
00041                  (addr.addr >> 8) & 0xff,
00042                  (addr.addr) & 0xff);
00043         return buf;
00044 }

void print_network ( struct wl_network_t *  wl_network  ) 

Definition at line 64 of file util.c.

References mac2str(), and printk().

Referenced by cmd_status(), and print_network_list().

00065 {
00066         char ssid[WL_SSID_MAX_LENGTH + 1];
00067         printk("%s ", mac2str(wl_network->bssid.octet));
00068         memset(ssid, 0, sizeof(ssid));
00069         if (wl_network->ssid.len) {
00070                 strncpy(ssid, wl_network->ssid.ssid, wl_network->ssid.len);
00071                 printk("\"%s\"", ssid);
00072         }
00073         else {
00074                 printk("\"\"");
00075         }
00076         printk(" RSSI %d dBm ", wl_network->rssi);
00077         switch (wl_network->enc_type) {
00078         case ENC_TYPE_WEP :
00079                 printk(" (WEP encryption)");
00080                 break;
00081         case ENC_TYPE_TKIP :
00082                 printk(" (TKIP encryption)");
00083                 break;
00084         case ENC_TYPE_CCMP :
00085                 printk(" (CCMP encryption)");
00086                 break;
00087         case ENC_TYPE_NONE :
00088                 break;
00089         }
00090         printk("\n");
00091 }

void print_network_list ( void   ) 

Definition at line 93 of file util.c.

References print_network(), and printk().

Referenced by cmd_scan().

00094 {
00095         struct wl_network_t* wl_network_list;
00096         uint8_t wl_network_cnt, i;
00097         
00098         wl_get_network_list(&wl_network_list, &wl_network_cnt);
00099         if (wl_network_cnt == 0)
00100                 printk("no nets found\n");
00101 
00102         for (i = 0; i < wl_network_cnt; i++)
00103                 print_network(&wl_network_list[i]);
00104 }

struct ip_addr str2ip ( const char *  str  )  [read]

Definition at line 46 of file util.c.

References str.

Referenced by cmd_ttcp(), and init_ping_info().

00047 {
00048         int a,b,c,d;
00049         uint32_t ip = 0;
00050 
00051         if (siscanf(str,"%d.%d.%d.%d",&a,&b,&c,&d) != 4)
00052                 goto out;
00053 
00054         if (a < 0 || a > 255 || b < 0 || b > 255 ||
00055             c < 0 || c > 255 || d < 0 || d > 255)
00056                 goto out;
00057         
00058         ip = (a << 24) | (b << 16) | (c << 8) | d;
00059 
00060  out:
00061         return *(struct ip_addr*) &ip;
00062 }


Generated on Thu Dec 17 19:57:55 2009 for AVR32 - H&D by  doxygen 1.5.5