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>
26 #include "ap-curses.h"
28 #define ESSID _("[E] ESSID: ")
29 #define AP_NAME _("[N] AP name: ")
31 #define CONTACT _("[K] AP contact: ")
32 #define LOCATION _("[L] AP location: ")
34 #define RTS_TR _("[R] RTS threshold: ")
35 #define FRG_TR _("[F] Fragmentation threshold: ")
36 #define PREAMBULE _("[P] Preambule type: ")
37 #define AUTH _("[A] Auth type: ")
38 #define OSYS _("Open system")
39 #define SH_KEY _("Shared key")
40 #define BOTH_TYPE _("Both types")
41 #define RETRAIN _("[U] Auto rate fallback: ")
42 #define HIDE_ESSID _("[S] Insert ESSID in broadcast packets: ")
43 #define RATES _("Basic and Supported rates:")
44 #define RATES_HEAD _("Key Rate Status")
45 #define RATES_RECORD "[%d] %4.1fM "
46 #define INT_ROAMING _("[I] International roaming: ")
47 #define BEACON_PER _("[B] Beacon period (msec): ")
48 #define DTIM_I _("[D] DTIM sending interval (beacons): ")
49 #define SIFS_T _("[T] SIFS time (msec): ")
50 #define WLAN_HELP _("[key] - set option; W - write conf; Q - quit to menu")
53 extern char IS_ATMEL12350_TELLUS;
54 extern char IS_ATMEL12350_VERNET;
58 char sysDeviceInfo[] = {
59 0x2B, 0x06, 0x01, 0x04, 0x01, 0x83, 0x1A, 0x01, 0x01, 0x01, 0x05, 0x00
62 char operChannelID[] = {
63 0x2B, 0x06, 0x01, 0x04, 0x01, 0x83, 0x1A, 0x01, 0x02, 0x01, 0x01, 0x00
65 char operESSIDLength[] = {
66 0x2B, 0x06, 0x01, 0x04, 0x01, 0x83, 0x1A, 0x01, 0x02, 0x01, 0x02, 0x00
69 0x2B, 0x06, 0x01, 0x04, 0x01, 0x83, 0x1A, 0x01, 0x02, 0x01, 0x03, 0x00
71 char operRTSThreshold[] = {
72 0x2B, 0x06, 0x01, 0x04, 0x01, 0x83, 0x1A, 0x01, 0x02, 0x01, 0x04, 0x00
74 char operFragmentationThreshold[] = {
75 0x2B, 0x06, 0x01, 0x04, 0x01, 0x83, 0x1A, 0x01, 0x02, 0x01, 0x05, 0x00
77 char operPreambleType[] = {
78 0x2B, 0x06, 0x01, 0x04, 0x01, 0x83, 0x1A, 0x01, 0x02, 0x01, 0x06, 0x00
80 char operAuthenticationType[] = {
81 0x2B, 0x06, 0x01, 0x04, 0x01, 0x83, 0x1A, 0x01, 0x02, 0x01, 0x07, 0x00
83 char operBasicRates[] = {
84 0x2B, 0x06, 0x01, 0x04, 0x01, 0x83, 0x1A, 0x01, 0x02, 0x01, 0x08, 0x00
86 char operAutoRateFallBack[] = {
87 0x2B, 0x06, 0x01, 0x04, 0x01, 0x83, 0x1A, 0x01, 0x02, 0x01, 0x09, 0x00
89 char operAccessPointName[] = {
90 0x2B, 0x06, 0x01, 0x04, 0x01, 0x83, 0x1A, 0x01, 0x02, 0x01, 0x0A, 0x00
92 char operSSIDBroadcasting[] = {
93 0x2B, 0x06, 0x01, 0x04, 0x01, 0x83, 0x1A, 0x01, 0x02, 0x01, 0x0B, 0x00
96 /* This one is ATMEL12350 MIB specific. */
97 char operInterRoaming[] = {
98 0x2B, 0x06, 0x01, 0x04, 0x01, 0xE0, 0x3E, 0x01, 0x02, 0x01, 0x0D, 0x00
100 /* These two are ATMEL12350 TELLUS MIB specific. */
101 char operBeaconPeriod[] = {
102 0x2B, 0x06, 0x01, 0x04, 0x01, 0xE0, 0x3E, 0x01, 0x02, 0x01, 0x0E, 0x00
105 0x2B, 0x06, 0x01, 0x04, 0x01, 0xE0, 0x3E, 0x01, 0x02, 0x01, 0x0F, 0x00
107 /* This one is ATMEL12350 VERNET MIB specific. */
108 char operSIFSTIME[] = {
109 0x2B, 0x06, 0x01, 0x04, 0x01, 0xE0, 0x3E, 0x01, 0x02, 0x01, 0x10, 0x00
112 extern WINDOW *main_sub;
113 varbind varbinds[16];
114 unsigned short int RTSThreshold, FragmentationThreshold,
115 InterRoaming, m_basic_rates = 0, first_channel = 1, BeaconPeriod = 0,
117 unsigned char dtim, ch;
118 char *AuthenticationTypes[3] = { OSYS, SH_KEY, BOTH_TYPE },
120 char domain[32], basic_rates[4], AutoRateFallBack, SSIDBroadcasting,
121 ap_name[32], ch_num = 0, PreambleType, AuthenticationType, channel;
122 char m_channel = 0, m_essid = 0, m_broadcast = 0, m_rts = 0,
123 m_fragment = 0, m_auth = 0, m_ap_name = 0, m_preambule = 0,
124 m_auto_rate = 0, m_inter_roaming = 0, m_beacon = 0, m_dtim = 0,
126 char *item_name[14], *rates[3] = { ON, OFF, BASIC }, *preambules[2] = {
127 _("Short"), _("Long")};
128 short __rates[4] = { 2, 4, 11, 22 };
130 unsigned short ap_regdomain;
131 struct SysDeviceInfo_ATMEL410 ptr410;
132 struct SysDeviceInfo_ATMEL12350 ptr12350;
135 if (ap_type == ATMEL12350) {
136 sysDeviceInfo[5] = 0xE0;
137 sysDeviceInfo[6] = 0x3E;
138 operChannelID[5] = 0xE0;
139 operChannelID[6] = 0x3E;
140 operESSIDLength[5] = 0xE0;
141 operESSIDLength[6] = 0x3E;
144 operRTSThreshold[5] = 0xE0;
145 operRTSThreshold[6] = 0x3E;
146 operFragmentationThreshold[5] = 0xE0;
147 operFragmentationThreshold[6] = 0x3E;
148 operPreambleType[5] = 0xE0;
149 operPreambleType[6] = 0x3E;
150 operAuthenticationType[5] = 0xE0;
151 operAuthenticationType[6] = 0x3E;
152 operBasicRates[5] = 0xE0;
153 operBasicRates[6] = 0x3E;
154 operAutoRateFallBack[5] = 0xE0;
155 operAutoRateFallBack[6] = 0x3E;
156 operAccessPointName[5] = 0xE0;
157 operAccessPointName[6] = 0x3E;
158 operSSIDBroadcasting[5] = 0xE0;
159 operSSIDBroadcasting[6] = 0x3E;
162 for (i = 0; i < 16; i++) {
163 varbinds[i].type = NULL_VALUE;
164 varbinds[i].len_val = 0;
165 varbinds[i].len_oid = sizeof(operChannelID);
170 varbinds[i++].oid = operChannelID;
171 varbinds[i++].oid = operESSIDLength;
172 varbinds[i++].oid = operESSID;
173 varbinds[i++].oid = operSSIDBroadcasting;
174 varbinds[i++].oid = operBasicRates;
175 varbinds[i++].oid = operAutoRateFallBack;
176 varbinds[i++].oid = operRTSThreshold;
177 varbinds[i++].oid = operFragmentationThreshold;
178 varbinds[i++].oid = operPreambleType;
179 varbinds[i++].oid = operAuthenticationType;
180 varbinds[i++].oid = operAccessPointName;
181 varbinds[i++].oid = sysDeviceInfo;
182 if (ap_type == ATMEL12350) {
183 varbinds[i++].oid = operInterRoaming;
184 if (IS_ATMEL12350_TELLUS) {
185 varbinds[i++].oid = operBeaconPeriod;
186 varbinds[i++].oid = operDTIM;
188 if (IS_ATMEL12350_VERNET)
189 varbinds[i++].oid = operSIFSTIME;
192 if (snmp(varbinds, i, GET) <= 0) {
193 print_helperr(ERR_RET);
197 channel = *(varbinds[0].value);
198 c = *(varbinds[1].value);
199 memcpy(domain, varbinds[2].value, 32);
200 SSIDBroadcasting = *(varbinds[3].value);
201 memcpy(basic_rates, varbinds[4].value, 4);
202 AutoRateFallBack = *(varbinds[5].value);
203 memcpy(&RTSThreshold, varbinds[6].value, 2);
204 RTSThreshold = ntohs(RTSThreshold);
205 memcpy(&FragmentationThreshold, varbinds[7].value, 2);
206 FragmentationThreshold = ntohs(FragmentationThreshold);
207 PreambleType = *(varbinds[8].value);
208 AuthenticationType = *(varbinds[9].value);
209 memcpy(ap_name, varbinds[10].value, 32);
210 if (ap_type == ATMEL12350) {
211 InterRoaming = *(varbinds[12].value);
212 if (IS_ATMEL12350_TELLUS) {
213 BeaconPeriod = varbinds[13].len_val == 2 ?
214 (varbinds[13].value[0] << 8) | varbinds[13].value[1] :
215 varbinds[13].value[0] < 0x80 ?
216 varbinds[13].value[0] : 0xff00 | varbinds[13].value[0];
217 dtim = *(varbinds[14].value);
219 if (IS_ATMEL12350_VERNET)
220 sifs = varbinds[15].len_val == 2 ?
221 (varbinds[15].value[0] << 8) | varbinds[15].value[1] :
222 varbinds[15].value[0] < 0x80 ?
223 varbinds[15].value[0] : 0xff00 | varbinds[15].value[0];
226 if (ap_type == ATMEL12350) {
227 memcpy(&ptr12350, varbinds[11].value,
228 sizeof(struct SysDeviceInfo_ATMEL12350));
229 ap_regdomain=ptr12350.RegulationDomain;
230 } else /* ATMEL410 */{
231 memcpy(&ptr410, varbinds[11].value,
232 sizeof(struct SysDeviceInfo_ATMEL410));
233 ap_regdomain = swap4(ptr410.RegulationDomain);
236 if ((ch_num = ch_list(ap_regdomain, item_name)) == 0) {
237 print_helperr(ERR_RET);
240 if (ap_regdomain == 0x31 || ap_regdomain == 0x32)
243 print_title(_("Wireless Settings"));
245 sprintf(message, "%s%02u (%u MHz)", CHANNEL, channel, 2407 + 5 * channel);
246 mvwaddstr(main_sub, 0, 0, message);
247 mvwaddstr(main_sub, 1, 0, ESSID);
248 waddnstr(main_sub, domain, c);
249 mvwaddstr(main_sub, 2, 0, AP_NAME);
250 for (i = 0; i < 32 && ap_name[i]; i++)
251 mvwaddch(main_sub, 2, strlen(AP_NAME) + i, ap_name[i]);
252 sprintf(message, "%s%d", RTS_TR, RTSThreshold);
253 mvwaddstr(main_sub, 3, 0, message);
254 sprintf(message, "%s%d", FRG_TR, FragmentationThreshold);
255 mvwaddstr(main_sub, 4, 0, message);
256 sprintf(message, "%s%s", PREAMBULE, preambules[PreambleType - 1]);
257 mvwaddstr(main_sub, 5, 0, message);
258 sprintf(message, "%s%s", AUTH, AuthenticationTypes[AuthenticationType - 1]);
259 mvwaddstr(main_sub, 6, 0, message);
260 sprintf(message, "%s%s", RETRAIN, (AutoRateFallBack == 1) ? ON : OFF);
261 mvwaddstr(main_sub, 7, 0, message);
262 sprintf(message, "%s%s", HIDE_ESSID, (SSIDBroadcasting == 1) ? ON : OFF);
263 mvwaddstr(main_sub, 8, 0, message);
264 mvwaddstr(main_sub, 9, 0, RATES);
265 mvwaddstr(main_sub, 10, 2, RATES_HEAD);
266 for (i = 0; i < 4; i++) {
267 sprintf(message, RATES_RECORD "%s", i + 1, (float) __rates[i] / 2,
268 basic(basic_rates[i]));
269 mvwaddstr(main_sub, 11 + i, 2, message);
271 if (ap_type == ATMEL12350) {
272 sprintf(message, "%s%s", INT_ROAMING, (InterRoaming == 1) ? ON : OFF);
273 mvwaddstr(main_sub, 15, 0, message);
274 if (IS_ATMEL12350_TELLUS) {
275 sprintf(message, "%s%u", BEACON_PER, BeaconPeriod);
276 mvwaddstr(main_sub, 16, 0, message);
277 sprintf(message, "%s%u", DTIM_I, dtim);
278 mvwaddstr(main_sub, 17, 0, message);
280 if (IS_ATMEL12350_VERNET) {
281 sprintf(message, "%s%u", SIFS_T, sifs);
282 mvwaddstr(main_sub, 18, 0, message);
288 print_help(WLAN_HELP);
303 switch (menu_choose(10 + i, 15, rates, 3)) {
305 basic_rates[i - 1] = __rates[i - 1];
308 basic_rates[i - 1] = 0;
311 basic_rates[i - 1] = __rates[i - 1] + 0x80;
313 clear_main_new(10 + i, 11 + i);
314 sprintf(message, RATES_RECORD, i, (float) __rates[i - 1] / 2);
315 print_menusel(10 + i, 2, message, basic(basic_rates[i - 1]));
320 channel = menu_choose(0, strlen(CHANNEL), item_name, ch_num)
322 sprintf(message, "%02u (%u MHz)", channel, 2407 + 5 * channel);
323 print_menusel(0, 0, CHANNEL, message);
329 menu_choose(6, strlen(AUTH), AuthenticationTypes, 3) + 1;
330 clear_main_new(6, 7);
331 print_menusel(6, 0, AUTH,
332 AuthenticationTypes[AuthenticationType - 1]);
337 PreambleType = menu_choose(5, strlen(PREAMBULE), preambules, 2) + 1;
338 clear_main_new(5, 6);
339 print_menusel(5, 0, PREAMBULE, preambules[PreambleType - 1]);
344 AutoRateFallBack = on_off(7, strlen(RETRAIN));
345 clear_main_new(7, 8);
346 print_menusel(7, 0, RETRAIN, (AutoRateFallBack == 1) ? ON : OFF);
351 SSIDBroadcasting = on_off(8, strlen(HIDE_ESSID));
352 clear_main_new(8, 9);
353 print_menusel(8, 0, HIDE_ESSID, (SSIDBroadcasting == 1) ? ON : OFF);
358 // make_field(2, strlen(AP_NAME), 32);
359 get_value(ap_name, 2, strlen(AP_NAME), 32, ANY_STRING, 0, 0, NULL);
364 // make_field(1, strlen(ESSID), 32);
365 get_value(domain, 1, strlen(ESSID), 32, ANY_STRING, 0, 0, NULL);
370 // make_field(4, strlen(FRG_TR), 6);
371 get_value(message, 4, strlen(FRG_TR), 6, INT_STRING, 256, 2346,
373 FragmentationThreshold = atoi(message);
378 // make_field(3, strlen(RTS_TR), 6);
379 get_value(message, 3, strlen(RTS_TR), 6, INT_STRING, 0, 2347,
381 RTSThreshold = atoi(message);
386 if (ap_type == ATMEL410)
388 InterRoaming = on_off(15, strlen(INT_ROAMING));
389 clear_main_new(15, 16);
390 print_menusel(15, 0, INT_ROAMING, (InterRoaming == 1) ? ON : OFF);
395 if (!IS_ATMEL12350_TELLUS)
397 get_value(message, 16, strlen(BEACON_PER), 6, INT_STRING, 0, 65535,
399 BeaconPeriod = atoi(message);
404 if (!IS_ATMEL12350_TELLUS)
406 get_value(message, 17, strlen(DTIM_I), 4, INT_STRING, 0, 255,
408 dtim = atoi(message);
413 if (!IS_ATMEL12350_VERNET)
415 get_value(message, 18, strlen(SIFS_T), 6, INT_STRING, 0, 65535,
417 sifs = atoi(message);
424 varbinds[i].oid = operChannelID;
425 varbinds[i].len_oid = sizeof(operChannelID);
426 varbinds[i].value = (char *) &channel;
427 varbinds[i].len_val = 1;
428 varbinds[i].type = INT_VALUE;
432 for (m_basic_rates = 0; m_basic_rates < 2; m_basic_rates++) {
433 c = basic_rates[3 - m_basic_rates];
434 basic_rates[3 - m_basic_rates] =
435 basic_rates[m_basic_rates];
436 basic_rates[m_basic_rates] = c;
438 varbinds[i].oid = operBasicRates;
439 varbinds[i].len_oid = sizeof(operBasicRates);
440 varbinds[i].value = basic_rates;
441 varbinds[i].len_val = 4;
442 varbinds[i].type = INT_VALUE;
446 varbinds[i].oid = operSSIDBroadcasting;
447 varbinds[i].len_oid = sizeof(operSSIDBroadcasting);
448 varbinds[i].value = (char *) &SSIDBroadcasting;
449 varbinds[i].len_val = 1;
450 varbinds[i].type = INT_VALUE;
454 varbinds[i].oid = operAuthenticationType;
455 varbinds[i].len_oid = sizeof(operAuthenticationType);
456 varbinds[i].value = &AuthenticationType;
457 varbinds[i].len_val = 1;
458 varbinds[i].type = INT_VALUE;
462 varbinds[i].oid = operPreambleType;
463 varbinds[i].len_oid = sizeof(operPreambleType);
464 varbinds[i].value = &PreambleType;
465 varbinds[i].len_val = 1;
466 varbinds[i].type = INT_VALUE;
470 varbinds[i].oid = operAutoRateFallBack;
471 varbinds[i].len_oid = sizeof(operAutoRateFallBack);
472 varbinds[i].value = &AutoRateFallBack;
473 varbinds[i].len_val = 1;
474 varbinds[i].type = INT_VALUE;
479 varbinds[i].oid = operAccessPointName;
480 varbinds[i].len_oid = sizeof(operAccessPointName);
481 varbinds[i].value = ap_name;
482 varbinds[i].len_val = c;
483 varbinds[i].type = STRING_VALUE;
487 varbinds[i].oid = operFragmentationThreshold;
488 varbinds[i].len_oid = sizeof(operFragmentationThreshold);
489 FragmentationThreshold = htons(FragmentationThreshold);
490 varbinds[i].value = (char *) &FragmentationThreshold;
491 varbinds[i].len_val = 2;
492 varbinds[i].type = INT_VALUE;
496 varbinds[i].oid = operRTSThreshold;
497 varbinds[i].len_oid = sizeof(operRTSThreshold);
498 RTSThreshold = htons(RTSThreshold);
499 varbinds[i].value = (char *) &RTSThreshold;
500 varbinds[i].len_val = 2;
501 varbinds[i].type = INT_VALUE;
506 varbinds[i].oid = operESSIDLength;
507 varbinds[i].len_oid = sizeof(operESSIDLength);
508 varbinds[i].value = (char *)&ch;
509 varbinds[i].len_val = 1;
510 varbinds[i].type = INT_VALUE;
512 varbinds[i].oid = operESSID;
513 varbinds[i].len_oid = sizeof(operESSID);
514 varbinds[i].value = domain;
515 varbinds[i].len_val = ch;
516 varbinds[i].type = STRING_VALUE;
519 if (m_inter_roaming) {
520 varbinds[i].oid = operInterRoaming;
521 varbinds[i].len_oid = sizeof(operInterRoaming);
522 varbinds[i].value = (char *) &InterRoaming;
523 varbinds[i].len_val = 1;
524 varbinds[i].type = INT_VALUE;
528 varbinds[i].oid = operBeaconPeriod;
529 varbinds[i].len_oid = sizeof(operBeaconPeriod);
530 BeaconPeriod = htons(BeaconPeriod);
531 varbinds[i].value = (char *) &BeaconPeriod;
532 varbinds[i].len_val = 2;
533 varbinds[i].type = INT_VALUE;
537 varbinds[i].oid = operDTIM;
538 varbinds[i].len_oid = sizeof(operDTIM);
539 varbinds[i].value = (char *) &dtim;
540 varbinds[i].len_val = 1;
541 varbinds[i].type = INT_VALUE;
545 varbinds[i].oid = operSIFSTIME;
546 varbinds[i].len_oid = sizeof(operSIFSTIME);
548 varbinds[i].value = (char *) &sifs;
549 varbinds[i].len_val = 2;
550 varbinds[i].type = INT_VALUE;
554 print_help(WAIT_SET);
555 if (snmp(varbinds, i, SET) <= 0) {
556 print_helperr(ERR_SET);
559 print_help(DONE_SET);
567 /* free memory allocated for channel list */
568 for (i = 0; i < ch_num; i++)
579 char oid_dot11SupportedAntenna[][11] = {
580 {0x2a, 0x86, 0x48, 0xce, 0x34, 0x04, 0x08, 0x01, 0x02, 0x01, 0x01},
581 {0x2a, 0x86, 0x48, 0xce, 0x34, 0x04, 0x08, 0x01, 0x02, 0x01, 0x02},
582 {0x2a, 0x86, 0x48, 0xce, 0x34, 0x04, 0x08, 0x01, 0x03, 0x01, 0x01},
583 {0x2a, 0x86, 0x48, 0xce, 0x34, 0x04, 0x08, 0x01, 0x03, 0x01, 0x02},
584 {0x2a, 0x86, 0x48, 0xce, 0x34, 0x04, 0x08, 0x01, 0x04, 0x01, 0x01},
585 {0x2a, 0x86, 0x48, 0xce, 0x34, 0x04, 0x08, 0x01, 0x04, 0x01, 0x02}
589 { 0x2b, 0x06, 0x01, 0x04, 0x01, 0x87, 0x29, 0x03, 0x01, 0x02, 0x01,
592 char operChannelID[] =
593 { 0x2a, 0x86, 0x48, 0xce, 0x34, 0x04, 0x05, 0x01, 0x01, 0x01 };
594 char sysTrapSwitch[] =
595 { 0x2B, 0x06, 0x01, 0x02, 0x01, 0x0b, 0x1e, 0x00 };
598 { 0x2a, 0x86, 0x48, 0xce, 0x34, 0x01, 0x01, 0x01, 0x09, 0x01 };
600 char operRTSThreshold[] =
601 { 0x2a, 0x86, 0x48, 0xce, 0x34, 0x02, 0x01, 0x01, 0x02, 0x01 };
602 char operFragmentationThreshold[] =
603 { 0x2a, 0x86, 0x48, 0xce, 0x34, 0x02, 0x01, 0x01, 0x05, 0x01 };
605 { 0x2a, 0x86, 0x48, 0xce, 0x34, 0x01, 0x02, 0x01, 0x03, 0x01,
609 { 0x2a, 0x86, 0x48, 0xce, 0x34, 0x01, 0x02, 0x01, 0x03, 0x01,
612 char operBasicRates[] =
613 { 0x2a, 0x86, 0x48, 0xce, 0x34, 0x01, 0x01, 0x01, 0xb, 0x01 };
614 char operAccessPointName[] =
615 { 0x2b, 0x06, 0x01, 0x02, 0x01, 0x01, 0x05, 0x00 };
616 char operAccessPointContact[] =
617 { 0x2b, 0x06, 0x01, 0x02, 0x01, 0x01, 0x04, 0x00 };
618 char operAccessPointLocation[] =
619 { 0x2b, 0x06, 0x01, 0x02, 0x01, 0x01, 0x06, 0x00 };
621 unsigned short int i, RTSThreshold, FragmentationThreshold,
622 m_basic_rates = 0, authi;
623 char *auth[3] = { OSYS, SH_KEY, BOTH_TYPE },
624 *rates[3] = { ON, OFF, BASIC },
626 m_antenna[6] = { 0, 0, 0, 0, 0, 0 },
628 channel_pref[2] = { 0, 0 };
629 extern WINDOW *main_sub;
630 char *domain, basic_rates[] =
631 { 0, 0, 0, 0 }, *ap_name, ap_location[32], ap_contact[32],
632 m_ap_contact = 0, m_ap_location = 0;
633 char m_channel = 0, m_essid = 0, m_rts = 0, m_fragment = 0, m_auth =
634 0, m_ap_name = 0, channel, traps, m_traps = 0;
635 varbind varbinds[11];
636 int c=0, ch_num = 0, first_channel=1, reg_domain=0;
637 short __rates[4] = { 2, 4, 11, 22};
639 domain = (char *) calloc(32, 1);
640 ap_name = (char *) calloc(32, 1);
642 for (i = 0; i < 8; i++) {
643 varbinds[i].len_val = 0;
644 varbinds[i].type = NULL_VALUE;
646 varbinds[0].oid = operChannelID;
647 varbinds[0].len_oid = sizeof(operChannelID);
648 varbinds[1].oid = operESSID;
649 varbinds[1].len_oid = sizeof(operESSID);
650 varbinds[2].oid = operRTSThreshold;
651 varbinds[2].len_oid = sizeof(operRTSThreshold);
652 varbinds[3].oid = operFragmentationThreshold;
653 varbinds[3].len_oid = sizeof(operFragmentationThreshold);
654 varbinds[4].oid = operBasicRates;
655 varbinds[4].len_oid = sizeof(operBasicRates);
656 varbinds[5].oid = OpenSystem;
657 varbinds[5].len_oid = sizeof(OpenSystem);
658 varbinds[6].oid = SharedKey;
659 varbinds[6].len_oid = sizeof(SharedKey);
660 varbinds[7].oid = operAccessPointName;
661 varbinds[7].len_oid = sizeof(operAccessPointName);
662 print_help(WAIT_RET);
663 if (snmp(varbinds, 8, GET) <= 0) {
664 print_helperr(ERR_RET);
668 channel = *(varbinds[0].value);
669 memcpy(domain, varbinds[1].value, varbinds[1].len_val);
670 memcpy(basic_rates, varbinds[4].value, varbinds[4].len_val);
671 memcpy(&RTSThreshold, (varbinds[2].value), 2);
672 RTSThreshold = ntohs(RTSThreshold);
673 memcpy(&FragmentationThreshold, (varbinds[3].value), 2);
674 FragmentationThreshold = ntohs(FragmentationThreshold);
675 authi = (*(varbinds[5].value) == 1 && *(varbinds[6].value) == 1) ? 2 :
676 (*(varbinds[5].value) == 1) ? 0 : 1;
677 memcpy(ap_name, varbinds[7].value, varbinds[7].len_val);
679 sprintf(message, "%s%02u (%u MHz)", CHANNEL, channel, 2407 + 5 * channel);
680 mvwaddstr(main_sub, 0, 0, message);
681 mvwaddstr(main_sub, 1, 0, ESSID);
682 for (i = 0; i < 32 && domain[i]; i++)
683 mvwaddch(main_sub, 1, strlen(ESSID) + i, domain[i]);
684 mvwaddstr(main_sub, 2, 0, AP_NAME);
685 for (i = 0; i < 32 && ap_name[i]; i++)
686 mvwaddch(main_sub, 2, strlen(AP_NAME) + i, ap_name[i]);
687 sprintf(message, "%s%d", RTS_TR, RTSThreshold);
688 mvwaddstr(main_sub, 3, 0, message);
689 sprintf(message, "%s%d", FRG_TR, FragmentationThreshold);
690 mvwaddstr(main_sub, 4, 0, message);
691 sprintf(message, "%s%s", AUTH, auth[authi]);
692 mvwaddstr(main_sub, 6, 0, message);
693 mvwaddstr(main_sub, 9, 0, RATES);
694 mvwaddstr(main_sub, 10, 2, RATES_HEAD);
695 for(i = 0; i < 4; i++) {
696 sprintf(message, RATES_RECORD "%s", i + 1, (float) __rates[i] / 2,
697 basic(basic_rates[i]));
698 mvwaddstr(main_sub, 11+i, 2, message);
701 reg_domain = get_RegDomain();
702 if ((ch_num = ch_list(reg_domain, item_name)) == 0) {
703 print_helperr(ERR_RET);
707 if(reg_domain == 0x31 || reg_domain == 0x32)
710 for (i = 0; i < 9; i++) {
711 varbinds[i].len_val = 0;
712 varbinds[i].type = NULL_VALUE;
715 for (i = 0; i < 6; i++) {
716 varbinds[i].oid = oid_dot11SupportedAntenna[i];
717 varbinds[i].len_oid = sizeof(oid_dot11SupportedAntenna[i]);
719 varbinds[6].oid = sysTrapSwitch;
720 varbinds[6].len_oid = sizeof(sysTrapSwitch);
721 varbinds[7].oid = operAccessPointContact;
722 varbinds[7].len_oid = sizeof(operAccessPointContact);
723 varbinds[8].oid = operAccessPointLocation;
724 varbinds[8].len_oid = sizeof(operAccessPointLocation);
726 if (snmp(varbinds, 9, GET) <= 0) {
727 print_helperr(ERR_RET);
731 for (i = 0; i < 6; i++) {
732 antenna[i] = *varbinds[i].value;
735 traps = *(varbinds[6].value);
736 memcpy(ap_contact, varbinds[7].value, varbinds[7].len_val);
737 if (varbinds[7].len_val < 32)
738 ap_contact[varbinds[7].len_val] = '\0';
739 memcpy(ap_location, varbinds[8].value, varbinds[8].len_val);
740 if (varbinds[8].len_val < 32)
741 ap_location[varbinds[8].len_val] = '\0';
743 sprintf(message, "%s%s", LOCATION, ap_location);
744 mvwaddstr(main_sub, 7, 0, message);
745 sprintf(message, "%s%s", CONTACT, ap_contact);
746 mvwaddstr(main_sub, 8, 0, message);
747 sprintf(message, "%s%s", TRAPS, (traps == 1) ? ON : OFF);
748 mvwaddstr(main_sub, 5, 0, message);
750 mvwaddstr(main_sub, 16, 0, _("Antenna Configuration:"));
751 sprintf(message, "%s %s %3s, %s %3s",
753 ANTENNA_RX_LEFT, (antenna[2] == 1) ? ON : OFF,
754 ANTENNA_RX_RIGHT, (antenna[3] == 1) ? ON : OFF);
755 mvwaddstr(main_sub, 17, 1, message);
756 sprintf(message, "%s %s %3s, %s %3s",
758 ANTENNA_TX_LEFT, (antenna[0] == 1) ? ON : OFF,
759 ANTENNA_TX_RIGHT, (antenna[1] == 1) ? ON : OFF);
760 mvwaddstr(main_sub, 18, 1, message);
761 sprintf(message, "%s %s %3s, %s %3s",
763 ANTENNA_DV_LEFT, (antenna[4] == 1) ? ON : OFF,
764 ANTENNA_DV_RIGHT, (antenna[5] == 1) ? ON : OFF);
765 mvwaddstr(main_sub, 19, 1, message);
767 print_title(_("General Options"));
769 ("UIOPTY - antenna; SCANLEDFR1234 - options; W - write conf; Q - quit to menu"));
779 i = strlen(ANTENNA_RX) + 1 +
780 strlen(ANTENNA_RX_LEFT) + 6 +
781 strlen(ANTENNA_RX_RIGHT) + 2;
782 antenna[3] = on_off(17, i);
783 sprintf(message, "%3s", (antenna[3] == 1) ? ON : OFF);
784 print_menusel(17, i, NULL, message);
789 i = strlen(ANTENNA_RX) + 1 +
790 strlen(ANTENNA_RX_LEFT) + 2;
791 antenna[2] = on_off(17, i);
792 sprintf(message, "%3s", (antenna[2] == 1) ? ON : OFF);
793 print_menusel(17, i, NULL, message);
798 i = strlen(ANTENNA_TX) + 1 +
799 strlen(ANTENNA_TX_LEFT) + 6 +
800 strlen(ANTENNA_TX_RIGHT) + 2;
801 antenna[1] = on_off(18, i);
802 sprintf(message, "%3s", (antenna[1] == 1) ? ON : OFF);
803 print_menusel(18, i, NULL, message);
808 i = strlen(ANTENNA_TX) + 1 +
809 strlen(ANTENNA_TX_LEFT) + 2;
810 antenna[0] = on_off(18, i);
811 sprintf(message, "%3s", (antenna[0] == 1) ? ON : OFF);
812 print_menusel(18, i, NULL, message);
817 i = strlen(ANTENNA_DV) + 1 +
818 strlen(ANTENNA_DV_LEFT) + 2;
819 antenna[4] = on_off(19, i);
820 sprintf(message, "%3s", (antenna[4] == 1) ? ON : OFF);
821 print_menusel(19, i, NULL, message);
826 i = strlen(ANTENNA_DV) + 1 +
827 strlen(ANTENNA_DV_LEFT) + 6 +
828 strlen(ANTENNA_DV_RIGHT) + 2;
829 antenna[5] = on_off(19, i);
830 sprintf(message, "%3s", (antenna[5] == 1) ? ON : OFF);
831 print_menusel(19, i, NULL, message);
836 traps = on_off(5, strlen(TRAPS));
837 clear_main_new(5, 6);
838 print_menusel(5, 0, TRAPS, (traps == 1) ? ON : OFF);
849 switch (menu_choose(10 + i, 15, rates, 3)) {
851 basic_rates[i-1] = __rates[i-1];
854 basic_rates[i-1] = 0;
857 basic_rates[i-1] = __rates[i-1] + 0x80;
859 clear_main_new(10 + i, 11 + i);
860 sprintf(message, RATES_RECORD, i, (float) __rates[i-1] / 2);
861 print_menusel(10 + i, 2, message, basic(basic_rates[i-1]));
866 channel = menu_choose(0, strlen(CHANNEL), item_name, ch_num)
868 sprintf(message, "%02u (%u MHz)", channel, 2407 + 5 * channel);
869 print_menusel(0, 0, CHANNEL, message);
874 authi = menu_choose(6, strlen(AUTH), auth, 3);
875 clear_main_new(6, 7);
876 print_menusel(6, 0, AUTH, auth[authi]);
881 get_value(ap_name, 2, strlen(AP_NAME), 32, ANY_STRING, 0, 0, NULL);
886 get_value(ap_location, 7, strlen(LOCATION), 32, ANY_STRING, 0, 0,
892 get_value(ap_contact, 8, strlen(CONTACT), 32, ANY_STRING, 0, 0,
898 get_value(domain, 1, strlen(ESSID), 32, ANY_STRING, 0, 0, NULL);
903 get_value(message, 4, strlen(FRG_TR), 6, INT_STRING, 256, 2346,
905 FragmentationThreshold = atoi(message);
910 get_value(message, 3, strlen(RTS_TR), 6, INT_STRING, 0, 2347,
912 RTSThreshold = atoi(message);
919 channel_pref[0] = channel;
920 varbinds[i].oid = ChannelPref;
921 varbinds[i].len_oid = sizeof(ChannelPref);
922 varbinds[i].value = channel_pref;
923 varbinds[i].len_val = 2;
924 varbinds[i].type = STRING_VALUE;
926 varbinds[i].oid = operChannelID;
927 varbinds[i].len_oid = sizeof(operChannelID);
928 varbinds[i].value = (char *) &channel;
929 varbinds[i].len_val = 1;
930 varbinds[i].type = 0x02;
935 varbinds[i].oid = operBasicRates;
936 varbinds[i].len_oid = sizeof(operBasicRates);
937 varbinds[i].value = basic_rates;
938 varbinds[i].len_val = 4;
939 varbinds[i].type = STRING_VALUE;
943 print_help(WAIT_SET);
944 if (snmp(varbinds, i, SET) <= 0) {
945 print_helperr(ERR_SET);
951 m_auth = (authi == 1) ? 2 : 1;
952 m_basic_rates = (authi == 0) ? 2 : 1;
953 varbinds[i].oid = OpenSystem;
954 varbinds[i].len_oid = sizeof(OpenSystem);
955 varbinds[i].value = (char *) &m_auth;
956 varbinds[i].len_val = 1;
957 varbinds[i].type = INT_VALUE;
959 varbinds[i].oid = SharedKey;
960 varbinds[i].len_oid = sizeof(SharedKey);
961 varbinds[i].value = (char *) &m_basic_rates;
962 varbinds[i].len_val = 1;
963 varbinds[i].type = INT_VALUE;
966 print_help(WAIT_SET);
967 if (snmp(varbinds, i, SET) <= 0) {
968 print_helperr(ERR_SET);
975 varbinds[i].oid = operAccessPointName;
976 varbinds[i].len_oid = sizeof(operAccessPointName);
977 varbinds[i].value = ap_name;
978 varbinds[i].len_val = c;
979 varbinds[i].type = STRING_VALUE;
984 c = strlen(ap_location);
985 varbinds[i].oid = operAccessPointLocation;
986 varbinds[i].len_oid = sizeof(operAccessPointLocation);
987 varbinds[i].value = ap_location;
988 varbinds[i].len_val = c;
989 varbinds[i].type = STRING_VALUE;
993 print_help(WAIT_SET);
994 if (snmp(varbinds, i, SET) <= 0) {
995 print_helperr(ERR_SET);
1001 c = strlen(ap_contact);
1002 varbinds[i].oid = operAccessPointContact;
1003 varbinds[i].len_oid = sizeof(operAccessPointContact);
1004 varbinds[i].value = ap_contact;
1005 varbinds[i].len_val = c;
1006 varbinds[i].type = STRING_VALUE;
1010 varbinds[i].oid = operFragmentationThreshold;
1011 varbinds[i].len_oid = sizeof(operFragmentationThreshold);
1012 FragmentationThreshold = htons(FragmentationThreshold);
1013 varbinds[i].value = (char *) &FragmentationThreshold;
1014 varbinds[i].len_val = 2;
1015 varbinds[i].type = 0x02;
1019 varbinds[i].oid = operRTSThreshold;
1020 varbinds[i].len_oid = sizeof(operRTSThreshold);
1021 RTSThreshold = htons(RTSThreshold);
1022 varbinds[i].value = (char *) &RTSThreshold;
1023 varbinds[i].len_val = 2;
1024 varbinds[i].type = 0x02;
1028 varbinds[i].oid = sysTrapSwitch;
1029 varbinds[i].len_oid = sizeof(sysTrapSwitch);
1030 varbinds[i].value = &traps;
1031 varbinds[i].len_val = 1;
1032 varbinds[i].type = 0x02;
1035 print_help(WAIT_SET);
1036 if (snmp(varbinds, i, SET) <= 0) {
1037 print_helperr(ERR_SET);
1041 for (i = 0; i < 4; i++)
1043 varbinds[c].oid = oid_dot11SupportedAntenna[i];
1044 varbinds[c].len_oid =
1045 sizeof(oid_dot11SupportedAntenna[i]);
1046 varbinds[c].value = &antenna[i];
1047 varbinds[c].len_val = 1;
1048 varbinds[c].type = INT_VALUE;
1051 print_help(WAIT_SET);
1052 if (snmp(varbinds, c, SET) <= 0) {
1053 print_helperr(ERR_SET);
1057 for (i = i; i < 6; i++)
1059 varbinds[c].oid = oid_dot11SupportedAntenna[i];
1060 varbinds[c].len_oid =
1061 sizeof(oid_dot11SupportedAntenna[i]);
1062 varbinds[c].value = &antenna[i];
1063 varbinds[c].len_val = 1;
1064 varbinds[c].type = INT_VALUE;
1067 print_help(WAIT_SET);
1068 if (snmp(varbinds, c, SET) <= 0) {
1069 print_helperr(ERR_SET);
1075 varbinds[i].oid = operESSID;
1076 varbinds[i].len_oid = sizeof(operESSID);
1077 varbinds[i].value = domain;
1078 varbinds[i].len_val = c;
1079 varbinds[i].type = 0x04;
1082 print_help(WAIT_SET);
1083 if (snmp(varbinds, i, SET) <= 0) {
1084 print_helperr(ERR_SET);
1088 print_help(DONE_SET);
1100 /* free memory allocated for channel list */
1101 for (i = 0; i < ch_num; i++)