aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/tls/tls_channel.h
diff options
context:
space:
mode:
authorMatthias Gierlings <[email protected]>2016-05-16 20:46:50 +0200
committerMatthias Gierlings <[email protected]>2016-06-19 18:28:36 +0200
commit93df95db45fa126725808fbd53aa978b00cf08ad (patch)
tree9c0b81ef8488a7c3142d1f95ac5904470ac3c3a9 /src/lib/tls/tls_channel.h
parent89b75a5a36c18a7593aa6bdbb472e301904a66b3 (diff)
Added virtual Callback Interface
- extracted inner class TLS::Channel::Callbacks to stand-alone class TLS::Callbacks. - provided default implementations for TLS::Callbacks members executing calls to std::function members for backward compatibility. - applied changes to cli, tests and TLS::Channel related classes to be compatible with new interface.
Diffstat (limited to 'src/lib/tls/tls_channel.h')
-rw-r--r--src/lib/tls/tls_channel.h47
1 files changed, 2 insertions, 45 deletions
diff --git a/src/lib/tls/tls_channel.h b/src/lib/tls/tls_channel.h
index 71356f382..d10ac2b6e 100644
--- a/src/lib/tls/tls_channel.h
+++ b/src/lib/tls/tls_channel.h
@@ -13,6 +13,7 @@
#include <botan/tls_session.h>
#include <botan/tls_alert.h>
#include <botan/tls_session_manager.h>
+#include <botan/tls_callbacks.h>
#include <botan/x509cert.h>
#include <vector>
#include <string>
@@ -35,50 +36,6 @@ class BOTAN_DLL Channel
public:
static size_t IO_BUF_DEFAULT_SIZE;
- class Callbacks
- {
- public:
- typedef std::function<void (const byte[], size_t)> output_fn;
- typedef std::function<void (const byte[], size_t)> data_cb;
- typedef std::function<void (Alert)> alert_cb;
- typedef std::function<bool (const Session&)> handshake_cb;
- typedef std::function<void (const Handshake_Message&)> handshake_msg_cb;
- /**
- * Encapsulates a set of callback functions required by a TLS Channel.
- * @param output_fn is called with data for the outbound socket
- *
- * @param app_data_cb is called when new application data is received
- *
- * @param alert_cb is called when a TLS alert is received
- *
- * @param handshake_cb is called when a handshake is completed
- */
- Callbacks(output_fn out, data_cb app_data_cb, alert_cb alert_cb,
- handshake_cb hs_cb)
- : m_output_function(out), m_app_data_cb(app_data_cb),
- m_alert_cb(alert_cb), m_hs_cb(hs_cb), m_hs_msg_cb() {}
-
- Callbacks(output_fn out, data_cb app_data_cb, alert_cb alert_cb,
- handshake_cb hs_cb, handshake_msg_cb hs_msg_cb)
- : m_output_function(out), m_app_data_cb(app_data_cb),
- m_alert_cb(alert_cb), m_hs_cb(hs_cb), m_hs_msg_cb(hs_msg_cb) {}
-
- const output_fn& out_fn() const { return m_output_function; }
- const data_cb& app_data() const { return m_app_data_cb; }
- const alert_cb& alert() const { return m_alert_cb; }
- const handshake_cb& handshake() const { return m_hs_cb; }
- const handshake_msg_cb& handshake_msg() const { return m_hs_msg_cb; }
-
- private:
- const output_fn m_output_function;
- const data_cb m_app_data_cb;
- const alert_cb m_alert_cb;
- const handshake_cb m_hs_cb;
- const handshake_msg_cb m_hs_msg_cb;
- };
-
-
-
Channel(const Callbacks& callbacks,
Session_Manager& session_manager,
RandomNumberGenerator& rng,
@@ -237,7 +194,7 @@ class BOTAN_DLL Channel
const Policy& policy() const { return m_policy; }
- bool save_session(const Session& session) const { return m_callbacks.handshake()(session); }
+ bool save_session(const Session& session) const { return m_callbacks.handshake(session); }
Callbacks get_callbacks() const { return m_callbacks; }
private: