ff6104e87464794392fefeb59c425406fb2f1c25
[senf.git] / senf / Packets / DefaultBundle / LlcSnapPacket.hh
1 // $Id$
2 //
3 // Copyright (C) 2007
4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
5 // Competence Center NETwork research (NET), St. Augustin, GERMANY
6 //     Thorsten Horstmann <tho@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 LLC/SNAP public header */
25
26 #ifndef HH_SENF_Packets_DefaultBundle_LlcSnapPacket_
27 #define HH_SENF_Packets_DefaultBundle_LlcSnapPacket_ 1
28
29 // Custom includes
30 #include <algorithm>
31 #include "EthernetPacket.hh"
32 #include <senf/Packets/Packets.hh>
33
34 //#include "LlcSnapPacket.mpp"
35 ///////////////////////////////hh.p////////////////////////////////////////
36
37 namespace senf {
38
39     /** \brief Parse a LLC/SNAP header
40
41         \image html LlcSnapPacket.png
42         \todo document me
43      */
44     struct LlcSnapPacketParser : public PacketParserBase
45     {
46 #       include SENF_FIXED_PARSER()
47
48         SENF_PARSER_FIELD( dsap, UInt8Parser );
49         SENF_PARSER_FIELD( ssap, UInt8Parser );
50         SENF_PARSER_FIELD( ctrl, UInt8Parser );
51
52         SENF_PARSER_FIELD( protocolId, UInt24Parser );
53         SENF_PARSER_FIELD( type_length, UInt16Parser );
54
55         SENF_PARSER_FINALIZE(LlcSnapPacketParser);
56
57         SENF_PARSER_INIT() {
58             dsap() = 0xaa;
59             ssap() = 0xaa;
60             ctrl() = 0x03;
61             protocolId() = 0x000000;
62         }
63     };
64
65     /** \brief LLC/SNAP header
66
67         \todo document me
68
69         \par Packet type (typedef):
70             \ref LlcSnapPacketType
71
72         \par Fields:
73             \ref LlcSnapPacketParser
74
75         \par Associated registries:
76             \ref EtherTypes
77
78         \par Finalize action:
79             XXXX
80
81         \ingroup protocolbundle_default
82      */
83     struct LlcSnapPacketType
84         : public PacketTypeBase,
85           public PacketTypeMixin<LlcSnapPacketType, EtherTypes>
86     {
87 #ifndef DOXYGEN
88         typedef PacketTypeMixin<LlcSnapPacketType, EtherTypes> mixin;
89 #endif
90         typedef ConcretePacket<LlcSnapPacketType> packet; ///< LLC/SNAP packet typedef
91         typedef LlcSnapPacketParser parser;               ///< typedef to the parser of LLC/SNAP packet
92
93         using mixin::nextPacketRange;
94         using mixin::initSize;
95         using mixin::init;
96
97         static factory_t nextPacketType(packet p);
98         /** \brief Dump given LlcSnapPacket in readable form to given output stream */
99         static void dump(packet p, std::ostream & os);
100         static void finalize(packet p);
101     };
102
103     /** \brief LLC/SNAP packet typedef
104         \ingroup protocolbundle_default
105      */
106     typedef ConcretePacket<LlcSnapPacketType> LlcSnapPacket;
107 }
108
109
110 ///////////////////////////////hh.e////////////////////////////////////////
111 //#include "LlcSnapPacket.cci"
112 //#include "LlcSnapPacket.ct"
113 //#include "LlcSnapPacket.cti"
114 #endif
115
116 \f
117 // Local Variables:
118 // mode: c++
119 // fill-column: 100
120 // c-file-style: "senf"
121 // indent-tabs-mode: nil
122 // ispell-local-dictionary: "american"
123 // compile-command: "scons -u test"
124 // comment-column: 40
125 // End: