Project

General

Profile

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