]> git.decadent.org.uk Git - ap-utils.git/blobdiff - src/bridge.c
Imported Upstream version 1.5~pre1
[ap-utils.git] / src / bridge.c
index edaf94e014945c5f0804294b775b1b67c9b346b1..7833cc510ffb38f72cc0f5cafcdd8274a7a21e60 100644 (file)
@@ -22,7 +22,6 @@
 #include <string.h>
 #include <sys/types.h>
 #include "ap-utils.h"
-#include "ap-curses.h"
 
 #define IPADDR _("[I] IP: ")
 #define NETMASK _("[N] Netmask: ")
 #define SB_UCAST _("[U] Isolate wireless clients (unicast traffic): ")
 #define HELP _("INGFPDOMSCTRBU - set; W - write conf; Q - quit to menu")
 
-extern short ap_type;
+extern short ap_type, ap_vendorext;
 
 void bridging()
 {
-
-    char sysTrapSwitch[] =
-       { 0x2B, 0x06, 0x01, 0x04, 0x01, 0x83, 0x1A, 0x01, 0x01, 0x01, 0x03,
-       0x00
+    char sysTrapSwitch[] = {
+       0x2B, 0x06, 0x01, 0x04, 0x01, 0x83, 0x1A, 0x01, 0x01, 0x01, 0x03, 0x00
     };
 
-    char operIPAddress[] =
-       { 0x2B, 0x06, 0x01, 0x04, 0x01, 0x83, 0x1A, 0x01, 0x01, 0x02, 0x01,
-       0x00
+    char operIPAddress[] = {
+       0x2B, 0x06, 0x01, 0x04, 0x01, 0x83, 0x1A, 0x01, 0x01, 0x02, 0x01, 0x00
     };
-    char operIPMask[] =
-       { 0x2B, 0x06, 0x01, 0x04, 0x01, 0x83, 0x1A, 0x01, 0x01, 0x02, 0x02,
-       0x00
+    char operIPMask[] = {
+       0x2B, 0x06, 0x01, 0x04, 0x01, 0x83, 0x1A, 0x01, 0x01, 0x02, 0x02, 0x00
     };
-    char operEthernetAddress[] =
-       { 0x2B, 0x06, 0x01, 0x04, 0x01, 0x83, 0x1A, 0x01, 0x01, 0x02, 0x03,
-       0x00
+    char operEthernetAddress[] = {
+       0x2B, 0x06, 0x01, 0x04, 0x01, 0x83, 0x1A, 0x01, 0x01, 0x02, 0x03, 0x00
     };
-    char operGateway[] =
-       { 0x2B, 0x06, 0x01, 0x04, 0x01, 0x83, 0x1A, 0x01, 0x01, 0x02, 0x04,
-       0x00
+    char operGateway[] = {
+       0x2B, 0x06, 0x01, 0x04, 0x01, 0x83, 0x1A, 0x01, 0x01, 0x02, 0x04, 0x00
     };
-    char operDHCP[] =
-       { 0x2B, 0x06, 0x01, 0x04, 0x01, 0x83, 0x1A, 0x01, 0x01, 0x02, 0x05,
-       0x00
+    char operDHCP[] = {
+       0x2B, 0x06, 0x01, 0x04, 0x01, 0x83, 0x1A, 0x01, 0x01, 0x02, 0x05, 0x00
     };
-    char PrimaryPort[] =
-       { 0x2B, 0x06, 0x01, 0x04, 0x01, 0x83, 0x1A, 0x01, 0x01, 0x02, 0x06,
-       0x00
+    char PrimaryPort[] = {
+       0x2B, 0x06, 0x01, 0x04, 0x01, 0x83, 0x1A, 0x01, 0x01, 0x02, 0x06, 0x00
     };
     /* This one is ATMEL12350 MIB specific. */
-    char ConfigPort[] =
-       { 0x2B, 0x06, 0x01, 0x04, 0x01, 0xE0, 0x3E, 0x01, 0x01, 0x02, 0x07,
-       0x00
+    char ConfigPort[] = {
+       0x2B, 0x06, 0x01, 0x04, 0x01, 0xE0, 0x3E, 0x01, 0x01, 0x02, 0x07, 0x00
     };
     /* This one is ATMEL12350 TELLUS MIB specific. */
-    char TrapPort[] =
-       { 0x2B, 0x06, 0x01, 0x04, 0x01, 0xE0, 0x3E, 0x01, 0x01, 0x02, 0x08,
-       0x00
+    char TrapPort[] = {
+       0x2B, 0x06, 0x01, 0x04, 0x01, 0xE0, 0x3E, 0x01, 0x01, 0x02, 0x08, 0x00
     };
 
-    char IPFilter[] =
-       { 0x2B, 0x06, 0x01, 0x04, 0x01, 0x83, 0x1A, 0x01, 0x01, 0x03, 0x01,
-       0x00
+    char IPFilter[] = {
+       0x2B, 0x06, 0x01, 0x04, 0x01, 0x83, 0x1A, 0x01, 0x01, 0x03, 0x01, 0x00
     };
-
     /* These 3 are ATMEL12350 MIB specific. */
-    char ForwardBroadcast[] =
-       { 0x2B, 0x06, 0x01, 0x04, 0x01, 0xE0, 0x3E, 0x01, 0x01, 0x03, 0x02,
-       0x00
+    char ForwardBroadcast[] = {
+       0x2B, 0x06, 0x01, 0x04, 0x01, 0xE0, 0x3E, 0x01, 0x01, 0x03, 0x02, 0x00
     };
-    char SendBackBcast[] =
-       { 0x2B, 0x06, 0x01, 0x04, 0x01, 0xE0, 0x3E, 0x01, 0x01, 0x03, 0x03,
-       0x00
+    char SendBackBcast[] = {
+       0x2B, 0x06, 0x01, 0x04, 0x01, 0xE0, 0x3E, 0x01, 0x01, 0x03, 0x03, 0x00
     };
-    char SendBackUnicast[] =
-       { 0x2B, 0x06, 0x01, 0x04, 0x01, 0xE0, 0x3E, 0x01, 0x01, 0x03, 0x04,
-       0x00
+    char SendBackUnicast[] = {
+       0x2B, 0x06, 0x01, 0x04, 0x01, 0xE0, 0x3E, 0x01, 0x01, 0x03, 0x04, 0x00
     };
 
-    char bridgeOperationalMode[] =
-       { 0x2B, 0x06, 0x01, 0x04, 0x01, 0x83, 0x1A, 0x01, 0x01, 0x04, 0x01,
-       0x00
+    char bridgeOperationalMode[] = {
+       0x2B, 0x06, 0x01, 0x04, 0x01, 0x83, 0x1A, 0x01, 0x01, 0x04, 0x01, 0x00
     };
-    char bridgeRemoteBridgeBSSID[] =
-       { 0x2B, 0x06, 0x01, 0x04, 0x01, 0x83, 0x1A, 0x01, 0x01, 0x04, 0x02,
-       0x00
+    char bridgeRemoteBridgeBSSID[] = {
+       0x2B, 0x06, 0x01, 0x04, 0x01, 0x83, 0x1A, 0x01, 0x01, 0x04, 0x02, 0x00
     };
 
     extern WINDOW *main_sub;
@@ -137,16 +119,12 @@ void bridging()
        _("Both"),
        _("Ethernet"),
        _("Wireless")
-    },
-       oui_sbridges[3] = { 0x00, 0x30, 0x1A },
-       oui_tellus[3] = { 0x00, 0x04, 0xDB },
-       IS_ATMEL410_SBRIDGES = 0,
-       IS_ATMEL12350_TELLUS = 0;
+    };
     int i;
     unsigned int trap_port = 0;
 
     if (ap_type == ATMEL12350) {
-       operEthernetAddress[5] = 0xE0;
+       operEthernetAddress[5] = 0xE0;
        operEthernetAddress[6] = 0x3E;
        IPFilter[5] = 0xE0;
        IPFilter[6] = 0x3E;
@@ -168,34 +146,15 @@ void bridging()
        sysTrapSwitch[6] = 0x3E;
     }
 
-
-    /* Determine the advanced MIB subtype of the device from its MAC address. */
-    varbinds[0].type = NULL_VALUE;
-    varbinds[0].oid = operEthernetAddress;
-    varbinds[0].len_oid = sizeof(operEthernetAddress);
-    varbinds[0].len_val = 0;
-
-    print_help(WAIT_RET);
-    if (snmp(varbinds, 1, GET) <= 0) {
-       print_helperr(ERR_RET);
-       goto exit;
-    }
-
-    if (ap_type == ATMEL410 && (memcmp(oui_sbridges, varbinds[0].value, 3) ==0))
-       IS_ATMEL410_SBRIDGES = 1;
-
-    if (ap_type == ATMEL12350 && (memcmp(oui_tellus, varbinds[0].value, 3) ==0))
-       IS_ATMEL12350_TELLUS = 1;
-
-
-    for (i = 1; i < 15; i++) {
+    for (i = 0; i < 15; i++) {
        varbinds[i].type = NULL_VALUE;
        varbinds[i].len_val = 0;
        varbinds[i].len_oid = sizeof(sysTrapSwitch);
     }
 
-    i = 1;
+    i = 0;
 
+    varbinds[i++].oid = operEthernetAddress;
     varbinds[i++].oid = IPFilter;
     varbinds[i++].oid = PrimaryPort;
     varbinds[i++].oid = operDHCP;
@@ -210,16 +169,17 @@ void bridging()
        varbinds[i++].oid = ForwardBroadcast;
        varbinds[i++].oid = SendBackBcast;
        varbinds[i++].oid = SendBackUnicast;
-       if (IS_ATMEL12350_TELLUS)
+       if (ap_vendorext == TELLUS || ap_vendorext == VERNET)
            varbinds[i++].oid = TrapPort;
     }
 
+    print_help(WAIT_RET);
     if (snmp(varbinds, i, GET) <= 0) {
        print_helperr(ERR_RET);
        goto exit;
     }
 
-    print_title(_("Bridging"));
+    print_top(NULL, _("Bridging"));
 
     sprintf(message, "%s%02X%02X%02X%02X%02X%02X", MAC,
            varbinds[0].value[0] & 0xFF,
@@ -246,11 +206,11 @@ void bridging()
     sprintf(message, "%s%s", IP_FILTER, (filter == 1) ? ON : OFF);
     mvwaddstr(main_sub, 3, 0, message);
 
-    if (IS_ATMEL410_SBRIDGES) {
+    if (ap_vendorext == SBRIDGES) {
        sprintf(message, "%s%02X%02X%02X%02X%02X%02X", SB_ATTMAC,
-               *(varbinds[2].value +0) & 0xFF, *(varbinds[1].value +1) & 0xFF,
-               *(varbinds[2].value +2) & 0xFF, *(varbinds[1].value +3) & 0xFF,
-               *(varbinds[2].value +4) & 0xFF, *(varbinds[1].value +5) & 0xFF);
+               *(varbinds[2].value +0) & 0xFF, *(varbinds[2].value +1) & 0xFF,
+               *(varbinds[2].value +2) & 0xFF, *(varbinds[2].value +3) & 0xFF,
+               *(varbinds[2].value +4) & 0xFF, *(varbinds[2].value +5) & 0xFF);
     } else {
        primary_port = *(varbinds[2].value);
        if (primary_port < 1 || primary_port > 2) {
@@ -286,7 +246,7 @@ void bridging()
        sprintf(message, "%s%s", CF_PORT, cf_trap_ports[config_port]);
        mvwaddstr(main_sub, 9, 0, message);
 
-       if (IS_ATMEL12350_TELLUS) {
+       if (ap_vendorext == TELLUS || ap_vendorext == VERNET) {
            for (i = 0; i < varbinds[14].len_val;
                    trap_port += varbinds[14].value[i] *
                    (1 << ((varbinds[14].len_val - i - 1) * 8)), i++);
@@ -336,7 +296,7 @@ void bridging()
            continue;
        case 'P':
        case 'p':
-           if (!IS_ATMEL410_SBRIDGES) {
+           if (ap_vendorext != SBRIDGES) {
                primary_port = menu_choose(4, strlen(PR_PORT), pr_ports, 2) + 1;
                clear_main_new(4, 5);
                print_menusel(4, 0, PR_PORT, pr_ports[primary_port - 1]);
@@ -403,7 +363,7 @@ void bridging()
            continue;
        case 'T':
        case 't':
-           if (IS_ATMEL12350_TELLUS) {
+           if (ap_vendorext == TELLUS || ap_vendorext == VERNET) {
                get_value(message, 10, strlen(TRAP_PORT), 6, INT_STRING,
                    0, 65535, HELP);
                trap_port = atoi(message);
@@ -577,7 +537,7 @@ void bridging()
   exit:
     getch();
   quit:
-    print_title("");
+    print_top(NULL, NULL);
     clear_main(0);
 }