diff --git a/ip.cpp.rl b/ip.cpp.rl index d1ccac3e..5a028159 100644 --- a/ip.cpp.rl +++ b/ip.cpp.rl @@ -14,7 +14,7 @@ * You should have received a copy of the GNU General Public License * along with libgim. If not, see . * - * Copyright 2011 Danny Robson + * Copyright 2011-2016 Danny Robson */ @@ -35,9 +35,9 @@ const ipv4::ip ipv4::ip::ANY ( 0, 0, 0, 0); //----------------------------------------------------------------------------- -const util::range ipv4::WELL_KNOWN_PORT ( 0, 1023), - ipv4::REGISTERED_PORT ( 1024, 49151), - ipv4::PRIVATE_PORT (49152, 65535); +const util::range ipv4::WELL_KNOWN_PORT ( 0, 1023), + ipv4::REGISTERED_PORT ( 1024, 49151), + ipv4::PRIVATE_PORT (49152, 65535); /////////////////////////////////////////////////////////////////////////////// @@ -131,7 +131,7 @@ ipv4::ip::ip (const std::string &data) %%write exec; if (!__success) - throw invalid_argument(data); + throw ipv4::error (); m_octets[0] = __octets[0]; m_octets[1] = __octets[1]; diff --git a/ip.hpp b/ip.hpp index e7a1ab72..61318eea 100644 --- a/ip.hpp +++ b/ip.hpp @@ -11,7 +11,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * - * Copyright 2011 Danny Robson + * Copyright 2011-2016 Danny Robson */ #ifndef __UTIL_IP_HPP @@ -46,12 +46,15 @@ namespace ipv4 { }; - typedef uint16_t port; - typedef uint32_t mask; + typedef uint16_t port_t; + typedef uint32_t mask_t; + + extern const util::range WELL_KNOWN_PORT, + REGISTERED_PORT, + PRIVATE_PORT; + + class error : public std::exception { }; - extern const util::range WELL_KNOWN_PORT, - REGISTERED_PORT, - PRIVATE_PORT; } @@ -62,13 +65,15 @@ namespace ipv6 { explicit ip (const std::string&) { ; } }; - typedef uint16_t port; + typedef uint16_t port_t; - struct mask { + struct mask_t { uint32_t m_quads[4]; - explicit mask (uint32_t) { ; } + explicit mask_t (uint32_t) { ; } }; + + class error : public std::exception { }; } diff --git a/net/address.hpp b/net/address.hpp index 10e307d6..538ac185 100644 --- a/net/address.hpp +++ b/net/address.hpp @@ -37,18 +37,18 @@ namespace net { template <> struct address_types { - typedef ipv4::ip ip; - typedef ipv4::mask mask; - typedef ipv4::port port; - typedef sockaddr_in sockaddr; + typedef ipv4::ip ip; + typedef ipv4::mask_t mask_t; + typedef ipv4::port_t port_t; + typedef sockaddr_in sockaddr; }; template <> struct address_types { typedef ipv6::ip ip; - typedef ipv6::mask mask; - typedef ipv6::port port; + typedef ipv6::mask_t mask_t; + typedef ipv6::port_t port_t; typedef sockaddr_in6 sockaddr; }; @@ -58,8 +58,8 @@ namespace net { class address { public: typedef typename address_types::ip ip_type; - typedef typename address_types::mask mask_type; - typedef typename address_types::port port_type; + typedef typename address_types::mask_t mask_type; + typedef typename address_types::port_t port_type; typedef typename address_types::sockaddr sockaddr_type; protected: