2 * stations.c from Access Point SNMP Utils for Linux
4 * Copyright (c) 2002 Roman Festchook <roma at polesye dot net>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License Version 2 from
8 * June 1991 as published by the Free Software Foundation.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28 #define MAX_LINES LINES-4
31 extern WINDOW *main_sub;
37 0x2B, 0x06, 0x01, 0x04, 0x01, 0x83, 0x1A, 0x01, 0x02, 0x05, 0x01, 0x00
40 0x2B, 0x06, 0x01, 0x04, 0x01, 0x83, 0x1A, 0x01, 0x02, 0x05, 0x02, 0x00
42 char bridgeOperationalMode[] = {
43 0x2B, 0x06, 0x01, 0x04, 0x01, 0x83, 0x1A, 0x01, 0x01, 0x04, 0x01, 0x00
46 struct AssociatedSTAsInfo {
48 unsigned char MacAddress[6];
51 unsigned char ParentMacAddress[6];
53 unsigned char LinkQuality;
55 unsigned char Reserved[2];
58 struct MacListStat *first = NULL, *curr = NULL;
60 int mac_num, begin, end, total_mac;
63 print_top(NULL, TITLE_STAS);
65 varbinds[0].oid = bridgeOperationalMode;
66 varbinds[0].len_oid = sizeof(bridgeOperationalMode);
67 varbinds[0].value = bridgeOperationalMode;
68 varbinds[0].len_val = 0;
69 varbinds[0].type = NULL_VALUE;
71 if (snmp(varbinds, 1, GET) <= 0) {
72 print_helperr(ERR_RET);
76 if (*(varbinds[0].value) == 3) {
77 mvwaddstr(main_sub, 3, 1, _("AP is currently in AP Client Mode => "
78 "no associated STAtions."));
85 varbinds[0].oid = StasNum;
86 varbinds[0].len_oid = sizeof(StasNum);
87 varbinds[0].value = StasNum;
88 varbinds[0].type = NULL_VALUE;
89 varbinds[0].len_val = 0;
91 if (snmp(varbinds, 1, GET) <= 0) {
92 print_helperr(ERR_RET);
97 total_mac = *(varbinds[0].value);
100 sprintf(message, "%s: %d", TITLE_STAS, total_mac);
101 print_top(NULL, message);
102 mvwaddstr(main_sub, 0, 1, _("# MAC LQ RSSI Status Port IP"));
105 while (mac_num <= total_mac) {
107 varbinds[0].oid = StasMac;
108 varbinds[0].len_oid = sizeof(StasMac);
109 varbinds[0].type = INT_VALUE;
110 get.Num = swap2(mac_num);
111 varbinds[0].value = (char *) &get;
112 varbinds[0].len_val = sizeof(get);
114 if (snmp(varbinds, 1, SET) <= 0) {
115 print_helperr(ERR_RET);
120 if (varbinds[0].len_val == 24) {
124 (struct AssociatedSTAsInfo *) malloc(varbinds[0].len_val);
125 memcpy(mac, varbinds[0].value, varbinds[0].len_val);
126 /* mac = (struct AssociatedSTAsInfo *) varbinds[0].value;*/
128 print_helperr(_("AssociatedSTAsInfo packet error"));
135 (struct MacListStat *) malloc(sizeof(struct MacListStat));
139 (struct MacListStat *) malloc(sizeof(struct MacListStat));
143 memcpy(curr->addr, mac->MacAddress, 6);
144 // memcpy(curr->ParentMacAddress, mac->ParentMacAddress, 6);
145 memcpy(&(curr->IP.s_addr), mac->IP, 4);
146 curr->quality = 100 - (minimum(mac->LinkQuality, 40)*2.5);
147 // curr->rssi = - 96 + mac->RSSI;
148 // curr->quality = mac->LinkQuality;
149 curr->rssi = mac->RSSI;
151 curr->Port = mac->Port;
152 curr->Status = mac->Status;
157 end = (MAX_LINES < mac_num) ? MAX_LINES : mac_num;
158 scroll_rows(first, begin, end, 1, 2);
160 print_help(_("Arrows - scroll; S - save to file; Q - quit to menu."));
164 save_Stations(first);
171 scroll_rows(first, begin, end, 1, 2);
179 scroll_rows(first, begin, end, 1, 2);
189 while ((curr = first) != 0) {
193 print_top(NULL, NULL);