UDPPacket.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_UDPPacket_
18 #define HH_SENF_Packets_DefaultBundle_UDPPacket_ 1
19 
20 // Custom includes
21 #include <senf/Packets/Packets.hh>
22 #include "Registries.hh"
23 
24 //-/////////////////////////////////////////////////////////////////////////////////////////////////
25 
26 namespace senf {
27 
37  {
38 # include SENF_FIXED_PARSER()
39 
44 
46 
47  boost::uint16_t calcChecksum() const;
48 
50  bool validateChecksum() const {
51  return checksum() == 0u || checksum() == calcChecksum();
52  }
53 
55  };
56 
84  : public PacketTypeBase,
85  public PacketTypeMixin<UDPPacketType>
86  {
90 
91  using mixin::nextPacketRange;
92  using mixin::initSize;
93  using mixin::init;
94 
96  static void dump(packet p, std::ostream & os);
97  static void finalize(packet p);
98 
102  static const IPTypes::key_t ipType = 17;
103  };
104 
110 }
111 
112 //-/////////////////////////////////////////////////////////////////////////////////////////////////
113 //#include "UDPPacket.cci"
114 //#include "UDPPacket.ct"
115 //#include "UDPPacket.cti"
116 #endif
117 
118 
119 // Local Variables:
120 // mode: c++
121 // fill-column: 100
122 // c-file-style: "senf"
123 // indent-tabs-mode: nil
124 // ispell-local-dictionary: "american"
125 // compile-command: "scons -u test"
126 // comment-column: 40
127 // End:
senf::UInt16Parser length() const
Mixin to provide standard implementations for nextPacketRange and nextPacketType. ...
Definition: PacketType.hh:300
UDPPacketParser parser
typedef to the parser of UDP packet
Definition: UDPPacket.hh:89
Packets public header.
senf::UInt16Parser destination() const
DefaultBundle packet registries public header.
boost::uint8_t key_t
Definition: Registries.hh:61
#define SENF_PARSER_FIELD(name, type)
Define normal parser field.
ConcretePacket< UDPPacketType > packet
UDP packet typedef.
Definition: UDPPacket.hh:88
#define SENF_PARSER_FINALIZE(name)
Generate parser control members.
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
senf::UInt16Parser source() const
SENF_PACKET_PREVENT_TEMPLATE_INSTANTIATION(RadiotapPacket)
Parser Base class.
senf::UInt16Parser checksum() const
PacketTypeMixin< UDPPacketType > mixin
Definition: UDPPacket.hh:87
Parse 16bit unsigned byte aligned integer.
Definition: IntParser.hh:174
bool validateChecksum() const
validate header checksum
Definition: UDPPacket.hh:50
UDP packet.
Definition: UDPPacket.hh:83
boost::uint16_t calcChecksum() const
calculate (pseudo-)header checksum
Definition: UDPPacket.cc:36
Parse a UDP packet.
Definition: UDPPacket.hh:36
ConcretePacket< UDPPacketType > UDPPacket
UDP packet typedef.
Definition: UDPPacket.hh:108