aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/tls/tls_callbacks.h
diff options
context:
space:
mode:
authorMatthias Gierlings <[email protected]>2016-05-16 23:02:58 +0200
committerMatthias Gierlings <[email protected]>2016-06-19 18:28:38 +0200
commit490d538512b7f732268358b3a3a6fcbfd2bb67c6 (patch)
tree200ef15842e924860c33f79d3c8be9c76e47ea39 /src/lib/tls/tls_callbacks.h
parent93df95db45fa126725808fbd53aa978b00cf08ad (diff)
Compatibility patch for TLS::Callback interface
- Added legacy constructor support for TLS::Channel, TLS::Client, TLS::Server.
Diffstat (limited to 'src/lib/tls/tls_callbacks.h')
-rw-r--r--src/lib/tls/tls_callbacks.h29
1 files changed, 22 insertions, 7 deletions
diff --git a/src/lib/tls/tls_callbacks.h b/src/lib/tls/tls_callbacks.h
index 854054c2b..216c58ce2 100644
--- a/src/lib/tls/tls_callbacks.h
+++ b/src/lib/tls/tls_callbacks.h
@@ -49,37 +49,52 @@ class BOTAN_DLL Callbacks
*
* @param handshake_cb is called when a handshake is completed
*/
-
+ BOTAN_DEPRECATED("Use TLS::Callbacks() (virtual interface).")
Callbacks(output_fn out, data_cb app_data_cb, alert_cb alert_cb,
handshake_cb hs_cb, handshake_msg_cb hs_msg_cb = nullptr)
: 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) {}
+ Callbacks()
+ : m_output_function(nullptr), m_app_data_cb(nullptr),
+ m_alert_cb(nullptr), m_hs_cb(nullptr), m_hs_msg_cb(nullptr) {}
+
+
virtual ~Callbacks() {}
virtual void out_fn(const byte data[], size_t size) const
{
- if (m_output_function != nullptr) { m_output_function(data, size); }
+ BOTAN_ASSERT(m_output_function != nullptr,
+ "Invalid TLS output function callback.");
+ m_output_function(data, size);
}
virtual void app_data(const byte data[], size_t size) const
{
- if (m_app_data_cb != nullptr) { m_app_data_cb(data, size); }
+ BOTAN_ASSERT(m_app_data_cb != nullptr,
+ "Invalid TLS app data callback.");
+ m_app_data_cb(data, size);
}
virtual void alert(Alert alert) const
{
- if (m_alert_cb != nullptr) { m_alert_cb(alert); }
+ BOTAN_ASSERT(m_alert_cb != nullptr,
+ "Invalid TLS alert callback.");
+ m_alert_cb(alert);
}
virtual bool handshake(const Session& session) const
{
- if (m_hs_cb != nullptr) { return m_hs_cb(session); }
+ BOTAN_ASSERT(m_hs_cb != nullptr,
+ "Invalid TLS handshake callback.");
+ return m_hs_cb(session);
}
- virtual void handshake_msg(const Handshake_Message& hmsg)
+ virtual void handshake_msg(const Handshake_Message& hmsg) const
{
- if (m_hs_msg_cb != nullptr) { m_hs_msg_cb(hmsg); }
+ // The handshake message callback is optional so we can
+ // not assume it has been set.
+ if(m_hs_msg_cb != nullptr) { m_hs_msg_cb(hmsg); }
}
private: