X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=senf%2FPackets%2FMainpage.dox;h=f36ac13e3e91b15f7a56b0c2e6ca811c27c7d1d6;hb=209950ee5f6898978cd68614ef339ae3531c5c53;hp=308d9ac404c9f28f29e1e90c5dcc2b24546180b5;hpb=601d1f509f5bb24df167a4dd5a20da67a0af9af8;p=senf.git diff --git a/senf/Packets/Mainpage.dox b/senf/Packets/Mainpage.dox index 308d9ac..f36ac13 100644 --- a/senf/Packets/Mainpage.dox +++ b/senf/Packets/Mainpage.dox @@ -282,7 +282,8 @@ checksums etc). Now the packet is ready. We may now send it out using a packet socket \code - senf::PacketSocketHandle sock ("eth0"); + senf::PacketSocketHandle sock(); + sock.bind( senf::LLSocketAddress("eth0")); sock.write(eth.data()); \endcode @@ -293,7 +294,8 @@ from a packet socket handle: \code - senf::PacketSocketHandle sock ("eth0"); + senf::PacketSocketHandle sock(); + sock.bind( senf::LLSocketAddress("eth0")); senf::EthernetPacket packet (senf::EthernetPacket::create(senf::noinit)); sock.read(packet.data(),0u); \endcode @@ -676,6 +678,10 @@ struct Timestamp { senf::ClockService::clock_t value; }; + + std::ostream & operator<<(std::ostream & os, Timestamp const & tstamp) { + os << tstamp.value; return os; + } senf::EthernetPacket packet (senf::EthernetPacket::create(senf::noinit)); sock.read(packet.data(), 0u); @@ -687,17 +693,20 @@ \code if (senf::ClockService::now() - packet.annotation().value > senf::ClockService::seconds(1)) { - // Ouch ... this packet is to old + // this packet is to old // ... } \endcode - + It is very important to define a specific structure (or class or enum) type for each type of annotation. \e Never directly store a fundamental type as an annotation: The name of the type is used to look up the annotation, so you can store only one annotation for each built-in type. \c typedef does not help since \c typedef does not introduce new type names, it only defines an alias. + The annotation type must support the output \c operator<< for description purposes + (e.g. for the \ref senf::Packet::dump() "Packet::dump()" member). + Of course, the annotation structure can be arbitrary. However, one very important caveat: If the annotation is not a POD type, it needs to inherit from senf::ComplexAnnotation. A type is POD, if it is really just a bunch of bytes: No (non-static) members, no constructor or destructor and