Browse Source

Add support for IPv6 mapping.

Joe Clarke 9 months ago
parent
commit
443a5c4cf5
2 changed files with 15 additions and 0 deletions
  1. 8 0
      www/swreg/swreg.inc.php
  2. 7 0
      www/swreg/swreg.php

+ 8 - 0
www/swreg/swreg.inc.php

@@ -37,6 +37,14 @@ define('REST_RETRIES', 1);
 define('REST_TIMEOUT', 300);
 define('DEBUG', 0);
 
+// IPv6 Config
+// Whether or not to do IPv6 mapping from IPv4 management address.
+define('MAP_V6', false);
+// The IPv6 Prefix to use for management.
+define('IPV6_PREFIX', '::');
+define('IPV6_PREFIXLEN', '64');
+define('IPV6_GW', '::');
+
 // Addressing scheme
 // Choose one of IDF, NEXT_FREE, or NONE
 // IDF : The IDF switch is assumed to be .1 and each switch associated with

+ 7 - 0
www/swreg/swreg.php

@@ -293,6 +293,13 @@ $contents = str_replace('%%MGMT_MASK%%', $row['mask'], $contents);
 $contents = str_replace('%%MGMT_GW%%', $row['gw'], $contents);
 $contents = str_replace('%%SNMP_LOCATION%%', $snmp_loc, $contents);
 
+if (MAP_V6 === true) {
+    $octets = explode('.', $row['ip']);
+    $contents = str_replace('%%MGMT_IP6%%', IPV6_PREFIX . ':' . $octets[3], $contents);
+    $contents = str_replace('%%MGMT_PREFIXLEN%%', IPV6_PREFIXLEN, $contents);
+    $contents = str_replace('%%MGMT_GW6%%', IPV6_GW, $contents);
+}
+
 $contents = str_replace('%%START_PORT%%', $start_port, $contents);
 $contents = str_replace('%%MAX_PORT%%', $max_ports, $contents);