/[pxelator]/bin/dhcpd.pl
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /bin/dhcpd.pl

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1 by dpavlin, Sun Jul 26 00:38:57 2009 UTC revision 6 by dpavlin, Sun Jul 26 15:16:52 2009 UTC
# Line 14  die "need to run $0 as root like this\ns Line 14  die "need to run $0 as root like this\ns
14    
15  my $debug = shift @ARGV;  my $debug = shift @ARGV;
16    
17  my $ip_server = '10.0.0.100';  our ( $server_ip, $next_file );
18    require "config.pl";
19    
20  my $sock = IO::Socket::INET->new(  my $sock = IO::Socket::INET->new(
21          LocalPort       => 67,          LocalPort       => 67,
# Line 71  while (1) { Line 72  while (1) {
72                  my $mac = substr($dhcp->chaddr(),0,$dhcp->hlen()*2);                  my $mac = substr($dhcp->chaddr(),0,$dhcp->hlen()*2);
73                  my $ip = client_ip($mac);                  my $ip = client_ip($mac);
74    
75                    my $file =  $next_file;
76                    $file = 'undionly.kpxe' if ! $file || $dhcp->getOptionValue(DHO_USER_CLASS()) ne 'gPXE';
77    
78                  my $packet = new Net::DHCP::Packet(                  my $packet = new Net::DHCP::Packet(
79                          Op              => BOOTREPLY(),                          Op              => BOOTREPLY(),
80                          Hops    => $dhcp->hops(),                          Hops    => $dhcp->hops(),
# Line 78  while (1) { Line 82  while (1) {
82                          Flags   => $dhcp->flags(),                          Flags   => $dhcp->flags(),
83                          Ciaddr  => $dhcp->ciaddr(),                          Ciaddr  => $dhcp->ciaddr(),
84                          Yiaddr  => $ip,                          Yiaddr  => $ip,
85                          Siaddr  => $ip_server,                          Siaddr  => $server_ip,
86                          Giaddr  => $dhcp->giaddr(),                          Giaddr  => $dhcp->giaddr(),
87                          Chaddr  => $dhcp->chaddr(),                          Chaddr  => $dhcp->chaddr(),
88                          File    => 'undionly.kpxe',                          File    => $file,
89  #                       DHO_DHCP_MESSAGE_TYPE() => DHCPACK(),  #                       DHO_DHCP_MESSAGE_TYPE() => DHCPACK(),
90                  DHO_SUBNET_MASK() => '255.0.0.0',                  DHO_SUBNET_MASK() => '255.0.0.0',
91                  );                  );
92    
93                  warn ">> $mac == $ip server $ip_server\n";                  warn ">> $mac == $ip server $server_ip\n";
94                                    
95                  warn "## ",$packet->toString(),"\n" if $debug;                  warn "## ",$packet->toString(),"\n" if $debug;
96    
97                  my $reply = IO::Socket::INET->new(                  my $reply = IO::Socket::INET->new(
98                          LocalAddr => $ip_server,                          LocalAddr => $server_ip,
99                          LocalPort => 67,                          LocalPort => 67,
100                          Proto => "udp",                          Proto => "udp",
101                          Broadcast => 1,                          Broadcast => 1,

Legend:
Removed from v.1  
changed lines
  Added in v.6

  ViewVC Help
Powered by ViewVC 1.1.26