]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
fix up printing of %eth0 scope in ComboAddress::toStringWithPort
authorBert Hubert <bert.hubert@netherlabs.nl>
Mon, 14 Feb 2011 14:57:11 +0000 (14:57 +0000)
committerBert Hubert <bert.hubert@netherlabs.nl>
Mon, 14 Feb 2011 14:57:11 +0000 (14:57 +0000)
git-svn-id: svn://svn.powerdns.com/pdns/trunk/pdns@2018 d19b8d6e-7fed-0310-83ef-9ca221ded41b

pdns/iputils.hh
pdns/nameserver.cc
pdns/tcpreceiver.cc

index 3af1dacda2e21c302acccea1d3eb451aa7688b44..8e840c2730581fbd5ec9a1b3f40705a35f41f4fa 100644 (file)
@@ -32,6 +32,9 @@
 #include <functional>
 #include "ahuexception.hh"
 #include "misc.hh"
+#include <sys/socket.h>
+#include <netdb.h>
+
 #include <boost/tuple/tuple.hpp>
 #include <boost/tuple/tuple_comparison.hpp>
 #include <boost/lexical_cast.hpp>
@@ -158,14 +161,10 @@ union ComboAddress {
 
   string toString() const
   {
-    char tmp[128];
-    if(sin4.sin_family==AF_INET && !Utility::inet_ntop(AF_INET, ( const char * ) &sin4.sin_addr, tmp, sizeof(tmp)))
-      return tmp;
-
-    if(sin4.sin_family==AF_INET6 && !Utility::inet_ntop(AF_INET6, ( const char * ) &sin6.sin6_addr, tmp, sizeof(tmp)))
-      return tmp;
+    char host[1024];
+    getnameinfo((struct sockaddr*) this, getSocklen(), host, sizeof(host),0, 0, NI_NUMERICHOST);
       
-    return tmp;
+    return host;
   }
 
   string toStringWithPort() const
index d6c3203f128152adb3ccadd86f265a3589729ac0..5c71b52e632b29a07d1900cf0006c50087596861 100644 (file)
@@ -156,7 +156,7 @@ void UDPNameserver::bindIPv6()
     }
     d_highfd=max(s,d_highfd);
     d_sockets.push_back(s);
-    L<<Logger::Error<<"UDPv6 server bound to ["<<localname<<"]:"<<::arg().asNum("local-port")<<endl;
+    L<<Logger::Error<<"UDPv6 server bound to "<<locala.toStringWithPort()<<endl;
     FD_SET(s, &d_rfds);
   }
 #endif // WIN32
index 151acb038d8bae083469a0893b8eb01010289a9c..789802da405e825054cb60a23ba5060c50115c10 100644 (file)
@@ -738,7 +738,7 @@ TCPNameserver::TCPNameserver()
     }
     
     listen(s,128);
-    L<<Logger::Error<<"TCPv6 server bound to "<<local.toStringWithPort()<<endl;
+    L<<Logger::Error<<"TCPv6 server bound to "<<local.toStringWithPort()<<endl; // this gets %eth0 right
     d_sockets.push_back(s);
 
     struct pollfd pfd;