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 // David Wagner <dw6@berlios.de>
28 \brief DTCPPacket public header */
30 #ifndef HH_SENF_Packets_MPEGDVBBundle_DTCPPacket_
31 #define HH_SENF_Packets_MPEGDVBBundle_DTCPPacket_ 1
34 #include <senf/Packets/DefaultBundle/IPv6Packet.hh>
36 //#include "DTCPPacket.mpp"
37 //-/////////////////////////////////////////////////////////////////////////////////////////////////
41 # define DTCP_V4_MCADDRESS "224.0.0.36"
42 # define DTCP_V6_MCADDRESS "FF02:0:0:0:0:0:1:4"
43 # define DTCP_UDP_PORT 652
45 struct DTCPIPv4AddressListParser : public PacketParserBase
47 # include SENF_PARSER()
49 SENF_PARSER_PRIVATE_FIELD( fbipCount_, UInt8Parser ); //<pkgdraw: hide
50 SENF_PARSER_PRIVATE_FIELD( reserved_, UInt8Parser ); //<pkgdraw: hide
52 SENF_PARSER_VECTOR( fbips, fbipCount_, INet4AddressParser );
54 // Needed since we do NOT want to init fbipCount_ or reseverd_. And since
55 // INet4AddressParser::init() is a no-op, we can just as well disable init completely
58 SENF_PARSER_FINALIZE(DTCPIPv4AddressListParser);
61 struct DTCPIPv6AddressListParser : public PacketParserBase
63 # include SENF_PARSER()
65 SENF_PARSER_PRIVATE_FIELD( fbipCount_, UInt8Parser ); //<pkgdraw: hide
66 SENF_PARSER_PRIVATE_FIELD( reserved_, UInt8Parser ); //<pkgdraw: hide
68 SENF_PARSER_VECTOR( fbips, fbipCount_, INet6AddressParser );
70 // Needed since we do NOT want to init fbipCount_ or reseverd_. And since
71 // INet4AddressParser::init() is a no-op, we can just as well disable init completely
74 SENF_PARSER_FINALIZE(DTCPIPv6AddressListParser);
77 /** \brief Parse a DTCP HELLO packet
79 Parser implementing the DTCP packet according to RFC 3077
81 \see DTCPHelloPacketType
83 struct DTCPHelloPacketParser : public PacketParserBase
85 # include SENF_PARSER()
88 SENF_PARSER_BITFIELD ( versionNumber, 4, unsigned ); // must be 1
89 SENF_PARSER_BITFIELD ( command, 4, unsigned ); //<pkgdraw: name=cmd
91 enum Command { JOIN=1, LEAVE=2 };
93 SENF_PARSER_FIELD ( interval, UInt8Parser ); // should be 5
94 SENF_PARSER_FIELD ( sequenceNumber, UInt16Parser );
96 SENF_PARSER_PRIVATE_BITFIELD ( reserved0_, 3, unsigned ); //<pkgdraw: name=
97 SENF_PARSER_BITFIELD ( receiveCapableFeed, 1, bool );
98 SENF_PARSER_BITFIELD_RO ( ipVersion, 4, unsigned ); // 4=IPv4, 6=IPv6
100 SENF_PARSER_FIELD ( tunnelProtocol, UInt8Parser );
101 SENF_PARSER_FIELD_RO ( fbipCount, UInt8Parser );
103 SENF_PARSER_PRIVATE_FIELD ( reserved1_, UInt8Parser ); // must be zero
105 // Go back to fbipCount so the variant has access to that field
106 SENF_PARSER_GOTO( fbipCount );
108 SENF_PARSER_VARIANT ( fbipList_, ipVersion,
109 ( ids(na, has_v4fbipList, init_v4fbipList,
110 key(4, DTCPIPv4AddressListParser)) )
111 ( ids(na, has_v6fbipList, init_v6fbipList,
112 key(6, DTCPIPv6AddressListParser)) ) );
114 // We define the two variant accessors ourselves so we can directly return the vector and
115 // not the collection parser which contains the vector ...
117 typedef DTCPIPv4AddressListParser::fbips_t v4fbipList_t;
118 v4fbipList_t v4fbipList() { return fbipList_().get<0>().fbips(); }
120 typedef DTCPIPv6AddressListParser::fbips_t v6fbipList_t;
121 v6fbipList_t v6fbipList() { return fbipList_().get<1>().fbips(); }
123 SENF_PARSER_FINALIZE(DTCPHelloPacketParser);
126 /** \brief DTCP HELLO packet
128 \par Packet type (typedef):
132 \ref DTCPHelloPacketParser
134 \image html DTCPPacket.png
136 \ingroup protocolbundle_mpegdvb
138 struct DTCPHelloPacketType
139 : public PacketTypeBase,
140 public PacketTypeMixin<DTCPHelloPacketType>
142 typedef PacketTypeMixin<DTCPHelloPacketType> mixin;
143 typedef ConcretePacket<DTCPHelloPacketType> packet;
144 typedef DTCPHelloPacketParser parser;
146 using mixin::nextPacketRange;
148 using mixin::initSize;
150 static void dump(packet p, std::ostream & os);
153 /** \brief DTCP packet typedef */
154 typedef DTCPHelloPacketType::packet DTCPHelloPacket;
157 //-/////////////////////////////////////////////////////////////////////////////////////////////////
158 //#include "DTCPPacket.cci"
159 //#include "DTCPPacket.ct"
160 //#include "DTCPPacket.cti"
167 // comment-column: 40
168 // c-file-style: "senf"
169 // indent-tabs-mode: nil
170 // ispell-local-dictionary: "american"
171 // compile-command: "scons -u test"