5ea93db33ef6fd6dae0e2017a7ea56ee003d2d55
[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         \see UDPPacketType
39             <a href="http://tools.ietf.org/html/rfc768">RFC 768</a>
40      */
41     struct Parse_UDP : public PacketParserBase
42     {
43         typedef Parse_UInt16 Parse_16bit;
44
45 #       ifndef DOXYGEN
46
47         SENF_PACKET_PARSER_INIT(Parse_UDP);
48
49         SENF_PACKET_PARSER_DEFINE_FIXED_FIELDS(
50             ((Field)( source,      Parse_16bit ))
51             ((Field)( destination, Parse_16bit ))
52             ((Field)( length,      Parse_16bit ))
53             ((Field)( crc,         Parse_16bit )) );
54
55 #       else
56
57         Parse_16bit source();
58         Parse_16bit destination();
59         Parse_16bit length();
60         Parse_16bit crc();
61
62 #       endif
63     };
64
65     /** \brief UDP packet
66         
67         \par Packet type (typedef):
68             \ref UDPPacket
69
70         \par Fields:
71             \ref Parse_UDP
72
73         \ingroup protocolbundle_default
74      */
75     struct UDPPacketType
76         : public PacketTypeBase,
77           public PacketTypeMixin<UDPPacketType>
78     {
79         typedef PacketTypeMixin<UDPPacketType> mixin;
80         typedef ConcretePacket<UDPPacketType> packet;
81         typedef Parse_UDP parser;
82
83         using mixin::nextPacketRange;
84         using mixin::initSize;
85         using mixin::init;
86
87         static void dump(packet p, std::ostream & os);
88     };
89
90     /** \brief UDP packet typedef */
91     typedef UDPPacketType::packet UDPPacket;
92 }
93
94
95 ///////////////////////////////hh.e////////////////////////////////////////
96 #endif
97 #ifndef SENF_PACKETS_DECL_ONLY
98 //#include UDPPacket.cci"
99 //#include "UDPPacket.ct"
100 //#include "UDPPacket.cti"
101 #endif
102
103 \f
104 // Local Variables:
105 // mode: c++
106 // fill-column: 100
107 // c-file-style: "senf"
108 // indent-tabs-mode: nil
109 // ispell-local-dictionary: "american"
110 // compile-command: "scons -u test"
111 // comment-column: 40
112 // End: