libtins 4.5
Loading...
Searching...
No Matches
dot11_assoc.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_ASSOC_H) && defined(TINS_HAVE_DOT11)
33#define TINS_DOT11_DOT11_ASSOC_H
34
35#include <tins/dot11/dot11_mgmt.h>
36#include <tins/macros.h>
37
38namespace Tins {
43class TINS_API Dot11Disassoc : public Dot11ManagementFrame {
44public:
48 static const PDU::PDUType pdu_flag = PDU::DOT11_DIASSOC;
49
59 Dot11Disassoc(const address_type& dst_hw_addr = address_type(),
60 const address_type& src_hw_addr = address_type());
61
76 Dot11Disassoc(const uint8_t* buffer, uint32_t total_sz);
77
83 uint16_t reason_code() const {
84 return Endian::le_to_host(body_.reason_code);
85 }
86
92 void reason_code(uint16_t new_reason_code);
93
100 uint32_t header_size() const;
101
107 return pdu_flag;
108 }
109
115 bool matches_flag(PDUType flag) const {
116 return flag == pdu_flag || Dot11ManagementFrame::matches_flag(flag);
117 }
118
125 return new Dot11Disassoc(*this);
126 }
127private:
128 struct dot11_disassoc_body {
129 uint16_t reason_code;
130 };
131
132 void write_fixed_parameters(Memory::OutputMemoryStream& stream);
133
134 dot11_disassoc_body body_;
135};
136
142public:
146 static const PDU::PDUType pdu_flag = PDU::DOT11_ASSOC_REQ;
147
157 Dot11AssocRequest(const address_type& dst_hw_addr = address_type(),
158 const address_type& src_hw_addr = address_type());
159
174 Dot11AssocRequest(const uint8_t* buffer, uint32_t total_sz);
175
183 return body_.capability;
184 }
185
193 return body_.capability;
194 }
195
201 uint16_t listen_interval() const {
202 return Endian::le_to_host(body_.listen_interval);
203 }
204
210 void listen_interval(uint16_t new_listen_interval);
211
218 uint32_t header_size() const;
219
225 return pdu_flag;
226 }
227
233 bool matches_flag(PDUType flag) const {
234 return flag == pdu_flag || Dot11ManagementFrame::matches_flag(flag);
235 }
236
243 return new Dot11AssocRequest(*this);
244 }
245private:
246 struct dot11_assoc_request_body {
247 capability_information capability;
248 uint16_t listen_interval;
249 };
250
251 void write_fixed_parameters(Memory::OutputMemoryStream& stream);
252
253 dot11_assoc_request_body body_;
254};
255
261public:
265 static const PDU::PDUType pdu_flag = PDU::DOT11_ASSOC_RESP;
266
276 Dot11AssocResponse(const address_type& dst_hw_addr = address_type(),
277 const address_type& src_hw_addr = address_type());
278
293 Dot11AssocResponse(const uint8_t* buffer, uint32_t total_sz);
294
302 return body_.capability;
303 }
304
312 return body_.capability;
313 }
314
320 uint16_t status_code() const {
321 return Endian::le_to_host(body_.status_code);
322 }
323
329 uint16_t aid() const {
330 return Endian::le_to_host(body_.aid);
331 }
332
338 void status_code(uint16_t new_status_code);
339
345 void aid(uint16_t new_aid);
346
353 uint32_t header_size() const;
354
360 return pdu_flag;
361 }
362
368 bool matches_flag(PDUType flag) const {
369 return flag == pdu_flag || Dot11ManagementFrame::matches_flag(flag);
370 }
371
378 return new Dot11AssocResponse(*this);
379 }
380private:
381 struct dot11_assoc_response_body {
382 capability_information capability;
383 uint16_t status_code;
384 uint16_t aid;
385 };
386
387 void write_fixed_parameters(Memory::OutputMemoryStream& stream);
388
389 dot11_assoc_response_body body_;
390};
391
397public:
401 static const PDU::PDUType pdu_flag = PDU::DOT11_REASSOC_REQ;
402
412 Dot11ReAssocRequest(const address_type& dst_hw_addr = address_type(),
413 const address_type& src_hw_addr = address_type());
414
429 Dot11ReAssocRequest(const uint8_t* buffer, uint32_t total_sz);
430
438 return body_.capability;
439 }
440
448 return body_.capability;
449 }
450
456 uint16_t listen_interval() const {
457 return Endian::le_to_host(body_.listen_interval);
458 }
459
466 return body_.current_ap;
467 }
468
474 void listen_interval(uint16_t new_listen_interval);
475
481 void current_ap(const address_type& new_current_ap);
482
489 uint32_t header_size() const;
490
496 return pdu_flag;
497 }
498
504 bool matches_flag(PDUType flag) const {
505 return flag == pdu_flag || Dot11ManagementFrame::matches_flag(flag);
506 }
507
514 return new Dot11ReAssocRequest(*this);
515 }
516private:
517 struct dot11_reassoc_request_body {
518 capability_information capability;
519 uint16_t listen_interval;
520 uint8_t current_ap[address_type::address_size];
521 };
522
523 void write_fixed_parameters(Memory::OutputMemoryStream& stream);
524
525 dot11_reassoc_request_body body_;
526};
527
533public:
537 static const PDU::PDUType pdu_flag = PDU::DOT11_REASSOC_RESP;
538
548 Dot11ReAssocResponse(const address_type& dst_hw_addr = address_type(),
549 const address_type& src_hw_addr = address_type());
550
565 Dot11ReAssocResponse(const uint8_t* buffer, uint32_t total_sz);
566
574 return body_.capability;
575 }
576
584 return body_.capability;
585 }
586
592 uint16_t status_code() const {
593 return Endian::le_to_host(body_.status_code);
594 }
595
601 uint16_t aid() const {
602 return Endian::le_to_host(body_.aid);
603 }
604
610 void status_code(uint16_t new_status_code);
611
617 void aid(uint16_t new_aid);
618
625 uint32_t header_size() const;
626
632 return pdu_flag;
633 }
634
640 bool matches_flag(PDUType flag) const {
641 return flag == pdu_flag || Dot11ManagementFrame::matches_flag(flag);
642 }
643
650 return new Dot11ReAssocResponse(*this);
651 }
652private:
653 struct dot11_reassoc_response_body {
654 capability_information capability;
655 uint16_t status_code;
656 uint16_t aid;
657 };
658
659 void write_fixed_parameters(Memory::OutputMemoryStream& stream);
660
661 dot11_reassoc_response_body body_;
662};
663
664} // namespace Tins
665
666#endif // TINS_DOT11_DOT11_ASSOC_H
Class representing an Association Request frame in the IEEE 802.11 Protocol.
Definition dot11_assoc.h:141
bool matches_flag(PDUType flag) const
Check whether this PDU matches the specified flag.
Definition dot11_assoc.h:233
PDUType pdu_type() const
Getter for the PDU's type.
Definition dot11_assoc.h:224
uint16_t listen_interval() const
Getter for the listen interval field.
Definition dot11_assoc.h:201
Dot11AssocRequest * clone() const
Clones this PDU.
Definition dot11_assoc.h:242
const capability_information & capabilities() const
Getter for the Capabilities Information.
Definition dot11_assoc.h:182
capability_information & capabilities()
Getter for the Capabilities Information.
Definition dot11_assoc.h:192
Class representing an Association Response frame in the IEEE 802.11 Protocol.
Definition dot11_assoc.h:260
PDUType pdu_type() const
Getter for the PDU's type.
Definition dot11_assoc.h:359
uint16_t status_code() const
Getter for the status code field.
Definition dot11_assoc.h:320
bool matches_flag(PDUType flag) const
Check whether this PDU matches the specified flag.
Definition dot11_assoc.h:368
Dot11AssocResponse * clone() const
Clones this PDU.
Definition dot11_assoc.h:377
const capability_information & capabilities() const
Getter for the Capabilities Information field.
Definition dot11_assoc.h:301
capability_information & capabilities()
Getter for the Capabilities Information field.
Definition dot11_assoc.h:311
uint16_t aid() const
Getter for the AID field.
Definition dot11_assoc.h:329
Class representing a Disassociation frame in the IEEE 802.11 Protocol.
Definition dot11_assoc.h:43
uint16_t reason_code() const
Getter for the reason code field.
Definition dot11_assoc.h:83
bool matches_flag(PDUType flag) const
Check whether this PDU matches the specified flag.
Definition dot11_assoc.h:115
Dot11Disassoc * clone() const
Clones this PDU.
Definition dot11_assoc.h:124
PDUType pdu_type() const
Getter for the PDU's type.
Definition dot11_assoc.h:106
Base class for all management frames in the IEEE 802.11 protocol.
Definition dot11_mgmt.h:45
Class representing an ReAssociation Request frame in the IEEE 802.11 Protocol.
Definition dot11_assoc.h:396
address_type current_ap() const
Getter for the current ap field.
Definition dot11_assoc.h:465
uint16_t listen_interval() const
Getter for the listen interval field.
Definition dot11_assoc.h:456
PDUType pdu_type() const
Getter for the PDU's type.
Definition dot11_assoc.h:495
Dot11ReAssocRequest * clone() const
Clones this PDU.
Definition dot11_assoc.h:513
bool matches_flag(PDUType flag) const
Check whether this PDU matches the specified flag.
Definition dot11_assoc.h:504
capability_information & capabilities()
Getter for the Capabilities Information.
Definition dot11_assoc.h:447
const capability_information & capabilities() const
Getter for the Capabilities Information.
Definition dot11_assoc.h:437
IEEE 802.11 ReAssociation Response frame.
Definition dot11_assoc.h:532
Dot11ReAssocResponse * clone() const
Clones this PDU.
Definition dot11_assoc.h:649
const capability_information & capabilities() const
Getter for the Capabilities Information.
Definition dot11_assoc.h:573
uint16_t aid() const
Getter for the AID field.
Definition dot11_assoc.h:601
uint16_t status_code() const
Getter for the status code field.
Definition dot11_assoc.h:592
bool matches_flag(PDUType flag) const
Check whether this PDU matches the specified flag.
Definition dot11_assoc.h:640
capability_information & capabilities()
Getter for the Capabilities Information.
Definition dot11_assoc.h:583
PDUType pdu_type() const
Getter for the PDU's type.
Definition dot11_assoc.h:631
PDUType
Enum which identifies each type of PDU.
Definition pdu.h:127
The Tins namespace.
Definition address_range.h:38