/usr/include/assa-3.5/assa/INETAddress.h is in libassa-3.5-5-dev 3.5.1-6.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 | // -*- c++ -*-
//------------------------------------------------------------------------------
// INETAddress.h
//------------------------------------------------------------------------------
// Copyright (c) 1999 by Vladislav Grinchenko
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Library General Public
// License as published by the Free Software Foundation; either
// version 2 of the License, or (at your option) any later version.
//------------------------------------------------------------------------------
#ifndef INET_ADDRESS_H
#define INET_ADDRESS_H
#include <vector>
using std::vector;
#include "assa/Address.h"
namespace ASSA {
/** @file INETAddress.h
An incapsulation of TCP/UDP Internet Protocol socket address structure.
*/
class INETAddress : public Address {
public:
/** @enum Protocol */
enum Protocol {
TCP, /**< TCP protocol */
UDP /**< UDP protocol */
};
public:
/// Default constructor.
INETAddress ();
/** Constructor to create address on a client side given
* address in struct in_addr and integer port number.
*
* @param haddr_ XDR-encoded server host address structure
* @param port_ Server listening port
*/
INETAddress (struct in_addr * haddr_, int port_);
/** Constructor to create address on the client side given
* host name and integer port number.
*
* @param host_ server host name
* @param port_ port server listens on
*/
INETAddress(const char* host_, int port_);
/** Constructor to create address on the client side given
* host name and service name (as in /etc/services) and
* optionally protocol type.
*
* @param host_ Server host name
* @param service_ Server listening port
* @param protocol_ protocol: TCP (default) or UDP
*/
INETAddress (const char* host_, const char* service_,
Protocol protocol_ = TCP);
/** Constructor to create address of listening socket on a
* server side from integer port number.
*
* @param port_ port to use
*/
INETAddress (int port_);
/** Constructor to create address both client- and server-side
addresses. Address is derived from the character string address_
which can be specified in one of the following formats:
Formats:
- [host:]service
- service[@@host]
If host is omitted, wildcard (INADDR_ANY) address is
assumed. This essentially creates an address of the server's
listening socket.
To create client-side address, use localhost (or host) name instead.
service entry can be either port name as listed in /etc/services or
integer port value.
@param address_ Address string.
@param protocol_ Protocol: TCP (by default) or UDP.
*/
INETAddress (const char* address_, Protocol protocol_ = TCP);
/// Copy constructor
INETAddress (SA_IN* address_);
/// Copy constructor from base address
INETAddress (SA* address_);
/// Destructor
~INETAddress () {
// trace_with_mask("INETAddress::~INETAddress",SOCKTRACE);
}
/// Return address length
const int getLength () const { return sizeof (m_address); }
/// Get hold of address structure
SA* getAddress () const { return (SA*) &m_address; }
/// Return host name
string getHostName ();
/// Return port
int getPort () const { return ntohs (m_address.sin_port); }
/// Dump the address content to log file
void dump ();
/** Return fully-qualified host name. Note that a host
can have name aliases. If it does, they are returned
via argument.
@param aliases_ List of host aliases, if any
@return fully-qualified host name.
*/
static string
get_fully_qualified_domain_name (vector<string>& aliases_);
private:
/** Makes socket address out of host name and port.
Host name is either a host name, or an IPv4 address in
standard dot notation, or an IPv6 address in colon
(and possibly dot) notation. If it is in dot notation,
no lookup is performed.
Otherwise, lookup is performed by consulting name resolution
services in order specified in in /etc/host.conf file
(named(8) first, then /etc/hosts, and so on).
Port port_ must be supplied in network-independent byte order.
If host_ is an empty string, then local host name is assumed.
If failed, state of the object is set to bad, and errno
indicates the error occured.
*/
void createHostPort (const char* host_, int port_);
/** Lookup port by its service name found in /etc/services.
serv_ is either service name, or integer port number.
If it is integer port number, it is converted to
the network-independent byte order and no lookup is performed.
@param serv_ Service name.
@param prot_ Protocol: tcp (default) or udp.
@return Port number in the network-independent byte order,
or 0 if lookup failed.
*/
int getServiceByName (string serv_, Protocol prot_ = TCP);
/** Perform initialization common to all ctors.
*/
void init ();
private:
/// Cached fully-qualified domain name
static string m_fqdn_cache;
private:
/// Internet address structure sockaddr_in
SA_IN m_address;
};
} // end namespace ASSA
#endif /* INET_ADDRESS_H */
|