/[pxelator]/bin/tftpd.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/tftpd.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 13 by dpavlin, Mon Jul 27 22:25:06 2009 UTC
# Line 6  use Net::TFTPd 0.03 qw(%OPCODES); Line 6  use Net::TFTPd 0.03 qw(%OPCODES);
6  die "need to run $0 as root like this\nsudo $0\n" unless $< == 0;  die "need to run $0 as root like this\nsudo $0\n" unless $< == 0;
7    
8  # change ROOTDIR to your TFTP root directory  # change ROOTDIR to your TFTP root directory
9  my $rootdir = $ARGV[0] || 'tftp';  my $rootdir = 'conf/' . readlink('conf/tftp.dir');
10    $rootdir =~ s{[^/]+/\.\./([^/]+)}{$1};
11    
12  unless(-d $rootdir)  unless(-d $rootdir)
13  {  {
14          print "\nUsage: $0 path/to/rootdir\n\n";          print "$rootdir isn't directory!\nUsage: $0 path/to/rootdir\n\n";
15          exit 1;          exit 1;
16  }  }
17    
# Line 27  sub callback Line 28  sub callback
28          {          {
29                  # WRQ                  # WRQ
30                  printf "block: %u\/%u\n", $req->{'_REQUEST_'}{'LASTBLK'}, $req->{'_REQUEST_'}{'LASTACK'};                  printf "block: %u\/%u\n", $req->{'_REQUEST_'}{'LASTBLK'}, $req->{'_REQUEST_'}{'LASTACK'};
31            } else {
32                    warn "IGNORED: ", dump( $req );
33          }          }
34  }  }
35    
# Line 42  my $listener = Net::TFTPd->new( Line 45  my $listener = Net::TFTPd->new(
45          BlkSize => 1456,        # IBM GE seems to be picky          BlkSize => 1456,        # IBM GE seems to be picky
46          Debug => 99,          Debug => 99,
47  ) or die Net::TFTPd->error;  ) or die Net::TFTPd->error;
48  printf "TFTP listener is bound to %s:%d\nTFTP listener is waiting %d seconds for a request\n", $listener->{'LocalAddr'} ? $listener->{'LocalAddr'} : "'any address'",  $listener->{'LocalPort'}, $listener->{'Timeout'};  printf "TFTP %s:%d [timeout %d s] $rootdir\n", $listener->{'LocalAddr'} ? $listener->{'LocalAddr'} : "'any address'",  $listener->{'LocalPort'}, $listener->{'Timeout'};
49    
50  while(1) {  while(1) {
51    

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

  ViewVC Help
Powered by ViewVC 1.1.26