/usr/include/bobcat/inetaddress is in libbobcat-dev 2.20.01-1.
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 | #ifndef INCLUDED_BOBCAT_INETADDRESS_
#define INCLUDED_BOBCAT_INETADDRESS_
#include <netinet/in.h>
#include <string>
#include <bobcat/errno>
/*
int-info coming in or going out: host byte order
*/
namespace FBB
{
class InetAddress
{
sockaddr_in d_address; // address/port: network byte order
// sa_family_t in_addr, uint16_t
// sin_family, sin_addr, sin_port
public:
uint16_t port() const;
// replaces the formerly available getAddress() member.
std::string dottedDecimalAddress() const;
sockaddr const *sockaddrPtr() const;
sockaddr_in const *sockaddr_inPtr() const;
size_t size() const;
protected:
InetAddress(std::string const &host, uint16_t port);
explicit InetAddress(uint16_t port);
explicit InetAddress(sockaddr_in const &address);
sockaddr *sockaddrPtr();
sockaddr_in *sockaddr_inPtr();
private:
void init(uint32_t addr, uint16_t port); // host byte order !
};
inline uint16_t InetAddress::port() const
{
return ntohs(d_address.sin_port);
}
inline sockaddr const *InetAddress::sockaddrPtr() const
{
return reinterpret_cast<sockaddr const *>(&d_address);
}
inline sockaddr_in const *InetAddress::sockaddr_inPtr() const
{
return &d_address;
}
inline size_t InetAddress::size() const
{
return sizeof(d_address);
}
inline InetAddress::InetAddress(uint16_t port)
{
init(INADDR_ANY, port);
}
inline InetAddress::InetAddress(sockaddr_in const &address)
:
d_address(address)
{}
inline sockaddr *InetAddress::sockaddrPtr()
{
return reinterpret_cast<sockaddr *>(&d_address);
}
inline sockaddr_in *InetAddress::sockaddr_inPtr()
{
return &d_address;
}
} // FBB
#endif
|