Fix documentation build under maverick (doxygen 1.7.1)
[senf.git] / senf / Packets / DefaultBundle / UDPPacket.hh
1 // $Id$
2 //
3 // Copyright (C) 2006
4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
5 // Competence Center NETwork research (NET), St. Augustin, GERMANY
6 //     Stefan Bund <g0dil@berlios.de>
7 //
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.
12 //
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.
17 //
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.
22
23 /** \file
24     \brief UDPPacket public header */
25
26 #ifndef HH_SENF_Packets_DefaultBundle_UDPPacket_
27 #define HH_SENF_Packets_DefaultBundle_UDPPacket_ 1
28
29 // Custom includes
30 #include <senf/Packets/Packets.hh>
31
32 //#include "UDPPacket.mpp"
33 //-/////////////////////////////////////////////////////////////////////////////////////////////////
34
35 namespace senf {
36
37     /** \brief Parse a UDP packet
38
39         Parser implementing the UDP header. The fields implemented are:
40         \image html UDPPacket.png
41
42         \see UDPPacketType \n
43             <a href="http://tools.ietf.org/html/rfc768">RFC 768</a>
44      */
45     struct UDPPacketParser : public PacketParserBase
46     {
47 #       include SENF_FIXED_PARSER()
48
49         SENF_PARSER_FIELD( source,      senf::UInt16Parser );
50         SENF_PARSER_FIELD( destination, senf::UInt16Parser );
51         SENF_PARSER_FIELD( length,      senf::UInt16Parser );
52         SENF_PARSER_FIELD( checksum,    senf::UInt16Parser );
53
54         SENF_PARSER_FINALIZE(UDPPacketParser);
55
56         boost::uint16_t calcChecksum() const; ///< calculate (pseudo-)header checksum
57                                               /**< calculate and return the checksum of the
58                                                    (pseudo-)header \see \ref senf::IpChecksum */
59         bool validateChecksum() const {
60             return checksum() == 0u || checksum() == calcChecksum();
61         }                               ///< validate header checksum
62                                         /**< return \c true if the \ref checksum() "checksum"
63                                              field is equal to the \ref calcChecksum() "calculated checksum" */
64     };
65
66     /** \brief UDP packet
67
68         \par Packet type (typedef):
69             \ref UDPPacket
70
71         \par Fields:
72             \ref UDPPacketParser
73
74         <table class="packet" cellpadding="5" cellspacing="1" border="1">
75           <tr>
76             <th width="25%">0</th> <th width="25%">8</th> <th width="25%">16</th>
77             <th width="15%">24</th> <th style="text-align:right" width="10%">31</th>
78           </tr><tr>
79             <td colspan="2">\ref UDPPacketParser::source() "Source Port"</td>
80             <td colspan="3">\ref UDPPacketParser::destination() "Destination Port"</td>
81           </tr><tr>
82             <td colspan="2">\ref UDPPacketParser::length() "Length"</td>
83             <td colspan="3">\ref UDPPacketParser::checksum() "Checksum"</td>
84           </tr>
85         </table>
86
87         \par Finalize action:
88             \copydetails finalize()
89
90         \ingroup protocolbundle_default
91      */
92     struct UDPPacketType
93         : public PacketTypeBase,
94           public PacketTypeMixin<UDPPacketType>
95     {
96 #ifndef DOXYGEN
97         typedef PacketTypeMixin<UDPPacketType> mixin;
98 #endif
99         typedef ConcretePacket<UDPPacketType> packet; ///< UDP packet typedef
100         typedef UDPPacketParser parser;               ///< typedef to the parser of UDP packet
101
102         using mixin::nextPacketRange;
103         using mixin::initSize;
104         using mixin::init;
105
106         /** \brief Dump given UDPPacket in readable form to given output stream */
107         static void dump(packet p, std::ostream & os);
108
109         static void finalize(packet p); ///< Finalize packet.
110                                         /**< \li set \ref UDPPacketParser::length() "length" from
111                                                payload size
112                                              \li calculate and set \ref UDPPacketParser::checksum()
113                                                "checksum" */
114     };
115
116     /** \brief UDP packet typedef
117         \ingroup protocolbundle_default
118      */
119     typedef ConcretePacket<UDPPacketType> UDPPacket;
120 }
121
122
123 //-/////////////////////////////////////////////////////////////////////////////////////////////////
124 //#include "UDPPacket.cci"
125 //#include "UDPPacket.ct"
126 //#include "UDPPacket.cti"
127 #endif
128
129 \f
130 // Local Variables:
131 // mode: c++
132 // fill-column: 100
133 // c-file-style: "senf"
134 // indent-tabs-mode: nil
135 // ispell-local-dictionary: "american"
136 // compile-command: "scons -u test"
137 // comment-column: 40
138 // End: