Packets/DefaultBundle: Documentation
[senf.git] / Packets / DefaultBundle / UDPPacket.hh
1 // $Id$
2 //
3 // Copyright (C) 2006
4 // Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS)
5 // Kompetenzzentrum fuer Satelitenkommunikation (SatCom)
6 //     Stefan Bund <stefan.bund@fokus.fraunhofer.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 #ifndef HH_UDPPacket_
24 #define HH_UDPPacket_ 1
25
26 // Custom includes
27 #include "Packets/Packets.hh"
28
29 //#include "UDPPacket.mpp"
30 ///////////////////////////////hh.p////////////////////////////////////////
31
32 namespace senf {
33
34     /** \brief Parse a UDP packet
35
36         Parser implementing the UDP header. The fields implemented are:
37
38         <table class="senf">
39             <tr><th>Field name</th><th>Parser type</th></tr>
40             <tr><td>source</td><td>\ref Parse_16bit</td></tr>
41             <tr><td>destination</td><td>\ref Parse_16bit</td></tr>
42             <tr><td>length</td><td>\ref Parse_16bit</td></tr>
43             <tr><td>crc</td><td>\ref Parse_16bit</td></tr>
44         </table>
45
46         \see UDPPacketType
47             <a href="http://tools.ietf.org/html/rfc768">RFC 768</a>
48      */
49     struct Parse_UDP : public PacketParserBase
50     {
51         SENF_PACKET_PARSER_INIT(Parse_UDP);
52
53         ///////////////////////////////////////////////////////////////////////////
54
55         typedef Parse_UInt16 Parse_16bit;
56
57         SENF_PACKET_PARSER_DEFINE_FIXED_FIELDS(
58             ((Field)( source,      Parse_16bit ))
59             ((Field)( destination, Parse_16bit ))
60             ((Field)( length,      Parse_16bit ))
61             ((Field)( crc,         Parse_16bit )) );
62     };
63
64     /** \brief UDP packet
65         
66         \par Packet type (typedef):
67             \ref UDPPacket
68
69         \par Fields:
70             \ref Parse_UDP
71
72         \ingroup protocolbundle_default
73      */
74     struct UDPPacketType
75         : public PacketTypeBase,
76           public PacketTypeMixin<UDPPacketType>
77     {
78         typedef PacketTypeMixin<UDPPacketType> mixin;
79         typedef ConcretePacket<UDPPacketType> packet;
80         typedef Parse_UDP parser;
81
82         using mixin::nextPacketRange;
83         using mixin::initSize;
84         using mixin::init;
85
86         static void dump(packet p, std::ostream & os);
87     };
88
89     /** \brief UDP packet typedef */
90     typedef UDPPacketType::packet UDPPacket;
91 }
92
93
94 ///////////////////////////////hh.e////////////////////////////////////////
95 #endif
96 #ifndef SENF_PACKETS_DECL_ONLY
97 //#include UDPPacket.cci"
98 //#include "UDPPacket.ct"
99 //#include "UDPPacket.cti"
100 #endif
101
102 \f
103 // Local Variables:
104 // mode: c++
105 // fill-column: 100
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
111 // End: