2 * wlan.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
24 #include <sys/types.h>
27 #define ESSID _("[E] ESSID: ")
28 #define AP_NAME _("[N] AP name: ")
30 #define CONTACT _("[K] AP contact: ")
31 #define LOCATION _("[L] AP location: ")
33 #define RTS_TR _("[R] RTS threshold: ")
34 #define FRG_TR _("[F] Fragmentation threshold: ")
35 #define PREAMBULE _("[P] Preambule type: ")
36 #define AUTH _("[A] Auth type: ")
37 #define OSYS _("Open system")
38 #define SH_KEY _("Shared key")
39 #define BOTH_TYPE _("Both types")
40 #define RETRAIN _("[U] Auto rate fallback: ")
41 #define HIDE_ESSID _("[S] Insert ESSID in broadcast packets: ")
42 #define RATES _("Basic and Supported rates:")
43 #define RATES_HEAD _("Key Rate Status")
44 #define RATES_RECORD "[%d] %4.1fM "
45 #define INT_ROAMING _("[I] International roaming: ")
46 #define BEACON_PER _("[B] Beacon period (msec): ")
47 #define DTIM_I _("[D] DTIM sending interval (beacons): ")
48 #define SIFS_T _("[T] SIFS time (msec): ")
49 #define WLAN_HELP _("[key] - set option; W - write conf; Q - quit to menu")
51 extern short ap_type, ap_vendorext;
55 char sysDeviceInfo[] = {
56 0x2B, 0x06, 0x01, 0x04, 0x01, 0x83, 0x1A, 0x01, 0x01, 0x01, 0x05, 0x00
59 char operChannelID[] = {
60 0x2B, 0x06, 0x01, 0x04, 0x01, 0x83, 0x1A, 0x01, 0x02, 0x01, 0x01, 0x00
62 char operESSIDLength[] = {
63 0x2B, 0x06, 0x01, 0x04, 0x01, 0x83, 0x1A, 0x01, 0x02, 0x01, 0x02, 0x00
66 0x2B, 0x06, 0x01, 0x04, 0x01, 0x83, 0x1A, 0x01, 0x02, 0x01, 0x03, 0x00
68 char operRTSThreshold[] = {
69 0x2B, 0x06, 0x01, 0x04, 0x01, 0x83, 0x1A, 0x01, 0x02, 0x01, 0x04, 0x00
71 char operFragmentationThreshold[] = {
72 0x2B, 0x06, 0x01, 0x04, 0x01, 0x83, 0x1A, 0x01, 0x02, 0x01, 0x05, 0x00
74 char operPreambleType[] = {
75 0x2B, 0x06, 0x01, 0x04, 0x01, 0x83, 0x1A, 0x01, 0x02, 0x01, 0x06, 0x00
77 char operAuthenticationType[] = {
78 0x2B, 0x06, 0x01, 0x04, 0x01, 0x83, 0x1A, 0x01, 0x02, 0x01, 0x07, 0x00
80 char operBasicRates[] = {
81 0x2B, 0x06, 0x01, 0x04, 0x01, 0x83, 0x1A, 0x01, 0x02, 0x01, 0x08, 0x00
83 char operAutoRateFallBack[] = {
84 0x2B, 0x06, 0x01, 0x04, 0x01, 0x83, 0x1A, 0x01, 0x02, 0x01, 0x09, 0x00
86 char operAccessPointName[] = {
87 0x2B, 0x06, 0x01, 0x04, 0x01, 0x83, 0x1A, 0x01, 0x02, 0x01, 0x0A, 0x00
89 char operSSIDBroadcasting[] = {
90 0x2B, 0x06, 0x01, 0x04, 0x01, 0x83, 0x1A, 0x01, 0x02, 0x01, 0x0B, 0x00
93 /* This one is ATMEL12350 MIB specific. */
94 char operInterRoaming[] = {
95 0x2B, 0x06, 0x01, 0x04, 0x01, 0xE0, 0x3E, 0x01, 0x02, 0x01, 0x0D, 0x00
97 /* These two are ATMEL12350 TELLUS MIB specific. */
98 char operBeaconPeriod[] = {
99 0x2B, 0x06, 0x01, 0x04, 0x01, 0xE0, 0x3E, 0x01, 0x02, 0x01, 0x0E, 0x00
102 0x2B, 0x06, 0x01, 0x04, 0x01, 0xE0, 0x3E, 0x01, 0x02, 0x01, 0x0F, 0x00
104 /* This one is ATMEL12350 VERNET MIB specific. */
105 char operSIFSTIME[] = {
106 0x2B, 0x06, 0x01, 0x04, 0x01, 0xE0, 0x3E, 0x01, 0x02, 0x01, 0x10, 0x00
109 extern WINDOW *main_sub;
110 extern rdprops regdom_types[];
111 extern char *channels[];
112 varbind varbinds[16];
113 unsigned short int RTSThreshold, FragmentationThreshold,
114 InterRoaming, m_basic_rates = 0, BeaconPeriod = 0, sifs = 0;
115 unsigned char dtim, ch;
116 char *AuthenticationTypes[3] = { OSYS, SH_KEY, BOTH_TYPE },
118 char domain[32], basic_rates[4], AutoRateFallBack, SSIDBroadcasting,
119 ap_name[32], PreambleType, AuthenticationType, channel;
120 char m_channel = 0, m_essid = 0, m_broadcast = 0, m_rts = 0,
121 m_fragment = 0, m_auth = 0, m_ap_name = 0, m_preambule = 0,
122 m_auto_rate = 0, m_inter_roaming = 0, m_beacon = 0, m_dtim = 0,
124 char *rates[3] = { ON, OFF, BASIC }, *preambules[2] = {
125 _("Short"), _("Long")};
126 short __rates[4] = { 2, 4, 11, 22 };
127 int i, c = 0, rd_idx;
128 unsigned short ap_regdomain;
129 struct sysDeviceInfo_ATMEL410 str410;
130 struct sysDeviceInfo_ATMEL12350 str12350;
133 if (ap_type == ATMEL12350) {
134 sysDeviceInfo[5] = 0xE0;
135 sysDeviceInfo[6] = 0x3E;
136 operChannelID[5] = 0xE0;
137 operChannelID[6] = 0x3E;
138 operESSIDLength[5] = 0xE0;
139 operESSIDLength[6] = 0x3E;
142 operRTSThreshold[5] = 0xE0;
143 operRTSThreshold[6] = 0x3E;
144 operFragmentationThreshold[5] = 0xE0;
145 operFragmentationThreshold[6] = 0x3E;
146 operPreambleType[5] = 0xE0;
147 operPreambleType[6] = 0x3E;
148 operAuthenticationType[5] = 0xE0;
149 operAuthenticationType[6] = 0x3E;
150 operBasicRates[5] = 0xE0;
151 operBasicRates[6] = 0x3E;
152 operAutoRateFallBack[5] = 0xE0;
153 operAutoRateFallBack[6] = 0x3E;
154 operAccessPointName[5] = 0xE0;
155 operAccessPointName[6] = 0x3E;
156 operSSIDBroadcasting[5] = 0xE0;
157 operSSIDBroadcasting[6] = 0x3E;
160 for (i = 0; i < 16; i++) {
161 varbinds[i].type = NULL_VALUE;
162 varbinds[i].len_val = 0;
163 varbinds[i].len_oid = sizeof(operChannelID);
168 varbinds[i++].oid = operChannelID;
169 varbinds[i++].oid = operESSIDLength;
170 varbinds[i++].oid = operESSID;
171 varbinds[i++].oid = operSSIDBroadcasting;
172 varbinds[i++].oid = operBasicRates;
173 varbinds[i++].oid = operAutoRateFallBack;
174 varbinds[i++].oid = operRTSThreshold;
175 varbinds[i++].oid = operFragmentationThreshold;
176 varbinds[i++].oid = operPreambleType;
177 varbinds[i++].oid = operAuthenticationType;
178 varbinds[i++].oid = operAccessPointName;
179 varbinds[i++].oid = sysDeviceInfo;
180 if (ap_type == ATMEL12350) {
181 varbinds[i++].oid = operInterRoaming;
182 if (ap_vendorext == TELLUS || ap_vendorext == VERNET) {
183 varbinds[i++].oid = operBeaconPeriod;
184 varbinds[i++].oid = operDTIM;
186 if (ap_vendorext == VERNET)
187 varbinds[i++].oid = operSIFSTIME;
190 print_help(WAIT_RET);
191 if (snmp(varbinds, i, GET) <= 0) {
192 print_helperr(ERR_RET);
196 channel = *(varbinds[0].value);
197 c = *(varbinds[1].value);
198 memcpy(domain, varbinds[2].value, 32);
199 SSIDBroadcasting = *(varbinds[3].value);
200 memcpy(basic_rates, varbinds[4].value, 4);
201 AutoRateFallBack = *(varbinds[5].value);
202 memcpy(&RTSThreshold, varbinds[6].value, 2);
203 RTSThreshold = ntohs(RTSThreshold);
204 memcpy(&FragmentationThreshold, varbinds[7].value, 2);
205 FragmentationThreshold = ntohs(FragmentationThreshold);
206 PreambleType = *(varbinds[8].value);
207 AuthenticationType = *(varbinds[9].value);
208 memcpy(ap_name, varbinds[10].value, 32);
209 if (ap_type == ATMEL12350) {
210 InterRoaming = *(varbinds[12].value);
211 if (ap_vendorext == TELLUS || ap_vendorext == VERNET) {
212 BeaconPeriod = varbinds[13].len_val == 2 ?
213 (varbinds[13].value[0] << 8) | varbinds[13].value[1] :
214 varbinds[13].value[0] < 0x80 ?
215 varbinds[13].value[0] : 0xff00 | varbinds[13].value[0];
216 dtim = *(varbinds[14].value);
218 if (ap_vendorext == VERNET)
219 sifs = varbinds[15].len_val == 2 ?
220 (varbinds[15].value[0] << 8) | varbinds[15].value[1] :
221 varbinds[15].value[0] < 0x80 ?
222 varbinds[15].value[0] : 0xff00 | varbinds[15].value[0];
225 if (ap_type == ATMEL12350) {
226 memcpy(&str12350, varbinds[11].value,
227 sizeof(struct sysDeviceInfo_ATMEL12350));
228 ap_regdomain=str12350.RegulatoryDomain;
229 } else /* ATMEL410 */{
230 memcpy(&str410, varbinds[11].value,
231 sizeof(struct sysDeviceInfo_ATMEL410));
232 ap_regdomain = swap4(str410.RegulatoryDomain);
235 rd_idx = regdom_idx(ap_regdomain);
237 print_top(NULL, _("Wireless Settings"));
239 sprintf(message, "%s%02u (%u MHz)", CHANNEL, channel, 2407 + 5 * channel);
240 mvwaddstr(main_sub, 0, 0, message);
241 mvwaddstr(main_sub, 1, 0, ESSID);
242 waddnstr(main_sub, domain, c);
243 mvwaddstr(main_sub, 2, 0, AP_NAME);
244 for (i = 0; i < 32 && ap_name[i]; i++)
245 mvwaddch(main_sub, 2, strlen(AP_NAME) + i, ap_name[i]);
246 sprintf(message, "%s%d", RTS_TR, RTSThreshold);
247 mvwaddstr(main_sub, 3, 0, message);
248 sprintf(message, "%s%d", FRG_TR, FragmentationThreshold);
249 mvwaddstr(main_sub, 4, 0, message);
250 sprintf(message, "%s%s", PREAMBULE, preambules[PreambleType - 1]);
251 mvwaddstr(main_sub, 5, 0, message);
252 sprintf(message, "%s%s", AUTH, AuthenticationTypes[AuthenticationType - 1]);
253 mvwaddstr(main_sub, 6, 0, message);
254 sprintf(message, "%s%s", RETRAIN, (AutoRateFallBack == 1) ? ON : OFF);
255 mvwaddstr(main_sub, 7, 0, message);
256 sprintf(message, "%s%s", HIDE_ESSID, (SSIDBroadcasting == 1) ? ON : OFF);
257 mvwaddstr(main_sub, 8, 0, message);
258 mvwaddstr(main_sub, 9, 0, RATES);
259 mvwaddstr(main_sub, 10, 2, RATES_HEAD);
260 for (i = 0; i < 4; i++) {
261 sprintf(message, RATES_RECORD "%s", i + 1, (float) __rates[i] / 2,
262 basic(basic_rates[i]));
263 mvwaddstr(main_sub, 11 + i, 2, message);
265 if (ap_type == ATMEL12350) {
266 sprintf(message, "%s%s", INT_ROAMING, (InterRoaming == 1) ? ON : OFF);
267 mvwaddstr(main_sub, 15, 0, message);
268 if (ap_vendorext == TELLUS || ap_vendorext == VERNET) {
269 sprintf(message, "%s%u", BEACON_PER, BeaconPeriod);
270 mvwaddstr(main_sub, 16, 0, message);
271 sprintf(message, "%s%u", DTIM_I, dtim);
272 mvwaddstr(main_sub, 17, 0, message);
274 if (ap_vendorext == VERNET) {
275 sprintf(message, "%s%u", SIFS_T, sifs);
276 mvwaddstr(main_sub, 18, 0, message);
282 print_help(WLAN_HELP);
297 switch (menu_choose(10 + i, 15, rates, 3)) {
299 basic_rates[i - 1] = __rates[i - 1];
302 basic_rates[i - 1] = 0;
305 basic_rates[i - 1] = __rates[i - 1] + 0x80;
307 clear_main_new(10 + i, 11 + i);
308 sprintf(message, RATES_RECORD, i, (float) __rates[i - 1] / 2);
309 print_menusel(10 + i, 2, message, basic(basic_rates[i - 1]));
314 channel = menu_choose(0, strlen(CHANNEL),
315 #ifndef NO_REG_DOMAIN
316 channels + regdom_types[rd_idx].first_ch - 1,
317 regdom_types[rd_idx].chans) + regdom_types[rd_idx].first_ch;
321 sprintf(message, "%02u (%u MHz)", channel, 2407 + 5 * channel);
322 print_menusel(0, 0, CHANNEL, message);
328 menu_choose(6, strlen(AUTH), AuthenticationTypes, 3) + 1;
329 clear_main_new(6, 7);
330 print_menusel(6, 0, AUTH,
331 AuthenticationTypes[AuthenticationType - 1]);
336 PreambleType = menu_choose(5, strlen(PREAMBULE), preambules, 2) + 1;
337 clear_main_new(5, 6);
338 print_menusel(5, 0, PREAMBULE, preambules[PreambleType - 1]);
343 AutoRateFallBack = on_off(7, strlen(RETRAIN));
344 clear_main_new(7, 8);
345 print_menusel(7, 0, RETRAIN, (AutoRateFallBack == 1) ? ON : OFF);
350 SSIDBroadcasting = on_off(8, strlen(HIDE_ESSID));
351 clear_main_new(8, 9);
352 print_menusel(8, 0, HIDE_ESSID, (SSIDBroadcasting == 1) ? ON : OFF);
357 // make_field(2, strlen(AP_NAME), 32);
358 get_value(ap_name, 2, strlen(AP_NAME), -32, ANY_STRING, 0, 0, NULL);
363 // make_field(1, strlen(ESSID), 32);
364 get_value(domain, 1, strlen(ESSID), 32, ANY_STRING, 0, 0, NULL);
369 // make_field(4, strlen(FRG_TR), 6);
370 get_value(message, 4, strlen(FRG_TR), 6, INT_STRING, 256, 2346,
372 FragmentationThreshold = atoi(message);
377 // make_field(3, strlen(RTS_TR), 6);
378 get_value(message, 3, strlen(RTS_TR), 6, INT_STRING, 0, 2347,
380 RTSThreshold = atoi(message);
385 if (ap_type == ATMEL410)
387 InterRoaming = on_off(15, strlen(INT_ROAMING));
388 clear_main_new(15, 16);
389 print_menusel(15, 0, INT_ROAMING, (InterRoaming == 1) ? ON : OFF);
394 if (ap_vendorext != TELLUS && ap_vendorext != VERNET)
396 get_value(message, 16, strlen(BEACON_PER), 6, INT_STRING, 0, 65535,
398 BeaconPeriod = atoi(message);
403 if (ap_vendorext != TELLUS && ap_vendorext != VERNET)
405 get_value(message, 17, strlen(DTIM_I), 4, INT_STRING, 0, 255,
407 dtim = atoi(message);
412 if (ap_vendorext != VERNET)
414 get_value(message, 18, strlen(SIFS_T), 6, INT_STRING, 0, 65535,
416 sifs = atoi(message);
423 varbinds[i].oid = operChannelID;
424 varbinds[i].len_oid = sizeof(operChannelID);
425 varbinds[i].value = (char *) &channel;
426 varbinds[i].len_val = 1;
427 varbinds[i].type = INT_VALUE;
431 for (m_basic_rates = 0; m_basic_rates < 2; m_basic_rates++) {
432 c = basic_rates[3 - m_basic_rates];
433 basic_rates[3 - m_basic_rates] =
434 basic_rates[m_basic_rates];
435 basic_rates[m_basic_rates] = c;
437 varbinds[i].oid = operBasicRates;
438 varbinds[i].len_oid = sizeof(operBasicRates);
439 varbinds[i].value = basic_rates;
440 varbinds[i].len_val = 4;
441 varbinds[i].type = INT_VALUE;
445 varbinds[i].oid = operSSIDBroadcasting;
446 varbinds[i].len_oid = sizeof(operSSIDBroadcasting);
447 varbinds[i].value = (char *) &SSIDBroadcasting;
448 varbinds[i].len_val = 1;
449 varbinds[i].type = INT_VALUE;
453 varbinds[i].oid = operAuthenticationType;
454 varbinds[i].len_oid = sizeof(operAuthenticationType);
455 varbinds[i].value = &AuthenticationType;
456 varbinds[i].len_val = 1;
457 varbinds[i].type = INT_VALUE;
461 varbinds[i].oid = operPreambleType;
462 varbinds[i].len_oid = sizeof(operPreambleType);
463 varbinds[i].value = &PreambleType;
464 varbinds[i].len_val = 1;
465 varbinds[i].type = INT_VALUE;
469 varbinds[i].oid = operAutoRateFallBack;
470 varbinds[i].len_oid = sizeof(operAutoRateFallBack);
471 varbinds[i].value = &AutoRateFallBack;
472 varbinds[i].len_val = 1;
473 varbinds[i].type = INT_VALUE;
478 varbinds[i].oid = operAccessPointName;
479 varbinds[i].len_oid = sizeof(operAccessPointName);
480 varbinds[i].value = ap_name;
481 varbinds[i].len_val = c;
482 varbinds[i].type = STRING_VALUE;
486 varbinds[i].oid = operFragmentationThreshold;
487 varbinds[i].len_oid = sizeof(operFragmentationThreshold);
488 FragmentationThreshold = htons(FragmentationThreshold);
489 varbinds[i].value = (char *) &FragmentationThreshold;
490 varbinds[i].len_val = 2;
491 varbinds[i].type = INT_VALUE;
495 varbinds[i].oid = operRTSThreshold;
496 varbinds[i].len_oid = sizeof(operRTSThreshold);
497 RTSThreshold = htons(RTSThreshold);
498 varbinds[i].value = (char *) &RTSThreshold;
499 varbinds[i].len_val = 2;
500 varbinds[i].type = INT_VALUE;
505 varbinds[i].oid = operESSIDLength;
506 varbinds[i].len_oid = sizeof(operESSIDLength);
507 varbinds[i].value = (char *)&ch;
508 varbinds[i].len_val = 1;
509 varbinds[i].type = INT_VALUE;
511 varbinds[i].oid = operESSID;
512 varbinds[i].len_oid = sizeof(operESSID);
513 varbinds[i].value = domain;
514 varbinds[i].len_val = ch;
515 varbinds[i].type = STRING_VALUE;
518 if (m_inter_roaming) {
519 varbinds[i].oid = operInterRoaming;
520 varbinds[i].len_oid = sizeof(operInterRoaming);
521 varbinds[i].value = (char *) &InterRoaming;
522 varbinds[i].len_val = 1;
523 varbinds[i].type = INT_VALUE;
527 varbinds[i].oid = operBeaconPeriod;
528 varbinds[i].len_oid = sizeof(operBeaconPeriod);
529 BeaconPeriod = htons(BeaconPeriod);
530 varbinds[i].value = (char *) &BeaconPeriod;
531 varbinds[i].len_val = 2;
532 varbinds[i].type = INT_VALUE;
536 varbinds[i].oid = operDTIM;
537 varbinds[i].len_oid = sizeof(operDTIM);
538 varbinds[i].value = (char *) &dtim;
539 varbinds[i].len_val = 1;
540 varbinds[i].type = INT_VALUE;
544 varbinds[i].oid = operSIFSTIME;
545 varbinds[i].len_oid = sizeof(operSIFSTIME);
547 varbinds[i].value = (char *) &sifs;
548 varbinds[i].len_val = 2;
549 varbinds[i].type = INT_VALUE;
553 print_help(WAIT_SET);
554 if (snmp(varbinds, i, SET) <= 0) {
555 print_helperr(ERR_SET);
558 print_help(DONE_SET);
566 print_top(NULL, NULL);
573 { 0x2a, 0x86, 0x48, 0xce, 0x34, 0x01, 0x01, 0x01, 0x09, 0x01 };
574 char operBasicRates[] =
575 { 0x2a, 0x86, 0x48, 0xce, 0x34, 0x01, 0x01, 0x01, 0x0b, 0x01 };
577 { 0x2a, 0x86, 0x48, 0xce, 0x34, 0x01, 0x02, 0x01, 0x03, 0x01, 0x01 };
579 { 0x2a, 0x86, 0x48, 0xce, 0x34, 0x01, 0x02, 0x01, 0x03, 0x01, 0x02 };
580 char operRTSThreshold[] =
581 { 0x2a, 0x86, 0x48, 0xce, 0x34, 0x02, 0x01, 0x01, 0x02, 0x01 };
582 char operFragmentationThreshold[] =
583 { 0x2a, 0x86, 0x48, 0xce, 0x34, 0x02, 0x01, 0x01, 0x05, 0x01 };
584 char operChannelID[] =
585 { 0x2a, 0x86, 0x48, 0xce, 0x34, 0x04, 0x05, 0x01, 0x01, 0x01 };
586 char oid_dot11SupportedAntenna[][11] = {
587 { 0x2a, 0x86, 0x48, 0xce, 0x34, 0x04, 0x08, 0x01, 0x02, 0x01, 0x01 },
588 { 0x2a, 0x86, 0x48, 0xce, 0x34, 0x04, 0x08, 0x01, 0x02, 0x01, 0x02 },
589 { 0x2a, 0x86, 0x48, 0xce, 0x34, 0x04, 0x08, 0x01, 0x03, 0x01, 0x01 },
590 { 0x2a, 0x86, 0x48, 0xce, 0x34, 0x04, 0x08, 0x01, 0x03, 0x01, 0x02 },
591 { 0x2a, 0x86, 0x48, 0xce, 0x34, 0x04, 0x08, 0x01, 0x04, 0x01, 0x01 },
592 { 0x2a, 0x86, 0x48, 0xce, 0x34, 0x04, 0x08, 0x01, 0x04, 0x01, 0x02 }
594 char operAccessPointContact[] =
595 { 0x2b, 0x06, 0x01, 0x02, 0x01, 0x01, 0x04, 0x00 };
596 char operAccessPointName[] =
597 { 0x2b, 0x06, 0x01, 0x02, 0x01, 0x01, 0x05, 0x00 };
598 char operAccessPointLocation[] =
599 { 0x2b, 0x06, 0x01, 0x02, 0x01, 0x01, 0x06, 0x00 };
600 char sysTrapSwitch[] =
601 { 0x2b, 0x06, 0x01, 0x02, 0x01, 0x0b, 0x1e, 0x00 };
603 { 0x2b, 0x06, 0x01, 0x04, 0x01, 0x87, 0x29, 0x03, 0x01, 0x02, 0x01,
606 unsigned short int i, RTSThreshold, FragmentationThreshold,
607 m_basic_rates = 0, authi;
608 char *auth[3] = { OSYS, SH_KEY, BOTH_TYPE },
609 *rates[3] = { ON, OFF, BASIC },
611 m_antenna[6] = { 0, 0, 0, 0, 0, 0 },
613 channel_pref[2] = { 0, 0 };
614 extern WINDOW *main_sub;
615 extern rdprops regdom_types[];
616 extern char *channels[];
617 char *domain, basic_rates[] =
618 { 0, 0, 0, 0 }, *ap_name, ap_location[32], ap_contact[32],
619 m_ap_contact = 0, m_ap_location = 0;
620 char m_channel = 0, m_essid = 0, m_rts = 0, m_fragment = 0, m_auth =
621 0, m_ap_name = 0, channel, traps, m_traps = 0;
622 varbind varbinds[11];
623 int c = 0, reg_domain = 0, rd_idx;
624 short __rates[4] = { 2, 4, 11, 22};
626 domain = (char *) calloc(32, 1);
627 ap_name = (char *) calloc(32, 1);
629 for (i = 0; i < 8; i++) {
630 varbinds[i].len_val = 0;
631 varbinds[i].type = NULL_VALUE;
633 varbinds[0].oid = operChannelID;
634 varbinds[0].len_oid = sizeof(operChannelID);
635 varbinds[1].oid = operESSID;
636 varbinds[1].len_oid = sizeof(operESSID);
637 varbinds[2].oid = operRTSThreshold;
638 varbinds[2].len_oid = sizeof(operRTSThreshold);
639 varbinds[3].oid = operFragmentationThreshold;
640 varbinds[3].len_oid = sizeof(operFragmentationThreshold);
641 varbinds[4].oid = operBasicRates;
642 varbinds[4].len_oid = sizeof(operBasicRates);
643 varbinds[5].oid = OpenSystem;
644 varbinds[5].len_oid = sizeof(OpenSystem);
645 varbinds[6].oid = SharedKey;
646 varbinds[6].len_oid = sizeof(SharedKey);
647 varbinds[7].oid = operAccessPointName;
648 varbinds[7].len_oid = sizeof(operAccessPointName);
649 print_help(WAIT_RET);
650 if (snmp(varbinds, 8, GET) <= 0) {
651 print_helperr(ERR_RET);
655 channel = *(varbinds[0].value);
656 memcpy(domain, varbinds[1].value, varbinds[1].len_val);
657 memcpy(basic_rates, varbinds[4].value, varbinds[4].len_val);
658 memcpy(&RTSThreshold, (varbinds[2].value), 2);
659 RTSThreshold = ntohs(RTSThreshold);
660 memcpy(&FragmentationThreshold, (varbinds[3].value), 2);
661 FragmentationThreshold = ntohs(FragmentationThreshold);
662 authi = (*(varbinds[5].value) == 1 && *(varbinds[6].value) == 1) ? 2 :
663 (*(varbinds[5].value) == 1) ? 0 : 1;
664 memcpy(ap_name, varbinds[7].value, varbinds[7].len_val);
666 sprintf(message, "%s%02u (%u MHz)", CHANNEL, channel, 2407 + 5 * channel);
667 mvwaddstr(main_sub, 0, 0, message);
668 mvwaddstr(main_sub, 1, 0, ESSID);
669 for (i = 0; i < 32 && domain[i]; i++)
670 mvwaddch(main_sub, 1, strlen(ESSID) + i, domain[i]);
671 mvwaddstr(main_sub, 2, 0, AP_NAME);
672 for (i = 0; i < 32 && ap_name[i]; i++)
673 mvwaddch(main_sub, 2, strlen(AP_NAME) + i, ap_name[i]);
674 sprintf(message, "%s%d", RTS_TR, RTSThreshold);
675 mvwaddstr(main_sub, 3, 0, message);
676 sprintf(message, "%s%d", FRG_TR, FragmentationThreshold);
677 mvwaddstr(main_sub, 4, 0, message);
678 sprintf(message, "%s%s", AUTH, auth[authi]);
679 mvwaddstr(main_sub, 6, 0, message);
680 mvwaddstr(main_sub, 9, 0, RATES);
681 mvwaddstr(main_sub, 10, 2, RATES_HEAD);
682 for(i = 0; i < 4; i++) {
683 sprintf(message, RATES_RECORD "%s", i + 1, (float) __rates[i] / 2,
684 basic(basic_rates[i]));
685 mvwaddstr(main_sub, 11+i, 2, message);
688 reg_domain = get_RegDomain();
689 rd_idx = regdom_idx(reg_domain);
691 for (i = 0; i < 9; i++) {
692 varbinds[i].len_val = 0;
693 varbinds[i].type = NULL_VALUE;
696 for (i = 0; i < 6; i++) {
697 varbinds[i].oid = oid_dot11SupportedAntenna[i];
698 varbinds[i].len_oid = sizeof(oid_dot11SupportedAntenna[i]);
700 varbinds[6].oid = sysTrapSwitch;
701 varbinds[6].len_oid = sizeof(sysTrapSwitch);
702 varbinds[7].oid = operAccessPointContact;
703 varbinds[7].len_oid = sizeof(operAccessPointContact);
704 varbinds[8].oid = operAccessPointLocation;
705 varbinds[8].len_oid = sizeof(operAccessPointLocation);
707 if (snmp(varbinds, 9, GET) <= 0) {
708 print_helperr(ERR_RET);
712 for (i = 0; i < 6; i++) {
713 antenna[i] = *varbinds[i].value;
716 traps = *(varbinds[6].value);
717 memcpy(ap_contact, varbinds[7].value, varbinds[7].len_val);
718 if (varbinds[7].len_val < 32)
719 ap_contact[varbinds[7].len_val] = '\0';
720 memcpy(ap_location, varbinds[8].value, varbinds[8].len_val);
721 if (varbinds[8].len_val < 32)
722 ap_location[varbinds[8].len_val] = '\0';
724 sprintf(message, "%s%s", LOCATION, ap_location);
725 mvwaddstr(main_sub, 7, 0, message);
726 sprintf(message, "%s%s", CONTACT, ap_contact);
727 mvwaddstr(main_sub, 8, 0, message);
728 sprintf(message, "%s%s", TRAPS, (traps == 1) ? ON : OFF);
729 mvwaddstr(main_sub, 5, 0, message);
731 mvwaddstr(main_sub, 16, 0, _("Antenna Configuration:"));
732 sprintf(message, "%s %s %3s, %s %3s",
734 ANTENNA_RX_LEFT, (antenna[2] == 1) ? ON : OFF,
735 ANTENNA_RX_RIGHT, (antenna[3] == 1) ? ON : OFF);
736 mvwaddstr(main_sub, 17, 1, message);
737 sprintf(message, "%s %s %3s, %s %3s",
739 ANTENNA_TX_LEFT, (antenna[0] == 1) ? ON : OFF,
740 ANTENNA_TX_RIGHT, (antenna[1] == 1) ? ON : OFF);
741 mvwaddstr(main_sub, 18, 1, message);
742 sprintf(message, "%s %s %3s, %s %3s",
744 ANTENNA_DV_LEFT, (antenna[4] == 1) ? ON : OFF,
745 ANTENNA_DV_RIGHT, (antenna[5] == 1) ? ON : OFF);
746 mvwaddstr(main_sub, 19, 1, message);
748 print_top(NULL, _("General Options"));
750 ("UIOPTY - antenna; SCANLEDFR1234 - options; W - write conf; Q - quit to menu"));
760 i = strlen(ANTENNA_RX) + 1 +
761 strlen(ANTENNA_RX_LEFT) + 6 +
762 strlen(ANTENNA_RX_RIGHT) + 2;
763 antenna[3] = on_off(17, i);
764 sprintf(message, "%3s", (antenna[3] == 1) ? ON : OFF);
765 print_menusel(17, i, NULL, message);
770 i = strlen(ANTENNA_RX) + 1 +
771 strlen(ANTENNA_RX_LEFT) + 2;
772 antenna[2] = on_off(17, i);
773 sprintf(message, "%3s", (antenna[2] == 1) ? ON : OFF);
774 print_menusel(17, i, NULL, message);
779 i = strlen(ANTENNA_TX) + 1 +
780 strlen(ANTENNA_TX_LEFT) + 6 +
781 strlen(ANTENNA_TX_RIGHT) + 2;
782 antenna[1] = on_off(18, i);
783 sprintf(message, "%3s", (antenna[1] == 1) ? ON : OFF);
784 print_menusel(18, i, NULL, message);
789 i = strlen(ANTENNA_TX) + 1 +
790 strlen(ANTENNA_TX_LEFT) + 2;
791 antenna[0] = on_off(18, i);
792 sprintf(message, "%3s", (antenna[0] == 1) ? ON : OFF);
793 print_menusel(18, i, NULL, message);
798 i = strlen(ANTENNA_DV) + 1 +
799 strlen(ANTENNA_DV_LEFT) + 2;
800 antenna[4] = on_off(19, i);
801 sprintf(message, "%3s", (antenna[4] == 1) ? ON : OFF);
802 print_menusel(19, i, NULL, message);
807 i = strlen(ANTENNA_DV) + 1 +
808 strlen(ANTENNA_DV_LEFT) + 6 +
809 strlen(ANTENNA_DV_RIGHT) + 2;
810 antenna[5] = on_off(19, i);
811 sprintf(message, "%3s", (antenna[5] == 1) ? ON : OFF);
812 print_menusel(19, i, NULL, message);
817 traps = on_off(5, strlen(TRAPS));
818 clear_main_new(5, 6);
819 print_menusel(5, 0, TRAPS, (traps == 1) ? ON : OFF);
830 switch (menu_choose(10 + i, 15, rates, 3)) {
832 basic_rates[i-1] = __rates[i-1];
835 basic_rates[i-1] = 0;
838 basic_rates[i-1] = __rates[i-1] + 0x80;
840 clear_main_new(10 + i, 11 + i);
841 sprintf(message, RATES_RECORD, i, (float) __rates[i-1] / 2);
842 print_menusel(10 + i, 2, message, basic(basic_rates[i-1]));
847 channel = menu_choose(0, strlen(CHANNEL),
848 #ifndef NO_REG_DOMAIN
849 channels + regdom_types[rd_idx].first_ch - 1,
850 regdom_types[rd_idx].chans) + regdom_types[rd_idx].first_ch;
854 sprintf(message, "%02u (%u MHz)", channel, 2407 + 5 * channel);
855 print_menusel(0, 0, CHANNEL, message);
860 authi = menu_choose(6, strlen(AUTH), auth, 3);
861 clear_main_new(6, 7);
862 print_menusel(6, 0, AUTH, auth[authi]);
867 get_value(ap_name, 2, strlen(AP_NAME), 32, ANY_STRING, 0, 0, NULL);
872 get_value(ap_location, 7, strlen(LOCATION), 32, ANY_STRING, 0, 0,
878 get_value(ap_contact, 8, strlen(CONTACT), 32, ANY_STRING, 0, 0,
884 get_value(domain, 1, strlen(ESSID), 32, ANY_STRING, 0, 0, NULL);
889 get_value(message, 4, strlen(FRG_TR), 6, INT_STRING, 256, 2346,
891 FragmentationThreshold = atoi(message);
896 get_value(message, 3, strlen(RTS_TR), 6, INT_STRING, 0, 2347,
898 RTSThreshold = atoi(message);
905 channel_pref[0] = channel;
906 varbinds[i].oid = ChannelPref;
907 varbinds[i].len_oid = sizeof(ChannelPref);
908 varbinds[i].value = channel_pref;
909 varbinds[i].len_val = 2;
910 varbinds[i].type = STRING_VALUE;
912 varbinds[i].oid = operChannelID;
913 varbinds[i].len_oid = sizeof(operChannelID);
914 varbinds[i].value = (char *) &channel;
915 varbinds[i].len_val = 1;
916 varbinds[i].type = 0x02;
921 varbinds[i].oid = operBasicRates;
922 varbinds[i].len_oid = sizeof(operBasicRates);
923 varbinds[i].value = basic_rates;
924 varbinds[i].len_val = 4;
925 varbinds[i].type = STRING_VALUE;
929 print_help(WAIT_SET);
930 if (snmp(varbinds, i, SET) <= 0) {
931 print_helperr(ERR_SET);
937 m_auth = (authi == 1) ? 2 : 1;
938 m_basic_rates = (authi == 0) ? 2 : 1;
939 varbinds[i].oid = OpenSystem;
940 varbinds[i].len_oid = sizeof(OpenSystem);
941 varbinds[i].value = (char *) &m_auth;
942 varbinds[i].len_val = 1;
943 varbinds[i].type = INT_VALUE;
945 varbinds[i].oid = SharedKey;
946 varbinds[i].len_oid = sizeof(SharedKey);
947 varbinds[i].value = (char *) &m_basic_rates;
948 varbinds[i].len_val = 1;
949 varbinds[i].type = INT_VALUE;
952 print_help(WAIT_SET);
953 if (snmp(varbinds, i, SET) <= 0) {
954 print_helperr(ERR_SET);
961 varbinds[i].oid = operAccessPointName;
962 varbinds[i].len_oid = sizeof(operAccessPointName);
963 varbinds[i].value = ap_name;
964 varbinds[i].len_val = c;
965 varbinds[i].type = STRING_VALUE;
970 c = strlen(ap_location);
971 varbinds[i].oid = operAccessPointLocation;
972 varbinds[i].len_oid = sizeof(operAccessPointLocation);
973 varbinds[i].value = ap_location;
974 varbinds[i].len_val = c;
975 varbinds[i].type = STRING_VALUE;
979 print_help(WAIT_SET);
980 if (snmp(varbinds, i, SET) <= 0) {
981 print_helperr(ERR_SET);
987 c = strlen(ap_contact);
988 varbinds[i].oid = operAccessPointContact;
989 varbinds[i].len_oid = sizeof(operAccessPointContact);
990 varbinds[i].value = ap_contact;
991 varbinds[i].len_val = c;
992 varbinds[i].type = STRING_VALUE;
996 varbinds[i].oid = operFragmentationThreshold;
997 varbinds[i].len_oid = sizeof(operFragmentationThreshold);
998 FragmentationThreshold = htons(FragmentationThreshold);
999 varbinds[i].value = (char *) &FragmentationThreshold;
1000 varbinds[i].len_val = 2;
1001 varbinds[i].type = 0x02;
1005 varbinds[i].oid = operRTSThreshold;
1006 varbinds[i].len_oid = sizeof(operRTSThreshold);
1007 RTSThreshold = htons(RTSThreshold);
1008 varbinds[i].value = (char *) &RTSThreshold;
1009 varbinds[i].len_val = 2;
1010 varbinds[i].type = 0x02;
1014 varbinds[i].oid = sysTrapSwitch;
1015 varbinds[i].len_oid = sizeof(sysTrapSwitch);
1016 varbinds[i].value = &traps;
1017 varbinds[i].len_val = 1;
1018 varbinds[i].type = 0x02;
1021 print_help(WAIT_SET);
1022 if (snmp(varbinds, i, SET) <= 0) {
1023 print_helperr(ERR_SET);
1027 for (i = 0; i < 4; i++)
1029 varbinds[c].oid = oid_dot11SupportedAntenna[i];
1030 varbinds[c].len_oid =
1031 sizeof(oid_dot11SupportedAntenna[i]);
1032 varbinds[c].value = &antenna[i];
1033 varbinds[c].len_val = 1;
1034 varbinds[c].type = INT_VALUE;
1037 print_help(WAIT_SET);
1038 if (snmp(varbinds, c, SET) <= 0) {
1039 print_helperr(ERR_SET);
1043 for (i = i; i < 6; i++)
1045 varbinds[c].oid = oid_dot11SupportedAntenna[i];
1046 varbinds[c].len_oid =
1047 sizeof(oid_dot11SupportedAntenna[i]);
1048 varbinds[c].value = &antenna[i];
1049 varbinds[c].len_val = 1;
1050 varbinds[c].type = INT_VALUE;
1053 print_help(WAIT_SET);
1054 if (snmp(varbinds, c, SET) <= 0) {
1055 print_helperr(ERR_SET);
1061 varbinds[i].oid = operESSID;
1062 varbinds[i].len_oid = sizeof(operESSID);
1063 varbinds[i].value = domain;
1064 varbinds[i].len_val = c;
1065 varbinds[i].type = 0x04;
1068 print_help(WAIT_SET);
1069 if (snmp(varbinds, i, SET) <= 0) {
1070 print_helperr(ERR_SET);
1074 print_help(DONE_SET);
1084 print_top(NULL, NULL);