Botan: src/ssl/tls_alerts.h Source File

Botan 1.10.16

tls_alerts.h
Go to the documentation of this file.
1 /*
2 * Alert Message
3 * (C) 2004-2006 Jack Lloyd
4 *
5 * Released under the terms of the Botan license
6 */
7
8 #ifndef BOTAN_TLS_ALERT_H__
9 #define BOTAN_TLS_ALERT_H__
10
11 #include <botan/tls_exceptn.h>
12
13 namespace Botan {
14
15 /**
16 * SSL/TLS Alert Message
17 */
18 class Alert
19 {
20 public:
21 /**
22 * @return if this alert is a fatal one or not
23 */
24 bool is_fatal() const { return fatal; }
25
26 /**
27 * @return type of alert
28 */
29 Alert_Type type() const { return type_code; }
30
31 /**
32 * Deserialize an Alert message
33 * @param buf the serialized alert
34 */
35 Alert(const MemoryRegion<byte>& buf)
36 {
37 if(buf.size() != 2)
38 throw Decoding_Error("Alert: Bad size for alert message");
39
40 if(buf[0] == 1) fatal = false;
41 else if(buf[0] == 2) fatal = true;
42 else
43 throw Decoding_Error("Alert: Bad type code for alert level");
44
45 type_code = static_cast<Alert_Type>(buf[1]);
46 }
47 private:
48 bool fatal;
49 Alert_Type type_code;
50 };
51
52 }
53
54 #endif
Botan::Alert::Alert
Alert(const MemoryRegion< byte > &buf)
Definition: tls_alerts.h:35
Botan::Decoding_Error
Definition: exceptn.h:138
Botan::MemoryRegion< byte >
Botan
Definition: algo_base.h:14
Botan::Alert::type
Alert_Type type() const
Definition: tls_alerts.h:29
Botan::Alert::is_fatal
bool is_fatal() const
Definition: tls_alerts.h:24
Botan::Alert_Type
Alert_Type
Definition: tls_magic.h:62
Botan::MemoryRegion::size
size_t size() const
Definition: secmem.h:29
Botan::Alert
Definition: tls_alerts.h:18