// $Id$
//
// Copyright (C) 2006
-// Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS)
-// Kompetenzzentrum fuer Satelitenkommunikation (SatCom)
-// Stefan Bund <stefan.bund@fokus.fraunhofer.de>
+// Fraunhofer Institute for Open Communication Systems (FOKUS)
+// Competence Center NETwork research (NET), St. Augustin, GERMANY
+// Stefan Bund <g0dil@berlios.de>
//
// 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
/** \file
\brief UDPPacket public header */
-#ifndef HH_UDPPacket_
-#define HH_UDPPacket_ 1
+#ifndef HH_SENF_Packets_DefaultBundle_UDPPacket_
+#define HH_SENF_Packets_DefaultBundle_UDPPacket_ 1
// Custom includes
#include "../../Packets/Packets.hh"
/** \brief Parse a UDP packet
Parser implementing the UDP header. The fields implemented are:
-
- \see UDPPacketType
+ \image html UDPPacket.png
+
+ \see UDPPacketType \n
<a href="http://tools.ietf.org/html/rfc768">RFC 768</a>
*/
- struct Parse_UDP : public PacketParserBase
+ struct UDPPacketParser : public PacketParserBase
{
# include SENF_FIXED_PARSER()
- SENF_PARSER_FIELD( source, senf::Parse_UInt16 );
- SENF_PARSER_FIELD( destination, senf::Parse_UInt16 );
- SENF_PARSER_FIELD( length, senf::Parse_UInt16 );
- SENF_PARSER_FIELD( checksum, senf::Parse_UInt16 );
+ 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(Parse_UDP);
-
- boost::uint16_t calcChecksum() const;
+ 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
\ref UDPPacket
\par Fields:
- \ref Parse_UDP
-
+ \ref UDPPacketParser
+
+ <table class="packet" cellpadding="5" cellspacing="1" border="1">
+ <tr>
+ <th width="25%">0</th> <th width="25%">8</th> <th width="25%">16</th>
+ <th width="15%">24</th> <th style="text-align:right" width="10%">31</th>
+ </tr><tr>
+ <td colspan="2">\ref UDPPacketParser::source() "Source Port"</td>
+ <td colspan="3">\ref UDPPacketParser::destination() "Destination Port"</td>
+ </tr><tr>
+ <td colspan="2">\ref UDPPacketParser::length() "Length"</td>
+ <td colspan="3">\ref UDPPacketParser::checksum() "Checksum"</td>
+ </tr>
+ </table>
+
\par Finalize action:
- Set \a length from payload size\n
- Calculate \a checksum
+ \copydetails finalize()
\ingroup protocolbundle_default
*/
: public PacketTypeBase,
public PacketTypeMixin<UDPPacketType>
{
+#ifndef DOXYGEN
typedef PacketTypeMixin<UDPPacketType> mixin;
- typedef ConcretePacket<UDPPacketType> packet;
- typedef Parse_UDP parser;
+#endif
+ typedef ConcretePacket<UDPPacketType> 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);
+
+ static void finalize(packet p); ///< Finalize packet.
+ /**< \li set \ref UDPPacketParser::length() "length" from
+ payload size
+ \li calculate and set \ref UDPPacketParser::checksum()
+ "checksum" */
};
/** \brief UDP packet typedef */
- typedef UDPPacketType::packet UDPPacket;
+ typedef ConcretePacket<UDPPacketType> UDPPacket;
}
///////////////////////////////hh.e////////////////////////////////////////
#endif
#ifndef SENF_PACKETS_DECL_ONLY
-//#include UDPPacket.cci"
+//#include "UDPPacket.cci"
//#include "UDPPacket.ct"
//#include "UDPPacket.cti"
#endif