X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=Socket%2FProtocols%2FINet%2FINetAddressing.hh;h=57efbe4752884dfaf1958f23429aaa574ded44da;hb=9cda1b12a3e68538ea8157ca96810f0423123a70;hp=43a13cf18d55b0c7466ce295fb81aee0ab811152;hpb=8d2d26f114d3df0a60c5c516fcf40671b1e55558;p=senf.git diff --git a/Socket/Protocols/INet/INetAddressing.hh b/Socket/Protocols/INet/INetAddressing.hh index 43a13cf..57efbe4 100644 --- a/Socket/Protocols/INet/INetAddressing.hh +++ b/Socket/Protocols/INet/INetAddressing.hh @@ -1,9 +1,9 @@ // $Id$ // // Copyright (C) 2006 -// Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS) -// Kompetenzzentrum fuer Satelitenkommunikation (SatCom) -// Stefan Bund +// Fraunhofer Institute for Open Communication Systems (FOKUS) +// Competence Center NETwork research (NET), St. Augustin, GERMANY +// Stefan Bund // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by @@ -36,6 +36,7 @@ #include "../../../Socket/ClientSocketHandle.hh" #include "../../../Socket/CommunicationPolicy.hh" #include "../../../Socket/Protocols/GenericAddressingPolicy.hh" +#include "../../../Utils/safe_bool.hh" #include "INet4Address.hh" #include "INet6Address.hh" @@ -56,9 +57,13 @@ namespace senf { */ class INet4SocketAddress : public boost::equality_comparable, - public senf::ComparableSafeBool + public senf::comparable_safe_bool { public: + /////////////////////////////////////////////////////////////////////////// + ///\name Structors and default members + ///@{ + INet4SocketAddress(); explicit INet4SocketAddress(std::string const & addr); ///< Set address and port /**< This constructor expects a string of the form @@ -66,9 +71,9 @@ namespace senf { initialize the host and port members. Since it uses the INet4Address::from_string constructor, this call may block while waiting for the resolver. - \throws SyntaxException if the address syntax is + \throws AddressSyntaxException if the address syntax is invalid - \throws INet4Address::UnknownHostnameException if the + \throws UnknownHostnameException if the address cannot be resolved. */ INet4SocketAddress(INet4Address const & addr, unsigned port); @@ -76,13 +81,20 @@ namespace senf { /**< \param[in] addr IP address \param[in] port port number */ + explicit INet4SocketAddress(unsigned port); + ///< Set port, address is set to 0.0.0.0 + /**< \param[in] port port number */ + + ///@} + /////////////////////////////////////////////////////////////////////////// + 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 empty (i.e. 0.0.0.0:0) + 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 @@ -98,10 +110,6 @@ namespace senf { /// @} - struct SyntaxException : public std::exception - { virtual char const * what() const throw() - { return "Invalid IpV4 socket address syntax"; } }; - private: struct ::sockaddr_in addr_; }; @@ -144,12 +152,11 @@ namespace senf { \ingroup addr_group */ class INet6SocketAddress + : public boost::equality_comparable, + public senf::comparable_safe_bool { public: /////////////////////////////////////////////////////////////////////////// - // Types - - /////////////////////////////////////////////////////////////////////////// ///\name Structors and default members ///@{ @@ -157,24 +164,27 @@ namespace senf { explicit INet6SocketAddress(std::string const & addr, INet6Address::Resolve_t resolve = INet6Address::ResolveINet6); ///< Initialize/convert from string representation - /**< \throws SyntaxException if the address syntax is + /**< \throws AddressSyntaxException if the address syntax is invalid - \throws INet6Address::UnknownHostnameException if the + \throws UnknownHostnameException if the address cannot be resolved. \param[in] addr Address to parse \param[in] resolve If this is - INet6Address::ResolveINet4, support IpV4 + INet6Address::ResolveINet4, support IPv4 addresses. See INet6Address. */ INet6SocketAddress(INet6Address const & addr, unsigned port); ///< Initialize from address and port INet6SocketAddress(INet6Address const & addr, unsigned port, std::string const & iface); ///< Initialize explicitly from given parameters + explicit INet6SocketAddress(unsigned port); + ///< Initialize from port and set to 'unspecified' addr + /**< The address is set to [::] + \param[in] port port number */ ///@} /////////////////////////////////////////////////////////////////////////// bool operator==(INet6SocketAddress const & other) const; ///< Check addresses for equality - bool operator!=(INet6SocketAddress const & other) const; ///< Inverse of above void clear(); ///< Clear socket address @@ -188,6 +198,8 @@ namespace senf { std::string iface() const; ///< Get interface name void iface(std::string const & iface); ///< Change interface + bool boolean_test() const; ///< \c true, if address is not empty (i.e. [::]:0) + ///\name Generic SocketAddress interface ///@{ @@ -197,10 +209,6 @@ namespace senf { ///@} - struct SyntaxException : public std::exception - { virtual char const * what() const throw() - { return "Invalid IpV6 socket address syntax"; } }; - protected: private: @@ -220,7 +228,7 @@ namespace senf { /** \brief Addressing policy supporting IPv4 addressing \par Address Type: - INet4Address + INet4SocketAddress This addressing policy implements addressing using Internet V4 addresses.