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:
43 exception_base()
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
56class option_not_found : public exception_base {
57public:
58 option_not_found() : exception_base("Option not found") { }
59};
60
64class malformed_packet : public exception_base {
65public:
66 malformed_packet() : exception_base("Malformed packet") { }
67 malformed_packet(const std::string& message) : exception_base(message) { }
68};
69
73class dns_decompression_pointer_out_of_bounds : public malformed_packet {
74public:
75 dns_decompression_pointer_out_of_bounds() : malformed_packet("DNS decompression: pointer out of bounds") { }
76};
77
81class dns_decompression_pointer_loops : public malformed_packet {
82public:
83 dns_decompression_pointer_loops() : malformed_packet("DNS decompression: pointer loops") { }
84};
85
86
90class serialization_error : public exception_base {
91public:
92 serialization_error() : exception_base("Serialization error") { }
93};
94
98class pdu_not_found : public exception_base {
99public:
100 pdu_not_found() : exception_base("PDU not found") { }
101};
102
107class invalid_interface : public exception_base {
108public:
109 invalid_interface() : exception_base("Invalid interface") { }
110};
111
116class invalid_address : public exception_base {
117public:
118 invalid_address() : exception_base("Invalid address") { }
119};
120
124class invalid_option_value : public exception_base {
125public:
126 invalid_option_value() : exception_base("Invalid option value") { }
127};
128
132class field_not_present : public exception_base {
133public:
134 field_not_present() : exception_base("Field not present") { }
135};
136
140class socket_open_error : public exception_base {
141public:
142 socket_open_error(const std::string& msg)
143 : exception_base(msg) { }
144};
145
149class socket_close_error : public exception_base {
150public:
151 socket_close_error(const std::string& msg)
152 : exception_base(msg) { }
153};
154
158class socket_write_error : public exception_base {
159public:
160 socket_write_error(const std::string& msg)
161 : exception_base(msg) { }
162};
163
168class invalid_socket_type : public exception_base {
169public:
170 invalid_socket_type() : exception_base("The provided socket type is invalid") { }
171};
172
177class unknown_link_type : public exception_base {
178public:
179 unknown_link_type() : exception_base("The sniffed link layer PDU type is unknown") { }
180};
181
185class malformed_option : public exception_base {
186public:
187 malformed_option() : exception_base("Malformed option") { }
188};
189
193class bad_tins_cast : public exception_base {
194public:
195 bad_tins_cast() : exception_base("Bad Tins cast") { }
196};
197
202class protocol_disabled : public exception_base {
203public:
204 protocol_disabled() : exception_base("Protocol disabled") { }
205};
206
211class feature_disabled : public exception_base {
212public:
213 feature_disabled() : exception_base("Feature disabled") { }
214};
215
220class option_payload_too_large : public exception_base {
221public:
222 option_payload_too_large() : exception_base("Option payload too large") { }
223};
224
229class invalid_ipv6_extension_header : public exception_base {
230public:
231 invalid_ipv6_extension_header() : exception_base("Invalid IPv6 extension header") { }
232};
233
237class pcap_error : public exception_base {
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
251class invalid_pcap_filter : public exception_base {
252public:
253 invalid_pcap_filter(const char* message) : exception_base(message) {
254
255 }
256};
257
262class pdu_not_serializable : public exception_base {
263public:
264 pdu_not_serializable() : exception_base("PDU not serializable") { }
265};
266
270class pcap_open_failed : public exception_base {
271public:
272 pcap_open_failed() : exception_base("Failed to create pcap handle") { }
273};
274
279class unsupported_function : public exception_base {
280public:
281 unsupported_function() : exception_base("Function is not supported on this OS") { }
282};
283
287class invalid_domain_name : public exception_base {
288public:
289 invalid_domain_name() : exception_base("Invalid domain name") { }
290};
291
295class stream_not_found : public exception_base {
296public:
297 stream_not_found() : exception_base("Stream not found") { }
298};
299
303class callback_not_set : public exception_base {
304public:
305 callback_not_set() : exception_base("Callback not set") { }
306};
307
311class invalid_packet : public exception_base {
312public:
313 invalid_packet() : exception_base("Invalid packet") { }
314};
315
316namespace Crypto {
317namespace WPA2 {
321 class invalid_handshake : public exception_base {
322 public:
323 invalid_handshake() : exception_base("Invalid WPA2 handshake") { }
324 };
325} // WPA2
326} // Crypto
327
328} // Tins
329
330#endif // TINS_EXCEPTIONS_H
The Tins namespace.
Definition address_range.h:38