Project

General

Profile

Download (25.9 KB) Statistics
| Branch: | Tag: | Revision:
1 b75d7fd5 Renato Botelho
<?php
2 b46bfcf5 Bill Marquette
/* $Id$ */
3 5b237745 Scott Ullrich
/*
4
	services_dhcp_edit.php
5
	part of m0n0wall (http://m0n0.ch/wall)
6 b75d7fd5 Renato Botelho
7 5b237745 Scott Ullrich
	Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>.
8
	All rights reserved.
9 b75d7fd5 Renato Botelho
10 5b237745 Scott Ullrich
	Redistribution and use in source and binary forms, with or without
11
	modification, are permitted provided that the following conditions are met:
12 b75d7fd5 Renato Botelho
13 5b237745 Scott Ullrich
	1. Redistributions of source code must retain the above copyright notice,
14
	   this list of conditions and the following disclaimer.
15 b75d7fd5 Renato Botelho
16 5b237745 Scott Ullrich
	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 b75d7fd5 Renato Botelho
20 5b237745 Scott Ullrich
	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 1d333258 Scott Ullrich
/*
32
	pfSense_BUILDER_BINARIES:	/usr/sbin/arp
33
	pfSense_MODULE:	dhcpserver
34
*/
35 5b237745 Scott Ullrich
36 6b07c15a Matthew Grooms
##|+PRIV
37
##|*IDENT=page-services-dhcpserver-editstaticmapping
38
##|*NAME=Services: DHCP Server : Edit static mapping page
39
##|*DESCR=Allow access to the 'Services: DHCP Server : Edit static mapping' page.
40
##|*MATCH=services_dhcp_edit.php*
41
##|-PRIV
42
43 f28a9efd jim-p
function staticmapcmp($a, $b) {
44 b75d7fd5 Renato Botelho
	return ipcmp($a['ipaddr'], $b['ipaddr']);
45 f28a9efd jim-p
}
46
47 0d64af59 Ermal Lu?i
function staticmaps_sort($ifgui) {
48 b75d7fd5 Renato Botelho
	global $g, $config;
49 0d64af59 Ermal Lu?i
50 b75d7fd5 Renato Botelho
	usort($config['dhcpd'][$ifgui]['staticmap'], "staticmapcmp");
51 0d64af59 Ermal Lu?i
}
52
53 4b559908 Ermal Luçi
require_once('globals.inc');
54
55 2ee0410f Scott Ullrich
if(!$g['services_dhcp_server_enable']) {
56 6f3d2063 Renato Botelho
	header("Location: /");
57 2ee0410f Scott Ullrich
	exit;
58
}
59 6b07c15a Matthew Grooms
60 5b237745 Scott Ullrich
require("guiconfig.inc");
61
62 62424bdb Renato Botelho
$referer = (isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '/services_dhcp.php');
63
64 5b237745 Scott Ullrich
$if = $_GET['if'];
65
if ($_POST['if'])
66
	$if = $_POST['if'];
67 b75d7fd5 Renato Botelho
68 5b237745 Scott Ullrich
if (!$if) {
69
	header("Location: services_dhcp.php");
70
	exit;
71
}
72
73 5b668994 Erik Fonnesbeck
if (!is_array($config['dhcpd']))
74
	$config['dhcpd'] = array();
75
if (!is_array($config['dhcpd'][$if]))
76
	$config['dhcpd'][$if] = array();
77
if (!is_array($config['dhcpd'][$if]['staticmap']))
78 5b237745 Scott Ullrich
	$config['dhcpd'][$if]['staticmap'] = array();
79 0baa37c5 Scott Ullrich
80 f657f5e1 Renato Botelho
if (!is_array($config['dhcpd'][$if]['pool']))
81
	$config['dhcpd'][$if]['pool'] = array();
82
$a_pools = &$config['dhcpd'][$if]['pool'];
83
84 01292dc2 jim-p
$static_arp_enabled=isset($config['dhcpd'][$if]['staticarp']);
85 d6d50244 Ermal
$netboot_enabled=isset($config['dhcpd'][$if]['netboot']);
86 5b237745 Scott Ullrich
$a_maps = &$config['dhcpd'][$if]['staticmap'];
87 a55e9c70 Ermal Lu?i
$ifcfgip = get_interface_ip($if);
88
$ifcfgsn = get_interface_subnet($if);
89
$ifcfgdescr = convert_friendly_interface_to_friendly_descr($if);
90 5b237745 Scott Ullrich
91 e41ec584 Renato Botelho
if (is_numericint($_GET['id']))
92
	$id = $_GET['id'];
93
if (isset($_POST['id']) && is_numericint($_POST['id']))
94 5b237745 Scott Ullrich
	$id = $_POST['id'];
95
96
if (isset($id) && $a_maps[$id]) {
97 b75d7fd5 Renato Botelho
	$pconfig['mac'] = $a_maps[$id]['mac'];
98 449f1dd2 Will Boyce
	$pconfig['cid'] = $a_maps[$id]['cid'];
99 b75d7fd5 Renato Botelho
	$pconfig['hostname'] = $a_maps[$id]['hostname'];
100
	$pconfig['ipaddr'] = $a_maps[$id]['ipaddr'];
101
	$pconfig['filename'] = $a_maps[$id]['filename'];
102
	$pconfig['rootpath'] = $a_maps[$id]['rootpath'];
103
	$pconfig['descr'] = $a_maps[$id]['descr'];
104
	$pconfig['arp_table_static_entry'] = isset($a_maps[$id]['arp_table_static_entry']);
105 7309ff39 Renato Botelho
	$pconfig['deftime'] = $a_maps[$id]['defaultleasetime'];
106
	$pconfig['maxtime'] = $a_maps[$id]['maxleasetime'];
107
	$pconfig['gateway'] = $a_maps[$id]['gateway'];
108
	$pconfig['domain'] = $a_maps[$id]['domain'];
109
	$pconfig['domainsearchlist'] = $a_maps[$id]['domainsearchlist'];
110
	list($pconfig['wins1'],$pconfig['wins2']) = $a_maps[$id]['winsserver'];
111 81af6a08 Phil Davis
	list($pconfig['dns1'],$pconfig['dns2'],$pconfig['dns3'],$pconfig['dns4']) = $a_maps[$id]['dnsserver'];
112 7309ff39 Renato Botelho
	$pconfig['ddnsdomain'] = $a_maps[$id]['ddnsdomain'];
113 87019fc4 Andres Petralli
	$pconfig['ddnsdomainprimary'] = $a_maps[$id]['ddnsdomainprimary'];
114
	$pconfig['ddnsdomainkeyname'] = $a_maps[$id]['ddnsdomainkeyname'];
115
	$pconfig['ddnsdomainkey'] = $a_maps[$id]['ddnsdomainkey'];
116 7309ff39 Renato Botelho
	$pconfig['ddnsupdate'] = isset($a_maps[$id]['ddnsupdate']);
117
	list($pconfig['ntp1'],$pconfig['ntp2']) = $a_maps[$id]['ntpserver'];
118
	$pconfig['tftp'] = $a_maps[$id]['tftp'];
119 3a32590b Scott Ullrich
} else {
120 b75d7fd5 Renato Botelho
	$pconfig['mac'] = $_GET['mac'];
121 449f1dd2 Will Boyce
	$pconfig['cid'] = $_GET['cid'];
122 b75d7fd5 Renato Botelho
	$pconfig['hostname'] = $_GET['hostname'];
123
	$pconfig['filename'] = $_GET['filename'];
124
	$pconfig['rootpath'] = $_GET['rootpath'];
125
	$pconfig['descr'] = $_GET['descr'];
126
	$pconfig['arp_table_static_entry'] = $_GET['arp_table_static_entry'];
127 7309ff39 Renato Botelho
	$pconfig['deftime'] = $_GET['defaultleasetime'];
128
	$pconfig['maxtime'] = $_GET['maxleasetime'];
129
	$pconfig['gateway'] = $_GET['gateway'];
130
	$pconfig['domain'] = $_GET['domain'];
131
	$pconfig['domainsearchlist'] = $_GET['domainsearchlist'];
132
	$pconfig['wins1'] = $_GET['wins1'];
133
	$pconfig['wins2'] = $_GET['wins2'];
134
	$pconfig['dns1'] = $_GET['dns1'];
135
	$pconfig['dns2'] = $_GET['dns2'];
136 81af6a08 Phil Davis
	$pconfig['dns3'] = $_GET['dns3'];
137
	$pconfig['dns4'] = $_GET['dns4'];
138 7309ff39 Renato Botelho
	$pconfig['ddnsdomain'] = $_GET['ddnsdomain'];
139 87019fc4 Andres Petralli
	$pconfig['ddnsdomainprimary'] = $_GET['ddnsdomainprimary'];
140
	$pconfig['ddnsdomainkeyname'] = $_GET['ddnsdomainkeyname'];
141
	$pconfig['ddnsdomainkey'] = $_GET['ddnsdomainkey'];
142 7309ff39 Renato Botelho
	$pconfig['ddnsupdate'] = isset($_GET['ddnsupdate']);
143
	$pconfig['ntp1'] = $_GET['ntp1'];
144
	$pconfig['ntp2'] = $_GET['ntp2'];
145
	$pconfig['tftp'] = $_GET['tftp'];
146 5b237745 Scott Ullrich
}
147
148
if ($_POST) {
149
150
	unset($input_errors);
151
	$pconfig = $_POST;
152
153
	/* input validation */
154 449f1dd2 Will Boyce
	$reqdfields = array();
155
	$reqdfieldsn = array();
156 b75d7fd5 Renato Botelho
157 1e9b4611 Renato Botelho
	do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors);
158 4f3401e0 Bill Marquette
159 84a27e31 Will Boyce
    /* either MAC or Client-ID must be specified */
160
    if (empty($_POST['mac']) && empty($_POST['cid']))
161
        $input_errors[] = gettext("Either MAC address or Client identifier must be specified");
162
163 4f3401e0 Bill Marquette
	/* normalize MAC addresses - lowercase and convert Windows-ized hyphenated MACs to colon delimited */
164
	$_POST['mac'] = strtolower(str_replace("-", ":", $_POST['mac']));
165 b75d7fd5 Renato Botelho
166 46c5b763 pierrepomes
	if ($_POST['hostname']) {
167 392687e5 Erik Fonnesbeck
		preg_match("/\-\$/", $_POST['hostname'], $matches);
168 d0ce82a3 Scott Ullrich
		if($matches)
169 b75d7fd5 Renato Botelho
			$input_errors[] = gettext("The hostname cannot end with a hyphen according to RFC952");
170 46c5b763 pierrepomes
		if (!is_hostname($_POST['hostname'])) {
171 8ffadf76 Rafael Lucas
			$input_errors[] = gettext("The hostname can only contain the characters A-Z, 0-9 and '-'.");
172 46c5b763 pierrepomes
		} else {
173
			if (strpos($_POST['hostname'],'.')) {
174 8ffadf76 Rafael Lucas
				$input_errors[] = gettext("A valid hostname is specified, but the domain name part should be omitted");
175 46c5b763 pierrepomes
			}
176
		}
177 6a01ea44 Bill Marquette
	}
178 5b237745 Scott Ullrich
	if (($_POST['ipaddr'] && !is_ipaddr($_POST['ipaddr']))) {
179 8ffadf76 Rafael Lucas
		$input_errors[] = gettext("A valid IP address must be specified.");
180 5b237745 Scott Ullrich
	}
181
	if (($_POST['mac'] && !is_macaddr($_POST['mac']))) {
182 8ffadf76 Rafael Lucas
		$input_errors[] = gettext("A valid MAC address must be specified.");
183 5b237745 Scott Ullrich
	}
184 01292dc2 jim-p
	if($static_arp_enabled && !$_POST['ipaddr']) {
185 f16ba51e Renato Botelho
		$input_errors[] = gettext("Static ARP is enabled.  You must specify an IP address.");
186 0baa37c5 Scott Ullrich
	}
187 b75d7fd5 Renato Botelho
188 5b237745 Scott Ullrich
	/* check for overlaps */
189
	foreach ($a_maps as $mapent) {
190
		if (isset($id) && ($a_maps[$id]) && ($a_maps[$id] === $mapent))
191
			continue;
192
193 ce13cc5f Individual IT Services
		if ((($mapent['hostname'] == $_POST['hostname']) && $mapent['hostname'])  || (($mapent['mac'] == $_POST['mac']) && $mapent['mac']) || (($mapent['ipaddr'] == $_POST['ipaddr']) && $mapent['ipaddr'] ) || (($mapent['cid'] == $_POST['cid']) && $mapent['cid'])) {
194 84a27e31 Will Boyce
			$input_errors[] = gettext("This Hostname, IP, MAC address or Client identifier already exists.");
195 5b237745 Scott Ullrich
			break;
196
		}
197
	}
198 b75d7fd5 Renato Botelho
199 5b237745 Scott Ullrich
	/* make sure it's not within the dynamic subnet */
200
	if ($_POST['ipaddr']) {
201 96033063 Erik Fonnesbeck
		$dynsubnet_start = ip2ulong($config['dhcpd'][$if]['range']['from']);
202
		$dynsubnet_end = ip2ulong($config['dhcpd'][$if]['range']['to']);
203 49e4ebf8 jim-p
		if ((ip2ulong($_POST['ipaddr']) >= $dynsubnet_start) &&
204
			(ip2ulong($_POST['ipaddr']) <= $dynsubnet_end)) {
205 ab8d138d jim-p
			$input_errors[] = sprintf(gettext("The IP address must not be within the DHCP range for this interface."));
206
		}
207
208 37c922a6 jim-p
		foreach ($a_pools as $pidx => $p) {
209 f657f5e1 Renato Botelho
			if (is_inrange_v4($_POST['ipaddr'], $p['range']['from'], $p['range']['to'])) {
210
				$input_errors[] = gettext("The IP address must not be within the range configured on a DHCP pool for this interface.");
211
				break;
212
			}
213
		}
214
215 96033063 Erik Fonnesbeck
		$lansubnet_start = ip2ulong(long2ip32(ip2long($ifcfgip) & gen_subnet_mask_long($ifcfgsn)));
216
		$lansubnet_end = ip2ulong(long2ip32(ip2long($ifcfgip) | (~gen_subnet_mask_long($ifcfgsn))));
217
		if ((ip2ulong($_POST['ipaddr']) < $lansubnet_start) ||
218
			(ip2ulong($_POST['ipaddr']) > $lansubnet_end)) {
219 8ffadf76 Rafael Lucas
			$input_errors[] = sprintf(gettext("The IP address must lie in the %s subnet."),$ifcfgdescr);
220 5b237745 Scott Ullrich
		}
221
	}
222
223 7309ff39 Renato Botelho
	if (($_POST['gateway'] && !is_ipaddrv4($_POST['gateway'])))
224
		$input_errors[] = gettext("A valid IP address must be specified for the gateway.");
225
	if (($_POST['wins1'] && !is_ipaddrv4($_POST['wins1'])) || ($_POST['wins2'] && !is_ipaddrv4($_POST['wins2'])))
226
		$input_errors[] = gettext("A valid IP address must be specified for the primary/secondary WINS servers.");
227
228
	$parent_ip = get_interface_ip($POST['if']);
229
	if (is_ipaddrv4($parent_ip) && $_POST['gateway']) {
230
		$parent_sn = get_interface_subnet($_POST['if']);
231
		if(!ip_in_subnet($_POST['gateway'], gen_subnet($parent_ip, $parent_sn) . "/" . $parent_sn) && !ip_in_interface_alias_subnet($_POST['if'], $_POST['gateway']))
232
			$input_errors[] = sprintf(gettext("The gateway address %s does not lie within the chosen interface's subnet."), $_POST['gateway']);
233
	}
234 81af6a08 Phil Davis
	if (($_POST['dns1'] && !is_ipaddrv4($_POST['dns1'])) || ($_POST['dns2'] && !is_ipaddrv4($_POST['dns2'])) || ($_POST['dns3'] && !is_ipaddrv4($_POST['dns3'])) || ($_POST['dns4'] && !is_ipaddrv4($_POST['dns4'])))
235
		$input_errors[] = gettext("A valid IP address must be specified for each of the DNS servers.");
236 7309ff39 Renato Botelho
237
	if ($_POST['deftime'] && (!is_numeric($_POST['deftime']) || ($_POST['deftime'] < 60)))
238
		$input_errors[] = gettext("The default lease time must be at least 60 seconds.");
239
	if ($_POST['maxtime'] && (!is_numeric($_POST['maxtime']) || ($_POST['maxtime'] < 60) || ($_POST['maxtime'] <= $_POST['deftime'])))
240
		$input_errors[] = gettext("The maximum lease time must be at least 60 seconds and higher than the default lease time.");
241
	if (($_POST['ddnsdomain'] && !is_domain($_POST['ddnsdomain'])))
242
		$input_errors[] = gettext("A valid domain name must be specified for the dynamic DNS registration.");
243 87019fc4 Andres Petralli
	if (($_POST['ddnsdomain'] && !is_ipaddrv4($_POST['ddnsdomainprimary'])))
244
		$input_errors[] = gettext("A valid primary domain name server IP address must be specified for the dynamic domain name.");
245
	if (($_POST['ddnsdomainkey'] && !$_POST['ddnsdomainkeyname']) ||
246
		($_POST['ddnsdomainkeyname'] && !$_POST['ddnsdomainkey']))
247
		$input_errors[] = gettext("You must specify both a valid domain key and key name.");
248 7309ff39 Renato Botelho
	if ($_POST['domainsearchlist']) {
249
		$domain_array=preg_split("/[ ;]+/",$_POST['domainsearchlist']);
250
		foreach ($domain_array as $curdomain) {
251
			if (!is_domain($curdomain)) {
252
				$input_errors[] = gettext("A valid domain search list must be specified.");
253
				break;
254
			}
255
		}
256
	}
257
258
	if (($_POST['ntp1'] && !is_ipaddrv4($_POST['ntp1'])) || ($_POST['ntp2'] && !is_ipaddrv4($_POST['ntp2'])))
259
		$input_errors[] = gettext("A valid IP address must be specified for the primary/secondary NTP servers.");
260
	if ($_POST['tftp'] && !is_ipaddrv4($_POST['tftp']) && !is_domain($_POST['tftp']) && !is_URL($_POST['tftp']))
261
		$input_errors[] = gettext("A valid IP address or hostname must be specified for the TFTP server.");
262
	if (($_POST['nextserver'] && !is_ipaddrv4($_POST['nextserver'])))
263
		$input_errors[] = gettext("A valid IP address must be specified for the network boot server.");
264
265 5b237745 Scott Ullrich
	if (!$input_errors) {
266
		$mapent = array();
267
		$mapent['mac'] = $_POST['mac'];
268 449f1dd2 Will Boyce
		$mapent['cid'] = $_POST['cid'];
269 5b237745 Scott Ullrich
		$mapent['ipaddr'] = $_POST['ipaddr'];
270 6a01ea44 Bill Marquette
		$mapent['hostname'] = $_POST['hostname'];
271 5b237745 Scott Ullrich
		$mapent['descr'] = $_POST['descr'];
272 25c1ebd5 N0YB
		$mapent['arp_table_static_entry'] = ($_POST['arp_table_static_entry']) ? true : false;
273 a2578c27 Anthony Wrather
		$mapent['filename'] = $_POST['filename'];
274
		$mapent['rootpath'] = $_POST['rootpath'];
275 7309ff39 Renato Botelho
		$mapent['defaultleasetime'] = $_POST['deftime'];
276
		$mapent['maxleasetime'] = $_POST['maxtime'];
277
278
		unset($mapent['winsserver']);
279
		if ($_POST['wins1'])
280
			$mapent['winsserver'][] = $_POST['wins1'];
281
		if ($_POST['wins2'])
282
			$mapent['winsserver'][] = $_POST['wins2'];
283
284
		unset($mapent['dnsserver']);
285
		if ($_POST['dns1'])
286
			$mapent['dnsserver'][] = $_POST['dns1'];
287
		if ($_POST['dns2'])
288
			$mapent['dnsserver'][] = $_POST['dns2'];
289 81af6a08 Phil Davis
		if ($_POST['dns3'])
290
			$mapent['dnsserver'][] = $_POST['dns3'];
291
		if ($_POST['dns4'])
292
			$mapent['dnsserver'][] = $_POST['dns4'];
293 7309ff39 Renato Botelho
294
		$mapent['gateway'] = $_POST['gateway'];
295
		$mapent['domain'] = $_POST['domain'];
296
		$mapent['domainsearchlist'] = $_POST['domainsearchlist'];
297
		$mapent['ddnsdomain'] = $_POST['ddnsdomain'];
298 87019fc4 Andres Petralli
		$mapent['ddnsdomainprimary'] = $_POST['ddnsdomainprimary'];
299
		$mapent['ddnsdomainkeyname'] = $_POST['ddnsdomainkeyname'];
300
		$mapent['ddnsdomainkey'] = $_POST['ddnsdomainkey'];
301 7309ff39 Renato Botelho
		$mapent['ddnsupdate'] = ($_POST['ddnsupdate']) ? true : false;
302
303
		unset($mapent['ntpserver']);
304
		if ($_POST['ntp1'])
305
			$mapent['ntpserver'][] = $_POST['ntp1'];
306
		if ($_POST['ntp2'])
307
			$mapent['ntpserver'][] = $_POST['ntp2'];
308
309
		$mapent['tftp'] = $_POST['tftp'];
310
		$mapent['ldap'] = $_POST['ldap'];
311 5b237745 Scott Ullrich
312
		if (isset($id) && $a_maps[$id])
313
			$a_maps[$id] = $mapent;
314
		else
315
			$a_maps[] = $mapent;
316 bb9689bd Erik Fonnesbeck
		staticmaps_sort($if);
317 b75d7fd5 Renato Botelho
318 5b237745 Scott Ullrich
		write_config();
319 608ef5e7 Scott Ullrich
320 6a01ea44 Bill Marquette
		if(isset($config['dhcpd'][$if]['enable'])) {
321 a368a026 Ermal Lu?i
			mark_subsystem_dirty('staticmaps');
322 ea1aca13 Renato Botelho
			if (isset($config['dnsmasq']['enable']) && isset($config['dnsmasq']['regdhcpstatic']))
323 a368a026 Ermal Lu?i
				mark_subsystem_dirty('hosts');
324 3453affc Warren Baker
			if (isset($config['unbound']['enable']) && isset($config['unbound']['regdhcpstatic']))
325
				mark_subsystem_dirty('unbound');
326 6a01ea44 Bill Marquette
		}
327 e4da84d0 Bill Marquette
328 5b237745 Scott Ullrich
		header("Location: services_dhcp.php?if={$if}");
329
		exit;
330
	}
331
}
332 4df96eff Scott Ullrich
333 180db186 Colin Fleming
$closehead = false;
334 8ffadf76 Rafael Lucas
$pgtitle = array(gettext("Services"),gettext("DHCP"),gettext("Edit static mapping"));
335 b32dd0a6 jim-p
$shortcut_section = "dhcp";
336 5224b8e7 jim-p
337 4df96eff Scott Ullrich
include("head.inc");
338
339 5b237745 Scott Ullrich
?>
340
341 91f026b0 ayvis
<script type="text/javascript">
342 180db186 Colin Fleming
//<![CDATA[
343 7309ff39 Renato Botelho
	function show_ddns_config() {
344
		document.getElementById("showddnsbox").innerHTML='';
345
		aodiv = document.getElementById('showddns');
346
		aodiv.style.display = "block";
347
	}
348
349
	function show_ntp_config() {
350
		document.getElementById("showntpbox").innerHTML='';
351
		aodiv = document.getElementById('showntp');
352
		aodiv.style.display = "block";
353
	}
354
355
	function show_tftp_config() {
356
		document.getElementById("showtftpbox").innerHTML='';
357
		aodiv = document.getElementById('showtftp');
358
		aodiv.style.display = "block";
359
	}
360 180db186 Colin Fleming
//]]>
361 7309ff39 Renato Botelho
</script>
362 180db186 Colin Fleming
</head>
363 7309ff39 Renato Botelho
364 5b237745 Scott Ullrich
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
365
<?php include("fbegin.inc"); ?>
366
<?php if ($input_errors) print_input_errors($input_errors); ?>
367
            <form action="services_dhcp_edit.php" method="post" name="iform" id="iform">
368 180db186 Colin Fleming
              <table class="tabcont" width="100%" border="0" cellpadding="6" cellspacing="0" summary="static mapping">
369 e22987a4 Scott Ullrich
				<tr>
370 8ffadf76 Rafael Lucas
					<td colspan="2" valign="top" class="listtopic"><?=gettext("Static DHCP Mapping");?></td>
371 b75d7fd5 Renato Botelho
				</tr>
372
                <tr>
373 449f1dd2 Will Boyce
                  <td width="22%" valign="top" class="vncell"><?=gettext("MAC address");?></td>
374 b75d7fd5 Renato Botelho
                  <td width="78%" class="vtable">
375 180db186 Colin Fleming
                    <input name="mac" type="text" class="formfld unknown" id="mac" size="30" value="<?=htmlspecialchars($pconfig['mac']);?>" />
376 f183b092 Scott Ullrich
		    <?php
377
			$ip = getenv('REMOTE_ADDR');
378
			$mac = `/usr/sbin/arp -an | grep {$ip} | cut -d" " -f4`;
379
			$mac = str_replace("\n","",$mac);
380
		    ?>
381 180db186 Colin Fleming
		    <a onclick="document.forms[0].mac.value='<?=$mac?>';" href="#"><?=gettext("Copy my MAC address");?></a>
382 8cd558b6 ayvis
                    <br />
383 8ffadf76 Rafael Lucas
                    <span class="vexpl"><?=gettext("Enter a MAC address in the following format: ".
384
                    "xx:xx:xx:xx:xx:xx");?></span></td>
385 449f1dd2 Will Boyce
                </tr>
386 180db186 Colin Fleming
                <tr>
387 449f1dd2 Will Boyce
                  <td width="22%" valign="top" class="vncell"><?=gettext("Client identifier");?></td>
388
                  <td width="78%" class="vtable">
389 180db186 Colin Fleming
                    <input name="cid" type="text" class="formfld unknown" id="cid" size="30" value="<?=htmlspecialchars($pconfig['cid']);?>" />
390
                  </td>
391 5b237745 Scott Ullrich
                </tr>
392 b75d7fd5 Renato Botelho
                <tr>
393 8ffadf76 Rafael Lucas
                  <td width="22%" valign="top" class="vncell"><?=gettext("IP address");?></td>
394 b75d7fd5 Renato Botelho
                  <td width="78%" class="vtable">
395 180db186 Colin Fleming
                    <input name="ipaddr" type="text" class="formfld unknown" id="ipaddr" size="20" value="<?=htmlspecialchars($pconfig['ipaddr']);?>" />
396 8cd558b6 ayvis
                    <br />
397 dbb1cdb5 jim-p
			<?=gettext("If an IPv4 address is entered, the address must be outside of the pool.");?>
398 8cd558b6 ayvis
			<br />
399 dbb1cdb5 jim-p
			<?=gettext("If no IPv4 address is given, one will be dynamically allocated from the pool.");?>
400
			</td>
401 5b237745 Scott Ullrich
                </tr>
402 b75d7fd5 Renato Botelho
                <tr>
403 8ffadf76 Rafael Lucas
                  <td width="22%" valign="top" class="vncell"><?=gettext("Hostname");?></td>
404 b75d7fd5 Renato Botelho
                  <td width="78%" class="vtable">
405 180db186 Colin Fleming
                    <input name="hostname" type="text" class="formfld unknown" id="hostname" size="20" value="<?=htmlspecialchars($pconfig['hostname']);?>" />
406 8cd558b6 ayvis
                    <br /> <span class="vexpl"><?=gettext("Name of the host, without domain part.");?></span></td>
407 b75d7fd5 Renato Botelho
                </tr>
408 d6d50244 Ermal
                <?php if($netboot_enabled) { ?>
409
		<tr>
410 a2578c27 Anthony Wrather
		  <td width="22%" valign="top" class="vncell">Netboot Filename</td>
411 d6d50244 Ermal
		  <td width="78%" class="vtable">
412 180db186 Colin Fleming
		    <input name="filename" type="text" class="formfld unknown" id="filename" size="20" value="<?=htmlspecialchars($pconfig['filename']);?>" />
413 8cd558b6 ayvis
		    <br /> <span class="vexpl">Name of the file that should be loaded when this host boots off of the network, overrides setting on main page.</span></td>
414 d6d50244 Ermal
		</tr>
415 a2578c27 Anthony Wrather
		<tr>
416
		  <td width="22%" valign="top" class="vncell">Root Path</td>
417
		  <td width="78%" class="vtable">
418 180db186 Colin Fleming
			<input name="rootpath" type="text" class="formfld unknown" id="rootpath" size="90" value="<?=htmlspecialchars($pconfig['rootpath']);?>" />
419 8cd558b6 ayvis
		    <br /> <span class="vexpl"><?=gettext("Enter the"); ?> <b><?=gettext("root-path"); ?></b>-<?=gettext("string");?>, overrides setting on main page.</span></td>
420 a2578c27 Anthony Wrather
		</tr>
421 d6d50244 Ermal
		<?php } ?>
422 b75d7fd5 Renato Botelho
                <tr>
423 8ffadf76 Rafael Lucas
                  <td width="22%" valign="top" class="vncell"><?=gettext("Description");?></td>
424 b75d7fd5 Renato Botelho
                  <td width="78%" class="vtable">
425 180db186 Colin Fleming
                    <input name="descr" type="text" class="formfld unknown" id="descr" size="40" value="<?=htmlspecialchars($pconfig['descr']);?>" />
426 8cd558b6 ayvis
                    <br /> <span class="vexpl"><?=gettext("You may enter a description here ".
427 8ffadf76 Rafael Lucas
                    "for your reference (not parsed).");?></span></td>
428 5b237745 Scott Ullrich
                </tr>
429 b75d7fd5 Renato Botelho
                <tr>
430 25c1ebd5 N0YB
                  <td width="22%" valign="top" class="vncell"><?=gettext("ARP Table Static Entry");?></td>
431 b75d7fd5 Renato Botelho
                  <td width="78%" class="vtable">
432 180db186 Colin Fleming
                    <input name="arp_table_static_entry" id="arp_table_static_entry" type="checkbox" value="yes" <?php if ($pconfig['arp_table_static_entry']) echo "checked=\"checked\""; ?> />
433
                    <br /> <span class="vexpl"><?=gettext("Create an ARP Table Static Entry for this MAC &amp; IP Address pair. ".
434 25c1ebd5 N0YB
                    "");?></span></td>
435
                </tr>
436 7309ff39 Renato Botelho
		<tr>
437
		<td width="22%" valign="top" class="vncell"><?=gettext("WINS servers");?></td>
438
		<td width="78%" class="vtable">
439 180db186 Colin Fleming
			<input name="wins1" type="text" class="formfld unknown" id="wins1" size="20" value="<?=htmlspecialchars($pconfig['wins1']);?>" /><br />
440
			<input name="wins2" type="text" class="formfld unknown" id="wins2" size="20" value="<?=htmlspecialchars($pconfig['wins2']);?>" />
441 7309ff39 Renato Botelho
		</td>
442
		</tr>
443
		<tr>
444
		<td width="22%" valign="top" class="vncell"><?=gettext("DNS servers");?></td>
445
		<td width="78%" class="vtable">
446 180db186 Colin Fleming
			<input name="dns1" type="text" class="formfld unknown" id="dns1" size="20" value="<?=htmlspecialchars($pconfig['dns1']);?>" /><br />
447
			<input name="dns2" type="text" class="formfld unknown" id="dns2" size="20" value="<?=htmlspecialchars($pconfig['dns2']);?>" /><br />
448 81af6a08 Phil Davis
			<input name="dns3" type="text" class="formfld unknown" id="dns3" size="20" value="<?=htmlspecialchars($pconfig['dns3']);?>" /><br />
449
			<input name="dns4" type="text" class="formfld unknown" id="dns4" size="20" value="<?=htmlspecialchars($pconfig['dns4']);?>" /><br />
450 7309ff39 Renato Botelho
			<?=gettext("NOTE: leave blank to use the system default DNS servers - this interface's IP if DNS forwarder is enabled, otherwise the servers configured on the General page.");?>
451
		</td>
452
		</tr>
453
		<tr>
454
		<td width="22%" valign="top" class="vncell"><?=gettext("Gateway");?></td>
455
		<td width="78%" class="vtable">
456 180db186 Colin Fleming
			<input name="gateway" type="text" class="formfld host" id="gateway" size="20" value="<?=htmlspecialchars($pconfig['gateway']);?>" /><br />
457 7309ff39 Renato Botelho
			 <?=gettext("The default is to use the IP on this interface of the firewall as the gateway. Specify an alternate gateway here if this is not the correct gateway for your network.");?>
458
		</td>
459
		</tr>
460
		<tr>
461
		<td width="22%" valign="top" class="vncell"><?=gettext("Domain name");?></td>
462
		<td width="78%" class="vtable">
463 180db186 Colin Fleming
			<input name="domain" type="text" class="formfld unknown" id="domain" size="20" value="<?=htmlspecialchars($pconfig['domain']);?>" /><br />
464 7309ff39 Renato Botelho
			 <?=gettext("The default is to use the domain name of this system as the default domain name provided by DHCP. You may specify an alternate domain name here.");?>
465
		</td>
466
		</tr>
467
		<tr>
468
		<td width="22%" valign="top" class="vncell"><?=gettext("Domain search list");?></td>
469
		<td width="78%" class="vtable">
470 180db186 Colin Fleming
			<input name="domainsearchlist" type="text" class="formfld unknown" id="domainsearchlist" size="20" value="<?=htmlspecialchars($pconfig['domainsearchlist']);?>" /><br />
471 5aa68a55 Renato Botelho
			<?=gettext("The DHCP server can optionally provide a domain search list. Use the semicolon character as separator ");?>
472 7309ff39 Renato Botelho
		</td>
473
		</tr>
474
		<tr>
475
		<td width="22%" valign="top" class="vncell"><?=gettext("Default lease time");?></td>
476
		<td width="78%" class="vtable">
477 180db186 Colin Fleming
			<input name="deftime" type="text" class="formfld unknown" id="deftime" size="10" value="<?=htmlspecialchars($pconfig['deftime']);?>" />
478 8cd558b6 ayvis
			<?=gettext("seconds");?><br />
479 7309ff39 Renato Botelho
			<?=gettext("This is used for clients that do not ask for a specific " .
480 8cd558b6 ayvis
			"expiration time."); ?><br />
481 7309ff39 Renato Botelho
			<?=gettext("The default is 7200 seconds.");?>
482
		</td>
483
		</tr>
484
		<tr>
485
		<td width="22%" valign="top" class="vncell"><?=gettext("Maximum lease time");?></td>
486
		<td width="78%" class="vtable">
487 180db186 Colin Fleming
			<input name="maxtime" type="text" class="formfld unknown" id="maxtime" size="10" value="<?=htmlspecialchars($pconfig['maxtime']);?>" />
488 8cd558b6 ayvis
			<?=gettext("seconds");?><br />
489 7309ff39 Renato Botelho
			<?=gettext("This is the maximum lease time for clients that ask".
490 8cd558b6 ayvis
			" for a specific expiration time."); ?><br />
491 7309ff39 Renato Botelho
			<?=gettext("The default is 86400 seconds.");?>
492
		</td>
493
		</tr>
494
		<tr>
495
		<td width="22%" valign="top" class="vncell"><?=gettext("Dynamic DNS");?></td>
496
		<td width="78%" class="vtable">
497
			<div id="showddnsbox">
498 264b3ca8 Colin Fleming
				<input type="button" onclick="show_ddns_config()" value="<?=gettext("Advanced");?>" /> - <?=gettext("Show Dynamic DNS");?>
499 7309ff39 Renato Botelho
			</div>
500
			<div id="showddns" style="display:none">
501 180db186 Colin Fleming
				<input style="vertical-align:middle" type="checkbox" value="yes" name="ddnsupdate" id="ddnsupdate" <?php if($pconfig['ddnsupdate']) echo "checked=\"checked\""; ?> />&nbsp;
502 7309ff39 Renato Botelho
				<b><?=gettext("Enable registration of DHCP client names in DNS.");?></b><br />
503
				<p>
504 180db186 Colin Fleming
				<input name="ddnsdomain" type="text" class="formfld unknown" id="ddnsdomain" size="20" value="<?=htmlspecialchars($pconfig['ddnsdomain']);?>" /><br />
505 7309ff39 Renato Botelho
				<?=gettext("Note: Leave blank to disable dynamic DNS registration.");?><br />
506
				<?=gettext("Enter the dynamic DNS domain which will be used to register client names in the DNS server.");?>
507 180db186 Colin Fleming
				<input name="ddnsdomainprimary" type="text" class="formfld unknown" id="ddnsdomainprimary" size="20" value="<?=htmlspecialchars($pconfig['ddnsdomainprimary']);?>" /><br />
508 87019fc4 Andres Petralli
				<?=gettext("Enter the primary domain name server IP address for the dynamic domain name.");?><br />
509 180db186 Colin Fleming
				<input name="ddnsdomainkeyname" type="text" class="formfld unknown" id="ddnsdomainkeyname" size="20" value="<?=htmlspecialchars($pconfig['ddnsdomainkeyname']);?>" /><br />
510 87019fc4 Andres Petralli
				<?=gettext("Enter the dynamic DNS domain key name which will be used to register client names in the DNS server.");?>
511 180db186 Colin Fleming
				<input name="ddnsdomainkey" type="text" class="formfld unknown" id="ddnsdomainkey" size="20" value="<?=htmlspecialchars($pconfig['ddnsdomainkey']);?>" /><br />
512 87019fc4 Andres Petralli
				<?=gettext("Enter the dynamic DNS domain key secret which will be used to register client names in the DNS server.");?>
513 180db186 Colin Fleming
				</p>
514 7309ff39 Renato Botelho
			</div>
515
		</td>
516
		</tr>
517
		<tr>
518
		<td width="22%" valign="top" class="vncell"><?=gettext("NTP servers");?></td>
519
		<td width="78%" class="vtable">
520
			<div id="showntpbox">
521 264b3ca8 Colin Fleming
				<input type="button" onclick="show_ntp_config()" value="<?=gettext("Advanced");?>" /> - <?=gettext("Show NTP configuration");?>
522 7309ff39 Renato Botelho
			</div>
523
			<div id="showntp" style="display:none">
524 180db186 Colin Fleming
				<input name="ntp1" type="text" class="formfld unknown" id="ntp1" size="20" value="<?=htmlspecialchars($pconfig['ntp1']);?>" /><br />
525
				<input name="ntp2" type="text" class="formfld unknown" id="ntp2" size="20" value="<?=htmlspecialchars($pconfig['ntp2']);?>" />
526 7309ff39 Renato Botelho
			</div>
527
		</td>
528
		</tr>
529
		<tr>
530
		<td width="22%" valign="top" class="vncell"><?=gettext("TFTP server");?></td>
531
		<td width="78%" class="vtable">
532
		<div id="showtftpbox">
533 264b3ca8 Colin Fleming
			<input type="button" onclick="show_tftp_config()" value="<?=gettext("Advanced");?>" /> - <?=gettext("Show TFTP configuration");?>
534 7309ff39 Renato Botelho
		</div>
535
		<div id="showtftp" style="display:none">
536 180db186 Colin Fleming
			<input name="tftp" type="text" class="formfld unknown" id="tftp" size="50" value="<?=htmlspecialchars($pconfig['tftp']);?>" /><br />
537 7309ff39 Renato Botelho
			<?=gettext("Leave blank to disable.  Enter a full hostname or IP for the TFTP server.");?>
538
		</div>
539
		</td>
540
		</tr>
541 b75d7fd5 Renato Botelho
                <tr>
542 5b237745 Scott Ullrich
                  <td width="22%" valign="top">&nbsp;</td>
543 b75d7fd5 Renato Botelho
                  <td width="78%">
544 62424bdb Renato Botelho
                    <input name="Submit" type="submit" class="formbtn" value="<?=gettext("Save");?>" />
545
                    <input type="button" class="formbtn" value="<?=gettext("Cancel");?>" onclick="window.location.href='<?=$referer;?>'" />
546 5b237745 Scott Ullrich
                    <?php if (isset($id) && $a_maps[$id]): ?>
547 180db186 Colin Fleming
                    <input name="id" type="hidden" value="<?=htmlspecialchars($id);?>" />
548 5b237745 Scott Ullrich
                    <?php endif; ?>
549 180db186 Colin Fleming
                    <input name="if" type="hidden" value="<?=htmlspecialchars($if);?>" />
550 5b237745 Scott Ullrich
                  </td>
551
                </tr>
552
              </table>
553
</form>
554
<?php include("fend.inc"); ?>
555
</body>
556 b75d7fd5 Renato Botelho
</html>