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 WLAN_HELP _("[key] - set option; W - write conf; Q - quit to menu")
55 char sysDeviceInfo[] =
56 { 0x2B, 0x06, 0x01, 0x04, 0x01, 0x83, 0x1A, 0x01, 0x01, 0x01, 0x05,
59 char operEthernetAddress[] =
60 { 0x2B, 0x06, 0x01, 0x04, 0x01, 0x83, 0x1A, 0x01, 0x01, 0x02, 0x03,
64 char operChannelID[] =
65 { 0x2B, 0x06, 0x01, 0x04, 0x01, 0x83, 0x1A, 0x01, 0x02, 0x01, 0x01,
68 char operESSIDLength[] =
69 { 0x2B, 0x06, 0x01, 0x04, 0x01, 0x83, 0x1A, 0x01, 0x02, 0x01, 0x02,
73 { 0x2B, 0x06, 0x01, 0x04, 0x01, 0x83, 0x1A, 0x01, 0x02, 0x01, 0x03,
76 char operRTSThreshold[] =
77 { 0x2B, 0x06, 0x01, 0x04, 0x01, 0x83, 0x1A, 0x01, 0x02, 0x01, 0x04,
80 char operFragmentationThreshold[] =
81 { 0x2B, 0x06, 0x01, 0x04, 0x01, 0x83, 0x1A, 0x01, 0x02, 0x01, 0x05,
84 char operPreambleType[] =
85 { 0x2B, 0x06, 0x01, 0x04, 0x01, 0x83, 0x1A, 0x01, 0x02, 0x01, 0x06,
88 char operAuthenticationType[] =
89 { 0x2B, 0x06, 0x01, 0x04, 0x01, 0x83, 0x1A, 0x01, 0x02, 0x01, 0x07,
92 char operBasicRates[] =
93 { 0x2B, 0x06, 0x01, 0x04, 0x01, 0x83, 0x1A, 0x01, 0x02, 0x01, 0x08,
96 char operAutoRateFallBack[] =
97 { 0x2B, 0x06, 0x01, 0x04, 0x01, 0x83, 0x1A, 0x01, 0x02, 0x01, 0x09,
100 char operAccessPointName[] =
101 { 0x2B, 0x06, 0x01, 0x04, 0x01, 0x83, 0x1A, 0x01, 0x02, 0x01, 0x0A,
104 char operSSIDBroadcasting[] =
105 { 0x2B, 0x06, 0x01, 0x04, 0x01, 0x83, 0x1A, 0x01, 0x02, 0x01, 0x0B,
109 /* This one is ATMEL12350 MIB specific. */
110 char operInterRoaming[] =
111 { 0x2B, 0x06, 0x01, 0x04, 0x01, 0xE0, 0x3E, 0x01, 0x02, 0x01, 0x0D,
114 /* These two are ATMEL12350 TELLUS MIB specific. */
115 char operBeaconPeriod[] =
116 { 0x2B, 0x06, 0x01, 0x04, 0x01, 0xE0, 0x3E, 0x01, 0x02, 0x01, 0x0E,
120 { 0x2B, 0x06, 0x01, 0x04, 0x01, 0xE0, 0x3E, 0x01, 0x02, 0x01, 0x0F,
124 extern WINDOW *main_sub;
125 varbind varbinds[15];
126 unsigned short int RTSThreshold, FragmentationThreshold,
127 InterRoaming, m_basic_rates = 0, first_channel = 1;
128 unsigned int BeaconPeriod = 0;
129 unsigned char dtim, ch;
130 char *AuthenticationTypes[3] = { OSYS, SH_KEY, BOTH_TYPE },
132 oui_tellus[3] = { 0x00, 0x04, 0xDB },
133 IS_ATMEL12350_TELLUS = 0; /* ATMEL12350 Tellus uses different MIB */
134 char domain[32], basic_rates[4], AutoRateFallBack, SSIDBroadcasting,
135 ap_name[32], ch_num = 0, PreambleType, AuthenticationType, channel;
136 char m_channel = 0, m_essid = 0, m_broadcast = 0, m_rts = 0,
137 m_fragment = 0, m_auth = 0, m_ap_name = 0, m_preambule = 0,
138 m_auto_rate = 0, m_inter_roaming = 0, m_beacon = 0, m_dtim = 0;
139 char *item_name[14], *rates[3] = { ON, OFF, BASIC }, *preambules[2] = {
140 _("Short"), _("Long")};
141 short __rates[4] = { 2, 4, 11, 22 };
143 unsigned short ap_regdomain;
144 struct SysDeviceInfo_ATMEL410 ptr410;
145 struct SysDeviceInfo_ATMEL12350 ptr12350;
148 if (ap_type == ATMEL12350) {
149 sysDeviceInfo[5] = 0xE0;
150 sysDeviceInfo[6] = 0x3E;
151 operEthernetAddress[5] = 0xE0;
152 operEthernetAddress[6] = 0x3E;
153 operChannelID[5] = 0xE0;
154 operChannelID[6] = 0x3E;
155 operESSIDLength[5] = 0xE0;
156 operESSIDLength[6] = 0x3E;
159 operRTSThreshold[5] = 0xE0;
160 operRTSThreshold[6] = 0x3E;
161 operFragmentationThreshold[5] = 0xE0;
162 operFragmentationThreshold[6] = 0x3E;
163 operPreambleType[5] = 0xE0;
164 operPreambleType[6] = 0x3E;
165 operAuthenticationType[5] = 0xE0;
166 operAuthenticationType[6] = 0x3E;
167 operBasicRates[5] = 0xE0;
168 operBasicRates[6] = 0x3E;
169 operAutoRateFallBack[5] = 0xE0;
170 operAutoRateFallBack[6] = 0x3E;
171 operAccessPointName[5] = 0xE0;
172 operAccessPointName[6] = 0x3E;
173 operSSIDBroadcasting[5] = 0xE0;
174 operSSIDBroadcasting[6] = 0x3E;
178 /* Find out whether the device uses enhanced ATMEL12350 TELLUS MIB. */
179 varbinds[0].type = NULL_VALUE;
180 varbinds[0].oid = operEthernetAddress;
181 varbinds[0].len_oid = sizeof(operEthernetAddress);
182 varbinds[0].len_val = 0;
184 print_help(WAIT_RET);
185 if (snmp(varbinds, 1, GET) <= 0) {
186 print_helperr(ERR_RET);
190 if (ap_type == ATMEL12350 && (memcmp(oui_tellus, varbinds[0].value, 3) ==0))
191 IS_ATMEL12350_TELLUS = 1;
194 for (i = 1; i < 15; i++) {
195 varbinds[i].type = NULL_VALUE;
196 varbinds[i].len_val = 0;
197 varbinds[i].len_oid = sizeof(operChannelID);
202 varbinds[i++].oid = operChannelID;
203 varbinds[i++].oid = operESSIDLength;
204 varbinds[i++].oid = operESSID;
205 varbinds[i++].oid = operSSIDBroadcasting;
206 varbinds[i++].oid = operBasicRates;
207 varbinds[i++].oid = operAutoRateFallBack;
208 varbinds[i++].oid = operRTSThreshold;
209 varbinds[i++].oid = operFragmentationThreshold;
210 varbinds[i++].oid = operPreambleType;
211 varbinds[i++].oid = operAuthenticationType;
212 varbinds[i++].oid = operAccessPointName;
213 varbinds[i++].oid = sysDeviceInfo;
214 if (ap_type == ATMEL12350) {
215 varbinds[i++].oid = operInterRoaming;
216 if (IS_ATMEL12350_TELLUS) {
217 varbinds[i++].oid = operBeaconPeriod;
218 varbinds[i++].oid = operDTIM;
222 if (snmp(varbinds, i, GET) <= 0) {
223 print_helperr(ERR_RET);
227 channel = *(varbinds[0].value);
228 c = *(varbinds[1].value);
229 memcpy(domain, varbinds[2].value, 32);
230 SSIDBroadcasting = *(varbinds[3].value);
231 memcpy(basic_rates, varbinds[4].value, 4);
232 AutoRateFallBack = *(varbinds[5].value);
233 memcpy(&RTSThreshold, varbinds[6].value, 2);
234 RTSThreshold = ntohs(RTSThreshold);
235 memcpy(&FragmentationThreshold, varbinds[7].value, 2);
236 FragmentationThreshold = ntohs(FragmentationThreshold);
237 PreambleType = *(varbinds[8].value);
238 AuthenticationType = *(varbinds[9].value);
239 memcpy(ap_name, varbinds[10].value, 32);
240 if (ap_type == ATMEL12350) {
241 InterRoaming = *(varbinds[12].value);
242 if (IS_ATMEL12350_TELLUS) {
243 for (i = 0; i < varbinds[13].len_val;
244 BeaconPeriod += varbinds[13].value[i] *
245 (1 << ((varbinds[13].len_val - i - 1) * 8)), i++);
246 dtim = *(varbinds[14].value);
250 if (ap_type == ATMEL12350) {
251 memcpy(&ptr12350, varbinds[11].value, sizeof(struct SysDeviceInfo_ATMEL12350));
252 ap_regdomain=ptr12350.RegulationDomain;
253 } else /* ATMEL410 */{
254 memcpy(&ptr410, varbinds[11].value, sizeof(struct SysDeviceInfo_ATMEL410));
255 ap_regdomain = swap4(ptr410.RegulationDomain);
258 if ((ch_num = ch_list(ap_regdomain, item_name)) == 0) {
259 print_helperr(ERR_RET);
262 if (ap_regdomain == 0x31 || ap_regdomain == 0x32)
265 print_title(_("Wireless Settings"));
267 sprintf(message, "%s%02u (%u MHz)", CHANNEL, channel, 2407 + 5 * channel);
268 mvwaddstr(main_sub, 0, 0, message);
269 mvwaddstr(main_sub, 1, 0, ESSID);
270 waddnstr(main_sub, domain, c);
271 mvwaddstr(main_sub, 2, 0, AP_NAME);
272 for (i = 0; i < 32 && ap_name[i]; i++)
273 mvwaddch(main_sub, 2, strlen(AP_NAME) + i, ap_name[i]);
274 sprintf(message, "%s%d", RTS_TR, RTSThreshold);
275 mvwaddstr(main_sub, 3, 0, message);
276 sprintf(message, "%s%d", FRG_TR, FragmentationThreshold);
277 mvwaddstr(main_sub, 4, 0, message);
278 sprintf(message, "%s%s", PREAMBULE, preambules[PreambleType - 1]);
279 mvwaddstr(main_sub, 5, 0, message);
280 sprintf(message, "%s%s", AUTH, AuthenticationTypes[AuthenticationType - 1]);
281 mvwaddstr(main_sub, 6, 0, message);
282 sprintf(message, "%s%s", RETRAIN, (AutoRateFallBack == 1) ? ON : OFF);
283 mvwaddstr(main_sub, 7, 0, message);
284 sprintf(message, "%s%s", HIDE_ESSID, (SSIDBroadcasting == 1) ? ON : OFF);
285 mvwaddstr(main_sub, 8, 0, message);
286 mvwaddstr(main_sub, 9, 0, RATES);
287 mvwaddstr(main_sub, 10, 2, RATES_HEAD);
288 for (i = 0; i < 4; i++) {
289 sprintf(message, RATES_RECORD "%s", i + 1, (float) __rates[i] / 2,
290 basic(basic_rates[i]));
291 mvwaddstr(main_sub, 11 + i, 2, message);
293 if (ap_type == ATMEL12350) {
294 sprintf(message, "%s%s", INT_ROAMING, (InterRoaming == 1) ? ON : OFF);
295 mvwaddstr(main_sub, 15, 0, message);
296 if (IS_ATMEL12350_TELLUS) {
297 sprintf(message, "%s%u", BEACON_PER, BeaconPeriod);
298 mvwaddstr(main_sub, 16, 0, message);
299 sprintf(message, "%s%u", DTIM_I, dtim);
300 mvwaddstr(main_sub, 17, 0, message);
306 print_help(WLAN_HELP);
321 switch (menu_choose(10 + i, 15, rates, 3)) {
323 basic_rates[i - 1] = __rates[i - 1];
326 basic_rates[i - 1] = 0;
329 basic_rates[i - 1] = __rates[i - 1] + 0x80;
331 clear_main_new(10 + i, 11 + i);
332 sprintf(message, RATES_RECORD, i, (float) __rates[i - 1] / 2);
333 print_menusel(10 + i, 2, message, basic(basic_rates[i - 1]));
338 channel = menu_choose(0, strlen(CHANNEL), item_name, ch_num)
340 sprintf(message, "%02u (%u MHz)", channel, 2407 + 5 * channel);
341 print_menusel(0, 0, CHANNEL, message);
347 menu_choose(6, strlen(AUTH), AuthenticationTypes, 3) + 1;
348 clear_main_new(6, 7);
349 print_menusel(6, 0, AUTH,
350 AuthenticationTypes[AuthenticationType - 1]);
355 PreambleType = menu_choose(5, strlen(PREAMBULE), preambules, 2) + 1;
356 clear_main_new(5, 6);
357 print_menusel(5, 0, PREAMBULE, preambules[PreambleType - 1]);
362 AutoRateFallBack = on_off(7, strlen(RETRAIN));
363 clear_main_new(7, 8);
364 print_menusel(7, 0, RETRAIN, (AutoRateFallBack == 1) ? ON : OFF);
369 SSIDBroadcasting = on_off(8, strlen(HIDE_ESSID));
370 clear_main_new(8, 9);
371 print_menusel(8, 0, HIDE_ESSID, (SSIDBroadcasting == 1) ? ON : OFF);
376 // make_field(2, strlen(AP_NAME), 32);
377 get_value(ap_name, 2, strlen(AP_NAME), 32, ANY_STRING, 0, 0, NULL);
382 // make_field(1, strlen(ESSID), 32);
383 get_value(domain, 1, strlen(ESSID), 32, ANY_STRING, 0, 0, NULL);
388 // make_field(4, strlen(FRG_TR), 6);
389 get_value(message, 4, strlen(FRG_TR), 6, INT_STRING, 256, 2346,
391 FragmentationThreshold = atoi(message);
396 // make_field(3, strlen(RTS_TR), 6);
397 get_value(message, 3, strlen(RTS_TR), 6, INT_STRING, 0, 2347,
399 RTSThreshold = atoi(message);
404 if (ap_type == ATMEL410)
406 InterRoaming = on_off(15, strlen(INT_ROAMING));
407 clear_main_new(15, 16);
408 print_menusel(15, 0, INT_ROAMING, (InterRoaming == 1) ? ON : OFF);
413 if (!IS_ATMEL12350_TELLUS)
415 get_value(message, 16, strlen(BEACON_PER), 6, INT_STRING, 0, 65535,
417 BeaconPeriod = atoi(message);
422 if (!IS_ATMEL12350_TELLUS)
424 get_value(message, 17, strlen(DTIM_I), 4, INT_STRING, 0, 255,
426 dtim = atoi(message);
433 varbinds[i].oid = operChannelID;
434 varbinds[i].len_oid = sizeof(operChannelID);
435 varbinds[i].value = (char *) &channel;
436 varbinds[i].len_val = 1;
437 varbinds[i].type = INT_VALUE;
441 for (m_basic_rates = 0; m_basic_rates < 2; m_basic_rates++) {
442 c = basic_rates[3 - m_basic_rates];
443 basic_rates[3 - m_basic_rates] =
444 basic_rates[m_basic_rates];
445 basic_rates[m_basic_rates] = c;
447 varbinds[i].oid = operBasicRates;
448 varbinds[i].len_oid = sizeof(operBasicRates);
449 varbinds[i].value = basic_rates;
450 varbinds[i].len_val = 4;
451 varbinds[i].type = INT_VALUE;
455 varbinds[i].oid = operSSIDBroadcasting;
456 varbinds[i].len_oid = sizeof(operSSIDBroadcasting);
457 varbinds[i].value = (char *) &SSIDBroadcasting;
458 varbinds[i].len_val = 1;
459 varbinds[i].type = INT_VALUE;
463 varbinds[i].oid = operAuthenticationType;
464 varbinds[i].len_oid = sizeof(operAuthenticationType);
465 varbinds[i].value = &AuthenticationType;
466 varbinds[i].len_val = 1;
467 varbinds[i].type = INT_VALUE;
471 varbinds[i].oid = operPreambleType;
472 varbinds[i].len_oid = sizeof(operPreambleType);
473 varbinds[i].value = &PreambleType;
474 varbinds[i].len_val = 1;
475 varbinds[i].type = INT_VALUE;
479 varbinds[i].oid = operAutoRateFallBack;
480 varbinds[i].len_oid = sizeof(operAutoRateFallBack);
481 varbinds[i].value = &AutoRateFallBack;
482 varbinds[i].len_val = 1;
483 varbinds[i].type = INT_VALUE;
488 varbinds[i].oid = operAccessPointName;
489 varbinds[i].len_oid = sizeof(operAccessPointName);
490 varbinds[i].value = ap_name;
491 varbinds[i].len_val = c;
492 varbinds[i].type = STRING_VALUE;
496 varbinds[i].oid = operFragmentationThreshold;
497 varbinds[i].len_oid = sizeof(operFragmentationThreshold);
498 FragmentationThreshold = htons(FragmentationThreshold);
499 varbinds[i].value = (char *) &FragmentationThreshold;
500 varbinds[i].len_val = 2;
501 varbinds[i].type = INT_VALUE;
505 varbinds[i].oid = operRTSThreshold;
506 varbinds[i].len_oid = sizeof(operRTSThreshold);
507 RTSThreshold = htons(RTSThreshold);
508 varbinds[i].value = (char *) &RTSThreshold;
509 varbinds[i].len_val = 2;
510 varbinds[i].type = INT_VALUE;
515 varbinds[i].oid = operESSIDLength;
516 varbinds[i].len_oid = sizeof(operESSIDLength);
517 varbinds[i].value = (char *)&ch;
518 varbinds[i].len_val = 1;
519 varbinds[i].type = INT_VALUE;
521 varbinds[i].oid = operESSID;
522 varbinds[i].len_oid = sizeof(operESSID);
523 varbinds[i].value = domain;
524 varbinds[i].len_val = ch;
525 varbinds[i].type = STRING_VALUE;
528 if (m_inter_roaming) {
529 varbinds[i].oid = operInterRoaming;
530 varbinds[i].len_oid = sizeof(operInterRoaming);
531 varbinds[i].value = (char *) &InterRoaming;
532 varbinds[i].len_val = 1;
533 varbinds[i].type = INT_VALUE;
539 len_val = (BeaconPeriod > 0x7fff) ? 3 :
540 (BeaconPeriod > 0x7f) ? 2 : 1;
541 varbinds[i].oid = operBeaconPeriod;
542 varbinds[i].len_oid = sizeof(operBeaconPeriod);
543 varbinds[i].value = (char *) &BeaconPeriod;
544 varbinds[i].len_val = len_val;
545 varbinds[i].type = STRING_VALUE;
549 varbinds[i].oid = operDTIM;
550 varbinds[i].len_oid = sizeof(operDTIM);
551 varbinds[i].value = (char *) &dtim;
552 varbinds[i].len_val = 1;
553 varbinds[i].type = INT_VALUE;
557 print_help(WAIT_SET);
558 if (snmp(varbinds, i, SET) <= 0) {
559 print_helperr(ERR_SET);
562 print_help(DONE_SET);
570 /* free memory allocated for channel list */
571 for (i = 0; i < ch_num; i++)
582 char oid_dot11SupportedAntenna[][11] = {
583 {0x2a, 0x86, 0x48, 0xce, 0x34, 0x04, 0x08, 0x01, 0x02, 0x01, 0x01},
584 {0x2a, 0x86, 0x48, 0xce, 0x34, 0x04, 0x08, 0x01, 0x02, 0x01, 0x02},
585 {0x2a, 0x86, 0x48, 0xce, 0x34, 0x04, 0x08, 0x01, 0x03, 0x01, 0x01},
586 {0x2a, 0x86, 0x48, 0xce, 0x34, 0x04, 0x08, 0x01, 0x03, 0x01, 0x02},
587 {0x2a, 0x86, 0x48, 0xce, 0x34, 0x04, 0x08, 0x01, 0x04, 0x01, 0x01},
588 {0x2a, 0x86, 0x48, 0xce, 0x34, 0x04, 0x08, 0x01, 0x04, 0x01, 0x02}
592 { 0x2b, 0x06, 0x01, 0x04, 0x01, 0x87, 0x29, 0x03, 0x01, 0x02, 0x01,
595 char operChannelID[] =
596 { 0x2a, 0x86, 0x48, 0xce, 0x34, 0x04, 0x05, 0x01, 0x01, 0x01 };
597 char sysTrapSwitch[] =
598 { 0x2B, 0x06, 0x01, 0x02, 0x01, 0x0b, 0x1e, 0x00 };
601 { 0x2a, 0x86, 0x48, 0xce, 0x34, 0x01, 0x01, 0x01, 0x09, 0x01 };
603 char operRTSThreshold[] =
604 { 0x2a, 0x86, 0x48, 0xce, 0x34, 0x02, 0x01, 0x01, 0x02, 0x01 };
605 char operFragmentationThreshold[] =
606 { 0x2a, 0x86, 0x48, 0xce, 0x34, 0x02, 0x01, 0x01, 0x05, 0x01 };
608 { 0x2a, 0x86, 0x48, 0xce, 0x34, 0x01, 0x02, 0x01, 0x03, 0x01,
612 { 0x2a, 0x86, 0x48, 0xce, 0x34, 0x01, 0x02, 0x01, 0x03, 0x01,
615 char operBasicRates[] =
616 { 0x2a, 0x86, 0x48, 0xce, 0x34, 0x01, 0x01, 0x01, 0xb, 0x01 };
617 char operAccessPointName[] =
618 { 0x2b, 0x06, 0x01, 0x02, 0x01, 0x01, 0x05, 0x00 };
619 char operAccessPointContact[] =
620 { 0x2b, 0x06, 0x01, 0x02, 0x01, 0x01, 0x04, 0x00 };
621 char operAccessPointLocation[] =
622 { 0x2b, 0x06, 0x01, 0x02, 0x01, 0x01, 0x06, 0x00 };
624 unsigned short int i, RTSThreshold, FragmentationThreshold,
625 m_basic_rates = 0, authi;
626 char *auth[3] = { OSYS, SH_KEY, BOTH_TYPE },
627 *rates[3] = { ON, OFF, BASIC },
629 m_antenna[6] = { 0, 0, 0, 0, 0, 0 },
631 channel_pref[2] = { 0, 0 };
632 extern WINDOW *main_sub;
633 char *domain, basic_rates[] =
634 { 0, 0, 0, 0 }, *ap_name, ap_location[32], ap_contact[32],
635 m_ap_contact = 0, m_ap_location = 0;
636 char m_channel = 0, m_essid = 0, m_rts = 0, m_fragment = 0, m_auth =
637 0, m_ap_name = 0, channel, traps, m_traps = 0;
638 varbind varbinds[11];
639 int c=0, ch_num = 0, first_channel=1, reg_domain=0;
640 short __rates[4] = { 2, 4, 11, 22};
642 domain = (char *) calloc(32, 1);
643 ap_name = (char *) calloc(32, 1);
645 for (i = 0; i < 8; i++) {
646 varbinds[i].len_val = 0;
647 varbinds[i].type = NULL_VALUE;
649 varbinds[0].oid = operChannelID;
650 varbinds[0].len_oid = sizeof(operChannelID);
651 varbinds[1].oid = operESSID;
652 varbinds[1].len_oid = sizeof(operESSID);
653 varbinds[2].oid = operRTSThreshold;
654 varbinds[2].len_oid = sizeof(operRTSThreshold);
655 varbinds[3].oid = operFragmentationThreshold;
656 varbinds[3].len_oid = sizeof(operFragmentationThreshold);
657 varbinds[4].oid = operBasicRates;
658 varbinds[4].len_oid = sizeof(operBasicRates);
659 varbinds[5].oid = OpenSystem;
660 varbinds[5].len_oid = sizeof(OpenSystem);
661 varbinds[6].oid = SharedKey;
662 varbinds[6].len_oid = sizeof(SharedKey);
663 varbinds[7].oid = operAccessPointName;
664 varbinds[7].len_oid = sizeof(operAccessPointName);
665 print_help(WAIT_RET);
666 if (snmp(varbinds, 8, GET) <= 0) {
667 print_helperr(ERR_RET);
671 channel = *(varbinds[0].value);
672 memcpy(domain, varbinds[1].value, varbinds[1].len_val);
673 memcpy(basic_rates, varbinds[4].value, varbinds[4].len_val);
674 memcpy(&RTSThreshold, (varbinds[2].value), 2);
675 RTSThreshold = ntohs(RTSThreshold);
676 memcpy(&FragmentationThreshold, (varbinds[3].value), 2);
677 FragmentationThreshold = ntohs(FragmentationThreshold);
678 authi = (*(varbinds[5].value) == 1 && *(varbinds[6].value) == 1) ? 2 :
679 (*(varbinds[5].value) == 1) ? 0 : 1;
680 memcpy(ap_name, varbinds[7].value, varbinds[7].len_val);
682 sprintf(message, "%s%02u (%u MHz)", CHANNEL, channel, 2407 + 5 * channel);
683 mvwaddstr(main_sub, 0, 0, message);
684 mvwaddstr(main_sub, 1, 0, ESSID);
685 for (i = 0; i < 32 && domain[i]; i++)
686 mvwaddch(main_sub, 1, strlen(ESSID) + i, domain[i]);
687 mvwaddstr(main_sub, 2, 0, AP_NAME);
688 for (i = 0; i < 32 && ap_name[i]; i++)
689 mvwaddch(main_sub, 2, strlen(AP_NAME) + i, ap_name[i]);
690 sprintf(message, "%s%d", RTS_TR, RTSThreshold);
691 mvwaddstr(main_sub, 3, 0, message);
692 sprintf(message, "%s%d", FRG_TR, FragmentationThreshold);
693 mvwaddstr(main_sub, 4, 0, message);
694 sprintf(message, "%s%s", AUTH, auth[authi]);
695 mvwaddstr(main_sub, 6, 0, message);
696 mvwaddstr(main_sub, 9, 0, RATES);
697 mvwaddstr(main_sub, 10, 2, RATES_HEAD);
698 for(i = 0; i < 4; i++) {
699 sprintf(message, RATES_RECORD "%s", i + 1, (float) __rates[i] / 2,
700 basic(basic_rates[i]));
701 mvwaddstr(main_sub, 11+i, 2, message);
704 reg_domain = get_RegDomain();
705 if ((ch_num = ch_list(reg_domain, item_name)) == 0) {
706 print_helperr(ERR_RET);
710 if(reg_domain == 0x31 || reg_domain == 0x32)
713 for (i = 0; i < 9; i++) {
714 varbinds[i].len_val = 0;
715 varbinds[i].type = NULL_VALUE;
718 for (i = 0; i < 6; i++) {
719 varbinds[i].oid = oid_dot11SupportedAntenna[i];
720 varbinds[i].len_oid = sizeof(oid_dot11SupportedAntenna[i]);
722 varbinds[6].oid = sysTrapSwitch;
723 varbinds[6].len_oid = sizeof(sysTrapSwitch);
724 varbinds[7].oid = operAccessPointContact;
725 varbinds[7].len_oid = sizeof(operAccessPointContact);
726 varbinds[8].oid = operAccessPointLocation;
727 varbinds[8].len_oid = sizeof(operAccessPointLocation);
729 if (snmp(varbinds, 9, GET) <= 0) {
730 print_helperr(ERR_RET);
734 for (i = 0; i < 6; i++) {
735 antenna[i] = *varbinds[i].value;
738 traps = *(varbinds[6].value);
739 memcpy(ap_contact, varbinds[7].value, varbinds[7].len_val);
740 if (varbinds[7].len_val < 32)
741 ap_contact[varbinds[7].len_val] = '\0';
742 memcpy(ap_location, varbinds[8].value, varbinds[8].len_val);
743 if (varbinds[8].len_val < 32)
744 ap_location[varbinds[8].len_val] = '\0';
746 sprintf(message, "%s%s", LOCATION, ap_location);
747 mvwaddstr(main_sub, 7, 0, message);
748 sprintf(message, "%s%s", CONTACT, ap_contact);
749 mvwaddstr(main_sub, 8, 0, message);
750 sprintf(message, "%s%s", TRAPS, (traps == 1) ? ON : OFF);
751 mvwaddstr(main_sub, 5, 0, message);
753 mvwaddstr(main_sub, 16, 0, _("Antenna Configuration:"));
754 sprintf(message, "%s %s %3s, %s %3s",
756 ANTENNA_RX_LEFT, (antenna[2] == 1) ? ON : OFF,
757 ANTENNA_RX_RIGHT, (antenna[3] == 1) ? ON : OFF);
758 mvwaddstr(main_sub, 17, 1, message);
759 sprintf(message, "%s %s %3s, %s %3s",
761 ANTENNA_TX_LEFT, (antenna[0] == 1) ? ON : OFF,
762 ANTENNA_TX_RIGHT, (antenna[1] == 1) ? ON : OFF);
763 mvwaddstr(main_sub, 18, 1, message);
764 sprintf(message, "%s %s %3s, %s %3s",
766 ANTENNA_DV_LEFT, (antenna[4] == 1) ? ON : OFF,
767 ANTENNA_DV_RIGHT, (antenna[5] == 1) ? ON : OFF);
768 mvwaddstr(main_sub, 19, 1, message);
770 print_title(_("General Options"));
772 ("UIOPTY - antenna; SCANLEDFR1234 - options; W - write conf; Q - quit to menu"));
782 i = strlen(ANTENNA_RX) + 1 +
783 strlen(ANTENNA_RX_LEFT) + 6 +
784 strlen(ANTENNA_RX_RIGHT) + 2;
785 antenna[3] = on_off(17, i);
786 sprintf(message, "%3s", (antenna[3] == 1) ? ON : OFF);
787 print_menusel(17, i, NULL, message);
792 i = strlen(ANTENNA_RX) + 1 +
793 strlen(ANTENNA_RX_LEFT) + 2;
794 antenna[2] = on_off(17, i);
795 sprintf(message, "%3s", (antenna[2] == 1) ? ON : OFF);
796 print_menusel(17, i, NULL, message);
801 i = strlen(ANTENNA_TX) + 1 +
802 strlen(ANTENNA_TX_LEFT) + 6 +
803 strlen(ANTENNA_TX_RIGHT) + 2;
804 antenna[1] = on_off(18, i);
805 sprintf(message, "%3s", (antenna[1] == 1) ? ON : OFF);
806 print_menusel(18, i, NULL, message);
811 i = strlen(ANTENNA_TX) + 1 +
812 strlen(ANTENNA_TX_LEFT) + 2;
813 antenna[0] = on_off(18, i);
814 sprintf(message, "%3s", (antenna[0] == 1) ? ON : OFF);
815 print_menusel(18, i, NULL, message);
820 i = strlen(ANTENNA_DV) + 1 +
821 strlen(ANTENNA_DV_LEFT) + 2;
822 antenna[4] = on_off(19, i);
823 sprintf(message, "%3s", (antenna[4] == 1) ? ON : OFF);
824 print_menusel(19, i, NULL, message);
829 i = strlen(ANTENNA_DV) + 1 +
830 strlen(ANTENNA_DV_LEFT) + 6 +
831 strlen(ANTENNA_DV_RIGHT) + 2;
832 antenna[5] = on_off(19, i);
833 sprintf(message, "%3s", (antenna[5] == 1) ? ON : OFF);
834 print_menusel(19, i, NULL, message);
839 traps = on_off(5, strlen(TRAPS));
840 clear_main_new(5, 6);
841 print_menusel(5, 0, TRAPS, (traps == 1) ? ON : OFF);
852 switch (menu_choose(10 + i, 15, rates, 3)) {
854 basic_rates[i-1] = __rates[i-1];
857 basic_rates[i-1] = 0;
860 basic_rates[i-1] = __rates[i-1] + 0x80;
862 clear_main_new(10 + i, 11 + i);
863 sprintf(message, RATES_RECORD, i, (float) __rates[i-1] / 2);
864 print_menusel(10 + i, 2, message, basic(basic_rates[i-1]));
869 channel = menu_choose(0, strlen(CHANNEL), item_name, ch_num)
871 sprintf(message, "%02u (%u MHz)", channel, 2407 + 5 * channel);
872 print_menusel(0, 0, CHANNEL, message);
877 authi = menu_choose(6, strlen(AUTH), auth, 3);
878 clear_main_new(6, 7);
879 print_menusel(6, 0, AUTH, auth[authi]);
884 get_value(ap_name, 2, strlen(AP_NAME), 32, ANY_STRING, 0, 0, NULL);
889 get_value(ap_location, 7, strlen(LOCATION), 32, ANY_STRING, 0, 0,
895 get_value(ap_contact, 8, strlen(CONTACT), 32, ANY_STRING, 0, 0,
901 get_value(domain, 1, strlen(ESSID), 32, ANY_STRING, 0, 0, NULL);
906 get_value(message, 4, strlen(FRG_TR), 6, INT_STRING, 256, 2346,
908 FragmentationThreshold = atoi(message);
913 get_value(message, 3, strlen(RTS_TR), 6, INT_STRING, 0, 2347,
915 RTSThreshold = atoi(message);
922 channel_pref[0] = channel;
923 varbinds[i].oid = ChannelPref;
924 varbinds[i].len_oid = sizeof(ChannelPref);
925 varbinds[i].value = channel_pref;
926 varbinds[i].len_val = 2;
927 varbinds[i].type = STRING_VALUE;
929 varbinds[i].oid = operChannelID;
930 varbinds[i].len_oid = sizeof(operChannelID);
931 varbinds[i].value = (char *) &channel;
932 varbinds[i].len_val = 1;
933 varbinds[i].type = 0x02;
938 varbinds[i].oid = operBasicRates;
939 varbinds[i].len_oid = sizeof(operBasicRates);
940 varbinds[i].value = basic_rates;
941 varbinds[i].len_val = 4;
942 varbinds[i].type = STRING_VALUE;
946 print_help(WAIT_SET);
947 if (snmp(varbinds, i, SET) <= 0) {
948 print_helperr(ERR_SET);
954 m_auth = (authi == 1) ? 2 : 1;
955 m_basic_rates = (authi == 0) ? 2 : 1;
956 varbinds[i].oid = OpenSystem;
957 varbinds[i].len_oid = sizeof(OpenSystem);
958 varbinds[i].value = (char *) &m_auth;
959 varbinds[i].len_val = 1;
960 varbinds[i].type = INT_VALUE;
962 varbinds[i].oid = SharedKey;
963 varbinds[i].len_oid = sizeof(SharedKey);
964 varbinds[i].value = (char *) &m_basic_rates;
965 varbinds[i].len_val = 1;
966 varbinds[i].type = INT_VALUE;
969 print_help(WAIT_SET);
970 if (snmp(varbinds, i, SET) <= 0) {
971 print_helperr(ERR_SET);
978 varbinds[i].oid = operAccessPointName;
979 varbinds[i].len_oid = sizeof(operAccessPointName);
980 varbinds[i].value = ap_name;
981 varbinds[i].len_val = c;
982 varbinds[i].type = STRING_VALUE;
987 c = strlen(ap_location);
988 varbinds[i].oid = operAccessPointLocation;
989 varbinds[i].len_oid = sizeof(operAccessPointLocation);
990 varbinds[i].value = ap_location;
991 varbinds[i].len_val = c;
992 varbinds[i].type = STRING_VALUE;
996 print_help(WAIT_SET);
997 if (snmp(varbinds, i, SET) <= 0) {
998 print_helperr(ERR_SET);
1004 c = strlen(ap_contact);
1005 varbinds[i].oid = operAccessPointContact;
1006 varbinds[i].len_oid = sizeof(operAccessPointContact);
1007 varbinds[i].value = ap_contact;
1008 varbinds[i].len_val = c;
1009 varbinds[i].type = STRING_VALUE;
1013 varbinds[i].oid = operFragmentationThreshold;
1014 varbinds[i].len_oid = sizeof(operFragmentationThreshold);
1015 FragmentationThreshold = htons(FragmentationThreshold);
1016 varbinds[i].value = (char *) &FragmentationThreshold;
1017 varbinds[i].len_val = 2;
1018 varbinds[i].type = 0x02;
1022 varbinds[i].oid = operRTSThreshold;
1023 varbinds[i].len_oid = sizeof(operRTSThreshold);
1024 RTSThreshold = htons(RTSThreshold);
1025 varbinds[i].value = (char *) &RTSThreshold;
1026 varbinds[i].len_val = 2;
1027 varbinds[i].type = 0x02;
1031 varbinds[i].oid = sysTrapSwitch;
1032 varbinds[i].len_oid = sizeof(sysTrapSwitch);
1033 varbinds[i].value = &traps;
1034 varbinds[i].len_val = 1;
1035 varbinds[i].type = 0x02;
1038 print_help(WAIT_SET);
1039 if (snmp(varbinds, i, SET) <= 0) {
1040 print_helperr(ERR_SET);
1044 for (i = 0; i < 4; i++)
1046 varbinds[c].oid = oid_dot11SupportedAntenna[i];
1047 varbinds[c].len_oid =
1048 sizeof(oid_dot11SupportedAntenna[i]);
1049 varbinds[c].value = &antenna[i];
1050 varbinds[c].len_val = 1;
1051 varbinds[c].type = INT_VALUE;
1054 print_help(WAIT_SET);
1055 if (snmp(varbinds, c, SET) <= 0) {
1056 print_helperr(ERR_SET);
1060 for (i = i; i < 6; i++)
1062 varbinds[c].oid = oid_dot11SupportedAntenna[i];
1063 varbinds[c].len_oid =
1064 sizeof(oid_dot11SupportedAntenna[i]);
1065 varbinds[c].value = &antenna[i];
1066 varbinds[c].len_val = 1;
1067 varbinds[c].type = INT_VALUE;
1070 print_help(WAIT_SET);
1071 if (snmp(varbinds, c, SET) <= 0) {
1072 print_helperr(ERR_SET);
1078 varbinds[i].oid = operESSID;
1079 varbinds[i].len_oid = sizeof(operESSID);
1080 varbinds[i].value = domain;
1081 varbinds[i].len_val = c;
1082 varbinds[i].type = 0x04;
1085 print_help(WAIT_SET);
1086 if (snmp(varbinds, i, SET) <= 0) {
1087 print_helperr(ERR_SET);
1091 print_help(DONE_SET);
1103 /* free memory allocated for channel list */
1104 for (i = 0; i < ch_num; i++)