diff options
author | gnhb <gnoahb@gmail.com> | 2010-03-30 12:29:07 +0700 |
---|---|---|
committer | gnhb <gnoahb@gmail.com> | 2010-03-30 12:29:07 +0700 |
commit | 589f92bb3ecbec0847952da5aa4bd17f11b7c979 (patch) | |
tree | c0ebe9d0d3ae92eba1f74dc932e50650b9ff3934 /usr/local/www | |
parent | b1bde547a96c30e21a5f2981354f0e70b5144514 (diff) | |
download | pfsense-589f92bb3ecbec0847952da5aa4bd17f11b7c979.zip pfsense-589f92bb3ecbec0847952da5aa4bd17f11b7c979.tar.gz |
mlppp implementation starts
Diffstat (limited to 'usr/local/www')
-rw-r--r-- | usr/local/www/interfaces_mlppp.php | 147 | ||||
-rw-r--r-- | usr/local/www/interfaces_mlppp_edit.php | 180 |
2 files changed, 327 insertions, 0 deletions
diff --git a/usr/local/www/interfaces_mlppp.php b/usr/local/www/interfaces_mlppp.php new file mode 100644 index 0000000..389fbfe --- /dev/null +++ b/usr/local/www/interfaces_mlppp.php @@ -0,0 +1,147 @@ +<?php +/* $Id$ */ +/* + interfaces_mlppp.php + part of m0n0wall (http://m0n0.ch/wall) + + Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>. + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, + INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, + OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. +*/ +/* + pfSense_BUILDER_BINARIES: /sbin/ifconfig + pfSense_MODULE: interfaces +*/ + +##|+PRIV +##|*IDENT=page-interfaces-vlan +##|*NAME=Interfaces: VLAN page +##|*DESCR=Allow access to the 'Interfaces: VLAN' page. +##|*MATCH=interfaces_vlan.php* +##|-PRIV + +require("guiconfig.inc"); + +if (!is_array($config['vlans']['vlan'])) + $config['vlans']['vlan'] = array(); + +$a_vlans = &$config['vlans']['vlan'] ; + +function vlan_inuse($num) { + global $config, $a_vlans; + + $iflist = get_configured_interface_list(false, true); + foreach ($iflist as $if) { + if ($config['interfaces'][$if]['if'] == $a_vlans[$num]['vlanif']) + return true; + } + + return false; +} + +if ($_GET['act'] == "del") { + /* check if still in use */ + if (vlan_inuse($_GET['id'])) { + $input_errors[] = "This VLAN cannot be deleted because it is still being used as an interface."; + } else { + mwexec("/sbin/ifconfig " . $a_vlans[$_GET['id']]['vlanif'] . " destroy"); + unset($a_vlans[$_GET['id']]); + + write_config(); + + header("Location: interfaces_vlan.php"); + exit; + } +} + + +$pgtitle = array("Interfaces","VLAN"); +include("head.inc"); + +?> + +<body link="#0000CC" vlink="#0000CC" alink="#0000CC"> +<?php include("fbegin.inc"); ?> +<?php if ($input_errors) print_input_errors($input_errors); ?> +<table width="100%" border="0" cellpadding="0" cellspacing="0"> + <tr><td> +<?php + $tab_array = array(); + $tab_array[0] = array("Interface assignments", false, "interfaces_assign.php"); + $tab_array[1] = array("Interface Groups", false, "interfaces_groups.php"); + $tab_array[2] = array("Wireless", false, "interfaces_wireless.php"); + $tab_array[3] = array("VLANs", true, "interfaces_vlan.php"); + $tab_array[4] = array("QinQs", false, "interfaces_qinq.php"); + $tab_array[5] = array("PPP", false, "interfaces_ppp.php"); + $tab_array[6] = array("GRE", false, "interfaces_gre.php"); + $tab_array[7] = array("GIF", false, "interfaces_gif.php"); + $tab_array[8] = array("Bridges", false, "interfaces_bridge.php"); + $tab_array[9] = array("LAGG", false, "interfaces_lagg.php"); + display_top_tabs($tab_array); +?> + </td></tr> + <tr> + <td> + <div id="mainarea"> + <table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0"> + <tr> + <td width="20%" class="listhdrr">Interface</td> + <td width="20%" class="listhdrr">VLAN tag</td> + <td width="50%" class="listhdr">Description</td> + <td width="10%" class="list"></td> + </tr> + <?php $i = 0; foreach ($a_vlans as $vlan): ?> + <tr ondblclick="document.location='interfaces_vlan_edit.php?id=<?=$i;?>'"> + <td class="listlr"> + <?=htmlspecialchars($vlan['if']);?> + </td> + <td class="listr"> + <?=htmlspecialchars($vlan['tag']);?> + </td> + <td class="listbg"> + <?=htmlspecialchars($vlan['descr']);?> + </td> + <td valign="middle" nowrap class="list"> <a href="interfaces_vlan_edit.php?id=<?=$i;?>"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_e.gif" width="17" height="17" border="0"></a> + <a href="interfaces_vlan.php?act=del&id=<?=$i;?>" onclick="return confirm('Do you really want to delete this VLAN?')"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" width="17" height="17" border="0"></a></td> + </tr> + <?php $i++; endforeach; ?> + <tr> + <td class="list" colspan="3"> </td> + <td class="list"> <a href="interfaces_vlan_edit.php"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0"></a></td> + </tr> + <tr> + <td colspan="3" class="list"><p class="vexpl"><span class="red"><strong> + Note:<br> + </strong></span> + Not all drivers/NICs support 802.1Q VLAN tagging properly. On cards that do not explicitly support it, VLAN tagging will still work, but the reduced MTU may cause problems. See the <?=$g['product_name']?> handbook for information on supported cards. </p> + </td> + <td class="list"> </td> + </tr> + </table> + </div> + </td> + </tr> +</table> +<?php include("fend.inc"); ?> +</body> +</html> diff --git a/usr/local/www/interfaces_mlppp_edit.php b/usr/local/www/interfaces_mlppp_edit.php new file mode 100644 index 0000000..1d958fd --- /dev/null +++ b/usr/local/www/interfaces_mlppp_edit.php @@ -0,0 +1,180 @@ +<?php +/* $Id$ */ +/* + interfaces_mlppp_edit.php + part of m0n0wall (http://m0n0.ch/wall) + + Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>. + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, + INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, + OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. +*/ +/* + pfSense_MODULE: interfaces +*/ + +##|+PRIV +##|*IDENT=page-interfaces-mlppp-edit +##|*NAME=Interfaces: mlppp: Edit page +##|*DESCR=Allow access to the 'Interfaces: mlppp: Edit' page. +##|*MATCH=interfaces_mlppp_edit.php* +##|-PRIV + +require("guiconfig.inc"); + +if (!is_array($config['mlppps']['mlppp'])) + $config['mlppps']['mlppp'] = array(); + +$a_mlppps = &$config['mlppps']['mlppp']; + +$portlist = get_interface_list(); + +$id = $_GET['id']; +if (isset($_POST['id'])) + $id = $_POST['id']; + +if (isset($id) && $a_mlppps[$id]) { + $pconfig['if'] = $a_mlppps[$id]['if']; + $pconfig['mlpppif'] = $a_mlppps[$id]['mlpppif']; + $pconfig['tag'] = $a_mlppps[$id]['tag']; + $pconfig['descr'] = $a_mlppps[$id]['descr']; +} + +if ($_POST) { + + unset($input_errors); + $pconfig = $_POST; + + /* input validation */ + $reqdfields = explode(" ", "if tag"); + $reqdfieldsn = explode(",", "Parent interface,mlppp tag"); + + do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors); + + if ($_POST['tag'] && (!is_numericint($_POST['tag']) || ($_POST['tag'] < '1') || ($_POST['tag'] > '4094'))) { + $input_errors[] = "The mlppp tag must be an integer between 1 and 4094."; + } + + foreach ($a_mlppps as $mlppp) { + if (isset($id) && ($a_mlppps[$id]) && ($a_mlppps[$id] === $mlppp)) + continue; + + if (($mlppp['if'] == $_POST['if']) && ($mlppp['tag'] == $_POST['tag'])) { + $input_errors[] = "A mlppp with the tag {$mlppp['tag']} is already defined on this interface."; + break; + } + } + if (is_array($config['qinqs']['qinqentry'])) { + foreach ($config['qinqs']['qinqentry'] as $qinq) + if ($qinq['tag'] == $_POST['tag'] && $qinq['if'] == $_POST['if']) + $input_errors[] = "A QinQ mlppp exists with this tag please remove it to use this tag with."; + } + + if (!$input_errors) { + $mlppp = array(); + $mlppp['if'] = $_POST['if']; + $mlppp['tag'] = $_POST['tag']; + $mlppp['descr'] = $_POST['descr']; + $mlppp['mlpppif'] = "{$_POST['if']}_mlppp{$_POST['tag']}"; + + $mlppp['mlpppif'] = interface_mlppp_configure($mlppp); + if ($mlppp['mlpppif'] == "" || !stristr($mlppp['mlpppif'], "mlppp")) + $input_errors[] = "Error occured creating interface, please retry."; + else { + if (isset($id) && $a_mlppps[$id]) + $a_mlppps[$id] = $mlppp; + else + $a_mlppps[] = $mlppp; + + write_config(); + + $confif = convert_real_interface_to_friendly_interface_name($mlppp['mlpppif']); + if ($confif <> "") + interface_configure($confif); + + header("Location: interfaces_mlppp.php"); + exit; + } + } +} + +$pgtitle = array("Firewall","mlppp","Edit"); +include("head.inc"); + +?> + +<body link="#0000CC" vlink="#0000CC" alink="#0000CC"> +<?php include("fbegin.inc"); ?> +<?php if ($input_errors) print_input_errors($input_errors); ?> + <form action="interfaces_mlppp_edit.php" method="post" name="iform" id="iform"> + <table width="100%" border="0" cellpadding="6" cellspacing="0"> + <tr> + <td colspan="2" valign="top" class="listtopic">mlppp configuration</td> + </tr> + <tr> + <td width="22%" valign="top" class="vncellreq">Parent interface</td> + <td width="78%" class="vtable"> + <select name="if" class="formselect"> + <?php + foreach ($portlist as $ifn => $ifinfo) + if (is_jumbo_capable($ifn)) { + echo "<option value=\"{$ifn}\""; + if ($ifn == $pconfig['if']) + echo "selected"; + echo ">"; + echo htmlspecialchars($ifn . " (" . $ifinfo['mac'] . ")"); + echo "</option>"; + } + ?> + </select> + <br/> + <span class="vexpl">Only mlppp capable interfaces will be shown.</span></td> + </tr> + <tr> + <td valign="top" class="vncellreq">mlppp tag </td> + <td class="vtable"> + <input name="tag" type="text" class="formfld unknown" id="tag" size="6" value="<?=htmlspecialchars($pconfig['tag']);?>"> + <br> + <span class="vexpl">802.1Q mlppp tag (between 1 and 4094) </span></td> + </tr> + <tr> + <td width="22%" valign="top" class="vncell">Description</td> + <td width="78%" class="vtable"> + <input name="descr" type="text" class="formfld unknown" id="descr" size="40" value="<?=htmlspecialchars($pconfig['descr']);?>"> + <br> <span class="vexpl">You may enter a description here + for your reference (not parsed).</span></td> + </tr> + <tr> + <td width="22%" valign="top"> </td> + <td width="78%"> + <input type="hidden" name="mlpppif" value="<?=$pconfig['mlpppif']; ?>"> + <input name="Submit" type="submit" class="formbtn" value="Save"> <input type="button" value="Cancel" onclick="history.back()"> + <?php if (isset($id) && $a_mlppps[$id]): ?> + <input name="id" type="hidden" value="<?=$id;?>"> + <?php endif; ?> + </td> + </tr> + </table> +</form> +<?php include("fend.inc"); ?> +</body> +</html> |