X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=Socket%2FProtocols%2FINet%2FINetAddressing.hh;h=362e55cc1b2cfc860fc751cc50c2ff60bc30ec1a;hb=a1fdb7bb122f0b05be809a922d4b7ef5e125fa67;hp=57efbe4752884dfaf1958f23429aaa574ded44da;hpb=9cda1b12a3e68538ea8157ca96810f0423123a70;p=senf.git diff --git a/Socket/Protocols/INet/INetAddressing.hh b/Socket/Protocols/INet/INetAddressing.hh index 57efbe4..362e55c 100644 --- a/Socket/Protocols/INet/INetAddressing.hh +++ b/Socket/Protocols/INet/INetAddressing.hh @@ -24,19 +24,18 @@ \brief INet[46]Address and INet[46]AddressingPolicy public header */ -#ifndef HH_INetAddressing_ -#define HH_INetAddressing_ 1 +#ifndef HH_SENF_Socket_Protocols_INet_INetAddressing_ +#define HH_SENF_Socket_Protocols_INet_INetAddressing_ 1 // Custom includes #include #include #include -#include -#include "../../../Socket/SocketPolicy.hh" -#include "../../../Socket/ClientSocketHandle.hh" -#include "../../../Socket/CommunicationPolicy.hh" -#include "../../../Socket/Protocols/GenericAddressingPolicy.hh" -#include "../../../Utils/safe_bool.hh" +#include "../../SocketPolicy.hh" +#include "../../ClientSocketHandle.hh" +#include "../../CommunicationPolicy.hh" +#include "../BSDAddressingPolicy.hh" +#include "../BSDSocketAddress.hh" #include "INet4Address.hh" #include "INet6Address.hh" @@ -56,10 +55,11 @@ namespace senf { \ingroup addr_group */ class INet4SocketAddress - : public boost::equality_comparable, - public senf::comparable_safe_bool + : public BSDSocketAddress { public: + static short const addressFamily = AF_INET; + /////////////////////////////////////////////////////////////////////////// ///\name Structors and default members ///@{ @@ -85,30 +85,20 @@ namespace senf { ///< Set port, address is set to 0.0.0.0 /**< \param[in] port port number */ + INet4SocketAddress(const INet4SocketAddress& other); + INet4SocketAddress& operator=(const INet4SocketAddress& other); + ///@} /////////////////////////////////////////////////////////////////////////// - bool operator==(INet4SocketAddress const & other) const; - ///< Check INet4SocketAddress for equality - INet4Address address() const; ///< Return address unsigned port() const; ///< Return port number - bool boolean_test() const; ///< \c true, if address is not empty (i.e. 0.0.0.0:0) - - void clear(); ///< Clear address/port to 0.0.0.0:0 - void address(INet4Address const & addr); ///< Set address void port(unsigned p); ///< Set port number - /// \name Generic Address Interface - /// @{ - - struct sockaddr * sockaddr_p(); - struct sockaddr const * sockaddr_p() const; - unsigned sockaddr_len() const; - - /// @} + using BSDSocketAddress::sockaddr_p; + using BSDSocketAddress::socklen_p; private: struct ::sockaddr_in addr_; @@ -119,6 +109,7 @@ namespace senf { \related INet4SocketAddress */ std::ostream & operator<<(std::ostream & os, INet4SocketAddress const & addr); + std::istream & operator>>(std::istream & is, INet4SocketAddress & addr); /** \brief IPv6 socket address @@ -152,10 +143,11 @@ namespace senf { \ingroup addr_group */ class INet6SocketAddress - : public boost::equality_comparable, - public senf::comparable_safe_bool + : public BSDSocketAddress { public: + static short const addressFamily = AF_INET6; + /////////////////////////////////////////////////////////////////////////// ///\name Structors and default members ///@{ @@ -176,38 +168,32 @@ namespace senf { ///< Initialize from address and port INet6SocketAddress(INet6Address const & addr, unsigned port, std::string const & iface); ///< Initialize explicitly from given parameters + /**< \throws AddressSyntaxException if the + given iface cannot be resolved. */ explicit INet6SocketAddress(unsigned port); ///< Initialize from port and set to 'unspecified' addr /**< The address is set to [::] \param[in] port port number */ + INet6SocketAddress(const INet6SocketAddress& other); + INet6SocketAddress& operator=(const INet6SocketAddress& other); + ///@} /////////////////////////////////////////////////////////////////////////// - bool operator==(INet6SocketAddress const & other) const; ///< Check addresses for equality - - void clear(); ///< Clear socket address - INet6Address address() const; ///< Get printable address representation - void address(INet6Address const & addr); ///< Change address unsigned port() const; ///< Get port number - void port(unsigned poirt); ///< Change port number + void port(unsigned port); ///< Change port number std::string iface() const; ///< Get interface name void iface(std::string const & iface); ///< Change interface + /**< \throws AddressSyntaxException if the + given iface cannot be resolved. */ - bool boolean_test() const; ///< \c true, if address is not empty (i.e. [::]:0) - - ///\name Generic SocketAddress interface - ///@{ - - struct sockaddr * sockaddr_p(); - struct sockaddr const * sockaddr_p() const; - unsigned sockaddr_len() const; - - ///@} + using BSDSocketAddress::sockaddr_p; + using BSDSocketAddress::socklen_p; protected: @@ -221,6 +207,7 @@ namespace senf { \related INet6SocketAddress */ std::ostream & operator<<(std::ostream & os, INet6SocketAddress const & addr); + std::istream & operator>>(std::istream & is, INet6SocketAddress & addr); /// \addtogroup policy_impl_group /// @{ @@ -234,19 +221,19 @@ namespace senf { addresses. The various members are directly imported from - GenericAddressingPolicy which see for a detailed + BSDAddressingPolicyMixin which see for a detailed documentation. */ struct INet4AddressingPolicy - : public AddressingPolicyBase, - private GenericAddressingPolicy + : public BSDAddressingPolicy, + private BSDAddressingPolicyMixin { typedef INet4SocketAddress Address; - using GenericAddressingPolicy::peer; - using GenericAddressingPolicy::local; - using GenericAddressingPolicy::connect; - using GenericAddressingPolicy::bind; + using BSDAddressingPolicyMixin::peer; + using BSDAddressingPolicyMixin::local; + using BSDAddressingPolicyMixin::connect; + using BSDAddressingPolicyMixin::bind; }; /** \brief Addressing policy supporting IPv6 addressing @@ -258,19 +245,19 @@ namespace senf { addresses. The various members are directly imported from - GenericAddressingPolicy which see for a detailed + BSDAddressingPolicyMixin which see for a detailed documentation. */ struct INet6AddressingPolicy - : public AddressingPolicyBase, - private GenericAddressingPolicy + : public BSDAddressingPolicy, + private BSDAddressingPolicyMixin { typedef INet6SocketAddress Address; - using GenericAddressingPolicy::peer; - using GenericAddressingPolicy::local; - using GenericAddressingPolicy::connect; - using GenericAddressingPolicy::bind; + using BSDAddressingPolicyMixin::peer; + using BSDAddressingPolicyMixin::local; + using BSDAddressingPolicyMixin::connect; + using BSDAddressingPolicyMixin::bind; }; /// @}