PPI: Allow IOEvents to be constructed with an in-valid() handle
Socket/Protocols/INet: Implement INet6Address::from_mac()
Socket/Protocols/Raw: Implement LLSocketAddress output streaming
git-svn-id: https://svn.berlios.de/svnroot/repos/senf/trunk@1183
270642c3-0616-0410-b53a-bc976706d245
template <class Handle>
prefix_ senf::ppi::IOEvent::IOEvent(Handle handle, unsigned events)
- : fd_ (senf::scheduler::get_descriptor(handle)),
- event_ ("senf::ppi::IOEvent", boost::bind(&IOEvent::cb,this,_1), fd_, events, false)
-{}
+ : fd_ (-1), event_ ("senf::ppi::IOEvent", boost::bind(&IOEvent::cb,this,_1))
+{
+ set(handle,events);
+}
///////////////////////////////cti.e///////////////////////////////////////
#undef prefix_
return addr;
}
+prefix_ senf::INet6Address senf::INet6Address::from_mac(senf::MACAddress const & mac)
+{
+ INet6Address addr;
+ addr[0] = 0xfe;
+ addr[1] = 0x80;
+ addr[8] = mac[0];
+ addr[9] = mac[1];
+ addr[10] = mac[2];
+ addr[11] = 0xff;
+ addr[12] = 0xfe;
+ addr[13] = mac[3];
+ addr[14] = mac[4];
+ addr[15] = mac[5];
+ return addr;
+}
+
prefix_ boost::uint64_t senf::INet6Address::network()
const
{
#include "../../../Utils/Tags.hh"
#include "INet4Address.hh"
#include "../AddressExceptions.hh"
+#include "../Raw/MACAddress.hh"
//#include "INet6Address.mpp"
#include "INet6Address.ih"
\par
INet4 compatible INet6 addresses are not directly
supported, they are deprecated in the RFC. */
+ static INet6Address from_mac(senf::MACAddress const & mac);
+ ///< Construct a link-local INet6 address
+ /**< This will construct a link local address of the form
+ <tt>fe80::xxxx:xxff:fexx:xxxx</tt>. */
+
in6_addr toin6_addr() const; ///< get the linux in6_addr struct (convinience only)
///@}
BOOST_CHECK_THROW( INet4SocketAddress(":12345"), AddressSyntaxException );
BOOST_CHECK_THROW( INet4SocketAddress("127.0.0.1:1234a"), AddressSyntaxException );
- BOOST_CHECK_EQUAL( INet4SocketAddress(12345).port(), 12345 );
+ BOOST_CHECK_EQUAL( INet4SocketAddress(12345).port(), 12345u );
BOOST_CHECK_EQUAL( INet4SocketAddress(12345).address(), INet4Address::None );
BOOST_CHECK_EQUAL( INet4SocketAddress("127.0.0.1:12345").address(), INet4Address::Loopback );
BOOST_CHECK_EQUAL( INet4SocketAddress("127.0.0.1:12345").port(), 12345u );
}
}
+prefix_ std::ostream & senf::operator<<(std::ostream & os, LLSocketAddress const & llAddr)
+{
+ os << "[" << llAddr.address()
+ << '%' << llAddr.interface()
+ << ' ' << llAddr.protocol()
+ << ' ' << llAddr.arptype()
+ << ( llAddr.pkttype() == senf::LLSocketAddress::Host ? " Host" :
+ llAddr.pkttype() == senf::LLSocketAddress::Broadcast ? " Broadcast" :
+ llAddr.pkttype() == senf::LLSocketAddress::Multicast ? " Multicast" :
+ llAddr.pkttype() == senf::LLSocketAddress::OtherHost ? " OtherHost" :
+ llAddr.pkttype() == senf::LLSocketAddress::Outgoing ? " Outgoing" :
+ llAddr.pkttype() == senf::LLSocketAddress::Broadcast ? "Broadcast" : "" )
+ << "]";
+ return os;
+}
+
///////////////////////////////cc.e////////////////////////////////////////
#undef prefix_
//#include "LLAddressing.mpp"
return MACAddress::from_data(&addr_.sll_addr[0]);
}
-prefix_ std::ostream & senf::operator<<(std::ostream & os, LLSocketAddress const & llAddr)
-{
- // TODO: expose more bytes from sockaddr_ll addr_
- os << "[some LLSocketAddress]";
- return os;
-}
-
///////////////////////////////cci.e///////////////////////////////////////
#undef prefix_
: FileHandle(other)
{
SENF_ASSERT( isChecked );
- SENF_ASSERT( dynamic_cast<SocketBody *>(&FileHandle::body()) );
+ SENF_ASSERT( ! valid() || dynamic_cast<SocketBody *>(&FileHandle::body()) );
}
template <class SPolicy>