# Returns a list of DHCP host structures for managed hosts
sub list_dhcp_hosts
{
+local $conf = &dhcpd::get_config();
+local $parent = &dhcpd::get_parent_config();
+local @rv;
+foreach my $h (&dhcpd::find("host", $conf)) {
+ $h->{'parent'} = $parent;
+ push(@rv, $h);
+ }
+foreach my $g (&dhcpd::find("group", $conf)) {
+ foreach my $h (&dhcpd::find("host", $g->{'members'})) {
+ $h->{'parent'} = $g;
+ push(@rv, $h);
+ }
+ }
+foreach my $s (&dhcpd::find("subnet", $conf)) {
+ foreach my $h (&dhcpd::find("host", $s->{'members'})) {
+ $h->{'parent'} = $s;
+ push(@rv, $h);
+ }
+ foreach my $g (&dhcpd::find("group", $s->{'members'})) {
+ foreach my $h (&dhcpd::find("host", $g->{'members'})) {
+ $h->{'parent'} = $g;
+ push(@rv, $h);
+ }
+ }
+ }
+return @rv;
}
# host_form([&host])
# Hostname
local $short = &short_hostname($h->{'values'}->[0]);
-local $indom = $new || $short eq $h->{'values'}->[0];
+local $indom = $new || $short ne $h->{'values'}->[0];
$rv .= &ui_table_row($text{'form_host'},
- &ui_textbox("host", $short, 40).
+ &ui_textbox("host", $short, 20).
($indom ? "<tt>.$config{'domain'}</tt>" : ""));
$rv .= &ui_hidden("indom", 1);
# MAC address
local $hard = &dhcpd::find("hardware", $h->{'members'});
$rv .= &ui_table_row($text{'form_mac'},
- &ui_textbox("mac", $hard ? $hard->{'values'}->[0] : undef, 20));
+ &ui_select("media", $hard ? $hard->{'values'}->[0] : "ethernet",
+ [ [ "ethernet", $text{'form_ethernet'} ],
+ [ "token-ring", $text{'form_tr'} ],
+ [ "fddi", $text{'form_fddi'} ] ], 1, 0, 1).
+ &ui_textbox("mac", $hard ? $hard->{'values'}->[1] : undef, 20));
$rv .= &ui_table_end();
if ($new) {
# Show hosts, if any
@hosts = &list_dhcp_hosts();
-@links = ( "<a href='edit.cgi?new=1'>$text{'index_add'}</a>" );
if (@hosts) {
@tds = ( "width=5" );
print &ui_form_start("delete.cgi");
@links = ( &select_all_link("d", 1),
- &select_invert_link("d", 1),
- @links );
+ &select_invert_link("d", 1) );
print &ui_links_row(\@links);
print &ui_columns_start([ "",
$text{'index_host'},
$fixed = &dhcpd::find("fixed-address", $h->{'members'});
$hard = &dhcpd::find("hardware", $h->{'members'});
print &ui_checked_columns_row([
- &html_escape(&short_hostname($h->{'values'}->[0])),
+ "<a href='edit.cgi?host=".&urlize($h->{'values'}->[0]).
+ "'>".
+ &html_escape(&short_hostname($h->{'values'}->[0])).
+ "</a>",
$fixed ? $fixed->{'values'}->[0] : undef,
- $hard ? $hard->{'values'}->[0] : undef,
+ $hard ? $hard->{'values'}->[1] : undef,
], \@tds, "d", $h->{'values'}->[0])
}
print &ui_columns_end();