#include <arpa/inet.h>
#include <netdb.h>
#include <boost/lexical_cast.hpp>
+#include <senf/Socket/Protocols/AddressExceptions.hh>
//#include "INet6Address.mpp"
#define prefix_
return senf::INet6Address::from_data(&ina.s6_addr[0]);
if (s.empty())
- throw AddressSyntaxException();
+ throw AddressSyntaxException() << ": empty string";
int herr (0);
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<unsigned>(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);
}
+prefix_ std::istream & senf::operator>>(std::istream & is, INet6Network & addr)
+{
+ std::string s;
+ if (!(is >> s))
+ return is;
+ try {
+ addr = INet6Network(s);
+ }
+ catch (AddressException &) {
+ is.setstate(std::ios::failbit);
+ }
+ return is;
+}
+
///////////////////////////////cc.e////////////////////////////////////////
#undef prefix_
//#include "INet6Address.mpp"
-\f
+
// Local Variables:
// mode: c++
// fill-column: 100