backwards compatibility with 4.2
[nodeconfig.git] / PlanetLabConf / sysctl.php
index 127362e..a17d80c 100755 (executable)
@@ -15,12 +15,27 @@ global $adm;
 $ip_forward = 0;
 
 // Look up the node
-$interfaces = $adm->GetInterfaces(array('ip' => $_SERVER['REMOTE_ADDR']));
+// backwards compatibility with the old 4.2 API
+global $__PLC_API_VERSION;
+if ( ! method_exists ($adm,"GetInterfaces"))
+  $__PLC_API_VERSION = 4.2;
+else
+  $__PLC_API_VERSION = 4.3;
+
+if ($__PLC_API_VERSION==4.2)
+  $interfaces = $adm->GetNodeNetworks(array('ip' => $_SERVER['REMOTE_ADDR']));
+else
+  $interfaces = $adm->GetInterfaces(array('ip' => $_SERVER['REMOTE_ADDR']));
+
 if (!empty($interfaces)) {
   $nodes = $adm->GetNodes(array($interfaces[0]['node_id']));
   if (!empty($nodes)) {
     $node = $nodes[0];
-    $interfaces = $adm->GetInterfaces($node['interface_ids']);
+    if ($__PLC_API_VERSION==4.2)
+      $interfaces = $adm->GetInterfaces($node['nodenetwork_ids']);
+    else
+      $interfaces = $adm->GetInterfaces($node['interface_ids']);
+
     foreach ($interfaces as $interface) {
       // Nodes with proxy socket interfaces need to be able to forward
       // between the fake proxy0 interface and the real interface.