summaryrefslogtreecommitdiffstats
path: root/src/PolarSSL++/BufferedSslContext.cpp
diff options
context:
space:
mode:
authorTycho <work.tycho+git@gmail.com>2014-05-24 13:44:49 +0200
committerTycho <work.tycho+git@gmail.com>2014-05-24 13:44:49 +0200
commit4ab82881165cb180b020e67f851028718ab84d87 (patch)
tree93e773ebd46fb76dd520821133b01f6d99b26e94 /src/PolarSSL++/BufferedSslContext.cpp
parentIgnore CTest files (diff)
parentMerge pull request #1022 from mc-server/FixMineshafts (diff)
downloadcuberite-4ab82881165cb180b020e67f851028718ab84d87.tar
cuberite-4ab82881165cb180b020e67f851028718ab84d87.tar.gz
cuberite-4ab82881165cb180b020e67f851028718ab84d87.tar.bz2
cuberite-4ab82881165cb180b020e67f851028718ab84d87.tar.lz
cuberite-4ab82881165cb180b020e67f851028718ab84d87.tar.xz
cuberite-4ab82881165cb180b020e67f851028718ab84d87.tar.zst
cuberite-4ab82881165cb180b020e67f851028718ab84d87.zip
Diffstat (limited to 'src/PolarSSL++/BufferedSslContext.cpp')
-rw-r--r--src/PolarSSL++/BufferedSslContext.cpp31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/PolarSSL++/BufferedSslContext.cpp b/src/PolarSSL++/BufferedSslContext.cpp
index 885b30c68..9f7caeb8a 100644
--- a/src/PolarSSL++/BufferedSslContext.cpp
+++ b/src/PolarSSL++/BufferedSslContext.cpp
@@ -20,6 +20,37 @@ cBufferedSslContext::cBufferedSslContext(size_t a_BufferSize):
+size_t cBufferedSslContext::WriteIncoming(const void * a_Data, size_t a_NumBytes)
+{
+ size_t NumBytes = std::min(m_IncomingData.GetFreeSpace(), a_NumBytes);
+ if (NumBytes > 0)
+ {
+ m_IncomingData.Write(a_Data, NumBytes);
+ return NumBytes;
+ }
+ return 0;
+}
+
+
+
+
+
+size_t cBufferedSslContext::ReadOutgoing(void * a_Data, size_t a_DataMaxSize)
+{
+ size_t NumBytes = std::min(m_OutgoingData.GetReadableSpace(), a_DataMaxSize);
+ if (NumBytes > 0)
+ {
+ m_OutgoingData.ReadBuf(a_Data, NumBytes);
+ m_OutgoingData.CommitRead();
+ return NumBytes;
+ }
+ return 0;
+}
+
+
+
+
+
int cBufferedSslContext::ReceiveEncrypted(unsigned char * a_Buffer, size_t a_NumBytes)
{
// Called when PolarSSL wants to read encrypted data from the SSL peer