version 1.22, 2004/09/02 02:58:20
|
version 1.29, 2005/06/06 14:27:55
|
|
|
//%2003//////////////////////////////////////////////////////////////////////// |
//%2005//////////////////////////////////////////////////////////////////////// |
// | // |
// Copyright (c) 2000, 2001, 2002 BMC Software, Hewlett-Packard Development |
// Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development |
// Company, L. P., IBM Corp., The Open Group, Tivoli Systems. |
// Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems. |
// Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L. P.; | // Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L. P.; |
// IBM Corp.; EMC Corporation, The Open Group. | // IBM Corp.; EMC Corporation, The Open Group. |
|
// Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.; |
|
// IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group. |
|
// Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.; |
|
// EMC Corporation; VERITAS Software Corporation; The Open Group. |
// | // |
// Permission is hereby granted, free of charge, to any person obtaining a copy | // Permission is hereby granted, free of charge, to any person obtaining a copy |
// of this software and associated documentation files (the "Software"), to | // of this software and associated documentation files (the "Software"), to |
|
|
// PEGASUS_OR_IOS_BINARY | // PEGASUS_OR_IOS_BINARY |
// Robert Kieninger, IBM (kieningr@de.ibm.com) for Bug#667 | // Robert Kieninger, IBM (kieningr@de.ibm.com) for Bug#667 |
// Dave Sudlik, IBM (dsudlik@us.ibm.com) for Bug#1462 | // Dave Sudlik, IBM (dsudlik@us.ibm.com) for Bug#1462 |
|
// Sean Keenan, Hewlett-Packard Company (sean.keenan@hp.com) |
// | // |
//%///////////////////////////////////////////////////////////////////////////// | //%///////////////////////////////////////////////////////////////////////////// |
| |
|
|
# include "SystemUnix.cpp" | # include "SystemUnix.cpp" |
#elif defined(PEGASUS_OS_TYPE_NSK) | #elif defined(PEGASUS_OS_TYPE_NSK) |
# include "SystemNsk.cpp" | # include "SystemNsk.cpp" |
|
#elif defined(PEGASUS_OS_VMS) |
|
# include "SystemVms.cpp" |
#else | #else |
# error "Unsupported platform" | # error "Unsupported platform" |
#endif | #endif |
|
|
return dirname; | return dirname; |
} | } |
| |
|
String System::getHostIP(const String &hostName) |
|
{ |
|
struct hostent * phostent; |
|
struct in_addr inaddr; |
|
String ipAddress = String::EMPTY; |
|
CString csName = hostName.getCString(); |
|
const char * ccName = csName; |
|
#ifndef PEGASUS_OS_OS400 |
|
if ((phostent = ::gethostbyname(ccName)) != NULL) |
|
#else |
|
char ebcdicHost[PEGASUS_MAXHOSTNAMELEN]; |
|
if (strlen(ccName) < PEGASUS_MAXHOSTNAMELEN) |
|
strcpy(ebcdicHost, ccName); |
|
else |
|
return ipAddress; |
|
AtoE(ebcdicHost); |
|
if ((phostent = ::gethostbyname(ebcdicHost)) != NULL) |
|
#endif |
|
{ |
|
::memcpy( &inaddr, phostent->h_addr,4); |
|
#ifdef PEGASUS_PLATFORM_ZOS_ZSERIES_IBM |
|
char * gottenIPAdress = NULL; |
|
gottenIPAdress = ::inet_ntoa( inaddr ); |
|
__etoa(gottenIPAdress); |
|
if (gottenIPAdress != NULL) |
|
{ |
|
ipAddress.assign(gottenIPAdress); |
|
} |
|
#else |
|
ipAddress = ::inet_ntoa( inaddr ); |
|
#endif |
|
} |
|
return ipAddress; |
|
} |
| |
// ------------------------------------------------------------------------ | // ------------------------------------------------------------------------ |
// Convert a hostname into a a single host unique integer representation | // Convert a hostname into a a single host unique integer representation |
|
|
{ | { |
// resolve hostaddr to a real host entry | // resolve hostaddr to a real host entry |
// casting to (const char *) as (char *) will work as (void *) too, those it fits all platforms | // casting to (const char *) as (char *) will work as (void *) too, those it fits all platforms |
|
#ifndef PEGASUS_OS_OS400 |
entry = gethostbyaddr((const char *) &tmp_addr, sizeof(tmp_addr), AF_INET); | entry = gethostbyaddr((const char *) &tmp_addr, sizeof(tmp_addr), AF_INET); |
|
#else |
|
entry = gethostbyaddr((char *) &tmp_addr, sizeof(tmp_addr), AF_INET); |
|
#endif |
if (entry == 0) | if (entry == 0) |
{ | { |
// error, couldn't resolve the ip | // error, couldn't resolve the ip |
|
|
return ip; | return ip; |
} | } |
| |
|
Boolean System::sameHost (const String & hostName) |
|
{ |
|
// |
|
// If a port is included, return false |
|
// |
|
if (hostName.find (":") != PEG_NOT_FOUND) |
|
{ |
|
return false; |
|
} |
|
|
|
// |
|
// Retrieve IP addresses for both hostnames |
|
// |
|
Uint32 hostNameIP, systemHostIP = 0xFFFFFFFF; |
|
hostNameIP = System::_acquireIP ((const char *) hostName.getCString ()); |
|
if (hostNameIP == 0x7F000001) |
|
{ |
|
// |
|
// localhost or IP address of 127.0.0.1 |
|
// real IP address needed for compare |
|
// |
|
hostNameIP = System::_acquireIP |
|
((const char *) System::getHostName ().getCString ()); |
|
} |
|
if (hostNameIP == 0xFFFFFFFF) |
|
{ |
|
// |
|
// Malformed IP address or not resolveable |
|
// |
|
return false; |
|
} |
|
|
|
systemHostIP = System::_acquireIP |
|
((const char *) System::getFullyQualifiedHostName ().getCString ()); |
|
|
|
if (systemHostIP == 0x7F000001) |
|
{ |
|
// |
|
// localhost or IP address of 127.0.0.1 |
|
// real IP address needed for compare |
|
// |
|
systemHostIP = System::_acquireIP |
|
((const char *) System::getHostName ().getCString ()); |
|
} |
|
if (systemHostIP == 0xFFFFFFFF) |
|
{ |
|
// |
|
// Malformed IP address or not resolveable |
|
// |
|
return false; |
|
} |
|
|
|
if (hostNameIP != systemHostIP) |
|
{ |
|
return false; |
|
} |
|
|
|
return true; |
|
} |
|
|
// System ID constants for Logger::put and Logger::trace | // System ID constants for Logger::put and Logger::trace |
const String System::CIMLISTENER = "cimlistener"; // Listener systme ID | const String System::CIMLISTENER = "cimlistener"; // Listener systme ID |
| |