]> git.decadent.org.uk Git - ap-utils.git/blobdiff - src/stations.c
Imported Upstream version 1.5~pre1
[ap-utils.git] / src / stations.c
index 5eb272d3815f08c7e6f9a625abc0418c9a8f94e6..6c23478305ad874811e587dfbf1945aa2a7cfef4 100644 (file)
 #include <signal.h>
 #include <string.h>
 #include "ap-utils.h"
-#include "ap-curses.h"
 
-#define STAS _("Associated Stations")
-#define STAS_HEADER \
+/*
+ * NOTE: SBRIDGES seems to be currently handled by ap-gl =>
+ * no SBRIDGES-related code here (yet)!
+ */
+
+#define TITLE_AP _("AP link state")
+
+/* following for any non-VERNET ATMEL* MIB */
+#define HEADER_STAS \
        _(" #            MAC                                               ")
 /* following for VERNET-enhanced ATMEL12350 MIB */
-#define STAS_HEADER_VERNET \
+#define HEADER_STAS_VERNET \
        _(" #     MAC       Parent MAC    RSSI  Status MACn      IP        ")
 
 #define MAX_LINES LINES-4
 
 extern int LINES;
 extern WINDOW *main_sub;
-extern short ap_type;
-extern char IS_ATMEL12350_VERNET;
+extern short ap_type, ap_vendorext;
 extern int sts_viewtype;
 
-void stations()
+void atmel_stations()
 {
     char bridgeOperationalMode[] = {
        0x2B, 0x06, 0x01, 0x04, 0x01, 0x83, 0x1A, 0x01, 0x01, 0x04, 0x01, 0x00
@@ -69,7 +74,6 @@ void stations()
     int mac_idx, begin, end, total_mac;
     varbind varbinds[1];
 
-
     if (ap_type == ATMEL12350) {
         bridgeOperationalMode[5] = 0xE0;
        bridgeOperationalMode[6] = 0x3E;
@@ -92,7 +96,7 @@ void stations()
     }
 
     /* for AP in AP-Client mode & without VERNET firmware, disable status */
-    if (*(varbinds[0].value) == 3 && !IS_ATMEL12350_VERNET) {
+    if (*(varbinds[0].value) == 3 && ap_vendorext != VERNET) {
        mvwaddstr(main_sub, 3, 1, _("AP is currently in AP Client Mode => "
            "no associated STAtions."));
        print_help(ANY_KEY);
@@ -103,10 +107,10 @@ void stations()
 
     noecho();
     wattrset(main_sub, COLOR_PAIR(3));
-    if (IS_ATMEL12350_VERNET)
-       mvwaddstr(main_sub, 0, 0, STAS_HEADER_VERNET);
+    if (ap_vendorext == VERNET)
+       mvwaddstr(main_sub, 0, 0, HEADER_STAS_VERNET);
     else
-       mvwaddstr(main_sub, 0, 0, STAS_HEADER);
+       mvwaddstr(main_sub, 0, 0, HEADER_STAS);
     wattrset(main_sub, A_NORMAL);
 
 refresh:
@@ -168,7 +172,7 @@ refresh:
 
        memcpy(curr->addr, mac->MacAddress, 6);
 
-       if (IS_ATMEL12350_VERNET) {
+       if (ap_vendorext == VERNET) {
            curr->Status = mac->Status;
            curr->Port = mac->Port;
            memcpy(curr->ParentMacAddress, mac->ParentMacAddress, 6);
@@ -183,22 +187,20 @@ refresh:
     begin = 1;
     end = (MAX_LINES < mac_idx) ? MAX_LINES : mac_idx;
 
-    if (IS_ATMEL12350_VERNET)
-       print_help(_("Arrows - scroll; S - save to file; Q - return; "
-                    "T - toggle view; Other key - refresh"));
-    else
-       print_help(_("Arrows - scroll; S - save to file; Q - return; "
-                    "Other key - refresh"));
-
+    sprintf(message, "%s: %d", TITLE_STAS, total_mac);
     while (1) {
-       sprintf(message, "%s: %d", STAS, total_mac);
-       print_title(message);
+       if (ap_vendorext == VERNET) {
+           print_top_rssi(message);
 
-       if (IS_ATMEL12350_VERNET) {
-           print_viewtype_rssi();
+           print_help(_("Arrows - scroll; S - save to file; Q - return; "
+                        "T - toggle view; Other - refresh"));
            scroll_rows(first, begin, end, 1, 3);
-       } else
+       } else {
+           print_top(NULL, message);
+           print_help(_("Arrows - scroll; S - save to file; Q - return; "
+                        "Other key - refresh"));
            scroll_rows(first, begin, end, 1, 0);
+       }
 
        switch (getch()) {
            case 'S':
@@ -224,7 +226,7 @@ refresh:
                goto exit;
            case 'T':
            case 't':
-               if (IS_ATMEL12350_VERNET) {
+               if (ap_vendorext == VERNET) {
                    sts_viewtype += 1;
                    if (sts_viewtype == 3)
                        sts_viewtype = 0;
@@ -245,7 +247,7 @@ exit:
        first = curr->next;
        free(curr);
     }
-    print_title("");
+    print_top(NULL, NULL);
     clear_main(0);
 }
 
@@ -272,9 +274,9 @@ void nwn_stations()
 
 
     mac_idx = 0;
-    print_title(_("Associated stations"));
+    print_top(NULL, TITLE_STAS);
     mvwaddstr(main_sub, 0, 3,
-             _("Id       MAC address     Quality  Age  RSSI"));
+       _("Id       MAC address     Quality  Age  RSSI"));
     noecho();
     print_help(WAIT_RET);
 
@@ -355,14 +357,21 @@ void nwn_stations()
        next_num = varbinds[0].oid[varbinds[0].len_oid - 1];
                                                
     }
-   sprintf(message, "%s: %d", _("Associated stations"), mac_idx);
-   print_title(message);
+
    if(mac_idx) {
+
     begin = 1;
-    end = (MAX_LINES < mac_idx+1) ? MAX_LINES : mac_idx+1;
-    scroll_rows(first, begin, end, 1, 1);
-    print_help(_("Arrows - scroll; S - save to file; Q - quit to menu."));
+    end = (MAX_LINES < mac_idx + 1) ? MAX_LINES : mac_idx + 1;
+
     while (1) {
+       print_help(_("Arrows - scroll; S - save to file; Q - return; "
+           "T - toggle view; Other - refresh"));
+
+       scroll_rows(first, begin, end, 1, 1);
+
+       sprintf(message, "%s: %d", TITLE_STAS, mac_idx);
+       print_top_rssi(message);
+
        switch (getch()) {
        case 'S':
        case 's':
@@ -373,7 +382,6 @@ void nwn_stations()
            if (end < mac_idx+1) {
                begin++;
                end++;
-               scroll_rows(first, begin, end, 1, 1);
            }
            continue;
        case KEY_UP:
@@ -381,12 +389,18 @@ void nwn_stations()
            if (begin > 1) {
                begin--;
                end--;
-               scroll_rows(first, begin, end, 1, 1);
            }
            continue;
        case 'Q':
        case 'q':
            goto exit;
+       case 'T':
+       case 't':
+           sts_viewtype += 1;
+           if (sts_viewtype == 3)
+               sts_viewtype = 0;
+
+           continue;
        }
     }
    }
@@ -400,7 +414,7 @@ void nwn_stations()
        free(curr);
     }
     
-    print_title("");
+    print_top(NULL, NULL);
     clear_main(0);
 }