16#include <sys/socket.h>
18#include <sys/utsname.h>
28#define BUFFER_SIZE 256
39 struct addrinfo* info_ptr;
40 const char* str =
name.c_str();
41 const int status = getaddrinfo(str, 0, 0, &info_ptr);
42 struct sockaddr_in address;
43 bzero(&address,
sizeof(address));
44 address.sin_family = AF_INET;
45 address.sin_addr.s_addr = 0;
47 struct sockaddr_in* ptr = (sockaddr_in*)info_ptr->ai_addr;
49 freeaddrinfo(info_ptr);
62 char buffer[NI_MAXHOST];
63 const struct sockaddr* ptr = (
const struct sockaddr*)&address;
64 const int status = getnameinfo(ptr,
sizeof(address), buffer,
sizeof(buffer), 0, 0, 0);
67 return std::string(buffer);
82 if (address.sin_addr.s_addr != 0)
84 return std::string(
name);
96 const char* s = inet_ntoa(ip_addr.sin_addr);
97 return std::string(s);
140OksSystem::Host::operator
struct sockaddr_in() const throw()
188 m_full_name = expand(m_name);
200 const struct sockaddr_in address =
ip();
271 struct utsname u_name_data;
272 const int status = ::uname(&u_name_data);
274 m_name = u_name_data.nodename;
280 char buffer[NI_MAXHOST];
281 const int host_status = gethostname(buffer,
sizeof(buffer));
282 if (host_status == 0) {
336 std::ostringstream stream;
337 stream << m_os_name <<
" " << m_release <<
"/" << m_machine;
338 m_description = stream.str();
void operator<<(TraceStreamer &x, const ers::Issue &r)
virtual ~Host()
destructor
std::string ip_string() const
get ip in string mode
static struct sockaddr_in resolve(const std::string &name)
name to ip conversion
const std::string & name() const
get name
static std::string expand(const std::string &name)
expands to full name
struct sockaddr_in ip() const
get ip address
static std::string to_string(struct sockaddr_in ip_addr)
ip to string conversion
bool equals(const Host &other) const
equality method
const std::string & full_name() const
get fully qualified name
std::string m_name
name of the host
Host()
constructor for current host
std::string m_full_name
cached fully qualified host name
Network host - localhost.
std::string m_os_name
name of the operating system
std::string m_version
version of the operating system
const std::string & description() const
machine type */
static LocalHost * s_instance
singleton for local host
const std::string & os_release() const
release of the operating system
static const std::string & full_local_name()
fully qualified local host name
std::string m_machine
machine type
const std::string & os_name() const
name of the operating system
static const LocalHost * instance()
pointer to the singleton local host
const std::string & os_version() const
version of the operating system
static const std::string & local_name()
localhostname
std::string m_release
release of the operating system
const std::string & machine() const
version of the operating system
std::string m_description
machine description (cached)
bool operator!=(const Host &a, const Host &b)
inequality operator
const char * getfullhost()
get fully qualified host name
bool operator==(const Host &a, const Host &b)
equality operator