Changeset 10677
- Timestamp:
- 10/28/08 22:31:27 (5 years ago)
- Location:
- src/router/wiviz2
- Files:
-
- 1 added
- 5 edited
-
Makefile (modified) (1 diff)
-
channelhopper.c (modified) (3 diffs)
-
wireless.h (added)
-
wiviz.c (modified) (11 diffs)
-
wl_access.c (modified) (2 diffs)
-
wl_access.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
src/router/wiviz2/Makefile
r10676 r10677 21 21 CCOPTS += -I$(SRCBASE)/include.v23 -L../shared -L../nvram -L../libutils 22 22 endif 23 24 23 ifeq ($(CONFIG_MADWIFI),y) 24 CCOPTS+=-DHAVE_MADWIFI -DNEED_PRINTF -I../shared -include $(TOP)/madwifi.dev/madwifi.dev/include/compat.h -DHEADERS_KERNEL 25 endif 25 26 26 27 wiviz: ${OBJS} -
src/router/wiviz2/channelhopper.c
r10676 r10677 3 3 #include <signal.h> 4 4 #include <sys/time.h> 5 #ifdef HAVE_MADWIFI 6 #include <sys/mman.h> 7 #include <stdio.h> 8 #include <unistd.h> 9 #include <signal.h> 10 #include <fcntl.h> 11 12 #include <sys/types.h> 13 #include <sys/file.h> 14 #include <sys/ioctl.h> 15 #include <sys/socket.h> 16 17 #include <stdio.h> 18 #include <stdlib.h> 19 #include <string.h> 20 #include <stdint.h> 21 #include <ctype.h> 22 #include <getopt.h> 23 #include <err.h> 24 25 #include <ctype.h> 26 #include <string.h> 27 #include <stdlib.h> 28 #include <stdio.h> 29 #include <bcmnvram.h> 30 #include <bcmutils.h> 31 #include <shutils.h> 32 #include <utils.h> 33 #include <unistd.h> 34 #include "wireless.h" 35 #endif 5 36 #include "wl_access.h" 6 37 #include "channelhopper.h" 7 38 #include "structs.h" 39 8 40 9 41 void ch_sig_handler(int i) { … … 11 43 } 12 44 45 #define IEEE80211_CHAN_2GHZ 1 46 #define IEEE80211_CHAN_5GHZ 2 47 u_int ieee80211_ieee2mhz(u_int chan, u_int flags) 48 { 49 if (flags & IEEE80211_CHAN_2GHZ) { /* 2GHz band */ 50 if (chan == 14) 51 return 2484; 52 if (chan < 14) 53 return ((2407) + chan * 5); 54 else { 55 if (chan > 236 && chan < 256) { 56 //recalculate offset 57 int newchan = chan - 256; 58 int newfreq = (2407) + (newchan * 5); 59 return newfreq; 60 } else 61 return ((2512) + ((chan - 15) * 20)); 62 } 63 } else if (flags & IEEE80211_CHAN_5GHZ) /* 5Ghz band */ 64 return ((5000) + (chan * 5)); 65 else { /* either, guess */ 66 if (chan == 14) 67 return 2484; 68 if (chan < 14) /* 0-13 */ 69 return ((2407) + chan * 5); 70 if (chan < 27) /* 15-26 */ 71 return ((2512) + ((chan - 15) * 20)); 72 if (chan > 236 && chan < 256) { 73 //recalculate offset 74 int newchan = chan - 256; 75 int newfreq = (2407) + (newchan * 5); 76 return newfreq; 77 } else 78 return ((5000) + (chan * 5)); 79 } 80 } 81 82 83 void set_channel(char *dev,int channel) 84 { 85 struct iwreq wrq; 86 memset( &wrq, 0, sizeof( struct iwreq ) ); 87 strncpy( wrq.ifr_name, get_monitor(), IFNAMSIZ ); 88 wrq.u.freq.m = (double) ieee80211_ieee2mhz(channel,1) * 100000; 89 wrq.u.freq.e = (double) 1; 90 91 if( ioctl( getsocket(), SIOCSIWFREQ, &wrq ) < 0 ) 92 { 93 usleep( 10000 ); /* madwifi needs a second chance */ 94 95 if( ioctl( getsocket(), SIOCSIWFREQ, &wrq ) < 0 ) 96 { 97 return; 98 } 99 } 100 101 } 13 102 void channelHopper(wiviz_cfg * cfg) { 14 103 int hopPos; … … 25 114 hopPos = (hopPos + 1) % cfg->channelHopSeqLen; 26 115 //Set the channel 27 fprintf(stderr, "It sets the channel to %i\n", nc);28 116 #ifdef HAVE_MADWIFI 29 sysprintf("iwconfig %s channel %d\n",wl_dev,nc);117 set_channel(get_wdev(),nc); 30 118 #else 31 119 wl_ioctl(get_wdev(), WLC_SET_CHANNEL, &nc, 4); -
src/router/wiviz2/wiviz.c
r10676 r10677 14 14 #include <linux/if_packet.h> 15 15 #include <linux/if_ether.h> 16 #include <sys/mman.h> 17 #include <stdio.h> 18 #include <unistd.h> 19 #include <signal.h> 20 #include <fcntl.h> 21 22 #include <sys/types.h> 23 #include <sys/file.h> 24 #include <sys/ioctl.h> 25 #include <sys/socket.h> 26 27 #include <stdio.h> 28 #include <stdlib.h> 29 #include <string.h> 30 #include <stdint.h> 31 #include <ctype.h> 32 #include <getopt.h> 33 #include <err.h> 34 35 #include <ctype.h> 36 #include <string.h> 37 #include <stdlib.h> 38 #include <stdio.h> 39 #include <bcmnvram.h> 40 #include <bcmutils.h> 41 #include <shutils.h> 42 #include <utils.h> 43 #include <unistd.h> 16 44 17 45 #define HOST_TIMEOUT 300 … … 81 109 } 82 110 111 #else 112 sysprintf("wlanconfig %s create wlandev %s wlanmode monitor",get_monitor(),getWifi(get_wdev())); 113 sysprintf("ifconfig %s up",get_monitor()); 114 cfg.readFromWl = 1; 83 115 #endif 84 116 reloadConfig(); 85 117 86 118 #ifdef HAVE_MADWIFI 87 s = openMonitorSocket( "mon0"); // for testing we use ath0119 s = openMonitorSocket(get_monitor()); // for testing we use ath0 88 120 #else 89 121 s = openMonitorSocket("prism0"); … … 126 158 #ifndef HAVE_MADWIFI 127 159 wl_ioctl(wl_dev, WLC_SET_MONITOR, &oldMonitor, 4); 128 #endif 129 160 #else 161 sysprintf("ifconfig %s down",get_monitor()); 162 sysprintf("wlanconfig %s destroy",get_monitor()); 163 #endif 130 164 close(s); 131 165 return 0; … … 265 299 if (cfg->readFromWl) { 266 300 #ifdef HAVE_MADWIFI 267 sysprintf("iwconfig %s channel %d\n",wl_dev,cfg->curChannel); 301 set_channel(wl_dev,cfg->curChannel); 302 // sysprintf("iwconfig %s channel %d\n",wl_dev,cfg->curChannel); 268 303 #else 269 304 if (wl_ioctl(wl_dev, WLC_SET_CHANNEL, &cfg->curChannel, 4) < 0) { … … 325 360 void dealWithPacket(wiviz_cfg * cfg, int pktlen, const u_char * packet) { 326 361 ieee802_11_hdr * hWifi; 327 prism_hdr * hPrism;328 362 wiviz_host * host; 329 363 wiviz_host * emergebss; … … 332 366 int rssi = 0; 333 367 int to_ds, from_ds; 334 prism_did * i;335 368 ieee_802_11_tag * e; 336 369 ieee_802_11_mgt_frame * m; … … 343 376 u_char ssidlen = 0; 344 377 ap_enc_type encType = aetUnknown; 345 346 378 if (!packet) return; 379 380 #ifdef HAVE_MADWIFI 381 int noise; 382 if (packet[0]>0) 383 { 384 printf( "Wrong radiotap header version.\n" ); 385 return; 386 } 387 int number = packet[2] | (unsigned int)((unsigned int)packet[3]<<8); 388 if (number<=0 || number>=pktlen) 389 { 390 printf("something wrong %d\n",number); 391 return; 392 } 393 noise = packet[number-3]; 394 rssi = -(100-(packet[number-4]-noise)); 395 hWifi = (ieee802_11_hdr *) (packet + (number)); 396 #else 397 prism_hdr * hPrism; 398 prism_did * i; 347 399 if (pktlen < sizeof(prism_hdr) + sizeof(ieee802_11_hdr)) return; 400 348 401 hPrism = (prism_hdr *) packet; 349 402 hWifi = (ieee802_11_hdr *) (packet + (hPrism->msg_length)); … … 355 408 i = (prism_did *) ((int)(i+1) + i->length); 356 409 } 410 #endif 357 411 358 412 //Establish the frame type 359 413 wfType = ((hWifi->frame_control & 0xF0) >> 4) + ((hWifi->frame_control & 0xC) << 2); 414 360 415 switch (wfType) { 361 416 case mgt_assocRequest: … … 519 574 if (!h->occupied) { 520 575 printf( "New host, "); 521 //fprint_mac(stderr, mac, ", type=");576 fprint_mac(stdout, mac, ", type="); 522 577 printf( "%s\n", (type==typeAP) ? "AP" : ((type==typeSta) ? "Sta" : "Unk")); 523 578 } … … 600 655 get_mac(wl_dev, mac); 601 656 printf( "AP mac: "); 602 //print_mac(mac, "\n");657 print_mac(mac, "\n"); 603 658 if (!nonzeromac(mac)) return; 604 659 if (nvram_nmatch("ap","%s_mode",wl_dev)) … … 631 686 macs = (maclist_t *) malloc(4 + MAX_STA_COUNT * sizeof(ether_addr_t)); 632 687 macs->count = MAX_STA_COUNT; 633 if (getassoclist(wl_dev,macs)>-1) 688 int code = getassoclist(wl_dev,macs); 689 printf("code :%d\n",code); 690 if (code>0) 634 691 { 635 692 for (i = 0; i < macs->count; i++) { -
src/router/wiviz2/wl_access.c
r10676 r10677 5 5 #include <sys/ioctl.h> 6 6 #include <net/if.h> 7 #include <sys/mman.h> 8 #include <stdio.h> 9 #include <unistd.h> 10 #include <signal.h> 11 #include <fcntl.h> 12 13 #include <sys/types.h> 14 #include <sys/file.h> 15 #include <sys/ioctl.h> 16 #include <sys/socket.h> 17 18 #include <stdio.h> 19 #include <stdlib.h> 20 #include <string.h> 21 #include <stdint.h> 22 #include <ctype.h> 23 #include <getopt.h> 24 #include <err.h> 25 26 #include <ctype.h> 27 #include <string.h> 28 #include <stdlib.h> 29 #include <stdio.h> 30 #include <bcmnvram.h> 31 #include <bcmutils.h> 32 #include <shutils.h> 33 #include <utils.h> 34 #include <unistd.h> 7 35 8 36 #include "wl_access.h" … … 33 61 return ret; 34 62 } 63 #else 64 65 66 char *get_monitor(void) 67 { 68 int devcount; 69 char *ifname = get_wdev(); 70 sscanf( ifname, "ath%d", &devcount ); 71 static char mon[32]; 72 sprintf(mon,"mon%d",devcount); 73 return mon; 74 } 35 75 #endif 36 76 -
src/router/wiviz2/wl_access.h
r5179 r10677 2 2 3 3 4 typedef unsigned int uint32;5 typedef unsigned char uchar;6 typedef int bool;7 4 8 5 typedef struct ether_addr {
Note: See TracChangeset
for help on using the changeset viewer.
