31 |
|
|
32 |
my $_ip = 10; |
my $_ip = 10; |
33 |
my $_mac2ip; |
my $_mac2ip; |
|
my $_ip_file; |
|
34 |
|
|
35 |
sub client_ip { |
sub client_ip { |
36 |
my ( $mac ) = @_; |
my ( $mac ) = @_; |
38 |
my $ip = $_mac2ip->{$mac}; |
my $ip = $_mac2ip->{$mac}; |
39 |
return $ip if $ip; |
return $ip if $ip; |
40 |
|
|
41 |
$ip = "10.0.0.$_ip"; |
$ip = $server_ip; |
42 |
|
$ip =~ s{\.\d+$}{.$_ip}; |
43 |
$_mac2ip->{$mac} = $ip; |
$_mac2ip->{$mac} = $ip; |
44 |
|
|
45 |
$_ip++; |
$_ip++; |
73 |
my $mac = substr($dhcp->chaddr(),0,$dhcp->hlen()*2); |
my $mac = substr($dhcp->chaddr(),0,$dhcp->hlen()*2); |
74 |
my $ip = client_ip($mac); |
my $ip = client_ip($mac); |
75 |
|
|
76 |
|
my $file = $next_file; |
77 |
|
$file = 'undionly.kpxe' if ! $file || $dhcp->getOptionValue(DHO_USER_CLASS()) ne 'gPXE'; |
78 |
|
|
79 |
my $packet = new Net::DHCP::Packet( |
my $packet = new Net::DHCP::Packet( |
80 |
Op => BOOTREPLY(), |
Op => BOOTREPLY(), |
81 |
Hops => $dhcp->hops(), |
Hops => $dhcp->hops(), |
86 |
Siaddr => $server_ip, |
Siaddr => $server_ip, |
87 |
Giaddr => $dhcp->giaddr(), |
Giaddr => $dhcp->giaddr(), |
88 |
Chaddr => $dhcp->chaddr(), |
Chaddr => $dhcp->chaddr(), |
89 |
File => $_ip_file->{$ip} || 'undionly.kpxe', |
File => $file, |
90 |
# DHO_DHCP_MESSAGE_TYPE() => DHCPACK(), |
# DHO_DHCP_MESSAGE_TYPE() => DHCPACK(), |
91 |
DHO_SUBNET_MASK() => '255.0.0.0', |
DHO_SUBNET_MASK() => '255.0.0.0', |
92 |
); |
); |
93 |
|
|
|
$_ip_file->{$ip} = $next_file; |
|
|
|
|
94 |
warn ">> $mac == $ip server $server_ip\n"; |
warn ">> $mac == $ip server $server_ip\n"; |
95 |
|
|
96 |
warn "## ",$packet->toString(),"\n" if $debug; |
warn "## ",$packet->toString(),"\n" if $debug; |