aboutsummaryrefslogtreecommitdiffstats
path: root/src/tls/tls_handshake_io.cpp
diff options
context:
space:
mode:
authorlloyd <[email protected]>2012-08-09 13:46:58 +0000
committerlloyd <[email protected]>2012-08-09 13:46:58 +0000
commit22041f0d8b863122dfafeb53f80e459adbdd938f (patch)
tree4d1fb8fd017d969a500794eb280d8d9c570b2b0a /src/tls/tls_handshake_io.cpp
parent59c4746d5e647790b45a0fcca219434cb43a17c1 (diff)
Lame but usable DTLS defragmentation
Diffstat (limited to 'src/tls/tls_handshake_io.cpp')
-rw-r--r--src/tls/tls_handshake_io.cpp20
1 files changed, 14 insertions, 6 deletions
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<byte>(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();
+ }
}
}