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