]> git.decadent.org.uk Git - ap-utils.git/blob - lib/stat.c
Imported Upstream version 1.5~pre1
[ap-utils.git] / lib / stat.c
1 /*
2  *      stat.c from Access Point SNMP Utils for Linux
3  *
4  * Copyright (c) 2002 Roman Festchook <roma at polesye dot net>
5  *
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.
9  *
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.
14  *
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
18  *
19  */
20 #include <unistd.h>
21 #include <stdlib.h>
22 #include <fcntl.h>
23 #include <signal.h>
24 #include <string.h>
25 #include <sys/time.h>
26 #include <sys/wait.h>
27 #include "ap-utils.h"
28
29 #define ETH_STAT _("Ethernet Statistics")
30 #define W_STAT _("Wireless Statistics")
31
32 extern WINDOW *main_sub;
33 extern short ap_type;
34 extern int wait_mode;
35
36 void EthStat()
37 {
38     struct EthernetRxStatistics *EthRxStat = NULL;
39     struct EthernetTxStatistics *EthTxStat = NULL;
40
41     char EthRx[] = { 0x2B, 0x06, 0x01, 0x04, 0x01, 0x83, 0x1A, 0x01, 0x01,
42         0x07, 0x01, 0x00
43     };
44
45     char EthTx[] = { 0x2B, 0x06, 0x01, 0x04, 0x01, 0x83, 0x1A, 0x01, 0x01,
46         0x07, 0x02, 0x00
47     };
48     char message[1024];
49     varbind varbinds[2];
50     int i;
51
52     if (ap_type == ATMEL12350) {
53         EthRx[5] = 0xE0;
54         EthRx[6] = 0x3E;
55         EthTx[5] = 0xE0;
56         EthTx[6] = 0x3E;
57     }
58     
59     print_top(wait_mode == WAIT_TIMEOUT ? POLL_ON : POLL_OFF, ETH_STAT);
60     noecho();
61
62     if (wait_mode == WAIT_TIMEOUT)
63         print_help(QT_HELP);
64
65     varbinds[0].oid = EthRx;
66     varbinds[0].len_oid = sizeof(EthRx);
67     varbinds[1].oid = EthTx;
68     varbinds[1].len_oid = sizeof(EthTx);
69
70     while (1) {
71 //      varbinds[0].value = EthTx;
72         varbinds[0].len_val = 0;
73         varbinds[0].type = NULL_VALUE;
74 //      varbinds[1].value = EthTx;
75         varbinds[1].len_val = 0;
76         varbinds[1].type = NULL_VALUE;
77
78         if (wait_mode == WAIT_FOREVER)
79             print_help(WAIT_RET);
80
81         if (snmp(varbinds, 2, GET) <= 0) {
82             print_helperr(ERR_RET);
83             getch();
84             goto quit;
85         }
86
87         if (wait_mode == WAIT_FOREVER)
88             print_help(QT_HELP);
89
90         if (varbinds[0].len_val == 64) {
91             if (EthRxStat)
92                 free(EthRxStat);
93             EthRxStat =
94                 (struct EthernetRxStatistics *) malloc(varbinds[0].
95                                                        len_val);
96             memcpy(EthRxStat, varbinds[0].value, varbinds[0].len_val);
97         } else {
98             print_helperr(_("EthRxStat packet error. Press any key."));
99             getch();
100             goto quit;
101         }
102
103         if (varbinds[1].len_val == 56) {
104             if (EthTxStat)
105                 free(EthTxStat);
106             EthTxStat =
107                 (struct EthernetTxStatistics *) malloc(varbinds[1].
108                                                        len_val);
109             memcpy(EthTxStat, varbinds[1].value, varbinds[1].len_val);
110         } else {
111             print_helperr(_("EthTxStat packet error. Press any key."));
112             getch();
113             goto quit;
114         }
115         mvwaddstr(main_sub, 1, 2, _("Received:"));
116         mvwaddstr(main_sub, 1, 30, _("Transmitted:"));
117         sprintf(message, "TotalBytes       %10u TotalBytes         %10u",
118                 swap4(EthRxStat->TotalBytesRx),
119                 swap4(EthTxStat->TotalBytesTx));
120         mvwaddstr(main_sub, 3, 2, message);
121         sprintf(message, "TotalPackets     %10u TotalPackets       %10u",
122                 swap4(EthRxStat->TotalPacketsRx),
123                 swap4(EthTxStat->TotalPacketsTx));
124         mvwaddstr(main_sub, 4, 2, message);
125         sprintf(message, "PacketCRCError   %10u PacketCRCError     %10u",
126                 swap4(EthRxStat->PacketCRCErrorRx),
127                 swap4(EthTxStat->PacketCRCErrorTx));
128         mvwaddstr(main_sub, 5, 2, message);
129         sprintf(message, "FalseCarrier     %10u",
130                 swap4(EthRxStat->FalseCarrierRx));
131         mvwaddstr(main_sub, 6, 2, message);
132
133         sprintf(message, "MulticastPacket  %10u MulticastPacket    %10u",
134                 swap4(EthRxStat->MulticastPacketRx),
135                 swap4(EthTxStat->MulticastPacketTx));
136         mvwaddstr(main_sub, 7, 2, message);
137         sprintf(message, "BroadcastPacket  %10u BroadcastPacket    %10u",
138                 swap4(EthRxStat->BroadcastPacketRx),
139                 swap4(EthTxStat->BroadcastPacketTx));
140         mvwaddstr(main_sub, 8, 2, message);
141
142         sprintf(message, "ControlFrames    %10u UnicastPacket      %10u",
143                 swap4(EthRxStat->ControlFramesRx),
144                 swap4(EthTxStat->UnicastPacketTx));
145         mvwaddstr(main_sub, 9, 2, message);
146         sprintf(message, "PauseFrames      %10u PauseFrames        %10u",
147                 swap4(EthRxStat->PauseFramesRx),
148                 swap4(EthTxStat->PauseFramesTx));
149         mvwaddstr(main_sub, 10, 2, message);
150
151         sprintf(message, "UnknownOPCode    %10u SingleDeferPacket  %10u",
152                 swap4(EthRxStat->UnknownOPCodeRx),
153                 swap4(EthTxStat->SingleDeferPacketTx));
154         mvwaddstr(main_sub, 11, 2, message);
155         sprintf(message, "AlignmentError   %10u MultiDeferPackets  %10u",
156                 swap4(EthRxStat->AlignmentRxError),
157                 swap4(EthTxStat->MultiDeferPacketsTx));
158         mvwaddstr(main_sub, 12, 2, message);
159         sprintf(message, "LengthOutOfRange %10u",
160                 swap4(EthRxStat->LengthOutOfRangeRx));
161         mvwaddstr(main_sub, 13, 2, message);
162         sprintf(message, "CodeError        %10u SingleCollisions   %10u",
163                 swap4(EthRxStat->CodeErrorRx),
164                 swap4(EthTxStat->SingleCollisionsTx));
165         mvwaddstr(main_sub, 14, 2, message);
166         sprintf(message, "TotalFragments   %10u MultiCollisions    %10u",
167                 swap4(EthRxStat->TotalFragmentsRx),
168                 swap4(EthTxStat->MultiCollisionsTx));
169         mvwaddstr(main_sub, 15, 2, message);
170         sprintf(message, "OversizePackets  %10u LateCollisions     %10u",
171                 swap4(EthRxStat->OversizePacketsRx),
172                 swap4(EthTxStat->LateCollisionsTx));
173         mvwaddstr(main_sub, 16, 2, message);
174         sprintf(message, "UndersizePackets %10u ExcessiveCollision %10u",
175                 swap4(EthRxStat->UndersizePacketsRx),
176                 swap4(EthTxStat->ExcessiveCollisionTx));
177         mvwaddstr(main_sub, 17, 2, message);
178         sprintf(message, "TotalJabber      %10u TotalCollisions    %10u",
179                 swap4(EthRxStat->TotalJabberRx),
180                 swap4(EthTxStat->TotalCollisionsTx));
181         mvwaddstr(main_sub, 18, 2, message);
182         wrefresh(main_sub);
183
184         i = wait_key();
185         if (i == -1)
186             goto quit;
187
188         switch((char) i) {
189             case 'q':
190             case 'Q':
191                 goto quit;
192             case 't':
193             case 'T':
194                 wait_mode = (wait_mode == WAIT_FOREVER ?
195                     WAIT_TIMEOUT : WAIT_FOREVER);
196                 print_top(wait_mode == WAIT_TIMEOUT ? POLL_ON : POLL_OFF,
197                     ETH_STAT);
198         }
199
200         /* either timeout for user input (i == 0) or invalid key => continue */
201     }
202
203   quit:
204     if (EthRxStat)
205         free(EthRxStat);
206     if (EthTxStat)
207         free(EthTxStat);
208
209     wclear(main_sub);
210     print_top(NULL, NULL);
211     clear_main(0);
212     return;
213 }
214
215 void WirelessStat()
216 {
217     struct WirelessStatistics *WirelessStat = NULL;
218
219     char Wireless[] =
220         { 0x2B, 0x06, 0x01, 0x04, 0x01, 0x83, 0x1A, 0x01, 0x02, 0x03, 0x01,
221         0x00
222     };
223     char message[80];
224     int i;
225     varbind varbinds[1];
226
227     if (ap_type == ATMEL12350) {
228         Wireless[5] = 0xE0;
229         Wireless[6] = 0x3E;
230     }
231
232     print_top(wait_mode == WAIT_TIMEOUT ? POLL_ON : POLL_OFF, W_STAT);
233     noecho();
234
235     if (wait_mode == WAIT_TIMEOUT)
236         print_help(QT_HELP);
237
238     varbinds[0].oid = Wireless;
239     varbinds[0].len_oid = sizeof(Wireless);
240
241     while (1) {
242         varbinds[0].value = Wireless;
243         varbinds[0].len_val = 0;
244         varbinds[0].type = NULL_VALUE;
245
246         if (wait_mode == WAIT_FOREVER)
247             print_help(WAIT_RET);
248
249         if (snmp(varbinds, 1, GET) <= 0) {
250             print_helperr(ERR_RET);
251             getch();
252             goto quit;
253         }
254
255         if (wait_mode == WAIT_FOREVER)
256             print_help(QT_HELP);
257
258         if (varbinds[0].len_val == 88 || varbinds[0].len_val == 104) {
259             /*
260              * 88 ... using traditional ATMEL 12350 MIB
261              * 104 .. using functionally enhanced ATMEL 12350 MIB by VERNET
262              */
263             if (WirelessStat)
264                 free(WirelessStat);
265             WirelessStat =
266                 (struct WirelessStatistics *) malloc(varbinds[0].len_val);
267             memcpy(WirelessStat, varbinds[0].value, varbinds[0].len_val);
268         } else {
269             print_helperr
270                 (_("WirelessStat packet error. Press any key."));
271             getch();
272             goto quit;
273         }
274
275         sprintf(message,
276                 "UnicastPacketsTx   %10u UnicastPacketsRx   %10u",
277                 swap4(WirelessStat->UnicastTransmittedPackets),
278                 swap4(WirelessStat->UnicastReceivedPackets));
279         mvwaddstr(main_sub, 1, 1, message);
280         sprintf(message,
281                 "BroadcastPacketsTx %10u BroadcastPacketsRx %10u",
282                 swap4(WirelessStat->BroadcastTransmittedPackets),
283                 swap4(WirelessStat->BroadcastReceivedPackets));
284         mvwaddstr(main_sub, 2, 1, message);
285         sprintf(message,
286                 "MulticastPacketsTx %10u MulticastPacketsRx %10u",
287                 swap4(WirelessStat->MulticastTransmittedPackets),
288                 swap4(WirelessStat->MulticastReceivedPackets));
289         mvwaddstr(main_sub, 3, 1, message);
290         sprintf(message,
291                 "BeaconTx           %10u BeaconRx           %10u",
292                 swap4(WirelessStat->TransmittedBeacon),
293                 swap4(WirelessStat->ReceivedBeacon));
294         mvwaddstr(main_sub, 4, 1, message);
295         sprintf(message,
296                 "ACKTx              %10u ACKRx              %10u",
297                 swap4(WirelessStat->TransmittedACK),
298                 swap4(WirelessStat->ReceivedACK));
299         mvwaddstr(main_sub, 5, 1, message);
300         sprintf(message,
301                 "RTSTx              %10u RTSRx              %10u",
302                 swap4(WirelessStat->TransmittedRTS),
303                 swap4(WirelessStat->ReceivedRTS));
304         mvwaddstr(main_sub, 6, 1, message);
305         sprintf(message,
306                 "CTSTx              %10u CTSRx              %10u",
307                 swap4(WirelessStat->TransmittedCTS),
308                 swap4(WirelessStat->ReceivedCTS));
309         mvwaddstr(main_sub, 7, 1, message);
310         sprintf(message, "ACKFailure         %10u",
311                 swap4(WirelessStat->ACKFailure));
312         mvwaddstr(main_sub, 8, 1, message);
313         sprintf(message, "CTSFailure         %10u",
314                 swap4(WirelessStat->CTSFailure));
315         mvwaddstr(main_sub, 9, 1, message);
316         sprintf(message, "RetryPackets       %10u",
317                 swap4(WirelessStat->RetryPackets));
318         mvwaddstr(main_sub, 10, 1, message);
319         sprintf(message, "ReceivedDuplicate  %10u",
320                 swap4(WirelessStat->ReceivedDuplicate));
321         mvwaddstr(main_sub, 11, 1, message);
322         sprintf(message, "FailedPackets      %10u",
323                 swap4(WirelessStat->FailedPackets));
324         mvwaddstr(main_sub, 12, 1, message);
325         sprintf(message, "AgedPackets        %10u",
326                 swap4(WirelessStat->AgedPackets));
327         mvwaddstr(main_sub, 13, 1, message);
328         sprintf(message, "FCSError           %10u",
329                 swap4(WirelessStat->FCSError));
330         mvwaddstr(main_sub, 14, 1, message);
331         sprintf(message, "InvalidPLCP        %10u",
332                 swap4(WirelessStat->InvalidPLCP));
333         mvwaddstr(main_sub, 15, 1, message);
334
335         /* ATMEL12350 MIB 'VERNET' modification has in addition the following */
336         if (varbinds[0].len_val == 104) {
337             mvwaddstr(main_sub, 16, 1, "TransmittedPackets:");
338             sprintf(message, "* at 11 Mbps       %10u",
339                 swap4(WirelessStat->TransmittedPackets_11Mbps));
340             mvwaddstr(main_sub, 17, 1, message);
341             sprintf(message, "* at 5.5 Mbps      %10u",
342                 swap4(WirelessStat->TransmittedPackets_55Mbps));
343             mvwaddstr(main_sub, 18, 1, message);
344             sprintf(message, "* at 2 Mbps        %10u",
345                 swap4(WirelessStat->TransmittedPackets_2Mbps));
346             mvwaddstr(main_sub, 19, 1, message);
347             sprintf(message, "* at 1 Mbps        %10u",
348                 swap4(WirelessStat->TransmittedPackets_1Mbps));
349             mvwaddstr(main_sub, 20, 1, message);
350         }
351         wrefresh(main_sub);
352
353         i = wait_key();
354         if (i == -1)
355             goto quit;
356
357         switch((char) i) {
358             case 'q':
359             case 'Q':
360                 goto quit;
361             case 't':
362             case 'T':
363                 wait_mode = (wait_mode == WAIT_FOREVER ?
364                     WAIT_TIMEOUT : WAIT_FOREVER);
365                 print_top(wait_mode == WAIT_TIMEOUT ? POLL_ON : POLL_OFF,
366                     W_STAT);
367         }
368
369         /* either timeout for user input (i == 0) or invalid key => continue */
370     }
371
372   quit:
373     if (WirelessStat)
374         free(WirelessStat);
375     wclear(main_sub);
376     print_top(NULL, NULL);
377     clear_main(0);
378 }
379
380
381 void nwn_wireless_stat()
382 {
383     char oid_dot11TransmittedFragmentCount[] =
384         { 0x2a, 0x86, 0x48, 0xce, 0x34, 0x02, 0x02, 0x01, 0x01, 0x01 };
385     char oid_dot11MulticastTransmittedFrameCount[] =
386         { 0x2a, 0x86, 0x48, 0xce, 0x34, 0x02, 0x02, 0x01, 0x02, 0x01 };
387     char oid_dot11FailedCount[] =
388         { 0x2a, 0x86, 0x48, 0xce, 0x34, 0x02, 0x02, 0x01, 0x03, 0x01 };
389     char oid_dot11RetryCount[] =
390         { 0x2a, 0x86, 0x48, 0xce, 0x34, 0x02, 0x02, 0x01, 0x04, 0x01 };
391     char oid_dot11MultipleRetryCount[] =
392         { 0x2a, 0x86, 0x48, 0xce, 0x34, 0x02, 0x02, 0x01, 0x05, 0x01 };
393     char oid_dot11FrameDuplicateCount[] =
394         { 0x2a, 0x86, 0x48, 0xce, 0x34, 0x02, 0x02, 0x01, 0x06, 0x01 };
395     char oid_dot11RTSSuccessCount[] =
396         { 0x2a, 0x86, 0x48, 0xce, 0x34, 0x02, 0x02, 0x01, 0x07, 0x01 };
397     char oid_dot11RTSFailureCount[] =
398         { 0x2a, 0x86, 0x48, 0xce, 0x34, 0x02, 0x02, 0x01, 0x08, 0x01 };
399     char oid_dot11ACKFailureCount[] =
400         { 0x2a, 0x86, 0x48, 0xce, 0x34, 0x02, 0x02, 0x01, 0x09, 0x01 };
401     char oid_dot11ReceivedFragmentCount[] =
402         { 0x2a, 0x86, 0x48, 0xce, 0x34, 0x02, 0x02, 0x01, 0x0a, 0x01 };
403     char oid_dot11MulticastReceivedFrameCount[] =
404         { 0x2a, 0x86, 0x48, 0xce, 0x34, 0x02, 0x02, 0x01, 0x0b, 0x01 };
405     char oid_dot11FCSErrorCount[] =
406         { 0x2a, 0x86, 0x48, 0xce, 0x34, 0x02, 0x02, 0x01, 0x0c, 0x01 };
407     char oid_dot11TransmittedFrameCount[] =
408         { 0x2a, 0x86, 0x48, 0xce, 0x34, 0x02, 0x02, 0x01, 0x0d, 0x01 };
409     char oid_dot11WEPUndecryptableCount[] =
410         { 0x2a, 0x86, 0x48, 0xce, 0x34, 0x02, 0x02, 0x01, 0x0e, 0x01 };
411     char oid_dot11WEPICVErrorCount[] =
412         { 0x2a, 0x86, 0x48, 0xce, 0x34, 0x01, 0x05, 0x01, 0x05, 0x01 };
413     char oid_dot11WEPExcludedCount[] =
414         { 0x2a, 0x86, 0x48, 0xce, 0x34, 0x01, 0x05, 0x01, 0x06, 0x01 };
415
416     char message[80];
417     int i;
418
419     varbind varbinds[16];
420     curs_set(0);
421
422     print_top(wait_mode == WAIT_TIMEOUT ? POLL_ON : POLL_OFF, W_STAT);
423     noecho();
424
425     if (wait_mode == WAIT_TIMEOUT)
426         print_help(QT_HELP);
427
428     varbinds[0].oid = oid_dot11TransmittedFragmentCount;
429     varbinds[0].len_oid = sizeof(oid_dot11TransmittedFragmentCount);
430     varbinds[1].oid = oid_dot11MulticastTransmittedFrameCount;
431     varbinds[1].len_oid = sizeof(oid_dot11MulticastTransmittedFrameCount);
432     varbinds[2].oid = oid_dot11FailedCount;
433     varbinds[2].len_oid = sizeof(oid_dot11FailedCount);
434     varbinds[3].oid = oid_dot11RetryCount;
435     varbinds[3].len_oid = sizeof(oid_dot11RetryCount);
436     varbinds[4].oid = oid_dot11MultipleRetryCount;
437     varbinds[4].len_oid = sizeof(oid_dot11MultipleRetryCount);
438     varbinds[5].oid = oid_dot11FrameDuplicateCount;
439     varbinds[5].len_oid = sizeof(oid_dot11FrameDuplicateCount);
440     varbinds[6].oid = oid_dot11RTSSuccessCount;
441     varbinds[6].len_oid = sizeof(oid_dot11RTSSuccessCount);
442     varbinds[7].oid = oid_dot11RTSFailureCount;
443     varbinds[7].len_oid = sizeof(oid_dot11RTSFailureCount);
444     varbinds[8].oid = oid_dot11ACKFailureCount;
445     varbinds[8].len_oid = sizeof(oid_dot11ACKFailureCount);
446     varbinds[9].oid = oid_dot11ReceivedFragmentCount;
447     varbinds[9].len_oid = sizeof(oid_dot11ReceivedFragmentCount);
448     varbinds[10].oid = oid_dot11MulticastReceivedFrameCount;
449     varbinds[10].len_oid = sizeof(oid_dot11MulticastReceivedFrameCount);
450     varbinds[11].oid = oid_dot11FCSErrorCount;
451     varbinds[11].len_oid = sizeof(oid_dot11FCSErrorCount);
452     varbinds[12].oid = oid_dot11TransmittedFrameCount;
453     varbinds[12].len_oid = sizeof(oid_dot11TransmittedFrameCount);
454     varbinds[13].oid = oid_dot11WEPUndecryptableCount;
455     varbinds[13].len_oid = sizeof(oid_dot11WEPUndecryptableCount);
456     varbinds[14].oid = oid_dot11WEPICVErrorCount;
457     varbinds[14].len_oid = sizeof(oid_dot11WEPICVErrorCount);
458     varbinds[15].oid = oid_dot11WEPExcludedCount;
459     varbinds[15].len_oid = sizeof(oid_dot11WEPExcludedCount);
460
461     while (1) {
462         for (i = 0; i < 16; i++) {
463             varbinds[i].value = oid_dot11TransmittedFragmentCount;
464             varbinds[i].len_val = 0;
465             varbinds[i].type = 0x05;
466         }
467
468         if (wait_mode == WAIT_FOREVER)
469             print_help(WAIT_RET);
470
471         if (snmp(varbinds, 16, GET) <= 0) {
472             print_helperr(ERR_RET);
473             getch();
474             goto quit;
475         }
476
477         if (wait_mode == WAIT_FOREVER)
478             print_help(QT_HELP);
479
480         sprintf(message, "FragmentTx       %10lu FragmentRx       %10lu",
481                 (long) swap4(*varbinds[0].value), (long) swap4(*varbinds[9].value));
482         mvwaddstr(main_sub, 1, 1, message);
483         sprintf(message, "TransmittedFrame %10lu",
484                 (long) swap4(*varbinds[12].value));
485         mvwaddstr(main_sub, 2, 1, message);
486         sprintf(message, "MulticasFrameTx  %10lu MulticastFrameRx %10lu",
487                 (long) swap4(*varbinds[1].value), (long) swap4(*varbinds[10].value));
488         mvwaddstr(main_sub, 3, 1, message);
489         sprintf(message, "WEPUndecryptable %10lu WEPExcluded      %10lu",
490                 (long) swap4(*varbinds[13].value), (long) swap4(*varbinds[15].value));
491         mvwaddstr(main_sub, 4, 1, message);
492         sprintf(message, "RTSSuccess       %10lu RTSFailure       %10lu",
493                 (long) swap4(*varbinds[6].value), (long) swap4(*varbinds[7].value));
494         mvwaddstr(main_sub, 5, 1, message);
495         sprintf(message, "ACKFailure       %10lu",
496                 (long) swap4(*varbinds[8].value));
497         mvwaddstr(main_sub, 6, 1, message);
498         sprintf(message, "Retry            %10lu MultipleRetry    %10lu",
499                 (long) swap4(*varbinds[3].value), (long) swap4(*varbinds[4].value));
500         mvwaddstr(main_sub, 7, 1, message);
501         sprintf(message, "FrameDuplicate   %10lu",
502                 (long) swap4(*varbinds[5].value));
503         mvwaddstr(main_sub, 8, 1, message);
504         sprintf(message, "Failed           %10lu",
505                 (long) swap4(*varbinds[2].value));
506         mvwaddstr(main_sub, 9, 1, message);
507         sprintf(message, "FCSError         %10lu WEPICVError      %10lu",
508                 (long) swap4(*(varbinds[11].value)),
509                 (long) swap4(*(varbinds[14].value)));
510         mvwaddstr(main_sub, 10, 1, message);
511         wrefresh(main_sub);
512
513         i = wait_key();
514         if (i == -1)
515             goto quit;
516
517         switch((char) i) {
518             case 'q':
519             case 'Q':
520                 goto quit;
521             case 't':
522             case 'T':
523                 wait_mode = (wait_mode == WAIT_FOREVER ?
524                     WAIT_TIMEOUT : WAIT_FOREVER);
525                 print_top(wait_mode == WAIT_TIMEOUT ? POLL_ON : POLL_OFF,
526                     W_STAT);
527         }
528
529         /* either timeout for user input (i == 0) or invalid key => continue */
530     }
531
532   quit:
533     wclear(main_sub);
534     print_top(NULL, NULL);
535     clear_main(0);
536 }
537