libtins 4.5
Loading...
Searching...
No Matches
exceptions.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#ifndef TINS_EXCEPTIONS_H
31#define TINS_EXCEPTIONS_H
32
33#include <string>
34#include <stdexcept>
35
36namespace Tins {
37
41class exception_base : public std::runtime_error {
42public:
44 : std::runtime_error(std::string()) { }
45
46 exception_base(const std::string& message)
47 : std::runtime_error(message) { }
48
49 exception_base(const char* message)
50 : std::runtime_error(message) { }
51};
52
57public:
58 option_not_found() : exception_base("Option not found") { }
59};
60
65public:
66 malformed_packet() : exception_base("Malformed packet") { }
67 malformed_packet(const std::string& message) : exception_base(message) { }
68};
69
74public:
75 dns_decompression_pointer_out_of_bounds() : malformed_packet("DNS decompression: pointer out of bounds") { }
76};
77
82public:
83 dns_decompression_pointer_loops() : malformed_packet("DNS decompression: pointer loops") { }
84};
85
86
91public:
92 serialization_error() : exception_base("Serialization error") { }
93};
94
99public:
100 pdu_not_found() : exception_base("PDU not found") { }
101};
102
108public:
109 invalid_interface() : exception_base("Invalid interface") { }
110};
111
117public:
118 invalid_address() : exception_base("Invalid address") { }
119};
120
125public:
126 invalid_option_value() : exception_base("Invalid option value") { }
127};
128
133public:
134 field_not_present() : exception_base("Field not present") { }
135};
136
141public:
142 socket_open_error(const std::string& msg)
143 : exception_base(msg) { }
144};
145
150public:
151 socket_close_error(const std::string& msg)
152 : exception_base(msg) { }
153};
154
159public:
160 socket_write_error(const std::string& msg)
161 : exception_base(msg) { }
162};
163
169public:
170 invalid_socket_type() : exception_base("The provided socket type is invalid") { }
171};
172
178public:
179 unknown_link_type() : exception_base("The sniffed link layer PDU type is unknown") { }
180};
181
186public:
187 malformed_option() : exception_base("Malformed option") { }
188};
189
194public:
195 bad_tins_cast() : exception_base("Bad Tins cast") { }
196};
197
203public:
204 protocol_disabled() : exception_base("Protocol disabled") { }
205};
206
212public:
213 feature_disabled() : exception_base("Feature disabled") { }
214};
215
221public:
222 option_payload_too_large() : exception_base("Option payload too large") { }
223};
224
230public:
231 invalid_ipv6_extension_header() : exception_base("Invalid IPv6 extension header") { }
232};
233
238public:
239 pcap_error(const char* message) : exception_base(message) {
240
241 }
242
243 pcap_error(const std::string& message) : exception_base(message) {
244
245 }
246};
247
252public:
253 invalid_pcap_filter(const char* message) : exception_base(message) {
254
255 }
256};
257
263public:
264 pdu_not_serializable() : exception_base("PDU not serializable") { }
265};
266
271public:
272 pcap_open_failed() : exception_base("Failed to create pcap handle") { }
273};
274
280public:
281 unsupported_function() : exception_base("Function is not supported on this OS") { }
282};
283
288public:
289 invalid_domain_name() : exception_base("Invalid domain name") { }
290};
291
296public:
297 stream_not_found() : exception_base("Stream not found") { }
298};
299
304public:
305 callback_not_set() : exception_base("Callback not set") { }
306};
307
312public:
313 invalid_packet() : exception_base("Invalid packet") { }
314};
315
316namespace Crypto {
317namespace WPA2 {
322 public:
323 invalid_handshake() : exception_base("Invalid WPA2 handshake") { }
324 };
325} // WPA2
326} // Crypto
327
328} // Tins
329
330#endif // TINS_EXCEPTIONS_H
Exception thrown when an invalid WPA2 handshake is found.
Definition exceptions.h:321
Exception thrown when a call to tins_cast fails.
Definition exceptions.h:193
Exception thrown when a required callback for an object is not set.
Definition exceptions.h:303
Exception thrown when a DNS decompression pointer loops.
Definition exceptions.h:81
Exception thrown when a DNS decompression pointer is out of bounds.
Definition exceptions.h:73
Base class for all libtins exceptions.
Definition exceptions.h:41
Exception thrown when a feature has been disabled at compile time.
Definition exceptions.h:211
Exception thrown when a field is not present in frame.
Definition exceptions.h:132
Exception thrown when an invalid string representation of an address is provided.
Definition exceptions.h:116
Exception thrown when an invalid domain name is parsed.
Definition exceptions.h:287
Exception thrown when PDU::send requires a valid interface, but an invalid is used.
Definition exceptions.h:107
Exception thrown when an IPv6 extension header is being created from invalid data.
Definition exceptions.h:229
Exception thrown when a PDU option is set using an incorrect value.
Definition exceptions.h:124
Exception thrown when an invalid packet is provided to some function.
Definition exceptions.h:311
Exception thrown when an invalid pcap filter is compiled.
Definition exceptions.h:251
Exception thrown when an invalid socket type is provided to PacketSender.
Definition exceptions.h:168
Exception thrown when a malformed option is found.
Definition exceptions.h:185
Exception thrown when a malformed packet is parsed.
Definition exceptions.h:64
Exception thrown when an option is not found.
Definition exceptions.h:56
Exception thrown when a payload is too large to fit into a PDUOption.
Definition exceptions.h:220
Generic pcap error.
Definition exceptions.h:237
Exception thrown when opening a pcap handle fails.
Definition exceptions.h:270
Exception thrown when a PDU is not found when using PDU::rfind_pdu.
Definition exceptions.h:98
Exception thrown when serialiation of a non-serializable PDU is attempted.
Definition exceptions.h:262
Exception thrown when sniffing a protocol that has been disabled at compile time.
Definition exceptions.h:202
Exception thrown when serializing a packet fails.
Definition exceptions.h:90
Exception thrown when PacketSender fails to close a socket.
Definition exceptions.h:149
Exception thrown when PacketSender fails to open a socket.
Definition exceptions.h:140
Exception thrown when PacketSender fails to write on a socket.
Definition exceptions.h:158
Exception thrown when a stream is not found.
Definition exceptions.h:295
Exception thrown when a function not supported on the current OS is called.
Definition exceptions.h:279
The Tins namespace.
Definition address_range.h:38