forked from ravinet/mahimahi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaddress.hh
38 lines (29 loc) · 995 Bytes
/
address.hh
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
/* -*-mode:c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
#ifndef ADDRESS_HH
#define ADDRESS_HH
#include <netinet/in.h>
#include <string>
#include "socket_type.hh"
class Address
{
private:
sockaddr_in addr_;
public:
Address( const sockaddr_in & s_addr );
Address( const sockaddr & s_addr );
Address( const std::string & hostname, const std::string & service );
Address( const std::string & ip, const uint16_t port );
Address();
static Address cgnat( const uint8_t last_octet );
std::string ip( void ) const;
uint16_t port( void ) const;
std::string str( const std::string port_separator = ":" ) const;
const sockaddr_in & raw_sockaddr_in( void ) const { return addr_; }
const sockaddr & raw_sockaddr( void ) const
{
return *reinterpret_cast<const sockaddr *>( &addr_ );
}
bool operator==( const Address & other ) const;
bool operator<( const Address & other ) const;
};
#endif /* ADDRESS_HH */