X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=Packets%2FDefaultBundle%2FUDPPacket.hh;h=e85c182dcf9f2f3be46aff0bd9f78bddb817547c;hb=5443435c4c2b6e4386c5334b5b8358273f2bae93;hp=26485486fa8fc987c2aa1b9c38030c9043ebca46;hpb=64e170521a221effc1ba11a0544f753544d03bac;p=senf.git diff --git a/Packets/DefaultBundle/UDPPacket.hh b/Packets/DefaultBundle/UDPPacket.hh index 2648548..e85c182 100644 --- a/Packets/DefaultBundle/UDPPacket.hh +++ b/Packets/DefaultBundle/UDPPacket.hh @@ -1,9 +1,9 @@ -// $Id: UDPPacket.hh 308 2007-07-14 22:31:20Z g0dil $ +// $Id$ // // Copyright (C) 2006 -// Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS) -// Kompetenzzentrum fuer Satelitenkommunikation (SatCom) -// Stefan Bund +// Fraunhofer Institute for Open Communication Systems (FOKUS) +// Competence Center NETwork research (NET), St. Augustin, GERMANY +// Stefan Bund // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by @@ -20,62 +20,108 @@ // Free Software Foundation, Inc., // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -#ifndef HH_UDPPacket_ -#define HH_UDPPacket_ 1 +/** \file + \brief UDPPacket public header */ + +#ifndef HH_SENF_Packets_DefaultBundle_UDPPacket_ +#define HH_SENF_Packets_DefaultBundle_UDPPacket_ 1 // Custom includes -#include "Packets/PacketType.hh" -#include "Packets/ParseInt.hh" -#include "Packets/PacketRegistry.hh" -#include "Packets/PacketParser.hh" +#include "../../Packets/Packets.hh" //#include "UDPPacket.mpp" ///////////////////////////////hh.p//////////////////////////////////////// namespace senf { - ///\addtogroup protocolbundle_default - ///@{ + /** \brief Parse a UDP packet - // See RFC768 - struct Parse_UDP : public PacketParserBase + Parser implementing the UDP header. The fields implemented are: + \image html UDPPacket.png + + \see UDPPacketType \n + RFC 768 + */ + struct UDPPacketParser : public PacketParserBase { - SENF_PACKET_PARSER_INIT(Parse_UDP); - - /////////////////////////////////////////////////////////////////////////// - - typedef Parse_UInt16 Parse_16bit; - - SENF_PACKET_PARSER_DEFINE_FIXED_FIELDS( - ((Field)( source, Parse_16bit )) - ((Field)( destination, Parse_16bit )) - ((Field)( length, Parse_16bit )) - ((Field)( crc, Parse_16bit )) ); +# include SENF_FIXED_PARSER() + + SENF_PARSER_FIELD( source, senf::UInt16Parser ); + SENF_PARSER_FIELD( destination, senf::UInt16Parser ); + SENF_PARSER_FIELD( length, senf::UInt16Parser ); + SENF_PARSER_FIELD( checksum, senf::UInt16Parser ); + + SENF_PARSER_FINALIZE(UDPPacketParser); + + boost::uint16_t calcChecksum() const; ///< calculate (pseudo-)header checksum + /**< calculate and return the checksum of the + (pseudo-)header \see \ref senf::IpChecksum */ + bool validateChecksum() const { + return checksum() == 0u || checksum() == calcChecksum(); + } ///< validate header checksum + /**< return \c true if the \ref checksum() "checksum" + field is equal to the \ref calcChecksum() "calculated checksum" */ }; + /** \brief UDP packet + + \par Packet type (typedef): + \ref UDPPacket + + \par Fields: + \ref UDPPacketParser + + + + + + + + + + + + +
0 8 1624 31
\ref UDPPacketParser::source() "Source Port"\ref UDPPacketParser::destination() "Destination Port"
\ref UDPPacketParser::length() "Length"\ref UDPPacketParser::checksum() "Checksum"
+ + \par Finalize action: + \copydetails finalize() + + \ingroup protocolbundle_default + */ struct UDPPacketType : public PacketTypeBase, public PacketTypeMixin { +#ifndef DOXYGEN typedef PacketTypeMixin mixin; - typedef ConcretePacket packet; - typedef Parse_UDP parser; +#endif + typedef ConcretePacket packet; ///< UDP packet typedef + typedef UDPPacketParser parser; ///< typedef to the parser of UDP packet using mixin::nextPacketRange; using mixin::initSize; using mixin::init; + /** \brief Dump given UDPPacket in readable form to given output stream */ static void dump(packet p, std::ostream & os); + + static void finalize(packet p); ///< Finalize packet. + /**< \li set \ref UDPPacketParser::length() "length" from + payload size + \li calculate and set \ref UDPPacketParser::checksum() + "checksum" */ }; - typedef UDPPacketType::packet UDPPacket; - - ///@} + /** \brief UDP packet typedef */ + typedef ConcretePacket UDPPacket; } ///////////////////////////////hh.e//////////////////////////////////////// -//#include UDPPacket.cci" +#endif +#ifndef SENF_PACKETS_DECL_ONLY +//#include "UDPPacket.cci" //#include "UDPPacket.ct" //#include "UDPPacket.cti" #endif