4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
5 // Competence Center NETwork research (NET), St. Augustin, GERMANY
6 // David Wagner <dw6@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 DTCPPacket public header */
26 #ifndef HH_DTCPPacket_
27 #define HH_DTCPPacket_ 1
30 #include "../../Packets/Packets.hh"
31 #include "../../Packets/DefaultBundle/IPv4Packet.hh"
32 #include "../../Packets/DefaultBundle/IPv6Packet.hh"
34 //#include "DTCPPacket.mpp"
35 ///////////////////////////////hh.p////////////////////////////////////////
39 # define DTCP_V4_MCADDRESS "224.0.0.36"
40 # define DTCP_V6_MCADDRESS "FF02:0:0:0:0:0:1:4"
41 # define DTCP_UDP_PORT 652
43 struct DTCPIPv4AddressListParser : public PacketParserBase
45 # include SENF_PARSER()
47 SENF_PARSER_PRIVATE_FIELD( fbipCount_, UInt8Parser );
48 SENF_PARSER_PRIVATE_FIELD( reserved_, UInt8Parser );
50 SENF_PARSER_VECTOR( fbips, fbipCount_, INet4AddressParser );
52 // Needed since we do NOT want to init fbipCount_ or reseverd_. And since
53 // INet4AddressParser::init() is a no-op, we can just as well disable init completely
56 SENF_PARSER_FINALIZE(DTCPIPv4AddressListParser);
59 struct DTCPIPv6AddressListParser : public PacketParserBase
61 # include SENF_PARSER()
63 SENF_PARSER_PRIVATE_FIELD( fbipCount_, UInt8Parser );
64 SENF_PARSER_PRIVATE_FIELD( reserved_, UInt8Parser );
66 SENF_PARSER_VECTOR( fbips, fbipCount_, INet6AddressParser );
68 // Needed since we do NOT want to init fbipCount_ or reseverd_. And since
69 // INet4AddressParser::init() is a no-op, we can just as well disable init completely
72 SENF_PARSER_FINALIZE(DTCPIPv6AddressListParser);
75 /** \brief Parse a DTCP HELLO packet
77 Parser implementing the DTCP packet according to RFC 3077
81 struct DTCPHelloPacketParser : public PacketParserBase
83 # include SENF_PARSER()
85 SENF_PARSER_BITFIELD ( versionNumber, 4, unsigned ); // must be 1
86 SENF_PARSER_BITFIELD ( command, 4, unsigned );
88 enum Command { JOIN=1, LEAVE=2 };
90 SENF_PARSER_FIELD ( interval, UInt8Parser ); // should be 5
91 SENF_PARSER_FIELD ( sequenceNumber, UInt16Parser );
93 SENF_PARSER_PRIVATE_BITFIELD ( reserved0_, 3, unsigned );
94 SENF_PARSER_BITFIELD ( receiveCapableFeed, 1, bool );
95 SENF_PARSER_BITFIELD_RO ( ipVersion, 4, unsigned ); // 4=IPv4, 6=IPv6
97 SENF_PARSER_FIELD ( tunnelProtocol, UInt8Parser );
98 SENF_PARSER_FIELD_RO ( fbipCount, UInt8Parser );
99 SENF_PARSER_PRIVATE_FIELD ( reserved1_, UInt8Parser ); //must be zero
101 // Go back to fbipCount so the variant has access to that field
102 SENF_PARSER_GOTO( fbipCount );
104 SENF_PARSER_VARIANT ( fbipList_, ipVersion,
105 ( ids(na, has_v4fbipList, init_v4fbipList,
106 key(4, DTCPIPv4AddressListParser)) )
107 ( ids(na, has_v6fbipList, init_v6fbipList,
108 key(6, DTCPIPv6AddressListParser)) ) );
110 // We define the two variant accessors ourselves so we can directly return the vector and
111 // not the collection parser which contains the vector ...
113 typedef DTCPIPv4AddressListParser::fbips_t v4fbipList_t;
114 v4fbipList_t v4fbipList() { return fbipList_().get<0>().fbips(); }
116 typedef DTCPIPv6AddressListParser::fbips_t v6fbipList_t;
117 v6fbipList_t v6fbipList() { return fbipList_().get<1>().fbips(); }
119 SENF_PARSER_FINALIZE(DTCPHelloPacketParser);
122 /** \brief DTCP HELLO packet
124 \par Packet type (typedef):
128 \ref DTCPHelloPacketParser
130 \ingroup protocolbundle_mpegdvb
132 struct DTCPHelloPacketType
133 : public PacketTypeBase,
134 public PacketTypeMixin<DTCPHelloPacketType>
136 typedef PacketTypeMixin<DTCPHelloPacketType> mixin;
137 typedef ConcretePacket<DTCPHelloPacketType> packet;
138 typedef DTCPHelloPacketParser parser;
140 using mixin::nextPacketRange;
142 using mixin::initSize;
144 static void dump(packet p, std::ostream & os);
147 /** \brief DTCP packet typedef */
148 typedef DTCPHelloPacketType::packet DTCPHelloPacket;
151 ///////////////////////////////hh.e////////////////////////////////////////
152 //#include "DTCPPacket.cci"
153 //#include "DTCPPacket.ct"
154 //#include "DTCPPacket.cti"
161 // comment-column: 40
162 // c-file-style: "senf"
163 // indent-tabs-mode: nil
164 // ispell-local-dictionary: "american"
165 // compile-command: "scons -u test"