remove legacy layer, just assume 4.3 and GetInterfaces
[nodeconfig.git] / PlanetLabConf / proxies.php
1 #
2 # /etc/planetlab/proxies
3 #
4 # post: service vnet restart
5 #
6 # Proxy (a.k.a. network telescope a.k.a. honeypot) interface configuration
7 #
8 # Aaron Klingaman <alk@cs.princeton.edu>
9 # Mark Huang <mlhuang@cs.princeton.edu>
10 # Copyright (C) 2004 The Trustees of Princeton University
11 #
12
13 <?php
14 // Get admin API handle
15 require_once 'plc_api.php';
16 global $adm;
17
18 $interfaces = $adm->GetInterfaces(array('ip' => $_SERVER['REMOTE_ADDR']));
19
20 if (!empty($interfaces)) {
21   $nodes = $adm->GetNodes(array($interfaces[0]['node_id']));
22   if (!empty($nodes)) {
23     $node = $nodes[0];
24   }
25 }
26
27 if (!isset($node)) {
28   exit();
29 }
30
31 $interfaces = $adm->GetInterfaces($node['interface_ids']);
32
33 foreach ($interfaces as $interface) {
34   // XXX PL2896: need interfaces.device
35   switch ($interface['method']) {
36   case 'tap':
37     $dev = "tap0";
38     $types['taps'][$dev][0] = $interface['ip'] . "/" . $interface['gateway'];
39     break;
40   case 'proxy':
41     $dev = "proxy0";
42     $types['proxies'][$dev][] = $interface['ip'];
43     break;
44   }
45 }
46
47 // taps="tap0 tap1 ..."
48 // tap0="1.2.3.4/5.6.7.8"
49 // tap1="9.10.11.12/13.14.15.16"
50 // ...
51 // proxies="proxy0 proxy1 ..."
52 // proxy0="1.2.3.4 5.6.7.8 ..."
53 // proxy1="9.10.11.12 13.14.15.16 ..."
54 // ...
55 if (isset($types)) {
56   foreach ($types as $type => $devs) {
57     print("$type=\"" . implode(" ", array_keys($devs)) . "\"\n");
58     foreach ($devs as $dev => $ips) {
59       print("$dev=\"" . implode(" ", $ips) . "\"\n");
60     }
61   }
62 }
63
64 ?>