4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
5 // Competence Center NETwork research (NET), St. Augustin, GERMANY
6 // Joachim Kaeber <jkaeber@berlios.de>
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.
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.
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.
24 \brief GREPacket public header */
26 #ifndef HH_SENF_Packets_MPEGDVBBundle_GREPacket_
27 #define HH_SENF_Packets_MPEGDVBBundle_GREPacket_ 1
30 #include <senf/Packets/DefaultBundle/EthernetPacket.hh>
32 //#include "GREPacket.mpp"
33 //-/////////////////////////////////////////////////////////////////////////////////////////////////
37 /** \brief Parse a GRE packet
39 Parser implementing the header of a General Routing Encapsulation (GRE, RFC 2784) Packet
43 struct GREChecksumParser : public PacketParserBase {
44 # include SENF_PARSER()
45 SENF_PARSER_FIELD ( checksum1_, UInt16Parser );
46 SENF_PARSER_PRIVATE_FIELD ( reserved1_, UInt16Parser );
47 SENF_PARSER_FINALIZE(GREChecksumParser);
50 struct GREPacketParser : public PacketParserBase
52 # include SENF_PARSER()
54 SENF_PARSER_BITFIELD ( checksum_present, 1, bool );
55 SENF_PARSER_PRIVATE_BITFIELD ( reserved0_, 12, unsigned ); // TODO: SKIP !!
56 SENF_PARSER_BITFIELD ( version_number, 3, unsigned ); // TODO: Always Zero !!
57 SENF_PARSER_FIELD ( protocol_type, UInt16Parser );
58 SENF_PARSER_PRIVATE_VARIANT ( checksum_, checksum_present,
59 (VoidPacketParser) (GREChecksumParser) );
61 SENF_PARSER_FINALIZE( GREPacketParser );
64 UInt16Parser checksum() const /// only defined if checksum_present() == \c true
65 { return checksum_().get<1>().checksum1_(); }
70 \par Packet type (typedef):
75 \image html GREPacket.png
77 \ingroup protocolbundle_mpegdvb
80 : public PacketTypeBase,
81 public PacketTypeMixin<GREPacketType, EtherTypes>
83 typedef PacketTypeMixin<GREPacketType, EtherTypes> mixin;
84 typedef ConcretePacket<GREPacketType> packet;
85 typedef GREPacketParser parser;
87 using mixin::nextPacketRange;
88 using mixin::nextPacketType;
90 using mixin::initSize;
92 static void dump(packet p, std::ostream & os);
93 static EtherTypes::key_t nextPacketKey(packet p) {
94 return p->protocol_type();
96 static void finalize(packet p) {
97 p->protocol_type() << key(p.next(nothrow));
98 p->version_number() = 0; // as per RFC2784, 2.3.1
100 if (p->checksum_present()) {
108 /** \brief GRE packet typedef */
109 typedef GREPacketType::packet GREPacket;
115 //-/////////////////////////////////////////////////////////////////////////////////////////////////
116 //#include "TransportPacket.cci"
117 //#include "TransportPacket.ct"
118 //#include "TransportPacket.cti"
125 // c-file-style: "senf"
126 // indent-tabs-mode: nil
127 // ispell-local-dictionary: "american"
128 // compile-command: "scons -u test"
129 // comment-column: 40