libtins 4.5
Loading...
Searching...
No Matches
dot11_auth.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_AUTH_H) && defined(TINS_HAVE_DOT11)
33#define TINS_DOT11_DOT11_AUTH_H
34
35#include <tins/dot11/dot11_mgmt.h>
36#include <tins/macros.h>
37
38namespace Tins {
43public:
47 static const PDU::PDUType pdu_flag = PDU::DOT11_AUTH;
48
58 Dot11Authentication(const address_type& dst_hw_addr = address_type(),
59 const address_type& src_hw_addr = address_type());
60
75 Dot11Authentication(const uint8_t* buffer, uint32_t total_sz);
76
82 uint16_t auth_algorithm() const {
83 return Endian::le_to_host(body_.auth_algorithm); }
84
90 uint16_t auth_seq_number() const {
91 return Endian::le_to_host(body_.auth_seq_number);
92 }
93
99 uint16_t status_code() const {
100 return Endian::le_to_host(body_.status_code);
101 }
102
109 void auth_algorithm(uint16_t new_auth_algorithm);
110
117 void auth_seq_number(uint16_t new_auth_seq_number);
118
124 void status_code(uint16_t new_status_code);
125
132 uint32_t header_size() const;
133
139 return pdu_flag;
140 }
141
147 bool matches_flag(PDUType flag) const {
148 return flag == pdu_flag || Dot11ManagementFrame::matches_flag(flag);
149 }
150
157 return new Dot11Authentication(*this);
158 }
159private:
160 struct dot11_auth_body {
161 uint16_t auth_algorithm;
162 uint16_t auth_seq_number;
163 uint16_t status_code;
164 };
165
166 void write_fixed_parameters(Memory::OutputMemoryStream& stream);
167
168 dot11_auth_body body_;
169};
170
176public:
180 static const PDU::PDUType pdu_flag = PDU::DOT11_DEAUTH;
181
191 Dot11Deauthentication(const address_type& dst_hw_addr = address_type(),
192 const address_type& src_hw_addr = address_type());
193
208 Dot11Deauthentication(const uint8_t* buffer, uint32_t total_sz);
209
215 uint16_t reason_code() const {
216 return Endian::le_to_host(body_.reason_code);
217 }
218
224 void reason_code(uint16_t new_reason_code);
225
232 uint32_t header_size() const;
233
239 return pdu_flag;
240 }
241
247 bool matches_flag(PDUType flag) const {
248 return flag == pdu_flag || Dot11ManagementFrame::matches_flag(flag);
249 }
250
257 return new Dot11Deauthentication(*this);
258 }
259private:
260 struct dot11_deauth_body {
261 uint16_t reason_code;
262 };
263
264 void write_fixed_parameters(Memory::OutputMemoryStream& stream);
265
266 dot11_deauth_body body_;
267};
268
269} // namespace Tins
270
271#endif // TINS_DOT11_DOT11_AUTH_H
IEEE 802.11 Authentication Request frame.
Definition dot11_auth.h:42
uint16_t status_code() const
Getter for the status code field.
Definition dot11_auth.h:99
bool matches_flag(PDUType flag) const
Check whether this PDU matches the specified flag.
Definition dot11_auth.h:147
Dot11Authentication * clone() const
Clones this PDU.
Definition dot11_auth.h:156
uint16_t auth_algorithm() const
Getter for the Authetication Algorithm Number field.
Definition dot11_auth.h:82
PDUType pdu_type() const
Getter for the PDU's type.
Definition dot11_auth.h:138
uint16_t auth_seq_number() const
Getter for the Authetication Sequence Number field.
Definition dot11_auth.h:90
IEEE 802.11 Deauthentication frame.
Definition dot11_auth.h:175
PDUType pdu_type() const
Getter for the PDU's type.
Definition dot11_auth.h:238
Dot11Deauthentication * clone() const
Clones this PDU.
Definition dot11_auth.h:256
uint16_t reason_code() const
Getter for the reason code field.
Definition dot11_auth.h:215
bool matches_flag(PDUType flag) const
Check whether this PDU matches the specified flag.
Definition dot11_auth.h:247
Base class for all management frames in the IEEE 802.11 protocol.
Definition dot11_mgmt.h:45
PDUType
Enum which identifies each type of PDU.
Definition pdu.h:127
The Tins namespace.
Definition address_range.h:38