]> git.decadent.org.uk Git - ap-utils.git/blobdiff - lib/stat.c
Merge commit 'upstream/1.5'
[ap-utils.git] / lib / stat.c
index 7ebe726a926bc266899692df6468de6358ade8e1..e5a340e704ea05c802c59965214dd982c48fea76 100644 (file)
 
 extern WINDOW *main_sub;
 extern short ap_type;
-extern int wait_mode;
+extern int wait_mode, poll_delay;
 
 void EthStat()
 {
-    struct EthernetRxStatistics *EthRxStat = NULL;
-    struct EthernetTxStatistics *EthTxStat = NULL;
+    struct EthRxStatistics_s *EthRxStat = NULL;
+    struct EthTxStatistics_s *EthTxStat = NULL;
 
-    char EthRx[] = { 0x2B, 0x06, 0x01, 0x04, 0x01, 0x83, 0x1A, 0x01, 0x01,
-       0x07, 0x01, 0x00
+    char EthRxStatistics[] = {
+       0x2B, 0x06, 0x01, 0x04, 0x01, 0x83, 0x1A, 0x01, 0x01, 0x07, 0x01, 0x00
     };
-
-    char EthTx[] = { 0x2B, 0x06, 0x01, 0x04, 0x01, 0x83, 0x1A, 0x01, 0x01,
-       0x07, 0x02, 0x00
+    char EthTxStatistics[] = {
+       0x2B, 0x06, 0x01, 0x04, 0x01, 0x83, 0x1A, 0x01, 0x01, 0x07, 0x02, 0x00
     };
+
     char message[1024];
     varbind varbinds[2];
     int i;
 
     if (ap_type == ATMEL12350) {
-       EthRx[5] = 0xE0;
-       EthRx[6] = 0x3E;
-       EthTx[5] = 0xE0;
-       EthTx[6] = 0x3E;
+       EthRxStatistics[5] = 0xE0;
+       EthRxStatistics[6] = 0x3E;
+       EthTxStatistics[5] = 0xE0;
+       EthTxStatistics[6] = 0x3E;
     }
     
     print_top(wait_mode == WAIT_TIMEOUT ? POLL_ON : POLL_OFF, ETH_STAT);
@@ -62,23 +62,23 @@ void EthStat()
     if (wait_mode == WAIT_TIMEOUT)
         print_help(QT_HELP);
 
-    varbinds[0].oid = EthRx;
-    varbinds[0].len_oid = sizeof(EthRx);
-    varbinds[1].oid = EthTx;
-    varbinds[1].len_oid = sizeof(EthTx);
+    varbinds[0].oid = EthRxStatistics;
+    varbinds[0].len_oid = sizeof(EthRxStatistics);
+    varbinds[1].oid = EthTxStatistics;
+    varbinds[1].len_oid = sizeof(EthTxStatistics);
 
     while (1) {
-//     varbinds[0].value = EthTx;
+//     varbinds[0].value = EthRxStatistics;
        varbinds[0].len_val = 0;
        varbinds[0].type = NULL_VALUE;
-//     varbinds[1].value = EthTx;
+//     varbinds[1].value = EthTxStatistics;
        varbinds[1].len_val = 0;
        varbinds[1].type = NULL_VALUE;
 
        if (wait_mode == WAIT_FOREVER)
            print_help(WAIT_RET);
 
-       if (snmp(varbinds, 2, GET) <= 0) {
+       if (snmp(varbinds, 2, GET) < 2) {
            print_helperr(ERR_RET);
            getch();
            goto quit;
@@ -91,7 +91,7 @@ void EthStat()
            if (EthRxStat)
                free(EthRxStat);
            EthRxStat =
-               (struct EthernetRxStatistics *) malloc(varbinds[0].
+               (struct EthRxStatistics_s *) malloc(varbinds[0].
                                                       len_val);
            memcpy(EthRxStat, varbinds[0].value, varbinds[0].len_val);
        } else {
@@ -104,7 +104,7 @@ void EthStat()
            if (EthTxStat)
                free(EthTxStat);
            EthTxStat =
-               (struct EthernetTxStatistics *) malloc(varbinds[1].
+               (struct EthTxStatistics_s *) malloc(varbinds[1].
                                                       len_val);
            memcpy(EthTxStat, varbinds[1].value, varbinds[1].len_val);
        } else {
@@ -181,7 +181,7 @@ void EthStat()
        mvwaddstr(main_sub, 18, 2, message);
        wrefresh(main_sub);
 
-       i = wait_key();
+       i = wait_key(poll_delay);
        if (i == -1)
            goto quit;
 
@@ -214,19 +214,19 @@ void EthStat()
 
 void WirelessStat()
 {
-    struct WirelessStatistics *WirelessStat = NULL;
+    struct wirelessStatistics_s *WirelessStat = NULL;
 
-    char Wireless[] =
-       { 0x2B, 0x06, 0x01, 0x04, 0x01, 0x83, 0x1A, 0x01, 0x02, 0x03, 0x01,
-       0x00
+    char wirelessStatistics[] = {
+       0x2B, 0x06, 0x01, 0x04, 0x01, 0x83, 0x1A, 0x01, 0x02, 0x03, 0x01, 0x00
     };
+
     char message[80];
     int i;
     varbind varbinds[1];
 
     if (ap_type == ATMEL12350) {
-       Wireless[5] = 0xE0;
-       Wireless[6] = 0x3E;
+       wirelessStatistics[5] = 0xE0;
+       wirelessStatistics[6] = 0x3E;
     }
 
     print_top(wait_mode == WAIT_TIMEOUT ? POLL_ON : POLL_OFF, W_STAT);
@@ -235,11 +235,11 @@ void WirelessStat()
     if (wait_mode == WAIT_TIMEOUT)
        print_help(QT_HELP);
 
-    varbinds[0].oid = Wireless;
-    varbinds[0].len_oid = sizeof(Wireless);
+    varbinds[0].oid = wirelessStatistics;
+    varbinds[0].len_oid = sizeof(wirelessStatistics);
 
     while (1) {
-       varbinds[0].value = Wireless;
+       varbinds[0].value = wirelessStatistics;
        varbinds[0].len_val = 0;
        varbinds[0].type = NULL_VALUE;
 
@@ -258,12 +258,12 @@ void WirelessStat()
        if (varbinds[0].len_val == 88 || varbinds[0].len_val == 104) {
            /*
             * 88 ... using traditional ATMEL 12350 MIB
-            * 104 .. using functionally enhanced ATMEL 12350 MIB by VERNET
+            * 104 .. using functionally enhanced ATMEL 12350 MIB by EZYNET
             */
            if (WirelessStat)
                free(WirelessStat);
            WirelessStat =
-               (struct WirelessStatistics *) malloc(varbinds[0].len_val);
+               (struct wirelessStatistics_s *) malloc(varbinds[0].len_val);
            memcpy(WirelessStat, varbinds[0].value, varbinds[0].len_val);
        } else {
            print_helperr
@@ -332,7 +332,7 @@ void WirelessStat()
                swap4(WirelessStat->InvalidPLCP));
        mvwaddstr(main_sub, 15, 1, message);
 
-       /* ATMEL12350 MIB 'VERNET' modification has in addition the following */
+       /* ATMEL12350 MIB EZYNET modification has in addition the following */
        if (varbinds[0].len_val == 104) {
            mvwaddstr(main_sub, 16, 1, "TransmittedPackets:");
            sprintf(message, "* at 11 Mbps       %10u",
@@ -350,7 +350,7 @@ void WirelessStat()
        }
        wrefresh(main_sub);
 
-       i = wait_key();
+       i = wait_key(poll_delay);
        if (i == -1)
            goto quit;
 
@@ -468,7 +468,7 @@ void nwn_wireless_stat()
        if (wait_mode == WAIT_FOREVER)
            print_help(WAIT_RET);
 
-       if (snmp(varbinds, 16, GET) <= 0) {
+       if (snmp(varbinds, 16, GET) < 16) {
            print_helperr(ERR_RET);
            getch();
            goto quit;
@@ -510,7 +510,7 @@ void nwn_wireless_stat()
        mvwaddstr(main_sub, 10, 1, message);
        wrefresh(main_sub);
 
-       i = wait_key();
+       i = wait_key(poll_delay);
        if (i == -1)
            goto quit;