From 22041f0d8b863122dfafeb53f80e459adbdd938f Mon Sep 17 00:00:00 2001 From: lloyd Date: Thu, 9 Aug 2012 13:46:58 +0000 Subject: Lame but usable DTLS defragmentation --- src/tls/tls_handshake_io.cpp | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'src/tls/tls_handshake_io.cpp') diff --git a/src/tls/tls_handshake_io.cpp b/src/tls/tls_handshake_io.cpp index abc2f49f7..08b9f58bb 100644 --- a/src/tls/tls_handshake_io.cpp +++ b/src/tls/tls_handshake_io.cpp @@ -220,12 +220,20 @@ void Datagram_Handshake_IO::Handshake_Reassembly::add_fragment( } else { - throw Internal_Error("Defragmentation not implemented"); - - m_fragments[fragment_offset] = - std::deque(fragment, fragment+fragment_length); - - auto range = m_fragments.equal_range(fragment_offset); + /* + * FIXME. This is a pretty lame way to do defragmentation, huge + * overhead with a tree node per byte. + */ + for(size_t i = 0; i != fragment_length; ++i) + m_fragments[fragment_offset+i] = fragment[i]; + + if(m_fragments.size() == m_msg_length) + { + m_message.resize(m_msg_length); + for(size_t i = 0; i != m_msg_length; ++i) + m_message[i] = m_fragments[i]; + m_fragments.clear(); + } } } -- cgit v1.2.3