Bug fixes to rfc2553 emulation
authorArch Librarian <arch@canonical.com>
Mon, 20 Sep 2004 16:56:08 +0000 (16:56 +0000)
committerArch Librarian <arch@canonical.com>
Mon, 20 Sep 2004 16:56:08 +0000 (16:56 +0000)
Author: jgg
Date: 2000-06-18 06:04:45 GMT
Bug fixes to rfc2553 emulation

methods/rfc2553emu.cc
methods/rfc2553emu.h

index 05d9f0c..22daa22 100644 (file)
@@ -1,6 +1,6 @@
 // -*- mode: cpp; mode: fold -*-
 // Description                                                         /*{{{*/
-// $Id: rfc2553emu.cc,v 1.6 1999/12/11 02:11:10 jgg Exp $
+// $Id: rfc2553emu.cc,v 1.7 2000/06/18 06:04:45 jgg Exp $
 /* ######################################################################
 
    RFC 2553 Emulation - Provides emulation for RFC 2553 getaddrinfo,
@@ -202,9 +202,9 @@ int getnameinfo(const struct sockaddr *sa, socklen_t salen,
       {
         struct servent *Ent;
         if ((flags & NI_DATAGRAM) == NI_DATAGRAM)
-           Ent = getservbyport(sin->sin_port,"udp");
+           Ent = getservbyport(ntohs(sin->sin_port),"udp");
         else
-           Ent = getservbyport(sin->sin_port,"tcp");
+           Ent = getservbyport(ntohs(sin->sin_port),"tcp");
         
         if (Ent != 0)
            strncpy(serv,Ent->s_name,servlen);
@@ -220,7 +220,7 @@ int getnameinfo(const struct sockaddr *sa, socklen_t salen,
       // Resolve as a plain numberic
       if ((flags & NI_NUMERICSERV) == NI_NUMERICSERV)
       {
-        snprintf(serv,servlen,"%u",sin->sin_port);
+        snprintf(serv,servlen,"%u",ntohs(sin->sin_port));
       }
    }
    
index 86765b3..b15facb 100644 (file)
@@ -1,6 +1,6 @@
 // -*- mode: cpp; mode: fold -*-
 // Description                                                         /*{{{*/
-// $Id: rfc2553emu.h,v 1.3 1999/12/10 07:21:52 jgg Exp $
+// $Id: rfc2553emu.h,v 1.4 2000/06/18 06:04:45 jgg Exp $
 /* ######################################################################
 
    RFC 2553 Emulation - Provides emulation for RFC 2553 getaddrinfo,
   #define EAI_MEMORY     -11
   #endif
 
+  /* If we don't have getaddrinfo then we probably don't have 
+     sockaddr_storage either (same RFC) so we definately will not be
+     doing any IPv6 stuff. Do not use the members of this structure to
+     retain portability, cast to a sockaddr. */
+  #define sockaddr_storage sockaddr_in
 #endif
 
 // getnameinfo support (glibc2.0 has getaddrinfo only)
   #define NI_DATAGRAM (1<<4)
   #endif
 
+  #define sockaddr_storage sockaddr_in
+#endif
+
+// Glibc 2.0.7 misses this one
+#ifndef AI_NUMERICHOST
+#define AI_NUMERICHOST 0
 #endif
 
 #endif