MPESection.cc
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 #include "MPESection.hh"
18 //#include "MPESection.ih"
19 
20 // Custom includes
21 #include <iomanip>
22 #include <boost/io/ios_state.hpp>
26 
27 #define prefix_
28 //-/////////////////////////////////////////////////////////////////////////////////////////////////
29 
31 
33  const
34 {
35  return std::for_each(
36  data().begin(),
37  boost::prior(data().end(), 4),
38  crc32_t() ).checksum();
39 }
40 
41 prefix_ void senf::MPESectionType::dump(packet p, std::ostream & os)
42 {
43  boost::io::ios_all_saver ias(os);
44  os << "MPE Section:\n"
45  << std::hex
46  << senf::fieldName("table_id") << "0x" << unsigned(p->table_id()) << "\n"
47  << senf::fieldName("section syntax indicator") << p->section_syntax_indicator() << "\n"
48  << senf::fieldName("private indicator") << p->private_indicator() << "\n"
49  << std::dec
50  << senf::fieldName("section length") << p->section_length() << "\n"
51  << std::hex
52  << senf::fieldName("MAC address 6") << "0x" << unsigned(p->mac_addr_6()) << "\n"
53  << senf::fieldName("MAC address 5") << "0x" << unsigned(p->mac_addr_5()) << "\n"
54  << senf::fieldName("payload scrambling ctrl") << "0x" << p->payload_scrmbl_ctrl() << "\n"
55  << senf::fieldName("address scrambling ctrl") << "0x" << p-> addr_scrmbl_ctrl() << "\n"
56  << senf::fieldName("LLC/SNAP flag") << "0x" << p->llc_snap_flag() << "\n"
57  << senf::fieldName("current next indicator") << "0x" << p->curr_next_indicator() << "\n"
58  << senf::fieldName("section number") << "0x" << unsigned(p->section_num()) << "\n"
59  << senf::fieldName("last section number") << "0x" << unsigned(p->last_section_num()) << "\n"
60  << senf::fieldName("real time parameters") << "\n"
61  << senf::fieldName(" delta_t") << "0x" << unsigned(p->real_time_parameters().delta_t()) << "\n"
62  << senf::fieldName(" table boundary") << "0x" << unsigned(p->real_time_parameters().table_boundary()) << "\n"
63  << senf::fieldName(" frame boundary") << "0x" << unsigned(p->real_time_parameters().frame_boundary()) << "\n"
64  << senf::fieldName(" address") << "0x" << unsigned(p->real_time_parameters().address()) << "\n"
65  << std::dec
66  << senf::fieldName("crc") << unsigned(p->crc()) << "\n";
67 }
68 
70 {
71  return parser::fixed_bytes + 32/8;
72 }
73 
75 {
76  return parser::fixed_bytes;
77 }
78 
80 {
81  if (p.data().size() > initSize()+1) {
82  if (p->llc_snap_flag())
83  return LlcSnapPacket::factory();
84  if (p->ip_datagram_version().value() == 4)
85  return IPv4Packet::factory();
86  if (p->ip_datagram_version().value() == 6)
87  return IPv6Packet::factory();
88  }
89  return no_factory();
90 }
91 
93 {
94  p->llc_snap_flag() = p.next(nothrow) && p.next().is<LlcSnapPacket>() ? 1 : 0;
95  p->section_length() = p.data().size() - 3;
96  p->crc() = p->calcCrc();
97 }
98 
99 //-/////////////////////////////////////////////////////////////////////////////////////////////////
100 #undef prefix_
101 
102 
103 // Local Variables:
104 // mode: c++
105 // fill-column: 100
106 // c-file-style: "senf"
107 // indent-tabs-mode: nil
108 // ispell-local-dictionary: "american"
109 // compile-command: "scons -u test"
110 // comment-column: 40
111 // End:
IPv6Packet public header.
static void dump(packet p, std::ostream &os)
Dump given MPESection in readable form to given output stream.
Definition: MPESection.cc:41
std::string fieldName(std::string const &s)
Definition: DumpFormat.cc:28
static PacketParserBase::size_type initHeadSize()
Definition: MPESection.cc:74
PacketData & data() const
Access the packets raw data container.
Protocol specific packet handle.
Definition: Packet.hh:87
#define prefix_
Definition: MPESection.cc:27
static factory_t nextPacketType(packet p)
Definition: MPESection.cc:79
Packet next() const
Get next packet in chain.
MPESection public header.
detail::packet::size_type size_type
Unsigned integral type.
nothrow
senf::UIntFieldParser<?,?+2 > addr_scrmbl_ctrl() const
size_type size() const
Returns the number of bytes in the packet data.
static PacketParserBase::size_type initSize()
Definition: MPESection.cc:69
PacketData & data() const
Access the packets raw data container.
SENF_PACKET_INSTANTIATE_TEMPLATE(senf::MPESection)
static factory_t factory()
Return factory for packets of specific type.
IPv4Packet public header.
static void finalize(packet p)
Definition: MPESection.cc:92
LLC/SNAP public header.
boost::uint32_t calcCrc() const
Definition: MPESection.cc:32
bool is() const
Check, whether this packet is of the given type.