]> git.decadent.org.uk Git - ap-utils.git/blobdiff - src/bridge.c
Imported Upstream version 1.4.2~pre2~a
[ap-utils.git] / src / bridge.c
index edaf94e014945c5f0804294b775b1b67c9b346b1..8c065004f775ce06c69b8ec0c8f578065559b855 100644 (file)
 #define HELP _("INGFPDOMSCTRBU - set; W - write conf; Q - quit to menu")
 
 extern short ap_type;
+extern char IS_ATMEL410_SBRIDGES;
+extern char IS_ATMEL12350_TELLUS;
 
 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 +122,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 +149,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;
@@ -248,9 +210,9 @@ void bridging()
 
     if (IS_ATMEL410_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) {