8ee0a1cf30114edce6f5a10e9e198aed483dfa5e
[senf.git] / Packets / DefaultBundle / MPLSPacket.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 //     Christian Niephaus <cni@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 MPLSPacket public header */
25
26 #ifndef HH_SENF_Packets_DefaultBundle_MPLSPacket_
27 #define HH_SENF_Packets_DefaultBundle_MPLSPacket_ 1
28
29 // Custom includes
30
31 #include "../../Packets/Packets.hh"
32
33 //#include "MPLSPacket.mpp"
34 ///////////////////////////////hh.p////////////////////////////////////////
35
36 namespace senf {
37
38     /** \brief Parse an MPLS packet
39
40         Parser implementing an MPLS header.
41
42         \see MPLSPacketType
43      */
44     struct MPLSPacketParser : public PacketParserBase
45     {
46 #       include SENF_FIXED_PARSER()
47
48         SENF_PARSER_BITFIELD( label, 20, unsigned);
49         SENF_PARSER_BITFIELD( tc, 3, unsigned);
50         SENF_PARSER_BITFIELD( s, 1, bool);
51         SENF_PARSER_FIELD( ttl, UInt8Parser);
52
53         SENF_PARSER_FINALIZE(MPLSPacketParser);
54     };
55
56     /** \brief MPLS packet
57
58         \par Packet type (typedef):
59             \ref MPLSPacket
60
61         \par Fields:
62             \ref MPLSPacketParser
63           
64
65         \ingroup protocolbundle_default
66      */
67     struct MPLSPacketType
68         : public PacketTypeBase,
69           public PacketTypeMixin<MPLSPacketType>
70     {
71 #ifndef DOXYGEN
72         typedef PacketTypeMixin<MPLSPacketType> mixin;
73 #endif
74         typedef ConcretePacket<MPLSPacketType> packet;
75         typedef MPLSPacketParser parser;
76
77         using mixin::nextPacketRange;
78         using mixin::initSize;
79         using mixin::init;
80
81         static factory_t nextPacketType(packet p);
82         /// Dump given MPLSPacket in readable form to given output stream
83         static void dump(packet p, std::ostream & os); 
84         static void finalize(packet p);
85     };
86
87     /** \brief MPLS packet typedef */
88     typedef ConcretePacket<MPLSPacketType> MPLSPacket;
89
90
91 }
92
93 ///////////////////////////////hh.e////////////////////////////////////////
94 #endif
95 #ifndef SENF_PACKETS_DECL_ONLY
96 //#include "MPLSPacket.cci"
97 //#include "MPLSPacket.ct"
98 //#include "MPLSPacket.cti"
99 #endif
100
101 \f
102 // Local Variables:
103 // mode: c++
104 // fill-column: 100
105 // c-file-style: "senf"
106 // indent-tabs-mode: nil
107 // ispell-local-dictionary: "american"
108 // compile-command: "scons -u test"
109 // comment-column: 40
110 // End: