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()