EthernetPacket.hh
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 #ifndef HH_SENF_Packets_DefaultBundle_EthernetPacket_
18 #define HH_SENF_Packets_DefaultBundle_EthernetPacket_ 1
19 
20 // Custom includes
22 #include <senf/Packets/Packets.hh>
23 #include "Registries.hh"
24 
25 //-/////////////////////////////////////////////////////////////////////////////////////////////////
26 
27 namespace senf {
28 
37  : public ArrayValueParserBase<MACAddressParser, MACAddress>
38  {
40 
41  bool local() const;
42  bool multicast() const;
43  bool broadcast() const;
44  bool null() const;
45  void hash(boost::uint64_t *, boost::uint16_t const & otherKey = 0) const;
46 
47  using Base::operator=;
48  };
49 
50 
58  {
59 # include SENF_FIXED_PARSER()
60 
64 
66  };
67 
86  : public PacketTypeBase,
87  public PacketTypeMixin<EthernetPacketType, EtherTypes>
88  {
92 
93  using mixin::nextPacketRange;
94  using mixin::initSize;
95  using mixin::init;
96 
97  static factory_t nextPacketType(packet p);
99  static void dump(packet p, std::ostream & os);
100  static void finalize(packet p);
101 
102  static const unsigned minPayloadSize = 60u; // without CRC - that's what we typically 'see' in SENF
103  static const unsigned minPayloadSizeCRC = 64u; // real h/w limit on 100Mbps Ethernet
104  };
105 
111 
112 
120  {
121 # include SENF_FIXED_PARSER()
122 
123  SENF_PARSER_BITFIELD( priority, 3, unsigned );
124  SENF_PARSER_BITFIELD( cfi, 1, bool );
125  SENF_PARSER_BITFIELD( vlanId, 12, unsigned );
126 
127  // field is named "type_length" analogue to EthernetPacketParser
129 
131  };
132 
151  : public PacketTypeBase,
152  public PacketTypeMixin<EthVLanSPacketType, EtherTypes>
153  {
157 
158  using mixin::nextPacketRange;
159  using mixin::nextPacketType;
160  using mixin::initSize;
161  using mixin::init;
162 
165  static key_t nextPacketKey(packet p)
166  { return p->type_length(); }
167 
169  static void dump(packet p, std::ostream & os);
170  static void finalize(packet p);
171 
172  // S-TAG
173  static const EtherTypes::key_t etherType = 0x88a8;
174  };
175 
181 
200  : public PacketTypeBase,
201  public PacketTypeMixin<EthVLanCPacketType, EtherTypes>
202  {
206 
207  using mixin::nextPacketRange;
208  using mixin::nextPacketType;
209  using mixin::initSize;
210  using mixin::init;
211 
214  static key_t nextPacketKey(packet p)
215  { return p->type_length(); }
216 
218  static void dump(packet p, std::ostream & os);
219  static void finalize(packet p);
220 
221  // C-TAG
222  static const EtherTypes::key_t etherType = 0x8100;
223  };
224 
230 
231 
232 
234  {
235 # include SENF_FIXED_PARSER()
236 
239 
241  };
242 
244  : public PacketTypeBase,
245  public PacketTypeMixin<EthOUIExtensionPacketType, EtherOUIExtTypes>
246  {
250 
251  using mixin::nextPacketRange;
252  using mixin::nextPacketType;
253  using mixin::initSize;
254  using mixin::init;
255 
256  static key_t nextPacketKey(packet p)
257  { return EtherOUIExtTypes::type(p->oui(), p->ext_type()); }
258  static void dump(packet p, std::ostream & os);
259  static void finalize(packet p);
260 
261  static const EtherTypes::key_t etherType = 0x88b7;
262 
263  static const std::uint32_t OUI_Fraunhofer_FOKUS = 0x001113;
264  static const std::uint32_t OUI_Fraunhofer_FIT = 0x3c11b2;
265  };
266 
268  SENF_PACKET_PREVENT_TEMPLATE_INSTANTIATION( EthOUIExtensionPacket );
269 
270 }
271 
272 //-/////////////////////////////////////////////////////////////////////////////////////////////////
273 #include "EthernetPacket.cci"
274 //#include "EthernetPacket.ct"
275 //#include "EthernetPacket.cti"
276 #endif
277 
278 
279 // Local Variables:
280 // mode: c++
281 // fill-column: 100
282 // c-file-style: "senf"
283 // indent-tabs-mode: nil
284 // ispell-local-dictionary: "american"
285 // compile-command: "scons -u test"
286 // comment-column: 40
287 // End:
static key_t nextPacketKey(packet p)
Parse an Ethernet packet.
#define SENF_PARSER_BITFIELD(name, bits, type)
Define bit-field.
EthVLanPacketParser parser
PacketTypeMixin< EthVLanCPacketType, EtherTypes > mixin
Mixin to provide standard implementations for nextPacketRange and nextPacketType. ...
Definition: PacketType.hh:300
ConcretePacket< EthVLanSPacketType > EthVLanSPacket
Ethernet VLAN S-Tag typedef.
bool multicast() const
true, if address is a group/multicast address
Packets public header.
DefaultBundle packet registries public header.
MACAddressParser(data_iterator i, state_type s)
#define SENF_PARSER_FIELD(name, type)
Define normal parser field.
Ethernet VLAN C-Tag.
Parse an Ethernet MAC address.
#define SENF_PARSER_FINALIZE(name)
Generate parser control members.
bool null() const
true, if address is the zero address
PacketTypeMixin< EthVLanSPacketType, EtherTypes > mixin
void dump(std::ostream &os, DirectoryNode &dir=root())
Protocol specific packet handle.
Definition: Packet.hh:87
Helper base-class implementing the PacketType interface.
Definition: PacketType.hh:100
EthernetPacketParser parser
EthVLanPacketParser parser
Packet data STL-sequence view.
Definition: PacketData.hh:61
data_iterator i() const
Return beginning of data to parse.
bool broadcast() const
true, if address is the broadcast address
Parse an ethernet VLAN tag.
SENF_PACKET_PREVENT_TEMPLATE_INSTANTIATION(RadiotapPacket)
static key_t nextPacketKey(packet p)
ConcretePacket< EthVLanCPacketType > EthVLanCPacket
Ethernet VLAN C-Tag typedef.
ConcretePacket< EthOUIExtensionPacketType > EthOUIExtensionPacket
ConcretePacket< EthVLanCPacketType > packet
bool local() const
true, if address is locally administered
ConcretePacket< EthernetPacketType > packet
static key_t nextPacketKey(packet p)
Parse 24bit unsigned byte aligned integer.
Definition: IntParser.hh:256
PacketTypeMixin< EthOUIExtensionPacketType, EtherOUIExtTypes > mixin
ConcretePacket< EthVLanSPacketType > packet
Parser Base class.
EthOUIExtensionPacketParser parser
PacketInterpreterBase::factory_t factory_t
Definition: PacketType.hh:112
void hash(boost::uint64_t *, boost::uint16_t const &otherKey=0) const
Return MAC address as uint64 value as hask key.
Parse 16bit unsigned byte aligned integer.
Definition: IntParser.hh:174
ConcretePacket< EthernetPacketType > EthernetPacket
Ethernet packet typedef.
Ethernet VLAN S-Tag.
boost::uint16_t key_t
Definition: Registries.hh:35
ConcretePacket< EthOUIExtensionPacketType > packet
static key_t type(boost::uint32_t oui, boost::uint16_t extType)
Definition: Registries.hh:41
detail::packet::iterator data_iterator
Raw data iterator type.
PacketTypeMixin< EthernetPacketType, EtherTypes > mixin