RadiotapPacket.cci
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 
14 /** \file
15  \brief RadiotapPacket inline non-template implementation */
16 
17 //#include "RadiotapPacket.ih"
18 
19 // Custom includes
20 
21 #define prefix_ inline
22 //-/////////////////////////////////////////////////////////////////////////////////////////////////
23 
24 //-/////////////////////////////////////////////////////////////////////////////////////////////////
25 // senf::RadiotapPacketParser
26 
27 prefix_ senf::RadiotapPacketParser::RadiotapPacketParser(data_iterator i, state_type s)
28  : RadiotapPacket_HeaderParser(i,s)
29 {
30  unsigned bytes = 4;
31  if (SENF_LIKELY(presentFlags() & EXTENDED_BITMASK_FLAG)) {
32  bytes += 4;
33  if (SENF_LIKELY(presentFlags_ext1() & EXTENDED_BITMASK_FLAG)) {
34  bytes += 4;
35  }
36  }
37  OffsetTable & table (offsetMap_[boost::hash_range(
38  data().begin() + presentFlags_offset,
39  data().begin() + presentFlags_offset + bytes)]);
40  if (SENF_UNLIKELY(! table[MAX_INDEX+1]))
41  parseOffsetTable(&(*data().begin()), data().size(), table);
42  currentTable_ = &table;
43 }
44 
45 prefix_ senf::RadiotapPacketParser::size_type senf::RadiotapPacketParser::bytes()
46  const
47 {
48  return length();
49 }
50 
51 prefix_ senf::UInt32Parser senf::RadiotapPacketParser::fcs()
52 {
53  validate(RadiotapPacket_HeaderParser::fixed_bytes+4);
54  return parse<senf::UInt32Parser>(data().end()-4);
55 }
56 
57 prefix_ bool senf::RadiotapPacketParser::has_fcs()
58 {
59  return flagsPresent() && flags().fcsAtEnd();
60 }
61 
62 prefix_ unsigned senf::RadiotapPacketParser::frameType()
63 {
64  return parse<RadiotapPacket_FrameTypeParser>(length()).frameType();
65 }
66 
67 //-/////////////////////////////////////////////////////////////////////////////////////////////////
68 // private members
69 
70 prefix_ void senf::RadiotapPacketParser::initField(unsigned index)
71 {
72  updatePresentFlags( presentFlags() | (1<<index) );
73 }
74 
75 prefix_ void senf::RadiotapPacketParser::disableField(unsigned index)
76 {
77  updatePresentFlags( presentFlags() & ~(1<<index) );
78 }
79 
80 prefix_ senf::RadiotapPacketParser::size_type senf::RadiotapPacketParser::calculateSize()
81  const
82 {
83  return currentTable()[MAX_INDEX+1];
84 }
85 
86 prefix_ senf::RadiotapPacketParser::OffsetTable const &
87 senf::RadiotapPacketParser::currentTable()
88  const
89 {
90  return *currentTable_;
91 }
92 
93 //-/////////////////////////////////////////////////////////////////////////////////////////////////
94 #undef prefix_
95 
96 
97 // Local Variables:
98 // mode: c++
99 // fill-column: 100
100 // comment-column: 40
101 // c-file-style: "senf"
102 // indent-tabs-mode: nil
103 // ispell-local-dictionary: "american"
104 // compile-command: "scons -u test"
105 // End: