1 |
1eca1a2f
|
Seth Mos
|
<?php
|
2 |
|
|
/*
|
3 |
|
|
services_dhcpv6_relay.php
|
4 |
|
|
|
5 |
|
|
Copyright (C) 2003-2004 Justin Ellison <justin@techadvise.com>.
|
6 |
1d7ba683
|
ayvis
|
Copyright (C) 2010 Ermal Luçi
|
7 |
1eca1a2f
|
Seth Mos
|
Copyright (C) 2010 Seth Mos
|
8 |
ce77a9c4
|
Phil Davis
|
Copyright (C) 2013-2015 Electric Sheep Fencing, LP
|
9 |
1eca1a2f
|
Seth Mos
|
All rights reserved.
|
10 |
|
|
|
11 |
|
|
Redistribution and use in source and binary forms, with or without
|
12 |
|
|
modification, are permitted provided that the following conditions are met:
|
13 |
|
|
|
14 |
|
|
1. Redistributions of source code must retain the above copyright notice,
|
15 |
|
|
this list of conditions and the following disclaimer.
|
16 |
|
|
|
17 |
|
|
2. Redistributions in binary form must reproduce the above copyright
|
18 |
|
|
notice, this list of conditions and the following disclaimer in the
|
19 |
|
|
documentation and/or other materials provided with the distribution.
|
20 |
|
|
|
21 |
|
|
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
22 |
|
|
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
23 |
|
|
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
24 |
|
|
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
25 |
|
|
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
26 |
|
|
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
27 |
|
|
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
28 |
|
|
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
29 |
|
|
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
30 |
|
|
POSSIBILITY OF SUCH DAMAGE.
|
31 |
|
|
*/
|
32 |
|
|
/*
|
33 |
|
|
pfSense_MODULE: dhcpv6relay
|
34 |
|
|
*/
|
35 |
|
|
|
36 |
|
|
##|+PRIV
|
37 |
|
|
##|*IDENT=page-services-dhcpv6relay
|
38 |
|
|
##|*NAME=Services: DHCPv6 Relay page
|
39 |
|
|
##|*DESCR=Allow access to the 'Services: DHCPv6 Relay' page.
|
40 |
|
|
##|*MATCH=services_dhcpv6_relay.php*
|
41 |
|
|
##|-PRIV
|
42 |
|
|
|
43 |
|
|
require("guiconfig.inc");
|
44 |
|
|
|
45 |
|
|
$pconfig['enable'] = isset($config['dhcrelay6']['enable']);
|
46 |
|
|
if (empty($config['dhcrelay6']['interface']))
|
47 |
|
|
$pconfig['interface'] = array();
|
48 |
|
|
else
|
49 |
|
|
$pconfig['interface'] = explode(",", $config['dhcrelay6']['interface']);
|
50 |
|
|
$pconfig['server'] = $config['dhcrelay6']['server'];
|
51 |
|
|
$pconfig['agentoption'] = isset($config['dhcrelay6']['agentoption']);
|
52 |
|
|
|
53 |
|
|
$iflist = get_configured_interface_with_descr();
|
54 |
|
|
|
55 |
|
|
/* set the enabled flag which will tell us if DHCP server is enabled
|
56 |
|
|
* on any interface. We will use this to disable dhcp-relay since
|
57 |
|
|
* the two are not compatible with each other.
|
58 |
|
|
*/
|
59 |
|
|
$dhcpd_enabled = false;
|
60 |
|
|
if (is_array($config['dhcpdv6'])) {
|
61 |
e94692c0
|
Renato Botelho
|
foreach($config['dhcpdv6'] as $dhcp) {
|
62 |
|
|
if (isset($dhcp['enable']) && isset($config['interfaces'][$dhcpif]['enable'])) {
|
63 |
1eca1a2f
|
Seth Mos
|
$dhcpd_enabled = true;
|
64 |
e94692c0
|
Renato Botelho
|
break;
|
65 |
|
|
}
|
66 |
|
|
}
|
67 |
1eca1a2f
|
Seth Mos
|
}
|
68 |
|
|
|
69 |
|
|
if ($_POST) {
|
70 |
|
|
|
71 |
|
|
unset($input_errors);
|
72 |
|
|
$pconfig = $_POST;
|
73 |
|
|
|
74 |
|
|
/* input validation */
|
75 |
|
|
if ($_POST['enable']) {
|
76 |
|
|
$reqdfields = explode(" ", "server interface");
|
77 |
|
|
$reqdfieldsn = array(gettext("Destination Server"), gettext("Interface"));
|
78 |
|
|
|
79 |
1e9b4611
|
Renato Botelho
|
do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors);
|
80 |
1eca1a2f
|
Seth Mos
|
|
81 |
|
|
if ($_POST['server']) {
|
82 |
|
|
$checksrv = explode(",", $_POST['server']);
|
83 |
|
|
foreach ($checksrv as $srv) {
|
84 |
|
|
if (!is_ipaddrv6($srv))
|
85 |
|
|
$input_errors[] = gettext("A valid Destination Server IPv6 address must be specified.");
|
86 |
|
|
}
|
87 |
|
|
}
|
88 |
|
|
}
|
89 |
|
|
|
90 |
|
|
if (!$input_errors) {
|
91 |
73c897eb
|
Michael Tharp
|
$config['dhcrelay6']['enable'] = $_POST['enable'] ? true : false;
|
92 |
|
|
$config['dhcrelay6']['interface'] = implode(",", $_POST['interface']);
|
93 |
|
|
$config['dhcrelay6']['agentoption'] = $_POST['agentoption'] ? true : false;
|
94 |
|
|
$config['dhcrelay6']['server'] = $_POST['server'];
|
95 |
1eca1a2f
|
Seth Mos
|
|
96 |
|
|
write_config();
|
97 |
|
|
|
98 |
|
|
$retval = 0;
|
99 |
|
|
$retval = services_dhcrelay6_configure();
|
100 |
|
|
$savemsg = get_std_save_message($retval);
|
101 |
|
|
|
102 |
|
|
}
|
103 |
|
|
}
|
104 |
|
|
|
105 |
3565970f
|
Colin Fleming
|
$closehead = false;
|
106 |
1eca1a2f
|
Seth Mos
|
$pgtitle = array(gettext("Services"),gettext("DHCPv6 Relay"));
|
107 |
b32dd0a6
|
jim-p
|
$shortcut_section = "dhcp6";
|
108 |
1eca1a2f
|
Seth Mos
|
include("head.inc");
|
109 |
|
|
|
110 |
|
|
?>
|
111 |
|
|
|
112 |
91f026b0
|
ayvis
|
<script type="text/javascript">
|
113 |
3565970f
|
Colin Fleming
|
//<![CDATA[
|
114 |
1eca1a2f
|
Seth Mos
|
function enable_change(enable_over) {
|
115 |
|
|
if (document.iform.enable.checked || enable_over) {
|
116 |
|
|
document.iform.server.disabled = 0;
|
117 |
|
|
document.iform.interface.disabled = 0;
|
118 |
|
|
document.iform.agentoption.disabled = 0;
|
119 |
|
|
} else {
|
120 |
|
|
document.iform.server.disabled = 1;
|
121 |
|
|
document.iform.interface.disabled = 1;
|
122 |
|
|
document.iform.agentoption.disabled = 1;
|
123 |
|
|
}
|
124 |
|
|
}
|
125 |
3565970f
|
Colin Fleming
|
//]]>
|
126 |
1eca1a2f
|
Seth Mos
|
</script>
|
127 |
3565970f
|
Colin Fleming
|
</head>
|
128 |
1eca1a2f
|
Seth Mos
|
|
129 |
|
|
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
|
130 |
|
|
<?php include("fbegin.inc"); ?>
|
131 |
|
|
<form action="services_dhcpv6_relay.php" method="post" name="iform" id="iform">
|
132 |
|
|
<?php if ($input_errors) print_input_errors($input_errors); ?>
|
133 |
|
|
<?php if ($savemsg) print_info_box($savemsg); ?>
|
134 |
|
|
|
135 |
3565970f
|
Colin Fleming
|
<table width="100%" border="0" cellpadding="0" cellspacing="0" summary="dhcpv6 relay">
|
136 |
1eca1a2f
|
Seth Mos
|
<tr>
|
137 |
|
|
<td>
|
138 |
|
|
<div id="mainarea">
|
139 |
3565970f
|
Colin Fleming
|
<table class="tabcont" width="100%" border="0" cellpadding="6" cellspacing="0" summary="main area">
|
140 |
1eca1a2f
|
Seth Mos
|
<tr>
|
141 |
|
|
<?php
|
142 |
|
|
if ($dhcpd_enabled) {
|
143 |
|
|
echo "<td>DHCPv6 Server is currently enabled. Cannot enable the DHCPv6 Relay service while the DHCPv6 Server is enabled on any interface.";
|
144 |
905bafa1
|
Colin Fleming
|
echo "</td></tr></table></div></td></tr></table></form>";
|
145 |
1eca1a2f
|
Seth Mos
|
include("fend.inc");
|
146 |
905bafa1
|
Colin Fleming
|
echo "</body></html>";
|
147 |
1eca1a2f
|
Seth Mos
|
exit;
|
148 |
|
|
}
|
149 |
|
|
?>
|
150 |
|
|
|
151 |
|
|
<td colspan="2" valign="top" class="listtopic"><?=gettext("DHCPv6 Relay configuration"); ?></td>
|
152 |
|
|
</tr>
|
153 |
|
|
<tr>
|
154 |
|
|
<td width="22%" valign="top" class="vncellreq">Enable</td>
|
155 |
|
|
<td width="78%" class="vtable">
|
156 |
3565970f
|
Colin Fleming
|
<input name="enable" type="checkbox" value="yes" <?php if ($pconfig['enable']) echo "checked=\"checked\""; ?> onclick="enable_change(false)" />
|
157 |
1eca1a2f
|
Seth Mos
|
<strong><?php printf(gettext("Enable DHCPv6 relay on interface"));?></strong>
|
158 |
|
|
</td>
|
159 |
|
|
</tr>
|
160 |
|
|
<tr>
|
161 |
|
|
<td width="22%" valign="top" class="vncellreq">Interface(s)</td>
|
162 |
|
|
<td width="78%" class="vtable">
|
163 |
3565970f
|
Colin Fleming
|
<select id="interface" name="interface[]" multiple="multiple" class="formselect" size="3">
|
164 |
1eca1a2f
|
Seth Mos
|
<?php
|
165 |
|
|
foreach ($iflist as $ifent => $ifdesc) {
|
166 |
|
|
if (!is_ipaddrv6(get_interface_ipv6($ifent)))
|
167 |
|
|
continue;
|
168 |
3565970f
|
Colin Fleming
|
echo "<option value=\"{$ifent}\"";
|
169 |
1eca1a2f
|
Seth Mos
|
if (in_array($ifent, $pconfig['interface']))
|
170 |
3565970f
|
Colin Fleming
|
echo " selected=\"selected\"";
|
171 |
1eca1a2f
|
Seth Mos
|
echo ">{$ifdesc}</option>\n";
|
172 |
|
|
}
|
173 |
|
|
?>
|
174 |
|
|
</select>
|
175 |
|
|
<br /><?=gettext("Interfaces without an IPv6 address will not be shown."); ?>
|
176 |
|
|
</td>
|
177 |
|
|
</tr>
|
178 |
|
|
<tr>
|
179 |
|
|
<td width="22%" valign="top" class="vtable"> </td>
|
180 |
|
|
<td width="78%" class="vtable">
|
181 |
3565970f
|
Colin Fleming
|
<input name="agentoption" type="checkbox" value="yes" <?php if ($pconfig['agentoption']) echo "checked=\"checked\""; ?> />
|
182 |
1d7ba683
|
ayvis
|
<strong><?=gettext("Append circuit ID and agent ID to requests"); ?></strong><br />
|
183 |
1eca1a2f
|
Seth Mos
|
<?php printf(gettext("If this is checked, the DHCPv6 relay will append the circuit ID (%s interface number) and the agent ID to the DHCPv6 request."), $g['product_name']); ?></td>
|
184 |
|
|
</tr>
|
185 |
|
|
<tr>
|
186 |
|
|
<td width="22%" valign="top" class="vncell"><?=gettext("Destination server");?></td>
|
187 |
|
|
<td width="78%" class="vtable">
|
188 |
3565970f
|
Colin Fleming
|
<input name="server" type="text" class="formfld unknown" id="server" size="20" value="<?=htmlspecialchars($pconfig['server']);?>" />
|
189 |
1d7ba683
|
ayvis
|
<br />
|
190 |
afde5956
|
Chris Buechler
|
<?=gettext("This is the IPv6 address of the server to which DHCPv6 requests are relayed. You can enter multiple server IPv6 addresses, separated by commas. ");?>
|
191 |
1eca1a2f
|
Seth Mos
|
</td>
|
192 |
|
|
</tr>
|
193 |
|
|
<tr>
|
194 |
|
|
<td width="22%" valign="top"> </td>
|
195 |
|
|
<td width="78%">
|
196 |
3565970f
|
Colin Fleming
|
<input name="Submit" type="submit" class="formbtn" value="<?=gettext("Save");?>" onclick="enable_change(true)" />
|
197 |
1eca1a2f
|
Seth Mos
|
</td>
|
198 |
|
|
</tr>
|
199 |
|
|
</table>
|
200 |
|
|
</div>
|
201 |
|
|
</td>
|
202 |
|
|
</tr>
|
203 |
|
|
</table>
|
204 |
|
|
</form>
|
205 |
91f026b0
|
ayvis
|
<script type="text/javascript">
|
206 |
3565970f
|
Colin Fleming
|
//<![CDATA[
|
207 |
1eca1a2f
|
Seth Mos
|
enable_change(false);
|
208 |
3565970f
|
Colin Fleming
|
//]]>
|
209 |
1eca1a2f
|
Seth Mos
|
</script>
|
210 |
|
|
<?php include("fend.inc"); ?>
|
211 |
|
|
</body>
|
212 |
|
|
</html>
|