2 * test.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
26 #define TEST_MODE _("[T] Test mode: ")
27 #define ANTENNA _("[A] Antenna: ")
28 #define SIGLEVEL _("[S] Signal level: ")
29 #define RATE _("[R] Rate: ")
30 #define FILER _("[F] TxFiler: ")
31 #define COMMAND _("[O] Command: ")
32 #define __HELP _("T - Test mode On/Off; CASRFO - set options; Q - quit to menu")
34 extern WINDOW *main_sub;
36 extern char *channels[];
40 struct TestModeCommandStruct_ATMEL410 {
41 unsigned char Channel;
42 unsigned char Antenna;
43 unsigned char RegCR31;
45 unsigned char TxFiler; //US 01 - JPN 02
46 unsigned char Command; //CMD_CONTINUOUS_TX 0x01, CMD_CONTINUOUS_RX 0x02, CMD_CARRIER_ACCURACY 0x03, CMD_IDLE 0x04
51 struct TestModeStatistics {
52 unsigned long SuccessFrames;
53 unsigned long FailedFrames;
56 char TestModeOnOff[] =
57 { 0x2B, 0x06, 0x01, 0x04, 0x01, 0x83, 0x1A, 0x01, 0x01, 0x08, 0x01,
60 char TestModeCommandStruct[] =
61 { 0x2B, 0x06, 0x01, 0x04, 0x01, 0x83, 0x1A, 0x01, 0x01, 0x08, 0x02,
64 char TestModeStatistics[] =
65 { 0x2B, 0x06, 0x01, 0x04, 0x01, 0x83, 0x1A, 0x01, 0x01, 0x08, 0x09,
69 char message[1024], *antenna[2] =
70 { _("Left"), _("Right") }, *filer[2] = {
71 "EN", "US"}, *rates[4] = {
72 "1", "2", "5.5", "11"};
73 char teston = 2, *commands[4] =
74 { "CONTINUOUS_TX", "CONTINUOUS_RX", "CARRIER_ACCURACY", "IDLE" };
77 if (ap_type == ATMEL12350) {
78 #if 1 /* Temporary kludge */
79 mvwaddstr(main_sub, 1, 0, _("Devices with ATMEL12350 MIB not yet supported."));
83 TestModeOnOff[5] = 0xE0;
84 TestModeOnOff[6] = 0x3E;
85 TestModeCommandStruct[5] = 0xE0;
86 TestModeCommandStruct[6] = 0x3E;
87 TestModeStatistics[5] = 0xE0;
88 TestModeStatistics[6] = 0x3E;
91 print_top(NULL, _("Test mode"));
92 mvwaddstr(main_sub, 3, 6,
94 ("Using the \"Test mode\" may cause loss of your current"));
95 mvwaddstr(main_sub, 4, 6, _("configuration."));
96 mvwaddstr(main_sub, 6, 20, _("Do you want to continue? "));
104 sprintf(message, "%s%s", TEST_MODE, OFF);
105 mvwaddstr(main_sub, 0, 0, message);
107 mvwaddstr(main_sub, 2, 1, _("Options:"));
108 testmode.Channel = 1;
109 sprintf(message, "%s%02u (%u MHz)", CHANNEL, testmode.Channel,
110 2407 + 5 * testmode.Channel);
111 mvwaddstr(main_sub, 3, 0, message);
113 testmode.Antenna = 1;
114 sprintf(message, "%s%s", ANTENNA, antenna[testmode.Antenna - 1]);
115 mvwaddstr(main_sub, 4, 0, message);
117 testmode.RegCR31 = 128;
118 sprintf(message, "%s%u", SIGLEVEL, testmode.RegCR31);
119 mvwaddstr(main_sub, 5, 0, message);
122 sprintf(message, "%s%.1f Mbit/s", RATE, (float) testmode.Rate / 2);
123 mvwaddstr(main_sub, 6, 0, message);
125 testmode.TxFiler = 1;
126 sprintf(message, "%s%s", FILER, filer[testmode.TxFiler - 1]);
127 mvwaddstr(main_sub, 7, 0, message);
129 testmode.Command = 1;
130 sprintf(message, "%s%s", COMMAND, commands[testmode.Command - 1]);
131 mvwaddstr(main_sub, 8, 0, message);
133 mvwaddstr(main_sub, 10, 1, _("Statistics:"));
134 mvwaddstr(main_sub, 11, 0, _("Success Frames: 0 Failed Frames: 0"));
144 varbinds[0].oid = TestModeOnOff;
145 varbinds[0].len_oid = sizeof(TestModeOnOff);
146 varbinds[0].value = &teston;
147 varbinds[0].len_val = 1;
148 varbinds[0].type = INT_VALUE;
149 if (snmp(varbinds, 1, SET) <= 0) {
150 print_helperr(ERR_RET);
157 teston = on_off(0, 1 + strlen(TEST_MODE));
160 clear_main_new(0, 1);
161 print_menusel(0, 0, TEST_MODE, ON);
162 varbinds[0].oid = TestModeOnOff;
163 varbinds[0].len_oid = sizeof(TestModeOnOff);
164 varbinds[0].value = &teston;
165 varbinds[0].len_val = 1;
166 varbinds[0].type = INT_VALUE;
167 varbinds[1].oid = TestModeCommandStruct;
168 varbinds[1].len_oid = sizeof(TestModeCommandStruct);
169 varbinds[1].len_val = sizeof(testmode);
170 varbinds[1].value = (char *) &testmode;
171 varbinds[1].type = STRING_VALUE;
172 if (snmp(varbinds, 2, SET) <= 0) {
173 print_helperr(ERR_RET);
177 varbinds[0].oid = TestModeStatistics;
178 varbinds[0].len_oid = sizeof(TestModeStatistics);
179 varbinds[0].value = TestModeStatistics;
180 varbinds[0].len_val = 0;
181 varbinds[0].type = NULL_VALUE;
183 if (snmp(varbinds, 1, GET) <= 0) {
184 print_helperr(ERR_RET);
189 (struct TestModeStatistics *) malloc(varbinds[0].
191 memcpy(teststat, varbinds[0].value,
192 sizeof(struct TestModeStatistics));
193 clear_main_new(11, 12);
195 _("Success Frames: %lu Failed Frames: %lu"),
196 swap4(teststat->SuccessFrames),
197 swap4(teststat->FailedFrames));
198 mvwaddstr(main_sub, 11, 0, message);
201 clear_main_new(0, 1);
202 sprintf(message, "%s%s", TEST_MODE, OFF);
203 mvwaddstr(main_sub, 0, 0, message);
205 varbinds[0].oid = TestModeOnOff;
206 varbinds[0].len_oid = sizeof(TestModeOnOff);
207 varbinds[0].value = &teston;
208 varbinds[0].len_val = 1;
209 varbinds[0].type = INT_VALUE;
211 if (snmp(varbinds, 1, SET) <= 0) {
212 print_helperr(ERR_RET);
220 testmode.Channel = menu_choose(3, strlen(CHANNEL), channels,
222 clear_main_new(3, 4);
223 sprintf(message, "%02u (%u MHz)", testmode.Channel,
224 2407 + 5 * testmode.Channel);
225 print_menusel(3, 0, CHANNEL, message);
229 switch (menu_choose(6, strlen(RATE), rates, 4)) {
242 clear_main_new(6, 7);
243 sprintf(message, "%.1f Mbit/s", (float) testmode.Rate / 2);
244 print_menusel(6, 0, RATE, message);
248 testmode.Antenna = menu_choose(4, strlen(ANTENNA), antenna, 2) + 1;
249 clear_main_new(4, 5);
250 print_menusel(4, 0, ANTENNA, antenna[testmode.Antenna - 1]);
254 testmode.Command = menu_choose(8, strlen(COMMAND), commands, 4) + 1;
255 clear_main_new(8, 9);
256 print_menusel(8, 0, COMMAND, commands[testmode.Command - 1]);
260 testmode.TxFiler = menu_choose(7, strlen(FILER), filer, 2) + 1;
261 clear_main_new(7, 8);
262 print_menusel(7, 0, FILER, filer[testmode.TxFiler - 1]);
266 // make_field(5, strlen(SIGLEVEL), 4);
267 get_value(message, 5, strlen(SIGLEVEL), 4, INT_STRING, 0, 255,
269 print_menusel(5, 0, SIGLEVEL, message);
270 testmode.RegCR31 = atoi(message) & 0xFF;
282 print_top(NULL, NULL);