X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=senf%2FPackets%2FDefaultBundle%2FIPv4Packet.hh;h=96431492e41b7b463696009e7e4e053aa28db599;hb=5cb66935d4b2973ea0fe7487b862b9ddc31648f4;hp=0cdae50f558752534870d50534512c05a659beaf;hpb=601d1f509f5bb24df167a4dd5a20da67a0af9af8;p=senf.git diff --git a/senf/Packets/DefaultBundle/IPv4Packet.hh b/senf/Packets/DefaultBundle/IPv4Packet.hh index 0cdae50..9643149 100644 --- a/senf/Packets/DefaultBundle/IPv4Packet.hh +++ b/senf/Packets/DefaultBundle/IPv4Packet.hh @@ -27,11 +27,11 @@ #define HH_SENF_Packets_DefaultBundle_IPv4Packet_ 1 // Custom includes -#include "../../Socket/Protocols/INet/INet4Address.hh" -#include "../../Packets/Packets.hh" +#include +#include //#include "IPv4Packet.mpp" -///////////////////////////////hh.p//////////////////////////////////////// +//-///////////////////////////////////////////////////////////////////////////////////////////////// namespace senf { @@ -39,29 +39,23 @@ namespace senf { \see INet4Address */ - struct INet4AddressParser : public PacketParserBase + struct INet4AddressParser + : public ValueParserBase { - INet4AddressParser(data_iterator i, state_type s) : PacketParserBase(i,s,fixed_bytes) {} - - /////////////////////////////////////////////////////////////////////////// - - typedef INet4Address value_type; - static const size_type fixed_bytes = 4u; + INet4AddressParser(data_iterator i, state_type s) : Base(i,s) {} value_type value() const { return value_type::from_data(i()); } void value(value_type const & v) { std::copy(v.begin(), v.end(), i()); } - operator value_type() const { return value(); } - byte & operator[](size_type index) const { return *boost::next(i(),index); } - INet4AddressParser const & operator= (value_type const & other) - { value(other); return *this; } + + using Base::operator=; }; /** \brief Parse an IPv4 packet Parser implementing the IPv4 header. - + \image html IPv4Packet.png - + \see IPv4PacketType \n RFC 791 @@ -96,7 +90,7 @@ namespace senf { } SENF_PARSER_FINALIZE(IPv4PacketParser); - + boost::uint16_t calcChecksum() const; ///< calculate header checksum /**< calculate and return the checksum of the header \see \ref senf::IpChecksum */ @@ -104,8 +98,8 @@ namespace senf { bool validateChecksum() const { return checksum() == calcChecksum(); } ///< validate header checksum - /**< return \c true if the \ref checksum() "checksum" - field is equal to the \ref calcChecksum() + /**< return \c true if the \ref checksum() "checksum" + field is equal to the \ref calcChecksum() "calculated checksum" */ }; @@ -117,11 +111,11 @@ namespace senf { PacketRegistry */ struct IpTypes { - typedef boost::uint16_t key_t; + typedef boost::uint8_t key_t; }; /** \brief IPv4 packet - + \par Packet type (typedef): \ref IPv4Packet @@ -139,7 +133,7 @@ namespace senf { \ref IPv4PacketParser::version() "Version" \ref IPv4PacketParser::ihl() "IHL" \ref IPv4PacketParser::tos() "TOS" - \ref IPv4PacketParser::length() "Length" + \ref IPv4PacketParser::length() "Length" \ref IPv4PacketParser::identifier() "Identifier" R @@ -162,7 +156,7 @@ namespace senf { \par Finalize action: \copydetails finalize() - + \ingroup protocolbundle_default */ struct IPv4PacketType @@ -180,27 +174,29 @@ namespace senf { using mixin::initSize; using mixin::init; - static key_t nextPacketKey(packet p) + static key_t nextPacketKey(packet p) { return p->protocol(); } - + /** \brief Dump given IPv4Packet in readable form to given output stream */ - static void dump(packet p, std::ostream & os); - + static void dump(packet p, std::ostream & os); + static void finalize(packet p); ///< Finalize packet. - /**< \li set \ref IPv4PacketParser::length() "length" + /**< \li set \ref IPv4PacketParser::length() "length" from payload size - \li set \ref IPv4PacketParser::protocol() "protocol" + \li set \ref IPv4PacketParser::protocol() "protocol" from type of next packet if found in \ref IpTypes - \li calculate and set + \li calculate and set \ref IPv4PacketParser::checksum() "checksum" */ }; - /** \brief IPv4 packet typedef */ + /** \brief IPv4 packet typedef + \ingroup protocolbundle_default + */ typedef ConcretePacket IPv4Packet; } -///////////////////////////////hh.e//////////////////////////////////////// +//-///////////////////////////////////////////////////////////////////////////////////////////////// //#include "IPv4Packet.cci" //#include "IPv4Packet.ct" //#include "IPv4Packet.cti"