remove legacy layer, just assume 4.3 and GetInterfaces
[nodeconfig.git] / PlanetLabConf / sysctl-ip_forward.php
1 <?php
2
3 // Get admin API handle
4 require_once 'plc_api.php';
5 global $adm;
6
7 $ip_forward = 0;
8
9 // Look up the node
10 $interfaces = $adm->GetInterfaces(array('ip' => $_SERVER['REMOTE_ADDR']));
11
12 if (!empty($interfaces)) {
13   $nodes = $adm->GetNodes(array($interfaces[0]['node_id']));
14   if (!empty($nodes)) {
15     $node = $nodes[0];
16     $interfaces = $adm->GetInterfaces($node['interface_ids']);
17
18     foreach ($interfaces as $interface) {
19       // Nodes with proxy socket interfaces need to be able to forward
20       // between the fake proxy0 interface and the real interface.
21       if ($interface['method'] == 'proxy') {
22         $ip_forward = 1;
23         break;
24       }
25     }
26   }
27 }
28
29 ?>
30
31 #
32 # sysctl configuration file to optionally enable/disable IP forwarding
33 #
34 # For binary values, 0 is disabled, 1 is enabled.  See sysctl(8) and
35 # sysctl.conf(5) for more details.
36 #
37 # This file is generated by NodeManager Configuration Files... 
38 # do not manually edit
39 #
40
41 # Controls IP packet forwarding
42 net.ipv4.ip_forward = <?php echo $ip_forward; ?>