4 // Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS)
5 // Kompetenzzentrum fuer Satelitenkommunikation (SatCom)
6 // Stefan Bund <stefan.bund@fokus.fraunhofer.de>
8 // This program is free software; you can redistribute it and/or modify
9 // it under the terms of the GNU General Public License as published by
10 // the Free Software Foundation; either version 2 of the License, or
11 // (at your option) any later version.
13 // This program is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 // GNU General Public License for more details.
18 // You should have received a copy of the GNU General Public License
19 // along with this program; if not, write to the
20 // Free Software Foundation, Inc.,
21 // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24 \brief UDPPacket public header */
27 #define HH_UDPPacket_ 1
30 #include "../../Packets/Packets.hh"
32 //#include "UDPPacket.mpp"
33 ///////////////////////////////hh.p////////////////////////////////////////
37 /** \brief Parse a UDP packet
39 Parser implementing the UDP header. The fields implemented are:
42 <a href="http://tools.ietf.org/html/rfc768">RFC 768</a>
44 struct Parse_UDP : public PacketParserBase
46 # include SENF_FIXED_PARSER()
48 SENF_PARSER_FIELD( source, senf::Parse_UInt16 );
49 SENF_PARSER_FIELD( destination, senf::Parse_UInt16 );
50 SENF_PARSER_FIELD( length, senf::Parse_UInt16 );
51 SENF_PARSER_FIELD( checksum, senf::Parse_UInt16 );
53 SENF_PARSER_FINALIZE(Parse_UDP);
55 boost::uint16_t calcChecksum() const;
57 bool validateChecksum() const {
58 return checksum() == 0u || checksum() == calcChecksum();
64 \par Packet type (typedef):
70 \ingroup protocolbundle_default
73 : public PacketTypeBase,
74 public PacketTypeMixin<UDPPacketType>
76 typedef PacketTypeMixin<UDPPacketType> mixin;
77 typedef ConcretePacket<UDPPacketType> packet;
78 typedef Parse_UDP parser;
80 using mixin::nextPacketRange;
81 using mixin::initSize;
84 static void dump(packet p, std::ostream & os);
86 static void finalize(packet p);
89 /** \brief UDP packet typedef */
90 typedef UDPPacketType::packet UDPPacket;
94 ///////////////////////////////hh.e////////////////////////////////////////
96 #ifndef SENF_PACKETS_DECL_ONLY
97 //#include UDPPacket.cci"
98 //#include "UDPPacket.ct"
99 //#include "UDPPacket.cti"
106 // c-file-style: "senf"
107 // indent-tabs-mode: nil
108 // ispell-local-dictionary: "american"
109 // compile-command: "scons -u test"
110 // comment-column: 40