19 #ifndef INCLUDE_RCF_IPADDRESS_HPP 20 #define INCLUDE_RCF_IPADDRESS_HPP 24 #include <RCF/Export.hpp> 25 #include <RCF/Config.hpp> 26 #include <RCF/ServerTransport.hpp> 28 #include <RCF/BsdSockets.hpp> 32 #if RCF_FEATURE_IPV6==1 34 typedef in6_addr In6Addr;
35 typedef sockaddr_in6 SockAddrIn6;
36 typedef sockaddr_storage SockAddrStorage;
52 struct In6Addr sin6_addr;
56 struct SockAddrStorage
58 sockaddr_in mSockAddrIn;
64 typedef std::shared_ptr<Exception> ExceptionPtr;
74 explicit IpAddress(
const std::string & ip);
77 explicit IpAddress(
const std::string & ip,
int port);
81 enum Type { V4_or_V6, V4, V6 };
83 static void setPreferredResolveProtocol(Type type);
84 static Type getPreferredResolveProtocol();
88 explicit IpAddress(
const std::string & ip,
int port, Type restrictTo);
89 explicit IpAddress(
const sockaddr_in &addr);
90 explicit IpAddress(
const SockAddrIn6 &addr);
91 explicit IpAddress(
const sockaddr &addr, std::size_t addrLen, Type type);
94 void init(
const sockaddr &addr, std::size_t addrLen, Type type);
96 int createSocket(
int socketType = SOCK_STREAM,
int protocol = IPPROTO_TCP)
const;
97 void getSockAddr(sockaddr *&, Platform::OS::BsdSockets::socklen_t &)
const;
98 std::string getIp()
const;
102 void resolve()
const;
103 void resolve(ExceptionPtr & e)
const;
104 std::string string()
const;
106 bool isResolved()
const;
107 bool isBroadcast()
const;
108 bool isMulticast()
const;
109 bool isLoopback()
const;
110 bool matches(
const IpAddress & rhs, std::size_t bits = std::size_t(-1))
const;
112 void setPort(
int port);
114 bool operator==(
const IpAddress & rhs)
const;
115 bool operator!=(
const IpAddress & rhs)
const;
116 bool operator<(
const IpAddress &rhs)
const;
120 void extractIpAndPort();
123 mutable bool mResolved;
124 mutable sockaddr_in mAddrV4;
125 mutable SockAddrIn6 mAddrV6;
153 #endif // ! INCLUDE_RCF_IPADDRESS_HPP Describes the network address of a remote peer.
Definition: ServerTransport.hpp:37
Represents an IPv6 IP address.
Definition: IpAddress.hpp:142
Represents an IPv4 IP address.
Definition: IpAddress.hpp:132
Definition: AmiIoHandler.hpp:24
RCF_EXPORT bool init(RcfConfigT *=nullptr)
Reference-counted initialization of RCF library. May be called multiple times (see deinit())...
Represents an IP address (IPv4 or IPv6).
Definition: IpAddress.hpp:67