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 DSMCCSection non-inline non-template implementation */
31 #include "SNDUPacket.hh"
32 //#include "SNDUPacket.ih"
38 //-/////////////////////////////////////////////////////////////////////////////////////////////////
40 prefix_ boost::uint32_t senf::SNDUPacketParser::calcCrc()
45 boost::prior(data().end(), 4),
46 ule_crc32() ).checksum();
49 //prefix_ senf::SNDUPacketType::key_t senf::SNDUPacketType::nextPacketKey(packet p)
54 prefix_ void senf::SNDUPacketType::init(packet p)
59 prefix_ senf::PacketInterpreterBase::factory_t senf::SNDUPacketType::nextPacketType(packet p)
61 if (p.data().size() < 8)
63 PacketInterpreterBase::factory_t f (no_factory());
64 if (p->type() < 1536) {
65 PacketRegistry<senf::ULEExtHeaderTypes>::Entry const * e (
66 PacketRegistry<senf::ULEExtHeaderTypes>::lookup( p->type(), nothrow ));
67 if (e) f = e->factory();
70 PacketRegistry<senf::EtherTypes>::Entry const * e (
71 PacketRegistry<senf::ULEExtHeaderTypes>::lookup( p->type(), nothrow ));
72 if (e) f = e->factory();
77 prefix_ senf::PacketInterpreterBase::optional_range
78 senf::SNDUPacketType::nextPacketRange(packet p)
80 if (p.data().size() < 8)
83 size_type sz = 2 + 2; // D-Bit + 15 bits length + 16 bits type field
85 sz += 6; // + 6 Byte NPA destination address
87 boost::next(p.data().begin(), sz),
88 boost::prior(p.data().end(), 4)); // - 32 bits crc
91 prefix_ void senf::SNDUPacketType::dump(packet p, std::ostream & os)
95 << senf::fieldName("d_bit") << p->d_bit() << "\n"
96 << senf::fieldName("length") << unsigned(p->length()) << "\n"
98 << senf::fieldName("type") << "0x" << unsigned(p->type()) << "\n"
100 << senf::fieldName("crc") << unsigned(p->crc()) << "\n";
103 prefix_ senf::PacketParserBase::size_type senf::SNDUPacketType::initSize()
105 return 2 + 2 + 4; // D-Bit + 15 bits length + 16 bits type field + 32 bits crc
108 prefix_ senf::PacketParserBase::size_type senf::SNDUPacketType::initHeadSize()
110 return 2 + 2; // D-Bit + 15 bits length + 16 bits type field
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