From: tho Date: Wed, 24 Feb 2010 10:11:39 +0000 (+0000) Subject: Socket: AddressSyntaxExceptions provide more information X-Git-Url: http://g0dil.de/git?p=senf.git;a=commitdiff_plain;h=5bd0f0d58ba30d95a02b46fc9122a7e981bcbcad Socket: AddressSyntaxExceptions provide more information SConstruct: added -pipe to CXXFLAGS git-svn-id: https://svn.berlios.de/svnroot/repos/senf/trunk@1582 270642c3-0616-0410-b53a-bc976706d245 --- diff --git a/SConstruct b/SConstruct index cce33f0..17696a1 100644 --- a/SConstruct +++ b/SConstruct @@ -96,7 +96,7 @@ env.Append( INLINE_OPTS_NORMAL = [ '-finline-limit=5000' ], INLINE_OPTS = [ '$INLINE_OPTS_NORMAL' ], CXXFLAGS = [ '-Wall', '-Woverloaded-virtual', '-Wno-long-long', '$INLINE_OPTS', - '$CXXFLAGS_' ], + '-pipe', '$CXXFLAGS_' ], CXXFLAGS_ = senfutil.BuildTypeOptions('CXXFLAGS'), CXXFLAGS_final = [ '-O3' ], CXXFLAGS_normal = [ '-O0', '-g' ], diff --git a/senf/Socket/Protocols/INet/INet4Address.cc b/senf/Socket/Protocols/INet/INet4Address.cc index dcb6611..d00dee2 100644 --- a/senf/Socket/Protocols/INet/INet4Address.cc +++ b/senf/Socket/Protocols/INet/INet4Address.cc @@ -55,7 +55,7 @@ prefix_ senf::INet4Address senf::INet4Address::from_string(std::string const & s return senf::INet4Address::from_inaddr(ina.s_addr); if (s.empty()) - throw AddressSyntaxException(); + throw AddressSyntaxException() << ": empty string"; int herr (0); @@ -130,11 +130,11 @@ prefix_ senf::INet4Network::INet4Network(std::string const & s) { std::string::size_type i (s.find('/')); if (i == std::string::npos) - throw AddressSyntaxException(); + throw AddressSyntaxException(s); try { prefix_len_ = boost::lexical_cast(std::string(s,i+1)); } catch (boost::bad_lexical_cast const &) { - throw AddressSyntaxException(); + throw AddressSyntaxException(s); } address_ = INet4Address(INet4Address::from_string(std::string(s, 0, i)).address() & mask()); } diff --git a/senf/Socket/Protocols/INet/INet6Address.cc b/senf/Socket/Protocols/INet/INet6Address.cc index f2c0204..760952b 100644 --- a/senf/Socket/Protocols/INet/INet6Address.cc +++ b/senf/Socket/Protocols/INet/INet6Address.cc @@ -50,7 +50,7 @@ prefix_ senf::INet6Address senf::INet6Address::from_string(std::string const & s return senf::INet6Address::from_data(&ina.s6_addr[0]); if (s.empty()) - throw AddressSyntaxException(); + throw AddressSyntaxException() << ": empty string"; int herr (0); @@ -131,11 +131,11 @@ prefix_ senf::INet6Network::INet6Network(std::string const & s) using boost::lambda::_2; std::string::size_type i (s.find('/')); if (i == std::string::npos) - throw AddressSyntaxException(); + throw AddressSyntaxException(s); try { prefix_len_ = boost::lexical_cast(std::string(s,i+1)); } catch (boost::bad_lexical_cast const &) { - throw AddressSyntaxException(); + throw AddressSyntaxException(s); } address_ = INet6Address::from_string(std::string(s, 0, i)); detail::apply_mask(prefix_len_, address_.begin(), address_.end(), _1 &= _2); diff --git a/senf/Socket/Protocols/INet/INetAddressing.cc b/senf/Socket/Protocols/INet/INetAddressing.cc index 23f372e..aead331 100644 --- a/senf/Socket/Protocols/INet/INetAddressing.cc +++ b/senf/Socket/Protocols/INet/INetAddressing.cc @@ -53,7 +53,7 @@ prefix_ senf::INet4SocketAddress::INet4SocketAddress(std::string const & addr) ? addr : std::string(addr,portIx+1)) ); } catch (boost::bad_lexical_cast const &) { - throw AddressSyntaxException() << "invalid port number"; + throw AddressSyntaxException(addr) << ": invalid port number"; } if (portIx != std::string::npos) address( INet4Address::from_string(std::string(addr,0,portIx)) ); @@ -112,7 +112,7 @@ prefix_ senf::INet6SocketAddress::INet6SocketAddress(std::string const & addr, boost::smatch match; if (! regex_match(addr, match, addressRx)) - throw AddressSyntaxException(); + throw AddressSyntaxException(addr); if (match[ZoneId].matched) assignIface(match[ZoneId]); @@ -148,7 +148,7 @@ prefix_ void senf::INet6SocketAddress::assignIface(std::string const & iface) else { sockaddr_.sin6_scope_id = if_nametoindex(iface.c_str()); if (sockaddr_.sin6_scope_id == 0) - throw AddressSyntaxException(); + throw AddressSyntaxException(iface); } } diff --git a/senf/Socket/Protocols/Raw/MACAddress.cc b/senf/Socket/Protocols/Raw/MACAddress.cc index 8021839..b992ce8 100644 --- a/senf/Socket/Protocols/Raw/MACAddress.cc +++ b/senf/Socket/Protocols/Raw/MACAddress.cc @@ -52,7 +52,7 @@ prefix_ senf::MACAddress::MACAddress senf::MACAddress::from_string(std::string c prefix_ senf::MACAddress senf::MACAddress::from_eui64(senf::EUI64 const & eui) { if (eui[3] != 0xffu || eui[4] != 0xfeu) - throw AddressSyntaxException(); + throw AddressSyntaxException() << "EUI64 is not MAC compatible: " << eui; MACAddress mac (senf::noinit); mac[0] = eui[0]; mac[1] = eui[1]; diff --git a/senf/Socket/Protocols/Raw/ParseString.ct b/senf/Socket/Protocols/Raw/ParseString.ct index 5aa40cf..9def22c 100644 --- a/senf/Socket/Protocols/Raw/ParseString.ct +++ b/senf/Socket/Protocols/Raw/ParseString.ct @@ -53,10 +53,10 @@ prefix_ void senf::detail::parseHexString(std::string const & value, std::string(boost::begin(*i),boost::end(*i)))); } catch (std::bad_cast &) { - throw AddressSyntaxException(); + throw AddressSyntaxException(value); } if (i!=i_end || f!=l) - throw AddressSyntaxException(); + throw AddressSyntaxException(value); } ///////////////////////////////ct.e////////////////////////////////////////