⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 survey.c

📁 atmel芯片的Linux驱动程序。很多802.11协议的无限网卡都使用该芯片
💻 C
字号:
/***************************************************************************************	Copyright 2000-2001 ATMEL Corporation.		This file is part of atmel wireless lan drivers.    Atmel wireless lan drivers is free software; you can redistribute it and/or modify    it under the terms of the GNU General Public License as published by    the Free Software Foundation; either version 2 of the License, or    (at your option) any later version.    Atmel wireless lan drivers is distributed in the hope that it will be useful,    but WITHOUT ANY WARRANTY; without even the implied warranty of    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the    GNU General Public License for more details.    You should have received a copy of the GNU General Public License    along with Atmel wireless lan drivers; if not, write to the Free Software    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA**************************************************************************************/#define CALLER_SURVEY#include "vnet.h"#include "strdefs.h"#undef CALLER_SURVEYvoid StartSiteSurvey(int fd, char *cname){	BSS_INFO_EX AP[MAX_BSS_ENTRIES];	int n_APs, ApIndex=0;	WINDOW *APs_virtual_win=NULL;	do {		wclear(justa_win); 		box(justa_win, 0, 0);		wrefresh(justa_win);		refresh();		if(Set_Site_Syrvey(fd, cname)<0) { // return 0 on success			ErrorWin("Site Survey Failed"); 			break;		}			n_APs = Get_APs(AP, fd, cname);		if (n_APs > LINES) n_APs = LINES;		APs_virtual_win = Print_APs(AP, n_APs);		ApIndex = APSelector(n_APs, APs_virtual_win);	} while(ApIndex == -1); // -1 returned by APSelector on Rescan	wclear(justa_win); 	destroy_win(justa_win); // release allocated memory for justa	delwin(APs_virtual_win);	justa_win = NULL; // indicating that window has been delwinned	if (ApIndex)  {		DEVICE_CONFIGURATION pAppInfo;		STATISTICS Stats;		ENCRYPTION_INFO pEncryptionInfo;		SelectAPbyIndex(ApIndex, cname, fd);		// Wait a bit for changes to take effect and Display Statistics Window		sleep(2);		set_win = create_newwin(WINHEIGHT, WIDTH, 6, 0); 		Get_Stats(&Stats, fd, cname);		Get_Config(&pAppInfo, fd, cname);		Print_Stats(set_win, &pAppInfo, &pEncryptionInfo, &Stats);		wrefresh(set_win);		refresh();	}}void SelectAPbyIndex(int ApIndex, char *cname, int fd){    struct iwreq wrq;	      strcpy(wrq.ifr_name, cname);    wrq.u.data.length = sizeof(int);    wrq.u.data.pointer= (caddr_t)&ApIndex;    wrq.u.data.flags = SELECT_AP_BY_INDEX;    ioctl(fd, SIOCDEVPRIVATE, &wrq);}WINDOW * Print_APs(BSS_INFO_EX *Ap, int ApSFound){  int bsindex, i;      WINDOW *apswin = newwin(ApSFound, WIDTH-4, 0, 2);    HEADER( justa_win, "Select AP to become Associated with" )	WATTR( justa_win, COLOR_PAIR(2), 	  	mvwprintw(justa_win, 3, 3, "Number of APs found:"); )	WATTR( justa_win, COLOR_PAIR(3),       mvwprintw(justa_win, 3, 25, "%d", ApSFound); )	WATTR( justa_win, COLOR_PAIR(1),       mvwhline(justa_win, 8, 1, ' ', WIDTH-2); 	  	mvwprintw(justa_win, 5, 8, "BSSID"); 	  	mvwprintw(justa_win, 5, 33, "SSID"); //	  	mvwprintw(justa_win, 5, 54, "SIG"); 	  	mvwprintw(justa_win, 5, 55, "CH"); // 60	  	mvwprintw(justa_win, 5, 60, "WEP"); // 64	  	mvwprintw(justa_win, 5, 67, "Mode "); //69      CENTER(justa_win, WINHEIGHT-2, "<F1> to Exit, <F6> to Rescan") )      mvwhline(justa_win, 4, 1, ACS_HLINE, WIDTH-2);       mvwhline(justa_win, 6, 1, ACS_HLINE, WIDTH-2);    //init_pair(45, COLOR_CYAN, COLOR_BLACK);      WATTR( apswin, COLOR_PAIR(4),     if (1)  // RADIO IS ON ? NOT CHECKED       for (i=0; i<ApSFound; i++) {	        bsindex=0;        //  BSSID        mvwprintw(apswin, i, bsindex, "%02X:%02X:%02X:%02X:%02X:%02X",          Ap[i].BSSID[0], Ap[i].BSSID[1], Ap[i].BSSID[2], Ap[i].BSSID[3], Ap[i].BSSID[4], Ap[i].BSSID[5]);        bsindex += 20;        //  SSID        memset(Ap[i].SSID + Ap[i].SSIDsize, ' ', 32 - Ap[i].SSIDsize);        mvwprintw(apswin, i, bsindex, "%.32s", Ap[i].SSID);        bsindex += 33;                // SIGNAL STRENGTH//        mvwprintw(apswin, i, bsindex, "%3.0f%%", Ap[i].RSSI>39 ? 100: Ap[i].RSSI * 2.5);	/*        mvwprintw(apswin, i, bsindex, "     ");         bsindex += 5;        */  	          // CHANNEL INFO        mvwprintw(apswin, i, bsindex, "%2d", Ap[i].Channel);         bsindex += 4;                                                                      // TO WEP OR NOT TO WEP        mvwprintw(apswin, i, bsindex, " %s ", nychoice[Ap[i].UsingWEP] );        bsindex += 6;                                                       // OPERATING MODE.... (AD_HOC or INFRASTRUCTURE)        mvwprintw(apswin, i, bsindex, " %.8s", opermode[Ap[i].BSStype-1] );        } ) // COLOR_PAIR(45)        mvwvline(apswin, 0, 18, ACS_VLINE, ApSFound);  //        mvwvline(apswin, 0, 51, ACS_VLINE, ApSFound);          mvwvline(apswin, 0, 51, ACS_VLINE, ApSFound);  // 56        mvwvline(apswin, 0, 56, ACS_VLINE, ApSFound);  // 61        mvwvline(apswin, 0, 62, ACS_VLINE, ApSFound);  // 65        wrefresh(justa_win);        return apswin;}int APSelector(int max, WINDOW *apswin){	int selection, realindex, mask;	register int i;	chtype purline[WIDTH-3]; // pure :) line, unchanged.	chtype curline[WIDTH-3]; // current highlighted line, with mask applied	WINDOW *toscroll;	selection=realindex=0;	mask = A_BLINK | A_REVERSE | COLOR_PAIR(4); 	toscroll= newwin(9, WIDTH-4, 13, 2);	memset(curline, 0, WIDTH-3);	//init_pair(45, COLOR_CYAN, COLOR_BLACK);	for(i=0; i<9 && i<max; i++) {		mvwinchnstr(apswin, i, 0, purline, WIDTH-4);		mvwaddchnstr(toscroll, i, 0, purline, WIDTH-4);	}	keypad(toscroll, TRUE);	scrollok(toscroll, TRUE);	wrefresh(toscroll);	mvwinchnstr(apswin, realindex, 0, purline, WIDTH-4);	for (i=0; i<WIDTH-4; i++) curline[i] = purline[i] | mask;	mvwaddchnstr(toscroll, selection, 0, curline, WIDTH-4);	//    wrefresh(justa_win);	//    refresh();	for(;;) {		switch(wgetch(toscroll)) {		case KEY_UP:		if(realindex) { // is there anything upwards to show?			if(selection) { // simply change higlighted line, or scroll?				mvwaddchnstr(toscroll, selection--, 0, purline, WIDTH-4);				mvwinchnstr(apswin, --realindex, 0, purline, WIDTH-4);				for (i=0; i<WIDTH-4; i++) curline[i] = purline[i] | mask;				mvwaddchnstr(toscroll, selection, 0, curline, WIDTH-4);			}			else {				mvwaddchnstr(toscroll, 0, 0, purline, WIDTH-4);				wscrl(toscroll, -1);				mvwinchnstr(apswin, --realindex, 0, purline, WIDTH-4);				for (i=0; i<WIDTH-4; i++) curline[i] = purline[i] | mask;				mvwaddchnstr(toscroll, 0, 0, curline, WIDTH-4);			}		}		break;		case KEY_DOWN:		if(realindex < max-1) { // is there anything downwards to show?			if(selection < 8) { // simply change higlighted line, or scroll?				mvwaddchnstr(toscroll, selection++, 0, purline, WIDTH-4);				mvwinchnstr(apswin, ++realindex, 0, purline, WIDTH-4);				for (i=0; i<WIDTH-4; i++) curline[i] = purline[i] | mask;				mvwaddchnstr(toscroll, selection, 0, curline, WIDTH-4);		  	}			else {				mvwaddchnstr(toscroll, 8, 0, purline, WIDTH-4);				wscrl(toscroll, 1);				mvwinchnstr(apswin, ++realindex, 0, purline, WIDTH-4);				for (i=0; i<WIDTH-4; i++) curline[i] = purline[i] | mask;				mvwaddchnstr(toscroll, 8, 0, curline, WIDTH-4);			}		}		break;		case KEY_F(1):			destroy_win(toscroll);			return 0;		case KEY_F(6):			destroy_win(toscroll);			return -1;		case 10:			destroy_win(toscroll);			if(max) return realindex+1;			else return -1;		default:			break;		}	}}int Set_Site_Syrvey(int fd, char *cname){	struct iwreq wrq;	HEADER( justa_win, "Site Survey in Progress" )	WATTR( justa_win, COLOR_PAIR(1)|A_BLINK, 	CENTER(justa_win, WINHEIGHT-2, "Scanning...")) 	wrefresh(justa_win);	refresh();	strcpy(wrq.ifr_name, cname);	(void)ioctl(fd, SIOCSIWSCAN, &wrq);	sleep(2);	return 0;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -