DTCPPacket.hh
Go to the documentation of this file.
1 //
2 // Copyright (c) 2020 Fraunhofer Institute for Applied Information Technology (FIT)
3 // Network Research Group (NET)
4 // Schloss Birlinghoven, 53754 Sankt Augustin, GERMANY
5 // Contact: support@wiback.org
6 //
7 // This file is part of the SENF code tree.
8 // It is licensed under the 3-clause BSD License (aka New BSD License).
9 // See LICENSE.txt in the top level directory for details or visit
10 // https://opensource.org/licenses/BSD-3-Clause
11 //
12 
13 
17 #ifndef HH_SENF_Packets_MPEGDVBBundle_DTCPPacket_
18 #define HH_SENF_Packets_MPEGDVBBundle_DTCPPacket_ 1
19 
20 // Custom includes
23 
24 //-/////////////////////////////////////////////////////////////////////////////////////////////////
25 
26 namespace senf {
27 
28 # define DTCP_V4_MCADDRESS "224.0.0.36"
29 # define DTCP_V6_MCADDRESS "FF02:0:0:0:0:0:1:4"
30 # define DTCP_UDP_PORT 652
31 
33  {
34 # include SENF_PARSER()
35 
38 
40 
42 
43  // Needed since we do NOT want to init fbipCount_ or reseverd_. And since
44  // INet4AddressParser::init() is a no-op, we can just as well disable init completely
46  };
47 
49  {
50 # include SENF_PARSER()
51 
54 
56 
58 
59  // Needed since we do NOT want to init fbipCount_ or reseverd_. And since
60  // INet4AddressParser::init() is a no-op, we can just as well disable init completely
62  };
63 
71  {
72  enum Command { JOIN=1, LEAVE=2 };
73 
74 # include SENF_PARSER()
75 
76  //>pkgdraw: name=vers
77  SENF_PARSER_BITFIELD( versionNumber, 4, unsigned ); // must be 1
78  SENF_PARSER_BITFIELD( command, 4, unsigned ); //<pkgdraw: name=cmd
79 
80  SENF_PARSER_FIELD( interval, UInt8Parser ); // should be 5
81  SENF_PARSER_FIELD( sequenceNumber, UInt16Parser );
82 
83  SENF_PARSER_PRIVATE_BITFIELD( reserved0_, 3, unsigned ); //<pkgdraw: name=
84  SENF_PARSER_BITFIELD ( receiveCapableFeed, 1, bool );
85  SENF_PARSER_BITFIELD_RO ( ipVersion, 4, unsigned ); // 4=IPv4, 6=IPv6
86 
87  SENF_PARSER_FIELD ( tunnelProtocol, UInt8Parser );
89  //>pkgdraw: name=
90  SENF_PARSER_PRIVATE_FIELD( reserved1_, UInt8Parser ); // must be zero
91 
92  // Go back to fbipCount so the variant has access to that field
93  SENF_PARSER_GOTO( fbipCount );
94 
95  SENF_PARSER_VARIANT( fbipList_, ipVersion,
96  ( ids(na, has_v4fbipList, init_v4fbipList, key(4, DTCPIPv4AddressListParser)) )
97  ( ids(na, has_v6fbipList, init_v6fbipList, key(6, DTCPIPv6AddressListParser)) ) );
98 
99  // We define the two variant accessors ourselves so we can directly return the vector and
100  // not the collection parser which contains the vector ...
101 
103  v4fbipList_t v4fbipList() { return fbipList_().get<0>().fbips(); }
104 
106  v6fbipList_t v6fbipList() { return fbipList_().get<1>().fbips(); }
107 
109  };
110 
124  : public PacketTypeBase,
125  public PacketTypeMixin<DTCPHelloPacketType>
126  {
130 
131  using mixin::nextPacketRange;
132  using mixin::init;
133  using mixin::initSize;
134 
135  static void dump(packet p, std::ostream & os);
136  };
137 
140 }
141 
142 //-/////////////////////////////////////////////////////////////////////////////////////////////////
143 //#include "DTCPPacket.cci"
144 //#include "DTCPPacket.ct"
145 //#include "DTCPPacket.cti"
146 #endif
147 
148 
149 // Local Variables:
150 // mode: c++
151 // fill-column: 100
152 // comment-column: 40
153 // c-file-style: "senf"
154 // indent-tabs-mode: nil
155 // ispell-local-dictionary: "american"
156 // compile-command: "scons -u test"
157 // End:
Parse a DTCP HELLO packet.
Definition: DTCPPacket.hh:70
IPv6Packet public header.
DTCPIPv4AddressListParser::fbips_t v4fbipList_t
Definition: DTCPPacket.hh:102
#define SENF_PARSER_BITFIELD(name, bits, type)
Define bit-field.
#define LEAVE()
DTCPHelloPacketType::packet DTCPHelloPacket
DTCP packet typedef.
Definition: DTCPPacket.hh:139
Mixin to provide standard implementations for nextPacketRange and nextPacketType. ...
Definition: PacketType.hh:300
Parse 8bit unsigned byte aligned integer.
Definition: IntParser.hh:91
DTCPHelloPacketParser parser
Definition: DTCPPacket.hh:129
#define SENF_PARSER_FIELD(name, type)
Define normal parser field.
#define SENF_PARSER_VARIANT(name, chooser, types)
Define VariantParser field.
#define SENF_PARSER_GOTO(name)
Change current offset.
ConcretePacket< DTCPHelloPacketType > packet
Definition: DTCPPacket.hh:128
#define SENF_PARSER_PRIVATE_FIELD(name, type)
Define parser field (private)
PacketTypeMixin< DTCPHelloPacketType > mixin
Definition: DTCPPacket.hh:127
UInt8Parser fbipCount_() const
#define SENF_PARSER_FINALIZE(name)
Generate parser control members.
senf::VectorParser< INet4AddressParser > fbips() const
void dump(std::ostream &os, DirectoryNode &dir=root())
Protocol specific packet handle.
Definition: Packet.hh:87
Helper base-class implementing the PacketType interface.
Definition: PacketType.hh:100
#define SENF_PARSER_VECTOR(name, size, elt_type)
Define VectorParser field.
#define SENF_PARSER_BITFIELD_RO(name, bits, type)
Define bit-field (read-only)
#define SENF_PARSER_INIT()
Define parser initialization routine.
#define SENF_PARSER_FIELD_RO(name, type)
Define parser field (read-only)
UInt8Parser reserved_() const
Collection of fixed-size elements.
Definition: VectorParser.hh:58
Parser Base class.
Parse an IPv6 address.
Definition: IPv6Packet.hh:33
DTCPIPv6AddressListParser::fbips_t v6fbipList_t
Definition: DTCPPacket.hh:105
IPv4Packet public header.
#define SENF_PARSER_PRIVATE_BITFIELD(name, bits, type)
Define bit-field (private)
Parse 16bit unsigned byte aligned integer.
Definition: IntParser.hh:174
DTCP HELLO packet.
Definition: DTCPPacket.hh:123
Parse in IPv4 address.
Definition: IPv4Packet.hh:33