libtins 4.5
Loading...
Searching...
No Matches
handshake_capturer.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_HANDSHAKE_CAPTURER_H) && defined(TINS_HAVE_DOT11)
33#define TINS_HANDSHAKE_CAPTURER_H
34
35#include <vector>
36#include <map>
37#include <utility>
38#include <tins/hw_address.h>
39#include <tins/macros.h>
40#include <tins/eapol.h>
41
42namespace Tins {
43
50template<typename T>
52public:
53 typedef std::vector<T> container_type;
55
60
71 const container_type& cont)
72 : cl_address_(client_address), suppl_address_(supplicant_address),
73 handshake_(cont) {
74 }
75
80 return cl_address_;
81 }
82
87 return suppl_address_;
88 }
89
93 const container_type& handshake() const {
94 return handshake_;
95 }
96private:
97 address_type cl_address_, suppl_address_;
98 container_type handshake_;
99};
100
105
109class TINS_API RSNHandshakeCapturer {
110public:
115
120 typedef std::vector<handshake_type> handshakes_type;
121
131 bool process_packet(const PDU& pdu);
132
143 return completed_handshakes_;
144 }
145
154 completed_handshakes_.clear();
155 }
156private:
157 typedef handshake_type::address_type address_type;
158 typedef handshake_type::container_type eapol_list;
159 typedef std::map<std::pair<address_type, address_type>, eapol_list> handshake_map;
160
161 bool do_insert(const handshake_map::key_type& key, const RSNEAPOL* eapol,
162 size_t expected);
163
164 handshake_map handshakes_;
165 handshakes_type completed_handshakes_;
166};
167
168} // Tins
169
170#endif // TINS_HANDSHAKE_CAPTURER_H
Generic EAPOL handshake.
Definition handshake_capturer.h:51
EAPOLHandshake(const address_type &client_address, const address_type &supplicant_address, const container_type &cont)
Definition handshake_capturer.h:69
const address_type & client_address() const
Definition handshake_capturer.h:79
EAPOLHandshake()
Default constructor.
Definition handshake_capturer.h:59
const container_type & handshake() const
Definition handshake_capturer.h:93
const address_type & supplicant_address() const
Definition handshake_capturer.h:86
Represents a hardware address.
Definition resolve_utils.h:43
Base class for protocol data units.
Definition pdu.h:107
Class that represents the RSN EAPOL PDU.
Definition eapol.h:397
Definition handshake_capturer.h:109
void clear_handshakes()
Clears the completed handshakes.
Definition handshake_capturer.h:153
const handshakes_type & handshakes() const
Retrieves the completed handshakes.
Definition handshake_capturer.h:142
std::vector< handshake_type > handshakes_type
Definition handshake_capturer.h:120
RSNHandshake handshake_type
Definition handshake_capturer.h:114
The Tins namespace.
Definition address_range.h:38
EAPOLHandshake< RSNEAPOL > RSNHandshake
Definition handshake_capturer.h:104