blob: 38013445ff829674c330ca7f516d9f35d88ffd8a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
|
/*
* TLS Protocol Version Management
* (C) 2012 Jack Lloyd
*
* Released under the terms of the Botan license
*/
#ifndef BOTAN_TLS_PROTOCOL_VERSION_H__
#define BOTAN_TLS_PROTOCOL_VERSION_H__
#include <botan/get_byte.h>
#include <string>
namespace Botan {
namespace TLS {
class BOTAN_DLL Protocol_Version
{
public:
enum Version_Code {
SSL_V3 = 0x0300,
TLS_V10 = 0x0301,
TLS_V11 = 0x0302,
TLS_V12 = 0x0303
};
Protocol_Version() : m_version(0) {}
Protocol_Version(Version_Code named_version) :
m_version(static_cast<u16bit>(named_version)) {}
Protocol_Version(byte major, byte minor) :
m_version((static_cast<u16bit>(major) << 8) | minor) {}
bool valid() const { return (m_version != 0); }
/**
* Get the major version of the protocol version
*/
byte major_version() const { return get_byte(0, m_version); }
/**
* Get the minor version of the protocol version
*/
byte minor_version() const { return get_byte(1, m_version); }
bool operator==(const Protocol_Version& other) const
{
return (m_version == other.m_version);
}
bool operator!=(const Protocol_Version& other) const
{
return (m_version != other.m_version);
}
bool operator>=(const Protocol_Version& other) const
{
return (m_version >= other.m_version);
}
bool operator>(const Protocol_Version& other) const
{
return (m_version > other.m_version);
}
bool operator<=(const Protocol_Version& other) const
{
return (m_version <= other.m_version);
}
bool operator<(const Protocol_Version& other) const
{
return (m_version < other.m_version);
}
std::string to_string() const;
private:
u16bit m_version;
};
}
}
#endif
|