mirror of
https://github.com/pfsense/pfsense.git
synced 2025-10-26 11:38:35 +00:00
Merge pull request #671 from wrboyce/master
allow defining dhcp static mappings using dhcp-client-identifier
This commit is contained in:
commit
bc82e33190
@ -755,11 +755,14 @@ EOD;
|
||||
|
||||
$i = 0;
|
||||
foreach ($dhcpifconf['staticmap'] as $sm) {
|
||||
$dhcpdconf .= <<<EOD
|
||||
host s_{$dhcpif}_{$i} {
|
||||
hardware ethernet {$sm['mac']};
|
||||
$dhcpdconf .= "host s_{$dhcpif}_{$i} {\n";
|
||||
|
||||
if ($sm['mac'])
|
||||
$dhcpdconf .= " hardware ethernet {$sm['mac']};\n";
|
||||
|
||||
if ($sm['cid'])
|
||||
$dhcpdconf .= " option dhcp-client-identifier \"{$sm['cid']}\";\n";
|
||||
|
||||
EOD;
|
||||
if ($sm['ipaddr'])
|
||||
$dhcpdconf .= " fixed-address {$sm['ipaddr']};\n";
|
||||
|
||||
|
||||
@ -92,6 +92,7 @@ if (isset($_POST['id']))
|
||||
|
||||
if (isset($id) && $a_maps[$id]) {
|
||||
$pconfig['mac'] = $a_maps[$id]['mac'];
|
||||
$pconfig['cid'] = $a_maps[$id]['cid'];
|
||||
$pconfig['hostname'] = $a_maps[$id]['hostname'];
|
||||
$pconfig['ipaddr'] = $a_maps[$id]['ipaddr'];
|
||||
$pconfig['filename'] = $a_maps[$id]['filename'];
|
||||
@ -111,6 +112,7 @@ if (isset($id) && $a_maps[$id]) {
|
||||
$pconfig['tftp'] = $a_maps[$id]['tftp'];
|
||||
} else {
|
||||
$pconfig['mac'] = $_GET['mac'];
|
||||
$pconfig['cid'] = $_GET['cid'];
|
||||
$pconfig['hostname'] = $_GET['hostname'];
|
||||
$pconfig['filename'] = $_GET['filename'];
|
||||
$pconfig['rootpath'] = $_GET['rootpath'];
|
||||
@ -138,11 +140,15 @@ if ($_POST) {
|
||||
$pconfig = $_POST;
|
||||
|
||||
/* input validation */
|
||||
$reqdfields = explode(" ", "mac");
|
||||
$reqdfieldsn = array(gettext("MAC address"));
|
||||
$reqdfields = array();
|
||||
$reqdfieldsn = array();
|
||||
|
||||
do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
|
||||
|
||||
/* either MAC or Client-ID must be specified */
|
||||
if (empty($_POST['mac']) && empty($_POST['cid']))
|
||||
$input_errors[] = gettext("Either MAC address or Client identifier must be specified");
|
||||
|
||||
/* normalize MAC addresses - lowercase and convert Windows-ized hyphenated MACs to colon delimited */
|
||||
$_POST['mac'] = strtolower(str_replace("-", ":", $_POST['mac']));
|
||||
|
||||
@ -173,8 +179,8 @@ if ($_POST) {
|
||||
if (isset($id) && ($a_maps[$id]) && ($a_maps[$id] === $mapent))
|
||||
continue;
|
||||
|
||||
if ((($mapent['hostname'] == $_POST['hostname']) && $mapent['hostname']) || ($mapent['mac'] == $_POST['mac'])) {
|
||||
$input_errors[] = gettext("This Hostname, IP or MAC address already exists.");
|
||||
if ((($mapent['hostname'] == $_POST['hostname']) && $mapent['hostname']) || (($mapent['mac'] == $_POST['mac']) && $mapent['mac']) || (($mapent['cid'] == $_POST['cid']) && $mapent['cid'])) {
|
||||
$input_errors[] = gettext("This Hostname, IP, MAC address or Client identifier already exists.");
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -243,6 +249,7 @@ if ($_POST) {
|
||||
if (!$input_errors) {
|
||||
$mapent = array();
|
||||
$mapent['mac'] = $_POST['mac'];
|
||||
$mapent['cid'] = $_POST['cid'];
|
||||
$mapent['ipaddr'] = $_POST['ipaddr'];
|
||||
$mapent['hostname'] = $_POST['hostname'];
|
||||
$mapent['descr'] = $_POST['descr'];
|
||||
@ -334,7 +341,7 @@ include("head.inc");
|
||||
<td colspan="2" valign="top" class="listtopic"><?=gettext("Static DHCP Mapping");?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td width="22%" valign="top" class="vncellreq"><?=gettext("MAC address");?></td>
|
||||
<td width="22%" valign="top" class="vncell"><?=gettext("MAC address");?></td>
|
||||
<td width="78%" class="vtable">
|
||||
<input name="mac" type="text" class="formfld unknown" id="mac" size="30" value="<?=htmlspecialchars($pconfig['mac']);?>">
|
||||
<?php
|
||||
@ -346,6 +353,11 @@ include("head.inc");
|
||||
<br>
|
||||
<span class="vexpl"><?=gettext("Enter a MAC address in the following format: ".
|
||||
"xx:xx:xx:xx:xx:xx");?></span></td>
|
||||
</tr>
|
||||
<td width="22%" valign="top" class="vncell"><?=gettext("Client identifier");?></td>
|
||||
<td width="78%" class="vtable">
|
||||
<input name="cid" type="text" class="formfld unknown" id="cid" size="30" value="<?=htmlspecialchars($pconfig['cid']);?>">
|
||||
<span class="vexpl"><?=gettext("");?></span></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td width="22%" valign="top" class="vncell"><?=gettext("IP address");?></td>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user