Fix documentation build under maverick (doxygen 1.7.1)
[senf.git] / senf / Packets / MPEGDVBBundle / MPESection.cc
1 // $Id$
2 //
3 // Copyright (C) 2007
4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
5 // Competence Center NETwork research (NET), St. Augustin, GERMANY
6 //     Thorsten Horstmann <tho@berlios.de>
7 //
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.
12 //
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.
17 //
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.
22
23 /** \file
24     \brief MPESection non-inline non-template implementation */
25
26 #include "MPESection.hh"
27 //#include "MPESection.ih"
28
29 // Custom includes
30 #include <iomanip>
31 #include <boost/io/ios_state.hpp>
32 #include <senf/Packets/DefaultBundle/LlcSnapPacket.hh>
33 #include <senf/Packets/DefaultBundle/IPv4Packet.hh>
34 #include <senf/Packets/DefaultBundle/IPv6Packet.hh>
35
36 #define prefix_
37 //-/////////////////////////////////////////////////////////////////////////////////////////////////
38
39
40 prefix_ boost::uint32_t senf::MPESectionParser::calcCrc()
41     const
42 {
43     return std::for_each(
44             data().begin(),
45             boost::prior(data().end(), 4),
46             crc32_t() ).checksum();
47 }
48
49
50 prefix_ void senf::MPESectionType::dump(packet p, std::ostream & os)
51 {
52     boost::io::ios_all_saver ias(os);
53     os << "MPE Section:\n"
54        << std::hex
55        << senf::fieldName("table_id")                  << "0x" << unsigned(p->table_id()) << "\n"
56        << senf::fieldName("section syntax indicator")  << p->section_syntax_indicator() << "\n"
57        << senf::fieldName("private indicator")         << p->private_indicator() << "\n"
58        << std::dec
59        << senf::fieldName("section length")            << p->section_length() << "\n"
60        << std::hex
61        << senf::fieldName("MAC address 6")             << "0x" << unsigned(p->mac_addr_6()) << "\n"
62        << senf::fieldName("MAC address 5")             << "0x" << unsigned(p->mac_addr_5()) << "\n"
63        << senf::fieldName("payload scrambling ctrl")   << "0x" << p->payload_scrmbl_ctrl() << "\n"
64        << senf::fieldName("address scrambling ctrl")   << "0x" << p-> addr_scrmbl_ctrl()  << "\n"
65        << senf::fieldName("LLC/SNAP flag")             << "0x" << p->llc_snap_flag() << "\n"
66        << senf::fieldName("current next indicator")    << "0x" << p->curr_next_indicator() << "\n"
67        << senf::fieldName("section number")            << "0x" << unsigned(p->section_num()) << "\n"
68        << senf::fieldName("last section number")       << "0x" << unsigned(p->last_section_num()) << "\n"
69        << senf::fieldName("real time parameters")      << "\n"
70        << senf::fieldName("  delta_t")                 << "0x" << unsigned(p->real_time_parameters().delta_t()) << "\n"
71        << senf::fieldName("  table boundary")          << "0x" << unsigned(p->real_time_parameters().table_boundary()) << "\n"
72        << senf::fieldName("  frame boundary")          << "0x" << unsigned(p->real_time_parameters().frame_boundary()) << "\n"
73        << senf::fieldName("  address")                 << "0x" << unsigned(p->real_time_parameters().address()) << "\n"
74        << std::dec
75        << senf::fieldName("crc")                       << unsigned(p->crc()) << "\n";
76 }
77
78 prefix_ senf::PacketParserBase::size_type senf::MPESectionType::initSize()
79 {
80     return parser::fixed_bytes + 32/8;
81 }
82
83 prefix_ senf::PacketParserBase::size_type senf::MPESectionType::initHeadSize()
84 {
85     return parser::fixed_bytes;
86 }
87
88 prefix_ senf::PacketInterpreterBase::factory_t senf::MPESectionType::nextPacketType(packet p)
89 {
90     if (p.data().size() > initSize()+1) {
91         if (p->llc_snap_flag())
92             return LlcSnapPacket::factory();
93         if (p->ip_datagram_version().value() == 4)
94             return IPv4Packet::factory();
95         if (p->ip_datagram_version().value() == 6)
96             return IPv6Packet::factory();
97     }
98     return no_factory();
99 }
100
101 prefix_ void senf::MPESectionType::finalize(packet p)
102 {
103     p->llc_snap_flag() = p.next(nothrow) && p.next().is<LlcSnapPacket>() ? 1 : 0;
104     p->section_length() = p.data().size() - 3;
105     p->crc() = p->calcCrc();
106 }
107
108 //-/////////////////////////////////////////////////////////////////////////////////////////////////
109 #undef prefix_
110
111 \f
112 // Local Variables:
113 // mode: c++
114 // fill-column: 100
115 // c-file-style: "senf"
116 // indent-tabs-mode: nil
117 // ispell-local-dictionary: "american"
118 // compile-command: "scons -u test"
119 // comment-column: 40
120 // End: