Patching GnuDIP 2.3.5 for IPv6

GnuDIP 2.3.5 is designed for IPv4 and it does not support IPv6 interface on the server which run inetd. Below is my patch to make it work with IPv6 interface.

--- gdipinet.pl.orig    2007-01-17 09:09:44.000000000 +0700
+++ gdipinet.pl 2007-01-17 08:46:30.000000000 +0700
@@ -17,6 +17,7 @@
 use Getopt::Std;
 use POSIX qw(strftime);
 use Socket;
+use Socket6;

 # global variables
 use vars qw($conf $gnudipdir $logger $ip);
@@ -106,8 +107,11 @@
   print "$msg\n";
   exit;
 }
-my ($port, $packed_ip) = sockaddr_in($client_addr);
-$ip = inet_ntoa($packed_ip);
+#my ($port, $packed_ip) = sockaddr_in($client_addr);
+my ($port, $packed_ip) = sockaddr_in6($client_addr);
+#$ip = inet_ntoa($packed_ip);
+$ip = inet_ntop(AF_INET6, $packed_ip);
+$ip =~ s/::ffff://;

 # flush after each print
 select(STDOUT);

Tags: , , ,

Post new comment