Fix documentation build under maverick (doxygen 1.7.1)
[senf.git] / senf / Packets / DefaultBundle / LlcSnapPacket.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 LlcSnapPacket non-inline non-template implementation */
25
26 #include "LlcSnapPacket.hh"
27 //#include "LlcSnapPacket.ih"
28
29 // Custom includes
30 #include <iomanip>
31 #include <boost/io/ios_state.hpp>
32
33 #define prefix_
34 //-/////////////////////////////////////////////////////////////////////////////////////////////////
35
36 prefix_ void senf::LlcSnapPacketType::dump(packet p, std::ostream & os)
37 {
38     boost::io::ios_all_saver ias(os);
39     os << "LLC/SNAP:\n"
40        << std::hex << std::setfill('0')
41        << "  LLC\n"
42        << senf::fieldName("  dsap")                    << "0x" << unsigned(p->dsap()) << "\n"
43        << senf::fieldName("  ssap")                    << "0x" << unsigned(p->ssap()) << "\n"
44        << senf::fieldName("  control id")              << "0x" << unsigned(p->ctrl()) << "\n"
45        << "  SNAP\n"
46        << senf::fieldName("  protocol id")             << "0x" << std::setw(6) << unsigned(p->protocolId()) << "\n"
47        << senf::fieldName("  type/length")             << "0x" << std::setw(4) << unsigned(p->type_length()) << "\n";
48 }
49
50 prefix_ senf::PacketInterpreterBase::factory_t senf::LlcSnapPacketType::nextPacketType(packet p)
51 {
52     if (p->type_length() >= 1536) {
53         PacketRegistry<senf::EtherTypes>::Entry const * e (
54             PacketRegistry<senf::EtherTypes>::lookup( p->type_length(), nothrow ));
55         return e ? e->factory() : no_factory();
56     }
57     if (p->type_length() <= 1500)
58         return EthernetPacket::factory();
59     return no_factory();
60 }
61
62 prefix_ void senf::LlcSnapPacketType::finalize(packet p)
63 {
64     optional_key_t k (key(p.next(nothrow)));
65     if (k)
66         p->type_length() << k;
67     else if (p.next().is<EthernetPacket>())
68         p->type_length() << p.next().data().size();
69 }
70
71
72 //-/////////////////////////////////////////////////////////////////////////////////////////////////
73 #undef prefix_
74
75 \f
76 // Local Variables:
77 // mode: c++
78 // fill-column: 100
79 // c-file-style: "senf"
80 // indent-tabs-mode: nil
81 // ispell-local-dictionary: "american"
82 // compile-command: "scons -u test"
83 // comment-column: 40
84 // End: