📄 cofvnet.c
字号:
}void DisplayDriverState(WINDOW * conf_win, ULONG StatusCode, int mode, ULONG Mgmt){ if ((StatusCode == 0x05) && (mode == 1)) { mvwprintw(conf_win, 7, 1, "Driver State \t\t: Associated "); return; } switch (StatusCode) { case 0x00: mvwprintw(conf_win, 7, 1, "Driver State \t\t: Initializing"); break; case 0x01: mvwprintw(conf_win, 7, 1, "Driver State \t\t: Scanning "); break; case 0x02: mvwprintw(conf_win, 7, 1, "Driver State \t\t: Joining "); break; case 0x03: mvwprintw(conf_win, 7, 1, "Driver State \t\t: Authenticating"); break; case 0x04: mvwprintw(conf_win, 7, 1, "Driver State \t\t: Associating"); break; case 0x05: mvwprintw(conf_win, 7, 1, "Driver State \t\t: Ready"); break; case 0x06: mvwprintw(conf_win, 7, 1, "Driver State \t\t: Station Out of Range"); break; case 0x07: mvwprintw(conf_win, 7, 1, "Driver State \t\t: Disassociating"); break; case 0x08: mvwprintw(conf_win, 7, 1, "Driver State \t\t: Disauthenticating"); break; case 0x09: mvwprintw(conf_win, 7, 1, "Driver State \t\t: Reassociating"); break; case 0x0a: mvwprintw(conf_win, 7, 1, "Driver State \t\t: Forced Joining"); break; case 0x0b: mvwprintw(conf_win, 7, 1, "Driver State \t\t: ReConfiguring"); break; case 0x0c: mvwprintw(conf_win, 7, 1, "Driver State \t\t: FW_Upgrade"); break; case 0x0d: mvwprintw(conf_win, 7, 1, "Driver State \t\t: Force Joining Failure"); break; case 0x0e: mvwprintw(conf_win, 7, 1, "Driver State \t\t: Resetting"); break; case 0x0f: mvwprintw(conf_win, 7, 1, "Driver State \t\t: Reset Pending"); break; case 0x13: mvwprintw(conf_win, 7, 1, "Driver State \t\t: Radio Off"); break; case 0xf0: mvwprintw(conf_win, 7, 1, "Driver State \t\t: No card Present"); break; case 0xf1: if(Mgmt == 0xa0){ mvwprintw(conf_win, 7, 1, "Driver State\t\t\t: Enable Encryption to join this BSS"); }else if(Mgmt == 0xa1){ mvwprintw(conf_win, 7, 1, "Driver State:\t\t\t: Disable Encryption to join this BSS"); }else{ mvwprintw(conf_win, 7, 1, "Driver State \t\t: "); DisplayErrorMsg(conf_win, StatusCode); } break; default: mvwprintw(conf_win, 7, 1, "Driver State \t\t: "); mvwprintw(conf_win, 7, 34, "Not Known yet...... "); }}void DisplayErrorMsg(WINDOW * conf_win, ULONG StatusCode){ switch (StatusCode) { case 1: //C80211_MGMT_SC_Unspecified: mvwprintw(conf_win, 7, 1, "Unspecified error in Management Frame...\n"); break; case 10: //C80211_MGMT_SC_SupportCapabilities: mvwprintw(conf_win, 7, 1, "Support Capabilities error in Association Request..."); break; case 11: //C80211_MGMT_SC_ReassDenied: mvwprintw(conf_win, 7, 1, "Re-Association Denied... \n"); break; case 12: //C80211_MGMT_SC_AssDenied: mvwprintw(conf_win, 7, 1, "Association Denied... \n"); break; case 13: //C80211_MGMT_SC_AuthAlgNotSupported: mvwprintw(conf_win, 7, 1, "Authentication Algorithm not supported..."); break; case 14: //C80211_MGMT_SC_AuthTransSeqNumError: mvwprintw(conf_win, 7, 1, "Bad Authentication transaction sequence number..."); break; case 15: //C80211_MGMT_SC_AuthRejectChallenge: mvwprintw(conf_win, 7, 1, "Authentication challenge text rejection..."); break; case 16: //C80211_MGMT_SC_AuthRejectTimeout: mvwprintw(conf_win, 7, 1, "Authentication Timeout..."); break; case 17: //C80211_MGMT_SC_AssDeniedHandleAP: mvwprintw(conf_win, 7, 1, "Access Point can not handle any more stations..."); break; case 18: //C80211_MGMT_SC_AssDeniedBSSRate: mvwprintw(conf_win, 7, 1, "Association Denied (Supported Rates mismatch)..."); break; default: mvwprintw(conf_win, 7, 1, "Failed to co-operate with the selected Access Point"); }}int open_sock(void){ int inet_sock = -1; int ipx_sock = -1; int ax25_sock = -1; int ddp_sock = -1; inet_sock = socket(AF_INET, SOCK_STREAM, 0); ipx_sock = socket(AF_IPX, SOCK_STREAM, 0); ax25_sock = socket(AF_AX25, SOCK_STREAM, 0); ddp_sock = socket(AF_APPLETALK, SOCK_STREAM, 0); if (inet_sock != -1) return inet_sock; if (ipx_sock != -1) return ipx_sock; if (ax25_sock != -1) return ax25_sock; return ddp_sock;}int startx = 0;int starty = 0;int total;int n_choices = sizeof(choices) / sizeof(char *);int main(int argc, char *argv[]){ WINDOW *menu_win; int highlight = 1; int choice = 0; uid_t uid; int d, sttruth = 0; int fd, i, res; char welcome[WIDTH]; DEVICE_CONFIGURATION pAppInfo; ENCRYPTION_INFO pEncryptionInfo; VERSION_INFO pVersionInfo; STATISTICS Stats; struct iwreq wrq; unsigned char BoardFound = 0; uid = getuid(); if(uid != 0){ printf("You Must Be root to Run lvnet\n"); return -EPERM; } if (argc > 1) { if (strncmp(argv[1], "--help", 6) == 0){ printf("Usage :\n"); printf("\tlvnet [-i] : i equals the interface name. Default atml0\n"); return -1; } } initscr(); clear(); noecho(); cbreak(); start_color(); init_all_pairs(); refresh(); memset(&wrq, 0, sizeof(struct iwreq)); signal(SIGINT, no_quit); for (i = 0; i < n_choices; ++i) { total += strlen(choices[i]); } total = (WIDTH - total) / n_choices;#if 0 if (argc > 1) { if ((strncmp(argv[1], "f", 1) == 0) || (strncmp(argv[1], "-f", 2) == 0)) { read_conf(&str_list); } else if (strncmp(argv[1], "u", 1) == 0) { CardRequested = USB; } else if (strncmp(argv[1], "u", 1) == 0) { CardRequested = PCMCIA; } else { return -1; } return 0; }#endif fd = open_sock(); if (fd < 0) { ErrorWin("No Card Found! Quitting..."); clear(); endwin(); exit(EXIT_FAILURE); } if (COLS<80 || LINES<25) { clear(); endwin(); printf("Sorry, your console doesn't seem to satisfy \n\ \rthe minimum size requirements: 80x25\n"); return -1; } if(argc > 1){ int arglen, c; if (strncmp(argv[1], "-i", 2) == 0) { if(strncmp(argv[2], "atml", 4) == 0){ arglen = strlen(argv[2]); for( c = 4 ; c < arglen; c++) { if (isdigit(argv[2][c]) == 0){ ErrorWin("Invalid Interface"); clear(); endwin(); exit(EXIT_FAILURE); } } strcpy(wrq.ifr_name, argv[2]); BoardFound |= (1 << i); } } } else { for (i = 0; i < 8; i++) { sprintf(ifname, "atml%d", i); strcpy(wrq.ifr_name, ifname); res = ioctl(fd, SIOCGIWNAME, &wrq); if (res < 0) continue; if ((strncmp(wrq.u.name, "ATMEL USB503A", 13) != 0) && (strncmp(wrq.u.name, "ATMEL INTERSIL", 14) != 0) && (strncmp(wrq.u.name, "ATMEL RFMD503A", 14) != 0) && (strncmp(wrq.u.name, "ATMEL RFMD505", 13) != 0) && (strncmp(wrq.u.name, "ATMEL RFMD505A", 14) != 0) && (strncmp(wrq.u.name, "ATMEL MX 505A", 13) != 0) && (strncmp(wrq.u.name, "ATMEL 2958505", 13) != 0) && (strncmp(wrq.u.name, "ATMEL RFMD", 10) != 0) && (strncmp(wrq.u.name, "ATMEL REVD", 10) != 0) && (strncmp(wrq.u.name, "ATMEL REVE", 10) != 0) && (strncmp(wrq.u.name, "ATMEL 504", 9) != 0) && (strncmp(wrq.u.name, "ATMEL 504A", 10) != 0) && (strncmp(wrq.u.name, "ATMEL PCI", 10) != 0) ) continue; BoardFound |= (1 << i); break; } } if (!BoardFound) { ErrorWin("No Atmel Card Found Inserted!"); clear(); endwin(); return -ENODEV; } if (Get_Config(&pAppInfo, fd, wrq.ifr_name) != 0) { ErrorWin("Get Configuration failed..."); clear(); endwin(); return -ENODEV; } if (Get_Stats(&Stats, fd, wrq.ifr_name)) { ErrorWin("Get Statistics failed..."); clear(); endwin(); return -ENODEV; } if (Get_Wep(&pEncryptionInfo, fd, wrq.ifr_name)) { ErrorWin("Get Wep Info Failed..."); clear(); endwin(); return -ENODEV; } if (Get_Ver(&pVersionInfo, fd, wrq.ifr_name)) { ErrorWin("Get Version failed..."); clear(); endwin(); return -ENODEV; } //startx = (90 - WIDTH) / 2; //starty = (9 - HEIGHT) / 2; startx = 0; starty = 3; menu_win = newwin(HEIGHT, WIDTH, starty, startx); keypad(menu_win, TRUE); keypad(stdscr, TRUE); attron(A_BOLD); menu_win = newwin(HEIGHT, WIDTH, starty, startx); keypad(menu_win, TRUE); keypad(stdscr, TRUE); attron(A_BOLD); attron(COLOR_PAIR(2)); sprintf(welcome, "%s Wireless Card Monitor Utility for interface %s - Card Type %s\n", CompanyName, wrq.ifr_name, &wrq.u.name[6]); CENTER(stdscr, 0, welcome) mvprintw(1, 9, "Driver Version :"); attron(COLOR_PAIR(3)); //CHNG mvprintw(1, 26, "%d.%d.%d.%d ", pVersionInfo.DriverMajorVersion, pVersionInfo.DriverMinorVersion, pVersionInfo.DriverSubVersion, pVersionInfo.DriverBuild); attroff(COLOR_PAIR(3)); //CHNG attron(COLOR_PAIR(2)); mvprintw(1, 38, "Firmware Version :"); attroff(COLOR_PAIR(2)); attron(COLOR_PAIR(3)); //CHNG mvprintw(1, 57, "%d.%d.%d.%d", pVersionInfo.FwMajorVersion, pVersionInfo.FwMinorVersion, pVersionInfo.FwSubVersion, pVersionInfo.FwBuild); attroff(COLOR_PAIR(3)); //CHNG WATTR(stdscr, COLOR_PAIR(2), CENTER(stdscr, 2, "Use arrow keys to go left and right. Press enter to select a choice <F1:Exit>") ) attroff(A_BOLD); refresh(); print_menu(menu_win, highlight); while (1) { d = wgetch(menu_win); sttruth = 0; switch (d) { case KEY_LEFT: if (highlight == 1) highlight = n_choices; else --highlight; break; case KEY_RIGHT: if (highlight == n_choices) highlight = 1; else ++highlight; break; case 10: choice = highlight; sttruth = 1; break;#ifndef LOW_RES case KEY_F(6): if (choice == 5 && justa_win != NULL) { wclear(justa_win); StartSiteSurvey(fd, wrq.ifr_name); } break;#endif //NOT LOW_RES default: refresh(); break; } print_menu(menu_win, highlight); if ((choice == n_choices) || (d == KEY_F(1))) { /* User did a choice come out of the infinite loop */ clear(); refresh(); exit_win = newwin(6, 50, 10, 15); box(exit_win, 0, 0); wattron(exit_win, A_BOLD); wattron(exit_win, COLOR_PAIR(2)); mvwprintw(exit_win, 1, 14, "You Exited Normally"); mvwprintw(exit_win, 2, 22, "FROM"); mvwprintw(exit_win, 3, 9, "ATMEL's Card Configuration tool"); wattroff(exit_win, COLOR_PAIR(2)); wattroff(exit_win, A_BOLD); wrefresh(exit_win); refresh(); break; } if (sttruth == 1) { if (choice == n_choices) { sttruth = 0; break; } switch (choice) { case 1: set_win = create_newwin(WINHEIGHT, WIDTH, 6, 0); //wattron(set_win, A_BOLD); Get_Stats(&Stats, fd, wrq.ifr_name); Get_Config(&pAppInfo, fd, wrq.ifr_name); Print_Stats(set_win, &pAppInfo, &pEncryptionInfo, &Stats); //wattroff(set_win, A_BOLD); wrefresh(set_win); refresh(); break; case 2: attron(A_BOLD); Get_Stats(&Stats, fd, wrq.ifr_name); Get_Config(&pAppInfo, fd, wrq.ifr_name); Print_Wep_Stats(wep_win, &pEncryptionInfo, &pAppInfo, &Stats); attroff(A_BOLD); refresh(); break; case 3: WepDlg(&pAppInfo, wrq.ifr_name, fd, &pEncryptionInfo); refresh(); break; case 4: read_ioctls_wlan(&pAppInfo, &pEncryptionInfo, fd, wrq.ifr_name); refresh(); break;#ifndef LOW_RES case 5: justa_win = create_newwin(WINHEIGHT, WIDTH, 6, 0); HEADER( justa_win, "No Site Survey in Progress") WATTR( justa_win, A_BLINK | COLOR_PAIR(1), CENTER(justa_win, 9, "Press <F6> to Start Scanning") ) wrefresh(justa_win); refresh(); break;#endif //NOT LOW_RES default: refresh(); break; } sttruth = 0; } } signal(SIGINT, no_quit); clrtoeol(); refresh(); endwin(); return 0;}void print_menu(WINDOW * menu_win, int highlight){ int x, y, i; x = 2; y = 2; box(menu_win, 0, 0); noecho(); for (i = 0; i < n_choices; ++i) { if (highlight == i + 1) { /* High light the present choice */ wattron(menu_win, A_REVERSE | A_BOLD); mvwprintw(menu_win, 1, x, "%s", choices[i]); wattroff(menu_win, A_REVERSE | A_BOLD); } else mvwprintw(menu_win, 1, x, "%s", choices[i]); x += (strlen(choices[i]) + total); } wrefresh(menu_win);}WINDOW *create_newwin(int height, int width, int starty, int startx){ WINDOW *local_win; local_win = newwin(height, width, starty, startx); box(local_win, 0, 0); /* 0, 0 gives default characters * for the vertical and horizontal * lines */ wrefresh(local_win); /* Show that box */ return local_win;}WINDOW *create_inputwin(int height, int width, int starty, int startx){ WINDOW *local_win; local_win = newwin(height, width, starty, startx);// box(local_win, 0, 0); /* 0, 0 gives default characters * for the vertical and horizontal * lines */ wrefresh(local_win); /* Show that box */ return local_win;}void destroy_win(WINDOW * local_win){ wborder(local_win, ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '); wrefresh(local_win); delwin(local_win);}void print_my_menu(WINDOW * my_win, int reverse){ int x, y, i; x = 4; y = 3; box(my_win, 0, 0); HEADER(my_win, "Card Configuration Menu") for (i = 0; i < config_choices; i++) { if (reverse == i + 1) { /* High reverse the present choice */ wattron(my_win, A_BOLD); wattron(my_win, A_REVERSE); mvwprintw(my_win, y, x, "%s", conf_choices[i]); wattroff(my_win, A_REVERSE); wattroff(my_win, A_BOLD); } else mvwprintw(my_win, y, x, "%s", conf_choices[i]); y++; } wrefresh(my_win);}void no_quit(int signum){ signal(SIGINT, no_quit); signal(SIGINT, SIG_IGN);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -