libtins  4.0
dot11_probe.h
1 /*
2  * Copyright (c) 2017, Matias Fontanini
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are
7  * met:
8  *
9  * * Redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer.
11  * * Redistributions in binary form must reproduce the above
12  * copyright notice, this list of conditions and the following disclaimer
13  * in the documentation and/or other materials provided with the
14  * distribution.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27  *
28  */
29 
30 #include <tins/config.h>
31 
32 #if !defined(TINS_DOT11_DOT11_PROBE_H) && defined(TINS_HAVE_DOT11)
33 
34 #define TINS_DOT11_DOT11_PROBE_H
35 
36 #include <tins/dot11/dot11_mgmt.h>
37 #include <tins/macros.h>
38 
39 namespace Tins {
44 class TINS_API Dot11ProbeRequest : public Dot11ManagementFrame {
45 public:
49  static const PDU::PDUType pdu_flag = PDU::DOT11_PROBE_REQ;
50 
60  Dot11ProbeRequest(const address_type& dst_hw_addr = address_type(),
61  const address_type& src_hw_addr = address_type());
62 
77  Dot11ProbeRequest(const uint8_t* buffer, uint32_t total_sz);
78 
83  PDUType pdu_type() const {
84  return pdu_flag;
85  }
86 
92  bool matches_flag(PDUType flag) const {
93  return flag == pdu_flag || Dot11ManagementFrame::matches_flag(flag);
94  }
95 
102  return new Dot11ProbeRequest(*this);
103  }
104 
105 };
106 
111 class TINS_API Dot11ProbeResponse : public Dot11ManagementFrame {
112 public:
116  static const PDU::PDUType pdu_flag = PDU::DOT11_PROBE_RESP;
117 
127  Dot11ProbeResponse(const address_type& dst_hw_addr = address_type(),
128  const address_type& src_hw_addr = address_type());
129 
144  Dot11ProbeResponse(const uint8_t* buffer, uint32_t total_sz);
145 
151  uint64_t timestamp() const {
152  return Endian::le_to_host(body_.timestamp);
153  }
154 
160  uint16_t interval() const {
161  return Endian::le_to_host(body_.interval);
162  }
163 
171  return body_.capability;
172  }
173 
181  return body_.capability;
182  }
183 
189  void timestamp(uint64_t new_timestamp);
190 
196  void interval(uint16_t new_interval);
197 
204  uint32_t header_size() const;
205 
212  return new Dot11ProbeResponse(*this);
213  }
214 
219  PDUType pdu_type() const { return pdu_flag; }
220 
226  bool matches_flag(PDUType flag) const {
227  return flag == pdu_flag || Dot11ManagementFrame::matches_flag(flag);
228  }
229 private:
230  void write_fixed_parameters(Memory::OutputMemoryStream& stream);
231 
232  TINS_BEGIN_PACK
233  struct dot11_probe_response_header {
234  uint64_t timestamp;
235  uint16_t interval;
236  capability_information capability;
237  } TINS_END_PACK;
238 
239  dot11_probe_response_header body_;
240 };
241 
242 } // namespace Tins
243 
244 #endif // TINS_DOT11_DOT11_PROBE_H
Class representing an Probe Response frame in the IEEE 802.11 Protocol.
Definition: dot11_probe.h:111
Dot11ProbeRequest * clone() const
Clones this PDU.
Definition: dot11_probe.h:101
Class representing an Probe Request frame in the IEEE 802.11 Protocol.
Definition: dot11_probe.h:44
PDUType pdu_type() const
Getter for the PDU&#39;s type.
Definition: dot11_probe.h:83
PDUType
Enum which identifies each type of PDU.
Definition: pdu.h:127
bool matches_flag(PDUType flag) const
Check whether this PDU matches the specified flag.
Definition: dot11_mgmt.h:1226
uint16_t interval() const
Getter for the interval field.
Definition: dot11_probe.h:160
PDUType pdu_type() const
Getter for the PDU&#39;s type.
Definition: dot11_probe.h:219
uint64_t timestamp() const
Getter for the timestamp field.
Definition: dot11_probe.h:151
Base class for all management frames in the IEEE 802.11 protocol.
Definition: dot11_mgmt.h:45
const capability_information & capabilities() const
Getter for the Capabilities Information.
Definition: dot11_probe.h:170
The Tins namespace.
Definition: address_range.h:38
capability_information & capabilities()
Getter for the Capabilities Information.
Definition: dot11_probe.h:180
bool matches_flag(PDUType flag) const
Check whether this PDU matches the specified flag.
Definition: dot11_probe.h:92
Dot11ProbeResponse * clone() const
Clones this PDU.
Definition: dot11_probe.h:211
bool matches_flag(PDUType flag) const
Check whether this PDU matches the specified flag.
Definition: dot11_probe.h:226