4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
6 // The contents of this file are subject to the Fraunhofer FOKUS Public License
7 // Version 1.0 (the "License"); you may not use this file except in compliance
8 // with the License. You may obtain a copy of the License at
9 // http://senf.berlios.de/license.html
11 // The Fraunhofer FOKUS Public License Version 1.0 is based on,
12 // but modifies the Mozilla Public License Version 1.1.
13 // See the full license text for the amendments.
15 // Software distributed under the License is distributed on an "AS IS" basis,
16 // WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
17 // for the specific language governing rights and limitations under the License.
19 // The Original Code is Fraunhofer FOKUS code.
21 // The Initial Developer of the Original Code is Fraunhofer-Gesellschaft e.V.
22 // (registered association), Hansastraße 27 c, 80686 Munich, Germany.
23 // All Rights Reserved.
26 // Joachim Kaeber <jkaeber@berlios.de>
28 \brief GREPacket public header */
30 #ifndef HH_SENF_Packets_MPEGDVBBundle_GREPacket_
31 #define HH_SENF_Packets_MPEGDVBBundle_GREPacket_ 1
34 #include <senf/Packets/DefaultBundle/EthernetPacket.hh>
36 //#include "GREPacket.mpp"
37 //-/////////////////////////////////////////////////////////////////////////////////////////////////
41 /** \brief Parse a GRE packet
43 Parser implementing the header of a General Routing Encapsulation (GRE, RFC 2784) Packet
47 struct GREChecksumParser : public PacketParserBase {
48 # include SENF_PARSER()
49 SENF_PARSER_FIELD ( checksum1_, UInt16Parser );
50 SENF_PARSER_PRIVATE_FIELD ( reserved1_, UInt16Parser );
51 SENF_PARSER_FINALIZE(GREChecksumParser);
54 struct GREPacketParser : public PacketParserBase
56 # include SENF_PARSER()
58 SENF_PARSER_BITFIELD ( checksum_present, 1, bool );
59 SENF_PARSER_PRIVATE_BITFIELD ( reserved0_, 12, unsigned ); // TODO: SKIP !!
60 SENF_PARSER_BITFIELD ( version_number, 3, unsigned ); // TODO: Always Zero !!
61 SENF_PARSER_FIELD ( protocol_type, UInt16Parser );
62 SENF_PARSER_PRIVATE_VARIANT ( checksum_, checksum_present,
63 (VoidPacketParser) (GREChecksumParser) );
65 SENF_PARSER_FINALIZE( GREPacketParser );
68 UInt16Parser checksum() const /// only defined if checksum_present() == \c true
69 { return checksum_().get<1>().checksum1_(); }
74 \par Packet type (typedef):
79 \image html GREPacket.png
81 \ingroup protocolbundle_mpegdvb
84 : public PacketTypeBase,
85 public PacketTypeMixin<GREPacketType, EtherTypes>
87 typedef PacketTypeMixin<GREPacketType, EtherTypes> mixin;
88 typedef ConcretePacket<GREPacketType> packet;
89 typedef GREPacketParser parser;
91 using mixin::nextPacketRange;
92 using mixin::nextPacketType;
94 using mixin::initSize;
96 static void dump(packet p, std::ostream & os);
97 static EtherTypes::key_t nextPacketKey(packet p) {
98 return p->protocol_type();
100 static void finalize(packet p) {
101 p->protocol_type() << key(p.next(nothrow));
102 p->version_number() = 0; // as per RFC2784, 2.3.1
104 if (p->checksum_present()) {
112 /** \brief GRE packet typedef */
113 typedef GREPacketType::packet GREPacket;
119 //-/////////////////////////////////////////////////////////////////////////////////////////////////
120 //#include "TransportPacket.cci"
121 //#include "TransportPacket.ct"
122 //#include "TransportPacket.cti"
129 // c-file-style: "senf"
130 // indent-tabs-mode: nil
131 // ispell-local-dictionary: "american"
132 // compile-command: "scons -u test"
133 // comment-column: 40