PPPoEPacket.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 "PPPoEPacket.hh"
18 
19 // Custom includes
20 #include <iomanip>
21 #include <boost/io/ios_state.hpp>
22 #include "IPv4Packet.hh"
23 #include "IPv6Packet.hh"
24 
25 #define prefix_
26 //-/////////////////////////////////////////////////////////////////////////////////////////////////
27 
30 
33 
34 template <typename PacketType>
36 {
37  boost::io::ios_all_saver ias(os);
38  os << "PPPoE:\n"
39  << std::hex << std::setfill('0') << std::right
40  << senf::fieldName(" version") << "0x" << p->version() << "\n"
41  << senf::fieldName(" type") << "0x" << p->type() << "\n"
42  << senf::fieldName(" code") << "0x" << unsigned(p->code()) << "\n"
43  << senf::fieldName(" sessionId") << "0x" << p->sessionId() << "\n"
44  << senf::fieldName(" length") << "0x" << p->length() << "\n"
45  << senf::fieldName(" pppProtocol") << "0x" << p->pppProtocol() << "\n";
46 }
47 
48 template <typename PacketType>
50 {
51  switch (p->pppProtocol()) {
52  case 0x0021:
53  if (p->code() == 0x0)
54  return IPv4Packet::factory();
55  break;
56  case 0x0057:
57  if (p->code() == 0x0)
58  return IPv6Packet::factory();
59  break;
60  default:
61  // there are other types, such as PAP, CHAP, LCP, etc....
62  break;
63  }
64  return no_factory();
65 }
66 
67 //-/////////////////////////////////////////////////////////////////////////////////////////////////
68 #undef prefix_
69 
70 
71 // Local Variables:
72 // mode: c++
73 // fill-column: 100
74 // c-file-style: "senf"
75 // indent-tabs-mode: nil
76 // ispell-local-dictionary: "american"
77 // compile-command: "scons -u test"
78 // comment-column: 40
79 // End:
IPv6Packet public header.
static factory_t nextPacketType(packet p)
Definition: PPPoEPacket.cc:49
static void dump(packet p, std::ostream &os)
Definition: PPPoEPacket.cc:35
std::string fieldName(std::string const &s)
Definition: DumpFormat.cc:28
#define prefix_
Definition: PPPoEPacket.cc:25
SENF_PACKET_INSTANTIATE_TEMPLATE(senf::PPPoEDPacket)
PPPOE public header.
void type
Type of the packet.
Definition: Packet.hh:139
Main Packet class.
Definition: Packet.hh:131
Protocol specific packet handle.
Definition: Packet.hh:87
EtherType registry.
Definition: Registries.hh:34
static const EtherTypes::key_t etherType
Definition: PPPoEPacket.hh:76
IPv4Packet public header.
static const EtherTypes::key_t etherType
Definition: PPPoEPacket.hh:72
SENF_PACKET_REGISTRY_REGISTER(senf::EtherTypes, senf::PPPoEDPacketType::etherType, senf::PPPoEDPacket)