aboutsummaryrefslogtreecommitdiffstats
path: root/src/tls/tls_heartbeats.h
blob: 00b1970893fd4ff83f34b7f9a722ce55612009e9 (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
/*
* TLS Heartbeats
* (C) 2012 Jack Lloyd
*
* Released under the terms of the Botan license
*/

#ifndef BOTAN_TLS_HEARTBEATS_H__
#define BOTAN_TLS_HEARTBEATS_H__

#include <botan/secmem.h>

namespace Botan {

namespace TLS {

/**
* TLS Heartbeat message
*/
class Heartbeat_Message
   {
   public:
      enum Type { REQUEST = 1, RESPONSE = 2 };

      std::vector<byte> contents() const;

      const std::vector<byte>& payload() const { return m_payload; }

      bool is_request() const { return m_type == REQUEST; }

      Heartbeat_Message(const std::vector<byte>& buf);

      Heartbeat_Message(Type type, const byte payload[], size_t payload_len);
   private:
      Type m_type;
      std::vector<byte> m_payload;
   };

}

}

#endif