bcast-bridge/web/config.php

82 lines
1.9 KiB
PHP
Raw Permalink Normal View History

2006-12-11 21:36:44 +01:00
<?php
require_once('include.php');
$bridgeid = Input::getVar('bridgeid', INP_GET | INP_INT | INP_DEFAULT, 0);
if ($bridgeid == 0)
die();
$retval = array();
$bridges = Bridge::getAll();
$bridge = $bridges[$bridgeid];
$retval['bridge'] = array(
'id' => $bridge->id,
'ctrlip' => $bridge->ctrlip,
'macmask' => $bridge->basemac."/FF:FF:FF:FF:FF:00"
);
$device = 0;
$retval['tunnel'] = array();
foreach ($bridges as $bridge) {
if ($bridge->id == $bridgeid)
continue;
if ($bridge->ctrlip == "0.0.0.0")
continue;
$retval['tunnel'][$bridge->id] = array(
'name' => (($bridge->id < $bridgeid) ? "tap-{$bridgeid}-{$bridge->id}" : "tap-{$bridge->id}-{$bridgeid}"),
'dest' => $bridge->ctrlip,
'mode' => (($bridge->id < $bridgeid) ? "client" : "server"),
'device' => "tap".$device++,
'macmask' => $bridge->basemac."/FF:FF:FF:FF:FF:00"
);
}
$retval['vlan'] = array();
$trunks = Trunk::getAll($bridgeid);
foreach ($trunks as $trunk) {
$vlans = Vlan::getAll($trunk->id);
foreach ($vlans as $vlan)
$retval['vlan'][$vlan->id] = array(
'name' => (($vlan->vlannum > 1) ? "{$trunk->name}.{$vlan->vlannum}" : $trunk->name),
'bw' => $vlan->bandwidth,
'mac' => $vlan->mac
);
}
$retval['hlsw'] = array();
$masters = Hlsw::getAll();
foreach ($masters as $hlsw) {
if (isset($retval['vlan'][$hlsw->vlanid])) {
$retval['hlsw'][$hlsw->id] = array(
'dev' => $retval['vlan'][$hlsw->vlanid]['name'],
'ip' => $hlsw->ip
);
}
}
$retval['forward'] = array();
$forwards = Forward::getAll();
foreach ($forwards as $forward)
$retval['forward'][$forward->id] = array(
'portlo' => $forward->portlo,
'porthi' => $forward->porthi,
'active' => $forward->isActive()
);
$action = Input::getVar('action', INP_GET | INP_STRING | INP_DEFAULT, 'fetch');
switch ($action) {
case 'show':
Helper::show($retval);
break;
default:
case 'fetch':
header("Content-Type: file/plain");
echo serialize($retval);
break;
}
?>