(file) Return to HostAddress.cpp CVS log (file) (dir) Up to [Pegasus] / pegasus / src / Pegasus / Common

Diff for /pegasus/src/Pegasus/Common/HostAddress.cpp between version 1.1.2.1 and 1.1.2.2

version 1.1.2.1, 2007/06/08 10:43:20 version 1.1.2.2, 2007/06/12 09:31:58
Line 31 
Line 31 
 // //
 //%///////////////////////////////////////////////////////////////////////////// //%/////////////////////////////////////////////////////////////////////////////
  
 #include <string.h>  
 #include <stdlib.h>  
 #include <ctype.h>  
 #include <Pegasus/Common/String.h>  
 #include <Pegasus/Common/HostAddress.h> #include <Pegasus/Common/HostAddress.h>
 #include <Pegasus/Common/PegasusAssert.h>  
  
 PEGASUS_NAMESPACE_BEGIN PEGASUS_NAMESPACE_BEGIN
  
 #if defined (PEGASUS_OS_TYPE_WINDOWS) || defined (PEGASUS_DISABLE_IPV6)  #ifdef PEGASUS_OS_VMS
   const struct in6_addr in6addr_any = IN6ADDR_ANY_INIT;
   #endif
   
   #if defined (PEGASUS_OS_TYPE_WINDOWS) || !defined (PEGASUS_ENABLE_IPV6)
  
 /* /*
     Address conversion utility functions.     Address conversion utility functions.
Line 113 
Line 112 
     return 1;     return 1;
 } }
  
 #ifndef PEGASUS_DISABLE_IPV6  #ifdef PEGASUS_ENABLE_IPV6
 /* /*
      Converts given ipv6 text address (ex. ::1) to binary form and stroes      Converts given ipv6 text address (ex. ::1) to binary form and stroes
      in "dst" buffer (ex. 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1). Returns 1      in "dst" buffer (ex. 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1). Returns 1
Line 226 
Line 225 
    return dst;    return dst;
 } }
  
 #ifndef PEGASUS_DISABLE_IPV6  #ifdef PEGASUS_ENABLE_IPV6
 /* /*
     Converts given ipv6 address in binary form to text form. Ex.     Converts given ipv6 address in binary form to text form. Ex.
     0000000000000001 to ::1.     0000000000000001 to ::1.
Line 321 
Line 320 
     return dst;     return dst;
 } }
 #endif #endif
 #endif  // defined (PEGASUS_OS_TYPE_WINDOWS) || defined (PEGASUS_DISABLE_IPV6)  #endif  // defined (PEGASUS_OS_TYPE_WINDOWS) || !defined (PEGASUS_ENABLE_IPV6)
  
 void HostAddress::_init() void HostAddress::_init()
 { {
Line 410 
Line 409 
 { {
     switch (af)     switch (af)
     {     {
 #ifndef PEGASUS_DISABLE_IPV6  #ifdef PEGASUS_ENABLE_IPV6
         case AF_INET6:         case AF_INET6:
              return !memcmp(p1, p2, sizeof(struct in6_addr));              return !memcmp(p1, p2, sizeof(struct in6_addr));
 #endif #endif
Line 428 
Line 427 
         _isValid = false;         _isValid = false;
         return;         return;
     }     }
   
     Uint32 i = 0;     Uint32 i = 0;
 #ifndef PEGASUS_DISABLE_IPV6  #ifdef PEGASUS_ENABLE_IPV6
     if (_hostAddrStr[0] == '[')     if (_hostAddrStr[0] == '[')
     {     {
         i = 1;         i = 1;
Line 454 
Line 452 
             return;             return;
         }         }
     }     }
       else if ((_isValid = isValidIPV6Address(_hostAddrStr)))
       {
           _addrType = AT_IPV6;
           _hostAddress = _hostAddrStr;
           return;
       }
     else     else
 #endif #endif
     if (!_isValid)     if (!_isValid)
Line 506 
Line 510 
     }     }
 } }
  
 #ifndef PEGASUS_DISABLE_IPV6  #ifdef PEGASUS_ENABLE_IPV6
 Boolean HostAddress::isValidIPV6Address (const String &ipv6Address) Boolean HostAddress::isValidIPV6Address (const String &ipv6Address)
 { {
     CString addr = ipv6Address.getCString();     CString addr = ipv6Address.getCString();
Line 572 
Line 576 
  
 int HostAddress::convertTextToBinary(int af, const char *src, void *dst) int HostAddress::convertTextToBinary(int af, const char *src, void *dst)
 { {
 #ifdef PEGASUS_DISABLE_IPV6  #ifndef PEGASUS_ENABLE_IPV6
     if (af == AF_INET)     if (af == AF_INET)
     {     {
         return _inet_ptonv4(src, dst);         return _inet_ptonv4(src, dst);
     }     }
     return -1;     return -1;
 #else #else
 #ifdef PEGASUS_OS_TYPE_UNIX  #if defined (PEGASUS_OS_TYPE_UNIX) || defined (PEGASUS_OS_VMS)
     return ::inet_pton(af, src, dst);     return ::inet_pton(af, src, dst);
 #else #else
     if (af == AF_INET)     if (af == AF_INET)
Line 595 
Line 599 
         return -1; // Unsupported address family.         return -1; // Unsupported address family.
     }     }
 #endif // PEGASUS_OS_TYPE_UNIX #endif // PEGASUS_OS_TYPE_UNIX
 #endif // PEGASUS_DISABLE_IPV6  #endif // PEGASUS_ENABLE_IPV6
 } }
  
 const char * HostAddress::convertBinaryToText(int af, const void *src, const char * HostAddress::convertBinaryToText(int af, const void *src,
     char *dst, Uint32 size)     char *dst, Uint32 size)
 { {
 #ifdef PEGASUS_DISABLE_IPV6  #ifndef PEGASUS_ENABLE_IPV6
     if (af == AF_INET)     if (af == AF_INET)
     {     {
         return _inet_ntopv4(src, dst, size);         return _inet_ntopv4(src, dst, size);
     }     }
     return 0;     return 0;
 #else #else
 #ifdef PEGASUS_OS_TYPE_UNIX  #if defined (PEGASUS_OS_TYPE_UNIX) || defined (PEGASUS_OS_VMS)
     return ::inet_ntop(af, src, dst, size);     return ::inet_ntop(af, src, dst, size);
 #else #else
     if (af == AF_INET)     if (af == AF_INET)
Line 624 
Line 628 
         return 0; // Unsupported address family.         return 0; // Unsupported address family.
     }     }
 #endif // PEGASUS_OS_TYPE_UNIX #endif // PEGASUS_OS_TYPE_UNIX
 #endif // PEGASUS_DISABLE_IPV6  #endif // PEGASUS_ENABLE_IPV6
 } }
  
 PEGASUS_NAMESPACE_END PEGASUS_NAMESPACE_END


Legend:
Removed from v.1.1.2.1  
changed lines
  Added in v.1.1.2.2

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2