Skip Menu |

This queue is for tickets about the Net-TFTPd CPAN distribution.

Report information
The Basics
Id: 79873
Status: resolved
Priority: 0/
Queue: Net-TFTPd

People
Owner: Nobody in particular
Requestors: VINSWORLD [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 0.04-withoutworldwriteables
Fixed in: (no value)



Subject: IPv6 Support - with patch!
This isn't a bug as much as a feature request. I sent you a patch a few years back about support for NetASCII which you were quick to incorporate - thanks! Now, IPv6 support would be nice. I have a quick patch to address this using the IO::Socket::IP module instead of IO::Socket. This will use IPv4 as the default to maintain backward compatibility, but adds the "Family" option under the new() method to select IPv4 or IPv6. I also added an accessor called server() to return the local server IO::Socket::IP object created. This way a user can call that and use the IO::Socket::IP accessors like local IP and port to print at status message - something like: Listening on 1.1.1.1:69. Patch attached. cheers, Vince.
Subject: TFTPd.patch
--- TFTPd.pm Tue Jul 07 16:29:41 2009 +++ TFTPd.pm Wed Sep 26 21:53:44 2012 @@ -4,7 +4,7 @@ use Carp; use strict; use warnings; -use IO::Socket; +use IO::Socket::IP -register; require Exporter; @@ -125,13 +125,29 @@ 'LocalPort' => $cfg{'LocalPort'} || TFTP_DEFAULT_PORT, ); + if (defined($cfg{'Family'})) { + if ($cfg{'Family'} =~ /^[46]$/) { + if ($cfg{'Family'} == 4) { + $params{'Family'} = AF_INET + } else { + $params{'Family'} = AF_INET6 + } + } else { + $LASTERROR = "Invalid family - $cfg{'Family'}"; + return(undef) + } + # Default to IPv4 for backward compatibility + } else { + $params{'Family'} = AF_INET + } + # bind only to specified address if($cfg{'LocalAddr'}) { $params{'LocalAddr'} = $cfg{'LocalAddr'}; } - if(my $udpserver = IO::Socket::INET->new(%params)) + if(my $udpserver = IO::Socket::IP->new(%params)) { #removed for using this module with IO v. 1.2301 under SUSE 10.1, O.Z. 15.08.2007 # $udpserver->setsockopt(SOL_SOCKET, SO_RCVBUF, 0); @@ -203,9 +219,8 @@ $request->{'_REQUEST_'}{'OPCODE'} = $opcode; # get peer port and address - my($peerport, $peeraddr) = sockaddr_in($udpserver->peername); - $request->{'_REQUEST_'}{'PeerPort'} = $peerport; - $request->{'_REQUEST_'}{'PeerAddr'} = inet_ntoa($peeraddr); + $request->{'_REQUEST_'}{'PeerPort'} = $udpserver->peerport; + $request->{'_REQUEST_'}{'PeerAddr'} = $udpserver->peerhost; # get filename and transfer mode my @datain = split("\0", $datain); @@ -504,7 +519,7 @@ } # open socket - if(my $udpserver = IO::Socket::INET->new(%params)) + if(my $udpserver = IO::Socket::IP->new(%params)) { #removed for using this module with IO v. 1.2301 under SUSE 10.1, O.Z. 15.08.2007 # $udpserver->setsockopt(SOL_SOCKET, SO_RCVBUF, 0); @@ -1176,6 +1191,11 @@ } } +sub server { + my $self = shift; + return $self->{'_UDPSERVER_'} +} + sub error { return($LASTERROR); @@ -1260,6 +1280,7 @@ ------ ----------- ------- LocalAddr Interface to bind to (for multi-homed server) any LocalPort Port to bind server to 69 + Family Address family IPv4/IPv6 given as integer 4 or 6 4 Timeout Timeout in seconds to wait for a request 10 ACKtimeout Timeout in seconds to wait for an ACK packet 4 ACKretries Maximum number of retries waiting for ACK 4 @@ -1322,6 +1343,13 @@ $ret = $request->getBlkSize(); Returns the block size used for the transfer. + +=head2 server() + + $ret = $syslogd->server(); + +Return IO::Socket::IP object for the created server. +All IO::Socket::IP accessors can then be called. =head2 getPeerAddr()
After some more experimenting, we have a better patch that allows for conditional use of IO::Socket::IP and falls back to IO::Socket::INET (IPv4 only) for systems with older Socket modules - that don't support IPv6. The new patch is attached. cheers. On Wed Sep 26 22:03:01 2012, VINSWORLD wrote: Show quoted text
> This isn't a bug as much as a feature request. I sent you a patch a
few Show quoted text
> years back about support for NetASCII which you were quick to > incorporate - thanks! > > Now, IPv6 support would be nice. I have a quick patch to address this > using the IO::Socket::IP module instead of IO::Socket. This will use > IPv4 as the default to maintain backward compatibility, but adds the > "Family" option under the new() method to select IPv4 or IPv6. I also > added an accessor called server() to return the local server > IO::Socket::IP object created. This way a user can call that and use > the IO::Socket::IP accessors like local IP and port to print at status > message - something like: > > Listening on 1.1.1.1:69. > > Patch attached. > > cheers, > > Vince.
Subject: TFTPd.patch
--- TFTPd.pm Tue Oct 09 20:17:22 2012 +++ TFTPd.pm Tue Oct 09 20:52:07 2012 @@ -4,7 +4,14 @@ use Carp; use strict; use warnings; -use IO::Socket; +use Socket qw(AF_INET AF_INET6 SO_ERROR); +my $HAVE_IO_Socket_IP = 0; +eval "use IO::Socket::IP -register"; +if(!$@) { + $HAVE_IO_Socket_IP = 1; +} else { + eval "use IO::Socket::INET" +} require Exporter; @@ -125,12 +132,58 @@ 'LocalPort' => $cfg{'LocalPort'} || TFTP_DEFAULT_PORT, ); - # bind only to specified address + if (defined($cfg{'Family'})) { + if ($cfg{'Family'} =~ /^(?:(?:(:?ip)?v?(?:4|6))|${\AF_INET}|${\AF_INET6})$/) { + if ($cfg{'Family'} =~ /^(?:(?:(:?ip)?v?4)|${\AF_INET})$/) { + $params{'Family'} = AF_INET + } else { + if (!$HAVE_IO_Socket_IP) { + $LASTERROR = "IO::Socket::IP required for IPv6"; + return(undef) + } + $params{'Family'} = AF_INET6 + } + } else { + $LASTERROR = "Invalid family - $cfg{'Family'}"; + return(undef) + } + } else { + $params{'Family'} = AF_INET + } + + # bind only to specified address if($cfg{'LocalAddr'}) { $params{'LocalAddr'} = $cfg{'LocalAddr'}; } + if ($HAVE_IO_Socket_IP) { + if(my $udpserver = IO::Socket::IP->new(%params)) + { +#removed for using this module with IO v. 1.2301 under SUSE 10.1, O.Z. 15.08.2007 +# $udpserver->setsockopt(SOL_SOCKET, SO_RCVBUF, 0); +# $udpserver->setsockopt(SOL_SOCKET, SO_SNDBUF, 0); + + return bless { + 'LocalPort' => TFTP_DEFAULT_PORT, + 'Timeout' => 10, + 'ACKtimeout' => 4, + 'ACKretries' => 4, + 'Readable' => 1, + 'Writable' => 0, + 'CallBack' => undef, + 'BlkSize' => TFTP_DEFAULT_BLKSIZE, + 'Debug' => 0, + %cfg, # merge user parameters + '_UDPSERVER_' => $udpserver + }, $class; + } + else + { + $LASTERROR = "Error opening socket for listener: $@\n"; + return(undef); + } + } else { if(my $udpserver = IO::Socket::INET->new(%params)) { #removed for using this module with IO v. 1.2301 under SUSE 10.1, O.Z. 15.08.2007 @@ -156,6 +209,7 @@ $LASTERROR = "Error opening socket for listener: $@\n"; return(undef); } + } } # @@ -203,9 +257,8 @@ $request->{'_REQUEST_'}{'OPCODE'} = $opcode; # get peer port and address - my($peerport, $peeraddr) = sockaddr_in($udpserver->peername); - $request->{'_REQUEST_'}{'PeerPort'} = $peerport; - $request->{'_REQUEST_'}{'PeerAddr'} = inet_ntoa($peeraddr); + $request->{'_REQUEST_'}{'PeerPort'} = $udpserver->peerport; + $request->{'_REQUEST_'}{'PeerAddr'} = $udpserver->peerhost; # get filename and transfer mode my @datain = split("\0", $datain); @@ -504,6 +557,22 @@ } # open socket + if ($HAVE_IO_Socket_IP) { + if(my $udpserver = IO::Socket::IP->new(%params)) + { +#removed for using this module with IO v. 1.2301 under SUSE 10.1, O.Z. 15.08.2007 +# $udpserver->setsockopt(SOL_SOCKET, SO_RCVBUF, 0); +# $udpserver->setsockopt(SOL_SOCKET, SO_SNDBUF, 0); + + $self->{'_UDPSERVER_'} = $udpserver; + return(1); + } + else + { + $LASTERROR = "Error opening socket for reply: $@\n"; + return(undef); + } + } else { if(my $udpserver = IO::Socket::INET->new(%params)) { #removed for using this module with IO v. 1.2301 under SUSE 10.1, O.Z. 15.08.2007 @@ -518,6 +587,7 @@ $LASTERROR = "Error opening socket for reply: $@\n"; return(undef); } + } } @@ -1176,6 +1246,11 @@ } } +sub server { + my $self = shift; + return $self->{'_UDPSERVER_'} +} + sub error { return($LASTERROR); @@ -1268,6 +1343,14 @@ BlkSize Minimum blocksize to negotiate for transfers 512 CallBack Reference to code executed for each transferred block - Debug Activates debug mode (verbose) 0 + Family Address family IPv4/IPv6 IPv4 + Valid values for IPv4: + 4, v4, ip4, ipv4, AF_INET (constant) + Valid values for IPv6: + 6, v6, ip6, ipv6, AF_INET6 (constant) + +B<NOTE>: IPv6 requires B<IO::Socket::IP>. Failback is B<IO::Socket::INET> +and only IPv4 support. =head2 CallBack @@ -1322,6 +1405,13 @@ $ret = $request->getBlkSize(); Returns the block size used for the transfer. + +=head2 server() + + $ret = $syslogd->server(); + +Return B<IO::Socket::*> object for the created server. +All B<IO::Socket::*> accessors can then be called. =head2 getPeerAddr()
Subject: RE: [rt.cpan.org #79873] IPv6 Support - with patch!
Date: Thu, 11 Oct 2012 15:23:48 +0200
To: <bug-Net-TFTPd [...] rt.cpan.org>
From: Luigino Masarati <lmasarati [...] hotmail.com>
Thanks Michael, I uploaded the patched version as 0.05. Regards. Luigino. Show quoted text
-----Original Message----- From: Michael Vincent via RT [mailto:bug-Net-TFTPd@rt.cpan.org] Sent: Wednesday, 10 October, 2012 03:08 To: undisclosed-recipients: Subject: [rt.cpan.org #79873] IPv6 Support - with patch! Queue: Net-TFTPd Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=79873 > After some more experimenting, we have a better patch that allows for conditional use of IO::Socket::IP and falls back to IO::Socket::INET (IPv4 only) for systems with older Socket modules - that don't support IPv6. The new patch is attached. cheers. On Wed Sep 26 22:03:01 2012, VINSWORLD wrote:
> This isn't a bug as much as a feature request. I sent you a patch a
few
> years back about support for NetASCII which you were quick to > incorporate - thanks! > > Now, IPv6 support would be nice. I have a quick patch to address this > using the IO::Socket::IP module instead of IO::Socket. This will use > IPv4 as the default to maintain backward compatibility, but adds the > "Family" option under the new() method to select IPv4 or IPv6. I also > added an accessor called server() to return the local server > IO::Socket::IP object created. This way a user can call that and use > the IO::Socket::IP accessors like local IP and port to print at status > message - something like: > > Listening on 1.1.1.1:69. > > Patch attached. > > cheers, > > Vince.
Subject: Re: [rt.cpan.org #79873] IPv6 Support - with patch!
Date: Thu, 11 Oct 2012 09:42:51 -0400
To: bug-Net-TFTPd [...] rt.cpan.org
From: Vince <vin [...] vinsworld.com>
Thanks Luigino for the quick turnaround. We have an IPv6 lab and need to backup router configs. Of course, with only IPv6 running, we needed an IPv6 TFTP server. I quickly hacked your Net::TFTPd module to work for us and when it was looking good / stable, I sent the patch. Thanks again for supporting the Perl community; we now have version 0.05 official installed and the first test ran brilliant! Just FYI, we're using Windows 7 and Strawberry Perl 5.16. But I also just tested with Strawberry 5.8 (doesn't support IPv6 due to older Socket module) and the failure was graceful - printing the "IO::Socket::IP required for IPv6" error message. A TFTP to / from the local host with version Perl 5.8 and Net::TFTPd 0.05 worked fine over IPv4 - so looks like backward compatibility is maintained. cheers. On Thu, Oct 11, 2012 at 9:23 AM, Luigino Masarati via RT <bug-Net-TFTPd@rt.cpan.org> wrote: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=79873 > > > Thanks Michael, > I uploaded the patched version as 0.05. > Regards. > Luigino. > > -----Original Message----- > From: Michael Vincent via RT [mailto:bug-Net-TFTPd@rt.cpan.org] > Sent: Wednesday, 10 October, 2012 03:08 > To: undisclosed-recipients: > Subject: [rt.cpan.org #79873] IPv6 Support - with patch! > > Queue: Net-TFTPd > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=79873 > > > After some more experimenting, we have a better patch that allows for conditional use of IO::Socket::IP and falls back to IO::Socket::INET > (IPv4 only) for systems with older Socket modules - that don't support IPv6. > > The new patch is attached. > > cheers. > > > On Wed Sep 26 22:03:01 2012, VINSWORLD wrote:
>> This isn't a bug as much as a feature request. I sent you a patch a
> few
>> years back about support for NetASCII which you were quick to >> incorporate - thanks! >> >> Now, IPv6 support would be nice. I have a quick patch to address this >> using the IO::Socket::IP module instead of IO::Socket. This will use >> IPv4 as the default to maintain backward compatibility, but adds the >> "Family" option under the new() method to select IPv4 or IPv6. I also >> added an accessor called server() to return the local server >> IO::Socket::IP object created. This way a user can call that and use >> the IO::Socket::IP accessors like local IP and port to print at status >> message - something like: >> >> Listening on 1.1.1.1:69. >> >> Patch attached. >> >> cheers, >> >> Vince.
> > > > >
Subject: RE: [rt.cpan.org #79873] IPv6 Support - with patch!
Date: Thu, 11 Oct 2012 16:27:11 +0200
To: <bug-Net-TFTPd [...] rt.cpan.org>
From: Luigino Masarati <lmasarati [...] hotmail.com>
Thanks Vince, I'm glad that soemone is still using Net-TFTPd, it was part of a bigger project we developed for one of our customer that now is not used anymore. Since you're still using (or better, maintaining) it, I've added you as a "co-maint" on PAUSE site. Regards. Luigino. Show quoted text
-----Original Message----- From: vinsworldcom via RT [mailto:bug-Net-TFTPd@rt.cpan.org] Sent: Thursday, 11 October, 2012 15:43 To: undisclosed-recipients: Subject: Re: [rt.cpan.org #79873] IPv6 Support - with patch! Queue: Net-TFTPd Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=79873 > Thanks Luigino for the quick turnaround. We have an IPv6 lab and need to backup router configs. Of course, with only IPv6 running, we needed an IPv6 TFTP server. I quickly hacked your Net::TFTPd module to work for us and when it was looking good / stable, I sent the patch. Thanks again for supporting the Perl community; we now have version 0.05 official installed and the first test ran brilliant! Just FYI, we're using Windows 7 and Strawberry Perl 5.16. But I also just tested with Strawberry 5.8 (doesn't support IPv6 due to older Socket module) and the failure was graceful - printing the "IO::Socket::IP required for IPv6" error message. A TFTP to / from the local host with version Perl 5.8 and Net::TFTPd 0.05 worked fine over IPv4 - so looks like backward compatibility is maintained. cheers. On Thu, Oct 11, 2012 at 9:23 AM, Luigino Masarati via RT <bug-Net-TFTPd@rt.cpan.org> wrote:
> <URL: https://rt.cpan.org/Ticket/Display.html?id=79873 > > > Thanks Michael, > I uploaded the patched version as 0.05. > Regards. > Luigino. > > -----Original Message----- > From: Michael Vincent via RT [mailto:bug-Net-TFTPd@rt.cpan.org] > Sent: Wednesday, 10 October, 2012 03:08 > To: undisclosed-recipients: > Subject: [rt.cpan.org #79873] IPv6 Support - with patch! > > Queue: Net-TFTPd > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=79873 > > > After some more experimenting, we have a better patch that allows for > conditional use of IO::Socket::IP and falls back to IO::Socket::INET > (IPv4 only) for systems with older Socket modules - that don't support IPv6. > > The new patch is attached. > > cheers. > > > On Wed Sep 26 22:03:01 2012, VINSWORLD wrote:
>> This isn't a bug as much as a feature request. I sent you a patch a
> few
>> years back about support for NetASCII which you were quick to >> incorporate - thanks! >> >> Now, IPv6 support would be nice. I have a quick patch to address >> this using the IO::Socket::IP module instead of IO::Socket. This >> will use >> IPv4 as the default to maintain backward compatibility, but adds the >> "Family" option under the new() method to select IPv4 or IPv6. I >> also added an accessor called server() to return the local server >> IO::Socket::IP object created. This way a user can call that and use >> the IO::Socket::IP accessors like local IP and port to print at >> status message - something like: >> >> Listening on 1.1.1.1:69. >> >> Patch attached. >> >> cheers, >> >> Vince.
> > > > >
Resolved with patch from VINSWORLD in version 0.05