version 1.1.2.4, 2007/06/18 12:02:27
|
version 1.6.4.1, 2013/06/03 22:35:12
|
|
|
//%2007//////////////////////////////////////////////////////////////////////// |
//%LICENSE//////////////////////////////////////////////////////////////// |
// | // |
// Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development |
// Licensed to The Open Group (TOG) under one or more contributor license |
// Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems. |
// agreements. Refer to the OpenPegasusNOTICE.txt file distributed with |
// Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L.P.; |
// this work for additional information regarding copyright ownership. |
// IBM Corp.; EMC Corporation, The Open Group. |
// Each contributor licenses this file to you under the OpenPegasus Open |
// Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.; |
// Source License; you may not use this file except in compliance with the |
// IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group. |
// License. |
// Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.; |
|
// EMC Corporation; VERITAS Software Corporation; The Open Group. |
|
// Copyright (c) 2006 Hewlett-Packard Development Company, L.P.; IBM Corp.; |
|
// EMC Corporation; Symantec Corporation; The Open Group. |
|
// |
|
// Permission is hereby granted, free of charge, to any person obtaining a copy |
|
// of this software and associated documentation files (the "Software"), to |
|
// deal in the Software without restriction, including without limitation the |
|
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or |
|
// sell copies of the Software, and to permit persons to whom the Software is |
|
// furnished to do so, subject to the following conditions: |
|
// |
|
// THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN |
|
// ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED |
|
// "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT |
|
// LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR |
|
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT |
|
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN |
|
// ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION |
|
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
|
// | // |
//============================================================================== |
// Permission is hereby granted, free of charge, to any person obtaining a |
|
// copy of this software and associated documentation files (the "Software"), |
|
// to deal in the Software without restriction, including without limitation |
|
// the rights to use, copy, modify, merge, publish, distribute, sublicense, |
|
// and/or sell copies of the Software, and to permit persons to whom the |
|
// Software is furnished to do so, subject to the following conditions: |
|
// |
|
// The above copyright notice and this permission notice shall be included |
|
// in all copies or substantial portions of the Software. |
|
// |
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
|
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
|
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
|
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY |
|
// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, |
|
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE |
|
// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
|
// |
|
////////////////////////////////////////////////////////////////////////// |
// | // |
//%///////////////////////////////////////////////////////////////////////////// | //%///////////////////////////////////////////////////////////////////////////// |
| |
|
|
| |
PEGASUS_NAMESPACE_BEGIN | PEGASUS_NAMESPACE_BEGIN |
| |
|
#ifdef INET_ADDRSTRLEN |
|
#define PEGASUS_INET_ADDRSTR_LEN INET_ADDRSTRLEN |
|
#else |
#define PEGASUS_INET_ADDRSTR_LEN 16 | #define PEGASUS_INET_ADDRSTR_LEN 16 |
|
#endif |
|
|
|
#ifdef INET6_ADDRSTRLEN |
|
#define PEGASUS_INET6_ADDRSTR_LEN INET6_ADDRSTRLEN |
|
#else |
#define PEGASUS_INET6_ADDRSTR_LEN 46 | #define PEGASUS_INET6_ADDRSTR_LEN 46 |
|
#endif |
| |
#define PEGASUS_IPV4_LOOPBACK_ADDRESS "127.0.0.1" |
#ifdef IN6ADDR_LOOPBACK_INIT |
#define PEGASUS_IPV6_LOOPBACK_ADDRESS "::1" |
#define PEGASUS_IPV6_LOOPBACK_INIT IN6ADDR_LOOPBACK_INIT |
|
#else |
#define PEGASUS_IPV6_LOOPBACK_INIT {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1} | #define PEGASUS_IPV6_LOOPBACK_INIT {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1} |
|
#endif |
|
|
|
|
|
#ifdef INADDR_LOOPBACK |
|
#define PEGASUS_IPV4_LOOPBACK_INIT INADDR_LOOPBACK |
|
#else |
#define PEGASUS_IPV4_LOOPBACK_INIT 0x7F000001 | #define PEGASUS_IPV4_LOOPBACK_INIT 0x7F000001 |
|
#endif |
|
|
|
#define PEGASUS_IPV4_LOOPBACK_RANGE_START 0x7F000000 |
|
#define PEGASUS_IPV4_LOOPBACK_RANGE_END 0x7FFFFFFF |
|
|
| |
#ifdef PEGASUS_ENABLE_IPV6 | #ifdef PEGASUS_ENABLE_IPV6 |
#define PEGASUS_IN6_ADDR_SIZE (sizeof (struct in6_addr)) | #define PEGASUS_IN6_ADDR_SIZE (sizeof (struct in6_addr)) |
|
|
HostAddress(); | HostAddress(); |
~HostAddress(); | ~HostAddress(); |
| |
/** |
|
Constructor. addrStr can be HostName or IPv4Address or |
|
IPv6Address. |
|
*/ |
|
HostAddress(const String &addrStr); |
|
HostAddress(const HostAddress &rhs); | HostAddress(const HostAddress &rhs); |
HostAddress& operator =(const HostAddress &rhs); | HostAddress& operator =(const HostAddress &rhs); |
| |
void setHostAddress(const String &addrStr); |
/** |
|
* AddrStr can be HostName or IPv4Address or IPv6Address |
|
* (without brackets). |
|
* Returns true, if set successfully. |
|
* Returns false, if unscessfully and the HostAddress is |
|
* invalid. |
|
*/ |
|
|
|
Boolean setHostAddress(const String &addrStr); |
| |
/** | /** |
Returns true if the address is valid. If vaild it can be HostName |
Returns true if the constructed HostAddress is valid. |
or IPv4Address or IPv6Address. |
If valid it can be HostName or IPv4Address or IPv6Address. |
|
Check if HostAddress is valid by using isValid() method |
|
before making any calls on HostAddress object. |
*/ | */ |
Boolean isValid(); |
Boolean isValid() const; |
| |
/** | /** |
Verifies given ipv4Address and returns true if it is valid. |
Verifies given IPv4Address and returns true if it is valid. |
*/ | */ |
static Boolean isValidIPV4Address(const String &ipv4Address); | static Boolean isValidIPV4Address(const String &ipv4Address); |
| |
/** | /** |
Verifies given ipv6Address and returns true if it is valid. |
Verifies given IPv6Address (without brackets) and returns |
|
true if it is valid. |
*/ | */ |
static Boolean isValidIPV6Address(const String &ipv6Address); | static Boolean isValidIPV6Address(const String &ipv6Address); |
| |
|
|
static Boolean equal(int af, void *p1, void *p2); | static Boolean equal(int af, void *p1, void *p2); |
| |
/** | /** |
Returns HostName or IPv4Address or IPv6Address. Removes port number |
Returns HostName or IPv4Address or IPv6Address. This returns an empty |
from HostAddress if present. This returns empty string HostAddress is |
String if HostAddress is not valid. |
not valid. Check if HostAddress is valid by using isValid() method |
Check if HostAddress is valid by using isValid() method |
before making any calls on HostAddress object. | before making any calls on HostAddress object. |
*/ | */ |
String getHost(); |
String getHost() const; |
| |
/** | /** |
Returns address type. It can be AT_IPV4, AT_IPV6 or AT_HOSTNAME. | Returns address type. It can be AT_IPV4, AT_IPV6 or AT_HOSTNAME. |
*/ | */ |
Uint32 getAddressType(); |
Uint32 getAddressType() const; |
|
|
|
/* |
|
* get the scope ID for the link-local address |
|
*/ |
|
Uint32 getScopeID() const; |
|
|
|
//check if the address in the _hostaddrStr is link-local |
|
Boolean isHostAddLinkLocal() const; |
| |
private: | private: |
void _init(); |
|
void _parseAddress(); |
|
String _hostAddrStr; | String _hostAddrStr; |
Uint16 _addrType; | Uint16 _addrType; |
Boolean _isValid; | Boolean _isValid; |
|
Boolean _isAddrLinkLocal; |
|
Uint32 _scopeID; |
|
|
|
/** |
|
* Retruns true if ip6add is a valid IPv6 address. |
|
* set _hostAddrStr to a valid IPv6 |
|
* _isAddrLinkLocal to true if ip6add is a link local address |
|
* _scopeID if it is a link local address. Other wise false. |
|
* |
|
*/ |
|
Boolean _checkIPv6AndLinkLocal(const String &ip6add); |
|
|
}; | }; |
| |
PEGASUS_NAMESPACE_END | PEGASUS_NAMESPACE_END |