LlcSnapPacket.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 "LlcSnapPacket.hh"
18 
19 // Custom includes
20 #include <iomanip>
21 #include <boost/io/ios_state.hpp>
22 #include "EthernetPacket.hh"
23 
24 #define prefix_
25 //-/////////////////////////////////////////////////////////////////////////////////////////////////
26 
28 
29 prefix_ void senf::LlcSnapPacketType::dump(packet p, std::ostream & os)
30 {
31  boost::io::ios_all_saver ias(os);
32  os << "LLC/SNAP:\n"
33  << std::hex << std::setfill('0') << std::right
34  << " LLC\n"
35  << senf::fieldName(" dsap") << "0x" << unsigned(p->dsap()) << "\n"
36  << senf::fieldName(" ssap") << "0x" << unsigned(p->ssap()) << "\n"
37  << senf::fieldName(" control id") << "0x" << unsigned(p->ctrl()) << "\n"
38  << " SNAP\n"
39  << senf::fieldName(" protocol id") << "0x" << std::setw(6) << unsigned(p->protocolId()) << "\n"
40  << senf::fieldName(" type/length") << "0x" << std::setw(4) << unsigned(p->type_length()) << "\n";
41 }
42 
44 {
45  if (p->type_length() >= 1536) {
48  return e ? e->factory() : no_factory();
49  }
50  if (p->type_length() <= 1500)
51  return EthernetPacket::factory();
52  return no_factory();
53 }
54 
56 {
57  p->type_length() << key(p.next(nothrow));
58 }
59 
60 //-/////////////////////////////////////////////////////////////////////////////////////////////////
61 #undef prefix_
62 
63 
64 // Local Variables:
65 // mode: c++
66 // fill-column: 100
67 // c-file-style: "senf"
68 // indent-tabs-mode: nil
69 // ispell-local-dictionary: "american"
70 // compile-command: "scons -u test"
71 // comment-column: 40
72 // End:
EthernetPacket public header.
static optional_key_t key(Packet const &p)
Find key of packet from registry.
#define prefix_
std::string fieldName(std::string const &s)
Definition: DumpFormat.cc:28
SENF_PACKET_INSTANTIATE_TEMPLATE(senf::LlcSnapPacket)
Protocol specific packet handle.
Definition: Packet.hh:87
Packet next() const
Get next packet in chain.
static factory_t nextPacketType(packet p)
detail::PacketRegistryImpl< typename Tag::key_t >::Entry Entry
nothrow
static void dump(packet p, std::ostream &os)
Dump given LlcSnapPacket in readable form to given output stream.
static factory_t no_factory()
static factory_t factory()
Return factory for packets of specific type.
Packet registration facility
LLC/SNAP public header.
static void finalize(packet p)