Project

General

Profile

Download (26 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
	foreach ($a_maps as $mapent) {
191
		if (isset($id) && ($a_maps[$id]) && ($a_maps[$id] === $mapent))
192
			continue;
193
194 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'])) {
195 84a27e31 Will Boyce
			$input_errors[] = gettext("This Hostname, IP, MAC address or Client identifier already exists.");
196 5b237745 Scott Ullrich
			break;
197
		}
198
	}
199 b75d7fd5 Renato Botelho
200 5b237745 Scott Ullrich
	/* make sure it's not within the dynamic subnet */
201
	if ($_POST['ipaddr']) {
202 96033063 Erik Fonnesbeck
		$dynsubnet_start = ip2ulong($config['dhcpd'][$if]['range']['from']);
203
		$dynsubnet_end = ip2ulong($config['dhcpd'][$if]['range']['to']);
204 49e4ebf8 jim-p
		if ((ip2ulong($_POST['ipaddr']) >= $dynsubnet_start) &&
205
			(ip2ulong($_POST['ipaddr']) <= $dynsubnet_end)) {
206 ab8d138d jim-p
			$input_errors[] = sprintf(gettext("The IP address must not be within the DHCP range for this interface."));
207
		}
208
209 37c922a6 jim-p
		foreach ($a_pools as $pidx => $p) {
210 f657f5e1 Renato Botelho
			if (is_inrange_v4($_POST['ipaddr'], $p['range']['from'], $p['range']['to'])) {
211
				$input_errors[] = gettext("The IP address must not be within the range configured on a DHCP pool for this interface.");
212
				break;
213
			}
214
		}
215
216 96033063 Erik Fonnesbeck
		$lansubnet_start = ip2ulong(long2ip32(ip2long($ifcfgip) & gen_subnet_mask_long($ifcfgsn)));
217
		$lansubnet_end = ip2ulong(long2ip32(ip2long($ifcfgip) | (~gen_subnet_mask_long($ifcfgsn))));
218
		if ((ip2ulong($_POST['ipaddr']) < $lansubnet_start) ||
219
			(ip2ulong($_POST['ipaddr']) > $lansubnet_end)) {
220 8ffadf76 Rafael Lucas
			$input_errors[] = sprintf(gettext("The IP address must lie in the %s subnet."),$ifcfgdescr);
221 5b237745 Scott Ullrich
		}
222
	}
223
224 7309ff39 Renato Botelho
	if (($_POST['gateway'] && !is_ipaddrv4($_POST['gateway'])))
225
		$input_errors[] = gettext("A valid IP address must be specified for the gateway.");
226
	if (($_POST['wins1'] && !is_ipaddrv4($_POST['wins1'])) || ($_POST['wins2'] && !is_ipaddrv4($_POST['wins2'])))
227
		$input_errors[] = gettext("A valid IP address must be specified for the primary/secondary WINS servers.");
228
229
	$parent_ip = get_interface_ip($POST['if']);
230
	if (is_ipaddrv4($parent_ip) && $_POST['gateway']) {
231
		$parent_sn = get_interface_subnet($_POST['if']);
232
		if(!ip_in_subnet($_POST['gateway'], gen_subnet($parent_ip, $parent_sn) . "/" . $parent_sn) && !ip_in_interface_alias_subnet($_POST['if'], $_POST['gateway']))
233
			$input_errors[] = sprintf(gettext("The gateway address %s does not lie within the chosen interface's subnet."), $_POST['gateway']);
234
	}
235 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'])))
236
		$input_errors[] = gettext("A valid IP address must be specified for each of the DNS servers.");
237 7309ff39 Renato Botelho
238
	if ($_POST['deftime'] && (!is_numeric($_POST['deftime']) || ($_POST['deftime'] < 60)))
239
		$input_errors[] = gettext("The default lease time must be at least 60 seconds.");
240
	if ($_POST['maxtime'] && (!is_numeric($_POST['maxtime']) || ($_POST['maxtime'] < 60) || ($_POST['maxtime'] <= $_POST['deftime'])))
241
		$input_errors[] = gettext("The maximum lease time must be at least 60 seconds and higher than the default lease time.");
242
	if (($_POST['ddnsdomain'] && !is_domain($_POST['ddnsdomain'])))
243
		$input_errors[] = gettext("A valid domain name must be specified for the dynamic DNS registration.");
244 87019fc4 Andres Petralli
	if (($_POST['ddnsdomain'] && !is_ipaddrv4($_POST['ddnsdomainprimary'])))
245
		$input_errors[] = gettext("A valid primary domain name server IP address must be specified for the dynamic domain name.");
246
	if (($_POST['ddnsdomainkey'] && !$_POST['ddnsdomainkeyname']) ||
247
		($_POST['ddnsdomainkeyname'] && !$_POST['ddnsdomainkey']))
248
		$input_errors[] = gettext("You must specify both a valid domain key and key name.");
249 7309ff39 Renato Botelho
	if ($_POST['domainsearchlist']) {
250
		$domain_array=preg_split("/[ ;]+/",$_POST['domainsearchlist']);
251
		foreach ($domain_array as $curdomain) {
252
			if (!is_domain($curdomain)) {
253
				$input_errors[] = gettext("A valid domain search list must be specified.");
254
				break;
255
			}
256
		}
257
	}
258
259
	if (($_POST['ntp1'] && !is_ipaddrv4($_POST['ntp1'])) || ($_POST['ntp2'] && !is_ipaddrv4($_POST['ntp2'])))
260
		$input_errors[] = gettext("A valid IP address must be specified for the primary/secondary NTP servers.");
261
	if ($_POST['tftp'] && !is_ipaddrv4($_POST['tftp']) && !is_domain($_POST['tftp']) && !is_URL($_POST['tftp']))
262
		$input_errors[] = gettext("A valid IP address or hostname must be specified for the TFTP server.");
263
	if (($_POST['nextserver'] && !is_ipaddrv4($_POST['nextserver'])))
264
		$input_errors[] = gettext("A valid IP address must be specified for the network boot server.");
265
266 5b237745 Scott Ullrich
	if (!$input_errors) {
267
		$mapent = array();
268
		$mapent['mac'] = $_POST['mac'];
269 449f1dd2 Will Boyce
		$mapent['cid'] = $_POST['cid'];
270 5b237745 Scott Ullrich
		$mapent['ipaddr'] = $_POST['ipaddr'];
271 6a01ea44 Bill Marquette
		$mapent['hostname'] = $_POST['hostname'];
272 5b237745 Scott Ullrich
		$mapent['descr'] = $_POST['descr'];
273 25c1ebd5 N0YB
		$mapent['arp_table_static_entry'] = ($_POST['arp_table_static_entry']) ? true : false;
274 a2578c27 Anthony Wrather
		$mapent['filename'] = $_POST['filename'];
275
		$mapent['rootpath'] = $_POST['rootpath'];
276 7309ff39 Renato Botelho
		$mapent['defaultleasetime'] = $_POST['deftime'];
277
		$mapent['maxleasetime'] = $_POST['maxtime'];
278
279
		unset($mapent['winsserver']);
280
		if ($_POST['wins1'])
281
			$mapent['winsserver'][] = $_POST['wins1'];
282
		if ($_POST['wins2'])
283
			$mapent['winsserver'][] = $_POST['wins2'];
284
285
		unset($mapent['dnsserver']);
286
		if ($_POST['dns1'])
287
			$mapent['dnsserver'][] = $_POST['dns1'];
288
		if ($_POST['dns2'])
289
			$mapent['dnsserver'][] = $_POST['dns2'];
290 81af6a08 Phil Davis
		if ($_POST['dns3'])
291
			$mapent['dnsserver'][] = $_POST['dns3'];
292
		if ($_POST['dns4'])
293
			$mapent['dnsserver'][] = $_POST['dns4'];
294 7309ff39 Renato Botelho
295
		$mapent['gateway'] = $_POST['gateway'];
296
		$mapent['domain'] = $_POST['domain'];
297
		$mapent['domainsearchlist'] = $_POST['domainsearchlist'];
298
		$mapent['ddnsdomain'] = $_POST['ddnsdomain'];
299 87019fc4 Andres Petralli
		$mapent['ddnsdomainprimary'] = $_POST['ddnsdomainprimary'];
300
		$mapent['ddnsdomainkeyname'] = $_POST['ddnsdomainkeyname'];
301
		$mapent['ddnsdomainkey'] = $_POST['ddnsdomainkey'];
302 7309ff39 Renato Botelho
		$mapent['ddnsupdate'] = ($_POST['ddnsupdate']) ? true : false;
303
304
		unset($mapent['ntpserver']);
305
		if ($_POST['ntp1'])
306
			$mapent['ntpserver'][] = $_POST['ntp1'];
307
		if ($_POST['ntp2'])
308
			$mapent['ntpserver'][] = $_POST['ntp2'];
309
310
		$mapent['tftp'] = $_POST['tftp'];
311
		$mapent['ldap'] = $_POST['ldap'];
312 5b237745 Scott Ullrich
313
		if (isset($id) && $a_maps[$id])
314
			$a_maps[$id] = $mapent;
315
		else
316
			$a_maps[] = $mapent;
317 bb9689bd Erik Fonnesbeck
		staticmaps_sort($if);
318 b75d7fd5 Renato Botelho
319 5b237745 Scott Ullrich
		write_config();
320 608ef5e7 Scott Ullrich
321 6a01ea44 Bill Marquette
		if(isset($config['dhcpd'][$if]['enable'])) {
322 a368a026 Ermal Lu?i
			mark_subsystem_dirty('staticmaps');
323 ea1aca13 Renato Botelho
			if (isset($config['dnsmasq']['enable']) && isset($config['dnsmasq']['regdhcpstatic']))
324 a368a026 Ermal Lu?i
				mark_subsystem_dirty('hosts');
325 3453affc Warren Baker
			if (isset($config['unbound']['enable']) && isset($config['unbound']['regdhcpstatic']))
326
				mark_subsystem_dirty('unbound');
327 6a01ea44 Bill Marquette
		}
328 e4da84d0 Bill Marquette
329 5b237745 Scott Ullrich
		header("Location: services_dhcp.php?if={$if}");
330
		exit;
331
	}
332
}
333 4df96eff Scott Ullrich
334 180db186 Colin Fleming
$closehead = false;
335 8ffadf76 Rafael Lucas
$pgtitle = array(gettext("Services"),gettext("DHCP"),gettext("Edit static mapping"));
336 b32dd0a6 jim-p
$shortcut_section = "dhcp";
337 5224b8e7 jim-p
338 4df96eff Scott Ullrich
include("head.inc");
339
340 5b237745 Scott Ullrich
?>
341
342 91f026b0 ayvis
<script type="text/javascript">
343 180db186 Colin Fleming
//<![CDATA[
344 7309ff39 Renato Botelho
	function show_ddns_config() {
345
		document.getElementById("showddnsbox").innerHTML='';
346
		aodiv = document.getElementById('showddns');
347
		aodiv.style.display = "block";
348
	}
349
350
	function show_ntp_config() {
351
		document.getElementById("showntpbox").innerHTML='';
352
		aodiv = document.getElementById('showntp');
353
		aodiv.style.display = "block";
354
	}
355
356
	function show_tftp_config() {
357
		document.getElementById("showtftpbox").innerHTML='';
358
		aodiv = document.getElementById('showtftp');
359
		aodiv.style.display = "block";
360
	}
361 180db186 Colin Fleming
//]]>
362 7309ff39 Renato Botelho
</script>
363 180db186 Colin Fleming
</head>
364 7309ff39 Renato Botelho
365 5b237745 Scott Ullrich
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
366
<?php include("fbegin.inc"); ?>
367
<?php if ($input_errors) print_input_errors($input_errors); ?>
368
            <form action="services_dhcp_edit.php" method="post" name="iform" id="iform">
369 180db186 Colin Fleming
              <table class="tabcont" width="100%" border="0" cellpadding="6" cellspacing="0" summary="static mapping">
370 e22987a4 Scott Ullrich
				<tr>
371 18620400 Phil Davis
					<td colspan="2" valign="top" class="listtopic"><?=sprintf(gettext("Static DHCP Mapping on %s"),$ifcfgdescr);?></td>
372 b75d7fd5 Renato Botelho
				</tr>
373
                <tr>
374 449f1dd2 Will Boyce
                  <td width="22%" valign="top" class="vncell"><?=gettext("MAC address");?></td>
375 b75d7fd5 Renato Botelho
                  <td width="78%" class="vtable">
376 180db186 Colin Fleming
                    <input name="mac" type="text" class="formfld unknown" id="mac" size="30" value="<?=htmlspecialchars($pconfig['mac']);?>" />
377 f183b092 Scott Ullrich
		    <?php
378
			$ip = getenv('REMOTE_ADDR');
379
			$mac = `/usr/sbin/arp -an | grep {$ip} | cut -d" " -f4`;
380
			$mac = str_replace("\n","",$mac);
381
		    ?>
382 180db186 Colin Fleming
		    <a onclick="document.forms[0].mac.value='<?=$mac?>';" href="#"><?=gettext("Copy my MAC address");?></a>
383 8cd558b6 ayvis
                    <br />
384 8ffadf76 Rafael Lucas
                    <span class="vexpl"><?=gettext("Enter a MAC address in the following format: ".
385
                    "xx:xx:xx:xx:xx:xx");?></span></td>
386 449f1dd2 Will Boyce
                </tr>
387 180db186 Colin Fleming
                <tr>
388 449f1dd2 Will Boyce
                  <td width="22%" valign="top" class="vncell"><?=gettext("Client identifier");?></td>
389
                  <td width="78%" class="vtable">
390 180db186 Colin Fleming
                    <input name="cid" type="text" class="formfld unknown" id="cid" size="30" value="<?=htmlspecialchars($pconfig['cid']);?>" />
391
                  </td>
392 5b237745 Scott Ullrich
                </tr>
393 b75d7fd5 Renato Botelho
                <tr>
394 8ffadf76 Rafael Lucas
                  <td width="22%" valign="top" class="vncell"><?=gettext("IP address");?></td>
395 b75d7fd5 Renato Botelho
                  <td width="78%" class="vtable">
396 180db186 Colin Fleming
                    <input name="ipaddr" type="text" class="formfld unknown" id="ipaddr" size="20" value="<?=htmlspecialchars($pconfig['ipaddr']);?>" />
397 8cd558b6 ayvis
                    <br />
398 dbb1cdb5 jim-p
			<?=gettext("If an IPv4 address is entered, the address must be outside of the pool.");?>
399 8cd558b6 ayvis
			<br />
400 dbb1cdb5 jim-p
			<?=gettext("If no IPv4 address is given, one will be dynamically allocated from the pool.");?>
401
			</td>
402 5b237745 Scott Ullrich
                </tr>
403 b75d7fd5 Renato Botelho
                <tr>
404 8ffadf76 Rafael Lucas
                  <td width="22%" valign="top" class="vncell"><?=gettext("Hostname");?></td>
405 b75d7fd5 Renato Botelho
                  <td width="78%" class="vtable">
406 180db186 Colin Fleming
                    <input name="hostname" type="text" class="formfld unknown" id="hostname" size="20" value="<?=htmlspecialchars($pconfig['hostname']);?>" />
407 8cd558b6 ayvis
                    <br /> <span class="vexpl"><?=gettext("Name of the host, without domain part.");?></span></td>
408 b75d7fd5 Renato Botelho
                </tr>
409 d6d50244 Ermal
                <?php if($netboot_enabled) { ?>
410
		<tr>
411 a2578c27 Anthony Wrather
		  <td width="22%" valign="top" class="vncell">Netboot Filename</td>
412 d6d50244 Ermal
		  <td width="78%" class="vtable">
413 180db186 Colin Fleming
		    <input name="filename" type="text" class="formfld unknown" id="filename" size="20" value="<?=htmlspecialchars($pconfig['filename']);?>" />
414 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>
415 d6d50244 Ermal
		</tr>
416 a2578c27 Anthony Wrather
		<tr>
417
		  <td width="22%" valign="top" class="vncell">Root Path</td>
418
		  <td width="78%" class="vtable">
419 180db186 Colin Fleming
			<input name="rootpath" type="text" class="formfld unknown" id="rootpath" size="90" value="<?=htmlspecialchars($pconfig['rootpath']);?>" />
420 8cd558b6 ayvis
		    <br /> <span class="vexpl"><?=gettext("Enter the"); ?> <b><?=gettext("root-path"); ?></b>-<?=gettext("string");?>, overrides setting on main page.</span></td>
421 a2578c27 Anthony Wrather
		</tr>
422 d6d50244 Ermal
		<?php } ?>
423 b75d7fd5 Renato Botelho
                <tr>
424 8ffadf76 Rafael Lucas
                  <td width="22%" valign="top" class="vncell"><?=gettext("Description");?></td>
425 b75d7fd5 Renato Botelho
                  <td width="78%" class="vtable">
426 180db186 Colin Fleming
                    <input name="descr" type="text" class="formfld unknown" id="descr" size="40" value="<?=htmlspecialchars($pconfig['descr']);?>" />
427 8cd558b6 ayvis
                    <br /> <span class="vexpl"><?=gettext("You may enter a description here ".
428 8ffadf76 Rafael Lucas
                    "for your reference (not parsed).");?></span></td>
429 5b237745 Scott Ullrich
                </tr>
430 b75d7fd5 Renato Botelho
                <tr>
431 25c1ebd5 N0YB
                  <td width="22%" valign="top" class="vncell"><?=gettext("ARP Table Static Entry");?></td>
432 b75d7fd5 Renato Botelho
                  <td width="78%" class="vtable">
433 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\""; ?> />
434
                    <br /> <span class="vexpl"><?=gettext("Create an ARP Table Static Entry for this MAC &amp; IP Address pair. ".
435 25c1ebd5 N0YB
                    "");?></span></td>
436
                </tr>
437 7309ff39 Renato Botelho
		<tr>
438
		<td width="22%" valign="top" class="vncell"><?=gettext("WINS servers");?></td>
439
		<td width="78%" class="vtable">
440 180db186 Colin Fleming
			<input name="wins1" type="text" class="formfld unknown" id="wins1" size="20" value="<?=htmlspecialchars($pconfig['wins1']);?>" /><br />
441
			<input name="wins2" type="text" class="formfld unknown" id="wins2" size="20" value="<?=htmlspecialchars($pconfig['wins2']);?>" />
442 7309ff39 Renato Botelho
		</td>
443
		</tr>
444
		<tr>
445
		<td width="22%" valign="top" class="vncell"><?=gettext("DNS servers");?></td>
446
		<td width="78%" class="vtable">
447 180db186 Colin Fleming
			<input name="dns1" type="text" class="formfld unknown" id="dns1" size="20" value="<?=htmlspecialchars($pconfig['dns1']);?>" /><br />
448
			<input name="dns2" type="text" class="formfld unknown" id="dns2" size="20" value="<?=htmlspecialchars($pconfig['dns2']);?>" /><br />
449 81af6a08 Phil Davis
			<input name="dns3" type="text" class="formfld unknown" id="dns3" size="20" value="<?=htmlspecialchars($pconfig['dns3']);?>" /><br />
450
			<input name="dns4" type="text" class="formfld unknown" id="dns4" size="20" value="<?=htmlspecialchars($pconfig['dns4']);?>" /><br />
451 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.");?>
452
		</td>
453
		</tr>
454
		<tr>
455
		<td width="22%" valign="top" class="vncell"><?=gettext("Gateway");?></td>
456
		<td width="78%" class="vtable">
457 180db186 Colin Fleming
			<input name="gateway" type="text" class="formfld host" id="gateway" size="20" value="<?=htmlspecialchars($pconfig['gateway']);?>" /><br />
458 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.");?>
459
		</td>
460
		</tr>
461
		<tr>
462
		<td width="22%" valign="top" class="vncell"><?=gettext("Domain name");?></td>
463
		<td width="78%" class="vtable">
464 180db186 Colin Fleming
			<input name="domain" type="text" class="formfld unknown" id="domain" size="20" value="<?=htmlspecialchars($pconfig['domain']);?>" /><br />
465 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.");?>
466
		</td>
467
		</tr>
468
		<tr>
469
		<td width="22%" valign="top" class="vncell"><?=gettext("Domain search list");?></td>
470
		<td width="78%" class="vtable">
471 180db186 Colin Fleming
			<input name="domainsearchlist" type="text" class="formfld unknown" id="domainsearchlist" size="20" value="<?=htmlspecialchars($pconfig['domainsearchlist']);?>" /><br />
472 5aa68a55 Renato Botelho
			<?=gettext("The DHCP server can optionally provide a domain search list. Use the semicolon character as separator ");?>
473 7309ff39 Renato Botelho
		</td>
474
		</tr>
475
		<tr>
476
		<td width="22%" valign="top" class="vncell"><?=gettext("Default lease time");?></td>
477
		<td width="78%" class="vtable">
478 180db186 Colin Fleming
			<input name="deftime" type="text" class="formfld unknown" id="deftime" size="10" value="<?=htmlspecialchars($pconfig['deftime']);?>" />
479 8cd558b6 ayvis
			<?=gettext("seconds");?><br />
480 7309ff39 Renato Botelho
			<?=gettext("This is used for clients that do not ask for a specific " .
481 8cd558b6 ayvis
			"expiration time."); ?><br />
482 7309ff39 Renato Botelho
			<?=gettext("The default is 7200 seconds.");?>
483
		</td>
484
		</tr>
485
		<tr>
486
		<td width="22%" valign="top" class="vncell"><?=gettext("Maximum lease time");?></td>
487
		<td width="78%" class="vtable">
488 180db186 Colin Fleming
			<input name="maxtime" type="text" class="formfld unknown" id="maxtime" size="10" value="<?=htmlspecialchars($pconfig['maxtime']);?>" />
489 8cd558b6 ayvis
			<?=gettext("seconds");?><br />
490 7309ff39 Renato Botelho
			<?=gettext("This is the maximum lease time for clients that ask".
491 8cd558b6 ayvis
			" for a specific expiration time."); ?><br />
492 7309ff39 Renato Botelho
			<?=gettext("The default is 86400 seconds.");?>
493
		</td>
494
		</tr>
495
		<tr>
496
		<td width="22%" valign="top" class="vncell"><?=gettext("Dynamic DNS");?></td>
497
		<td width="78%" class="vtable">
498
			<div id="showddnsbox">
499 264b3ca8 Colin Fleming
				<input type="button" onclick="show_ddns_config()" value="<?=gettext("Advanced");?>" /> - <?=gettext("Show Dynamic DNS");?>
500 7309ff39 Renato Botelho
			</div>
501
			<div id="showddns" style="display:none">
502 180db186 Colin Fleming
				<input style="vertical-align:middle" type="checkbox" value="yes" name="ddnsupdate" id="ddnsupdate" <?php if($pconfig['ddnsupdate']) echo "checked=\"checked\""; ?> />&nbsp;
503 7309ff39 Renato Botelho
				<b><?=gettext("Enable registration of DHCP client names in DNS.");?></b><br />
504
				<p>
505 180db186 Colin Fleming
				<input name="ddnsdomain" type="text" class="formfld unknown" id="ddnsdomain" size="20" value="<?=htmlspecialchars($pconfig['ddnsdomain']);?>" /><br />
506 7309ff39 Renato Botelho
				<?=gettext("Note: Leave blank to disable dynamic DNS registration.");?><br />
507 6b16c91c Phil Davis
				<?=gettext("Enter the dynamic DNS domain which will be used to register client names in the DNS server.");?><br />
508 180db186 Colin Fleming
				<input name="ddnsdomainprimary" type="text" class="formfld unknown" id="ddnsdomainprimary" size="20" value="<?=htmlspecialchars($pconfig['ddnsdomainprimary']);?>" /><br />
509 87019fc4 Andres Petralli
				<?=gettext("Enter the primary domain name server IP address for the dynamic domain name.");?><br />
510 180db186 Colin Fleming
				<input name="ddnsdomainkeyname" type="text" class="formfld unknown" id="ddnsdomainkeyname" size="20" value="<?=htmlspecialchars($pconfig['ddnsdomainkeyname']);?>" /><br />
511 6b16c91c Phil Davis
				<?=gettext("Enter the dynamic DNS domain key name which will be used to register client names in the DNS server.");?><br />
512 180db186 Colin Fleming
				<input name="ddnsdomainkey" type="text" class="formfld unknown" id="ddnsdomainkey" size="20" value="<?=htmlspecialchars($pconfig['ddnsdomainkey']);?>" /><br />
513 87019fc4 Andres Petralli
				<?=gettext("Enter the dynamic DNS domain key secret which will be used to register client names in the DNS server.");?>
514 180db186 Colin Fleming
				</p>
515 7309ff39 Renato Botelho
			</div>
516
		</td>
517
		</tr>
518
		<tr>
519
		<td width="22%" valign="top" class="vncell"><?=gettext("NTP servers");?></td>
520
		<td width="78%" class="vtable">
521
			<div id="showntpbox">
522 264b3ca8 Colin Fleming
				<input type="button" onclick="show_ntp_config()" value="<?=gettext("Advanced");?>" /> - <?=gettext("Show NTP configuration");?>
523 7309ff39 Renato Botelho
			</div>
524
			<div id="showntp" style="display:none">
525 180db186 Colin Fleming
				<input name="ntp1" type="text" class="formfld unknown" id="ntp1" size="20" value="<?=htmlspecialchars($pconfig['ntp1']);?>" /><br />
526
				<input name="ntp2" type="text" class="formfld unknown" id="ntp2" size="20" value="<?=htmlspecialchars($pconfig['ntp2']);?>" />
527 7309ff39 Renato Botelho
			</div>
528
		</td>
529
		</tr>
530
		<tr>
531
		<td width="22%" valign="top" class="vncell"><?=gettext("TFTP server");?></td>
532
		<td width="78%" class="vtable">
533
		<div id="showtftpbox">
534 264b3ca8 Colin Fleming
			<input type="button" onclick="show_tftp_config()" value="<?=gettext("Advanced");?>" /> - <?=gettext("Show TFTP configuration");?>
535 7309ff39 Renato Botelho
		</div>
536
		<div id="showtftp" style="display:none">
537 180db186 Colin Fleming
			<input name="tftp" type="text" class="formfld unknown" id="tftp" size="50" value="<?=htmlspecialchars($pconfig['tftp']);?>" /><br />
538 7309ff39 Renato Botelho
			<?=gettext("Leave blank to disable.  Enter a full hostname or IP for the TFTP server.");?>
539
		</div>
540
		</td>
541
		</tr>
542 b75d7fd5 Renato Botelho
                <tr>
543 5b237745 Scott Ullrich
                  <td width="22%" valign="top">&nbsp;</td>
544 b75d7fd5 Renato Botelho
                  <td width="78%">
545 62424bdb Renato Botelho
                    <input name="Submit" type="submit" class="formbtn" value="<?=gettext("Save");?>" />
546
                    <input type="button" class="formbtn" value="<?=gettext("Cancel");?>" onclick="window.location.href='<?=$referer;?>'" />
547 5b237745 Scott Ullrich
                    <?php if (isset($id) && $a_maps[$id]): ?>
548 180db186 Colin Fleming
                    <input name="id" type="hidden" value="<?=htmlspecialchars($id);?>" />
549 5b237745 Scott Ullrich
                    <?php endif; ?>
550 180db186 Colin Fleming
                    <input name="if" type="hidden" value="<?=htmlspecialchars($if);?>" />
551 5b237745 Scott Ullrich
                  </td>
552
                </tr>
553
              </table>
554
</form>
555
<?php include("fend.inc"); ?>
556
</body>
557 b75d7fd5 Renato Botelho
</html>