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 // Thorsten Horstmann <tho@berlios.de>
29 \brief MPESection non-inline non-template implementation */
31 #include "MPESection.hh"
32 //#include "MPESection.ih"
36 #include <boost/io/ios_state.hpp>
37 #include <senf/Packets/DefaultBundle/LlcSnapPacket.hh>
38 #include <senf/Packets/DefaultBundle/IPv4Packet.hh>
39 #include <senf/Packets/DefaultBundle/IPv6Packet.hh>
42 //-/////////////////////////////////////////////////////////////////////////////////////////////////
45 prefix_ boost::uint32_t senf::MPESectionParser::calcCrc()
50 boost::prior(data().end(), 4),
51 crc32_t() ).checksum();
55 prefix_ void senf::MPESectionType::dump(packet p, std::ostream & os)
57 boost::io::ios_all_saver ias(os);
58 os << "MPE Section:\n"
60 << senf::fieldName("table_id") << "0x" << unsigned(p->table_id()) << "\n"
61 << senf::fieldName("section syntax indicator") << p->section_syntax_indicator() << "\n"
62 << senf::fieldName("private indicator") << p->private_indicator() << "\n"
64 << senf::fieldName("section length") << p->section_length() << "\n"
66 << senf::fieldName("MAC address 6") << "0x" << unsigned(p->mac_addr_6()) << "\n"
67 << senf::fieldName("MAC address 5") << "0x" << unsigned(p->mac_addr_5()) << "\n"
68 << senf::fieldName("payload scrambling ctrl") << "0x" << p->payload_scrmbl_ctrl() << "\n"
69 << senf::fieldName("address scrambling ctrl") << "0x" << p-> addr_scrmbl_ctrl() << "\n"
70 << senf::fieldName("LLC/SNAP flag") << "0x" << p->llc_snap_flag() << "\n"
71 << senf::fieldName("current next indicator") << "0x" << p->curr_next_indicator() << "\n"
72 << senf::fieldName("section number") << "0x" << unsigned(p->section_num()) << "\n"
73 << senf::fieldName("last section number") << "0x" << unsigned(p->last_section_num()) << "\n"
74 << senf::fieldName("real time parameters") << "\n"
75 << senf::fieldName(" delta_t") << "0x" << unsigned(p->real_time_parameters().delta_t()) << "\n"
76 << senf::fieldName(" table boundary") << "0x" << unsigned(p->real_time_parameters().table_boundary()) << "\n"
77 << senf::fieldName(" frame boundary") << "0x" << unsigned(p->real_time_parameters().frame_boundary()) << "\n"
78 << senf::fieldName(" address") << "0x" << unsigned(p->real_time_parameters().address()) << "\n"
80 << senf::fieldName("crc") << unsigned(p->crc()) << "\n";
83 prefix_ senf::PacketParserBase::size_type senf::MPESectionType::initSize()
85 return parser::fixed_bytes + 32/8;
88 prefix_ senf::PacketParserBase::size_type senf::MPESectionType::initHeadSize()
90 return parser::fixed_bytes;
93 prefix_ senf::PacketInterpreterBase::factory_t senf::MPESectionType::nextPacketType(packet p)
95 if (p.data().size() > initSize()+1) {
96 if (p->llc_snap_flag())
97 return LlcSnapPacket::factory();
98 if (p->ip_datagram_version().value() == 4)
99 return IPv4Packet::factory();
100 if (p->ip_datagram_version().value() == 6)
101 return IPv6Packet::factory();
106 prefix_ void senf::MPESectionType::finalize(packet p)
108 p->llc_snap_flag() = p.next(nothrow) && p.next().is<LlcSnapPacket>() ? 1 : 0;
109 p->section_length() = p.data().size() - 3;
110 p->crc() = p->calcCrc();
113 //-/////////////////////////////////////////////////////////////////////////////////////////////////
120 // c-file-style: "senf"
121 // indent-tabs-mode: nil
122 // ispell-local-dictionary: "american"
123 // compile-command: "scons -u test"
124 // comment-column: 40