summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSeth Mos <seth.mos@xs4all.nl>2007-05-08 14:47:07 +0000
committerSeth Mos <seth.mos@xs4all.nl>2007-05-08 14:47:07 +0000
commitad1719997b25299696078eb7c2d8329d8bc8f84d (patch)
treee2c9b54b50040dbdb787f3b1e6a9ceb43d35379c
parent232d6540f9ceaf0c67b2ec500d15223eb63fc7f1 (diff)
downloadpfsense-ad1719997b25299696078eb7c2d8329d8bc8f84d.zip
pfsense-ad1719997b25299696078eb7c2d8329d8bc8f84d.tar.gz
Add NTP server field to dhcp config.
From: Alexander Schaber
-rw-r--r--cf/conf/config.xml1
-rw-r--r--conf.default/config.xml1
-rw-r--r--etc/inc/services.inc3
-rw-r--r--etc/inc/xmlparse.inc4
-rwxr-xr-xusr/local/www/services_dhcp.php31
5 files changed, 38 insertions, 2 deletions
diff --git a/cf/conf/config.xml b/cf/conf/config.xml
index f9782b7..a57dc18 100644
--- a/cf/conf/config.xml
+++ b/cf/conf/config.xml
@@ -163,6 +163,7 @@
<gateway>xxx.xxx.xxx.xxx</gateway>
<domain></domain>
<dnsserver></dnsserver>
+ <ntpserver>xxx.xxx.xxx.xxx</ntpserver>
<next-server></next-server>
<filename></filename>
-->
diff --git a/conf.default/config.xml b/conf.default/config.xml
index c8bdcbd..97442a4 100644
--- a/conf.default/config.xml
+++ b/conf.default/config.xml
@@ -162,6 +162,7 @@
<gateway>xxx.xxx.xxx.xxx</gateway>
<domain></domain>
<dnsserver></dnsserver>
+ <ntpserver>xxx.xxx.xxx.xxx</ntpserver>
<next-server></next-server>
<filename></filename>
-->
diff --git a/etc/inc/services.inc b/etc/inc/services.inc
index 341f00f..a95e22a 100644
--- a/etc/inc/services.inc
+++ b/etc/inc/services.inc
@@ -264,6 +264,9 @@ EOD;
$dhcpdconf .= " option netbios-node-type 8;\n";
}
+ if (is_array($dhcpifconf['ntpserver']) && $dhcpifconf['ntpserver'][0])
+ $dhcpdconf .= " option ntp-servers " . join(",", $dhcpifconf['ntpserver']) . ";\n";
+
if(isset($dhcpifconf['netboot'])) {
if (($dhcpifconf['next-server'] <> "") && ($dhcpifconf['filename'] <> "")) {
$dhcpdconf .= " next-server {$dhcpifconf['next-server']};\n";
diff --git a/etc/inc/xmlparse.inc b/etc/inc/xmlparse.inc
index b6bb16a..9abda50 100644
--- a/etc/inc/xmlparse.inc
+++ b/etc/inc/xmlparse.inc
@@ -36,7 +36,7 @@ function listtags() {
"earlyshellcmd encryption-algorithm-option field fieldname hash-algorithm-option " .
"hosts group interface_array item key lbpool menu mobilekey mount onetoone option package passthrumac priv proxyarpnet " .
"queue pages pipe route row rule schedule service servernat servers earlyshellcmd shellcmd staticmap subqueue " .
- "timerange tunnel user vip virtual_server vlan winsserver wolentry widget depends_on_package");
+ "timerange tunnel user vip virtual_server vlan winsserver ntpserver wolentry widget depends_on_package");
return $ret;
}
@@ -259,4 +259,4 @@ function dump_xml_config_raw($arr, $rootobj) {
return $xmlconfig;
}
-?> \ No newline at end of file
+?>
diff --git a/usr/local/www/services_dhcp.php b/usr/local/www/services_dhcp.php
index 583cf2e..273876b 100755
--- a/usr/local/www/services_dhcp.php
+++ b/usr/local/www/services_dhcp.php
@@ -72,6 +72,7 @@ $pconfig['denyunknown'] = isset($config['dhcpd'][$if]['denyunknown']);
$pconfig['staticarp'] = isset($config['dhcpd'][$if]['staticarp']);
$pconfig['ddnsdomain'] = $config['dhcpd'][$if]['ddnsdomain'];
$pconfig['ddnsupdate'] = isset($config['dhcpd'][$if]['ddnsupdate']);
+list($pconfig['ntp1'],$pconfig['ntp2']) = $config['dhcpd'][$if]['ntpserver'];
$pconfig['netboot'] = isset($config['dhcpd'][$if]['netboot']);
$pconfig['nextserver'] = $config['dhcpd'][$if]['next-server'];
$pconfig['filename'] = $config['dhcpd'][$if]['filename'];
@@ -137,6 +138,9 @@ if ($_POST) {
if (($_POST['ddnsdomain'] && !is_domain($_POST['ddnsdomain']))) {
$input_errors[] = "A valid domain name must be specified for the dynamic DNS registration.";
}
+ if (($_POST['ntp1'] && !is_ipaddr($_POST['ntp1'])) || ($_POST['ntp2'] && !is_ipaddr($_POST['ntp2']))) {
+ $input_errors[] = "A valid IP address must be specified for the primary/secondary NTP servers.";
+ }
if (($_POST['nextserver'] && !is_ipaddr($_POST['nextserver']))) {
$input_errors[] = "A valid IP address must be specified for the network boot server.";
}
@@ -191,6 +195,13 @@ if ($_POST) {
$config['dhcpd'][$if]['staticarp'] = ($_POST['staticarp']) ? true : false;
$config['dhcpd'][$if]['ddnsdomain'] = $_POST['ddnsdomain'];
$config['dhcpd'][$if]['ddnsupdate'] = ($_POST['ddnsupdate']) ? true : false;
+
+ unset($config['dhcpd'][$if]['ntpserver']);
+ if ($_POST['ntp1'])
+ $config['dhcpd'][$if]['ntpserver'][] = $_POST['ntp1'];
+ if ($_POST['ntp2'])
+ $config['dhcpd'][$if]['ntpserver'][] = $_POST['ntp2'];
+
$config['dhcpd'][$if]['netboot'] = ($_POST['netboot']) ? true : false;
$config['dhcpd'][$if]['next-server'] = $_POST['nextserver'];
$config['dhcpd'][$if]['filename'] = $_POST['filename'];
@@ -265,6 +276,8 @@ function enable_change(enable_over) {
document.iform.staticarp.disabled = endis;
document.iform.ddnsdomain.disabled = endis;
document.iform.ddnsupdate.disabled = endis;
+ document.iform.ntp1.disabled = endis;
+ document.iform.ntp2.disabled = endis;
document.iform.netboot.disabled = endis;
document.iform.nextserver.disabled = endis;
document.iform.filename.disabled = endis;
@@ -277,6 +290,12 @@ function show_ddns_config() {
aodiv.style.display = "block";
}
+function show_ntp_config() {
+ document.getElementById("showntpbox").innerHTML='';
+ aodiv = document.getElementById('showntp');
+ aodiv.style.display = "block";
+}
+
function show_netboot_config() {
document.getElementById("shownetbootbox").innerHTML='';
aodiv = document.getElementById('shownetboot');
@@ -468,6 +487,18 @@ function show_netboot_config() {
</td>
</tr>
<tr>
+ <td width="22%" valign="top" class="vncell">NTP servers</td>
+ <td width="78%" class="vtable">
+ <div id="showntpbox">
+ <input type="button" onClick="show_ntp_config()" value="Advanced"></input> - Show NTP configuration</a>
+ </div>
+ <div id="showntp" style="display:none">
+ <input name="ntp1" type="text" class="formfld" id="ntp1" size="20" value="<?=htmlspecialchars($pconfig['ntp1']);?>"><br>
+ <input name="ntp2" type="text" class="formfld" id="ntp2" size="20" value="<?=htmlspecialchars($pconfig['ntp2']);?>">
+ </div>
+ </td>
+ </tr>
+ <tr>
<td width="22%" valign="top" class="vncell">Enable Network booting</td>
<td width="78%" class="vtable">
<div id="shownetbootbox">
OpenPOWER on IntegriCloud