Commit 56ec56f7 authored by Guillaume Roguez's avatar Guillaume Roguez Committed by gerrit2

tls: add getMaxPayload() method to TlsSession

This method returns the maximal number of user data bytes
that one encrypted packet can transport.
After this number, data are split in as many as smaller packet possible
to not exceed this size.

Change-Id: I5f88c4ac1f830ed78b2ecaca2f30257c874a2a13
Tuleap: #660
parent 4933d789
......@@ -690,6 +690,7 @@ TlsSession::handleStateHandshake(TlsSessionState state)
callbacks_.onCertificatesUpdate(local, remote, remote_count);
maxPayload_ = gnutls_dtls_get_data_mtu(session_);
return TlsSessionState::ESTABLISHED;
......@@ -143,6 +143,10 @@ public:
// Request TLS thread to stop and quit. IO are not possible after that.
void shutdown();
// Return maximum application payload size in bytes
// Returned value must be checked and considered valid only if not 0 (session is initialized)
unsigned int getMaxPayload() const { return maxPayload_; }
// Can be called by onStateChange callback when state == ESTABLISHED
// to obtain the used cypher suite id.
// Return the name of current cipher.
......@@ -170,6 +174,7 @@ private:
TlsSessionState handleStateShutdown(TlsSessionState state);
std::map<TlsSessionState, StateHandler> fsmHandlers_ {};
std::atomic<TlsSessionState> state_ {TlsSessionState::SETUP};
std::atomic<unsigned int> maxPayload_ {0};
// IO GnuTLS <-> ICE
struct TxData {
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment