mirror of
https://github.com/SoftEtherVPN/SoftEtherVPN.git
synced 2024-11-22 17:39:53 +03:00
Codestyle fixes
This commit is contained in:
parent
9180e065a0
commit
8a856e4672
@ -3019,12 +3019,12 @@ bool PPPProcessEAPTlsResponse(PPP_SESSION* p, PPP_EAP* eap_packet, UINT eapTlsSi
|
||||
if (eapTlsSize == 1)
|
||||
{
|
||||
// This is an EAP-TLS message ACK
|
||||
if (p->Eap_TlsCtx.cachedBufferSend != NULL)
|
||||
if (p->Eap_TlsCtx.CachedBufferSend != NULL)
|
||||
{
|
||||
// We got an ACK to transmit the next fragmented message
|
||||
dataSize = p->Mru1 - 8 - 1 - 1; // Calculating the maximum payload size (without TlsLength)
|
||||
sizeLeft = GetMemSize(p->Eap_TlsCtx.cachedBufferSend);
|
||||
sizeLeft -= p->Eap_TlsCtx.cachedBufferSendPntr - p->Eap_TlsCtx.cachedBufferSend;
|
||||
sizeLeft = GetMemSize(p->Eap_TlsCtx.CachedBufferSend);
|
||||
sizeLeft -= p->Eap_TlsCtx.CachedBufferSendPntr - p->Eap_TlsCtx.CachedBufferSend;
|
||||
|
||||
flags = PPP_EAP_TLS_FLAG_FRAGMENTED; // M flag
|
||||
if (dataSize > sizeLeft)
|
||||
@ -3034,8 +3034,8 @@ bool PPPProcessEAPTlsResponse(PPP_SESSION* p, PPP_EAP* eap_packet, UINT eapTlsSi
|
||||
}
|
||||
lcp = BuildEAPTlsRequest(p->Eap_PacketId++, dataSize, flags);
|
||||
eap = lcp->Data;
|
||||
Copy(eap->Tls.TlsDataWithoutLength, p->Eap_TlsCtx.cachedBufferSendPntr, dataSize);
|
||||
p->Eap_TlsCtx.cachedBufferSendPntr += dataSize;
|
||||
Copy(eap->Tls.TlsDataWithoutLength, p->Eap_TlsCtx.CachedBufferSendPntr, dataSize);
|
||||
p->Eap_TlsCtx.CachedBufferSendPntr += dataSize;
|
||||
|
||||
if (!PPPSendAndRetransmitRequest(p, PPP_PROTOCOL_EAP, lcp))
|
||||
{
|
||||
@ -3048,16 +3048,16 @@ bool PPPProcessEAPTlsResponse(PPP_SESSION* p, PPP_EAP* eap_packet, UINT eapTlsSi
|
||||
if (flags == PPP_EAP_TLS_FLAG_NONE)
|
||||
{
|
||||
// As it is the latest message, we need to cleanup
|
||||
Free(p->Eap_TlsCtx.cachedBufferSend);
|
||||
p->Eap_TlsCtx.cachedBufferSend = NULL;
|
||||
p->Eap_TlsCtx.cachedBufferSendPntr = NULL;
|
||||
Free(p->Eap_TlsCtx.CachedBufferSend);
|
||||
p->Eap_TlsCtx.CachedBufferSend = NULL;
|
||||
p->Eap_TlsCtx.CachedBufferSendPntr = NULL;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// It probably should be the final ACK on closed SSL pipe
|
||||
SyncSslPipe(p->Eap_TlsCtx.SslPipe);
|
||||
if (p->Eap_TlsCtx.clientCert.X != NULL)
|
||||
if (p->Eap_TlsCtx.ClientCert.X != NULL)
|
||||
{
|
||||
IPC *ipc;
|
||||
ETHERIP_ID d;
|
||||
@ -3083,7 +3083,7 @@ bool PPPProcessEAPTlsResponse(PPP_SESSION* p, PPP_EAP* eap_packet, UINT eapTlsSi
|
||||
|
||||
ipc = NewIPC(p->Cedar, p->ClientSoftwareName, p->Postfix, d.HubName, d.UserName, "",
|
||||
&error_code, &p->ClientIP, p->ClientPort, &p->ServerIP, p->ServerPort,
|
||||
p->ClientHostname, p->CryptName, false, p->AdjustMss, NULL, p->Eap_TlsCtx.clientCert.X,
|
||||
p->ClientHostname, p->CryptName, false, p->AdjustMss, NULL, p->Eap_TlsCtx.ClientCert.X,
|
||||
IPC_LAYER_3);
|
||||
|
||||
if (ipc != NULL)
|
||||
@ -3175,38 +3175,38 @@ bool PPPProcessEAPTlsResponse(PPP_SESSION* p, PPP_EAP* eap_packet, UINT eapTlsSi
|
||||
if (p->Eap_TlsCtx.SslPipe == NULL)
|
||||
{
|
||||
p->Eap_TlsCtx.Dh = DhNewFromBits(DH_PARAM_BITS_DEFAULT);
|
||||
p->Eap_TlsCtx.SslPipe = NewSslPipeEx(true, p->Cedar->ServerX, p->Cedar->ServerK, p->Eap_TlsCtx.Dh, true, &(p->Eap_TlsCtx.clientCert));
|
||||
p->Eap_TlsCtx.SslPipe = NewSslPipeEx(true, p->Cedar->ServerX, p->Cedar->ServerK, p->Eap_TlsCtx.Dh, true, &(p->Eap_TlsCtx.ClientCert));
|
||||
}
|
||||
|
||||
// If the current frame is fragmented, or it is a possible last of a fragmented series, bufferize it
|
||||
if (isFragmented || p->Eap_TlsCtx.cachedBufferRecv != NULL)
|
||||
if (isFragmented || p->Eap_TlsCtx.CachedBufferRecv != NULL)
|
||||
{
|
||||
if (p->Eap_TlsCtx.cachedBufferRecv == NULL && tlsLength > 0)
|
||||
if (p->Eap_TlsCtx.CachedBufferRecv == NULL && tlsLength > 0)
|
||||
{
|
||||
p->Eap_TlsCtx.cachedBufferRecv = ZeroMalloc(MAX(dataSize, tlsLength));
|
||||
p->Eap_TlsCtx.cachedBufferRecvPntr = p->Eap_TlsCtx.cachedBufferRecv;
|
||||
p->Eap_TlsCtx.CachedBufferRecv = ZeroMalloc(MAX(dataSize, tlsLength));
|
||||
p->Eap_TlsCtx.CachedBufferRecvPntr = p->Eap_TlsCtx.CachedBufferRecv;
|
||||
}
|
||||
else if (p->Eap_TlsCtx.cachedBufferRecv == NULL)
|
||||
else if (p->Eap_TlsCtx.CachedBufferRecv == NULL)
|
||||
{
|
||||
p->Eap_TlsCtx.cachedBufferRecv = ZeroMalloc(MAX(dataSize, PPP_MRU_MAX * 10)); // 10 MRUs should be enough
|
||||
p->Eap_TlsCtx.cachedBufferRecvPntr = p->Eap_TlsCtx.cachedBufferRecv;
|
||||
p->Eap_TlsCtx.CachedBufferRecv = ZeroMalloc(MAX(dataSize, PPP_MRU_MAX * 10)); // 10 MRUs should be enough
|
||||
p->Eap_TlsCtx.CachedBufferRecvPntr = p->Eap_TlsCtx.CachedBufferRecv;
|
||||
}
|
||||
sizeLeft = GetMemSize(p->Eap_TlsCtx.cachedBufferRecv);
|
||||
sizeLeft -= p->Eap_TlsCtx.cachedBufferRecvPntr - p->Eap_TlsCtx.cachedBufferRecv;
|
||||
sizeLeft = GetMemSize(p->Eap_TlsCtx.CachedBufferRecv);
|
||||
sizeLeft -= p->Eap_TlsCtx.CachedBufferRecvPntr - p->Eap_TlsCtx.CachedBufferRecv;
|
||||
|
||||
Copy(p->Eap_TlsCtx.cachedBufferRecvPntr, dataBuffer, MIN(sizeLeft, dataSize));
|
||||
Copy(p->Eap_TlsCtx.CachedBufferRecvPntr, dataBuffer, MIN(sizeLeft, dataSize));
|
||||
|
||||
p->Eap_TlsCtx.cachedBufferRecvPntr += MIN(sizeLeft, dataSize);
|
||||
p->Eap_TlsCtx.CachedBufferRecvPntr += MIN(sizeLeft, dataSize);
|
||||
}
|
||||
|
||||
// If we got a cached buffer, we should feed the FIFOs via it
|
||||
if (p->Eap_TlsCtx.cachedBufferRecv != NULL)
|
||||
if (p->Eap_TlsCtx.CachedBufferRecv != NULL)
|
||||
{
|
||||
dataBuffer = p->Eap_TlsCtx.cachedBufferRecv;
|
||||
dataSize = GetMemSize(p->Eap_TlsCtx.cachedBufferRecv);
|
||||
dataBuffer = p->Eap_TlsCtx.CachedBufferRecv;
|
||||
dataSize = GetMemSize(p->Eap_TlsCtx.CachedBufferRecv);
|
||||
if (dataSize == MAX_BUFFERING_PACKET_SIZE)
|
||||
{
|
||||
dataSize = p->Eap_TlsCtx.cachedBufferRecvPntr - p->Eap_TlsCtx.cachedBufferRecv;
|
||||
dataSize = p->Eap_TlsCtx.CachedBufferRecvPntr - p->Eap_TlsCtx.CachedBufferRecv;
|
||||
}
|
||||
}
|
||||
|
||||
@ -3234,11 +3234,11 @@ bool PPPProcessEAPTlsResponse(PPP_SESSION* p, PPP_EAP* eap_packet, UINT eapTlsSi
|
||||
WriteFifo(p->Eap_TlsCtx.SslPipe->RawIn->SendFifo, dataBuffer, dataSize);
|
||||
SyncSslPipe(p->Eap_TlsCtx.SslPipe);
|
||||
// Delete the cached buffer after we fed it into the pipe
|
||||
if (p->Eap_TlsCtx.cachedBufferRecv != NULL)
|
||||
if (p->Eap_TlsCtx.CachedBufferRecv != NULL)
|
||||
{
|
||||
Free(p->Eap_TlsCtx.cachedBufferRecv);
|
||||
p->Eap_TlsCtx.cachedBufferRecv = NULL;
|
||||
p->Eap_TlsCtx.cachedBufferRecvPntr = NULL;
|
||||
Free(p->Eap_TlsCtx.CachedBufferRecv);
|
||||
p->Eap_TlsCtx.CachedBufferRecv = NULL;
|
||||
p->Eap_TlsCtx.CachedBufferRecvPntr = NULL;
|
||||
}
|
||||
|
||||
if (p->Eap_TlsCtx.SslPipe->IsDisconnected == false)
|
||||
@ -3247,12 +3247,12 @@ bool PPPProcessEAPTlsResponse(PPP_SESSION* p, PPP_EAP* eap_packet, UINT eapTlsSi
|
||||
// Do we need to send a fragmented packet?
|
||||
if (dataSize > p->Mru1 - 8 - 1 - 1)
|
||||
{
|
||||
if (p->Eap_TlsCtx.cachedBufferSend == NULL)
|
||||
if (p->Eap_TlsCtx.CachedBufferSend == NULL)
|
||||
{
|
||||
p->Eap_TlsCtx.cachedBufferSend = ZeroMalloc(dataSize);
|
||||
p->Eap_TlsCtx.cachedBufferSendPntr = p->Eap_TlsCtx.cachedBufferSend;
|
||||
p->Eap_TlsCtx.CachedBufferSend = ZeroMalloc(dataSize);
|
||||
p->Eap_TlsCtx.CachedBufferSendPntr = p->Eap_TlsCtx.CachedBufferSend;
|
||||
}
|
||||
ReadFifo(p->Eap_TlsCtx.SslPipe->RawOut->RecvFifo, p->Eap_TlsCtx.cachedBufferSend, dataSize);
|
||||
ReadFifo(p->Eap_TlsCtx.SslPipe->RawOut->RecvFifo, p->Eap_TlsCtx.CachedBufferSend, dataSize);
|
||||
|
||||
// Now send data from the cached buffer with set fragmentation flag and also total TLS Size
|
||||
tlsLength = dataSize;
|
||||
@ -3262,8 +3262,8 @@ bool PPPProcessEAPTlsResponse(PPP_SESSION* p, PPP_EAP* eap_packet, UINT eapTlsSi
|
||||
lcp = BuildEAPTlsRequest(p->Eap_PacketId++, dataSize, flags);
|
||||
eap = lcp->Data;
|
||||
eap->Tls.TlsDataWithLength.TlsLength = Endian32(tlsLength);
|
||||
Copy(eap->Tls.TlsDataWithLength.Data, p->Eap_TlsCtx.cachedBufferSend, dataSize);
|
||||
p->Eap_TlsCtx.cachedBufferSendPntr += dataSize;
|
||||
Copy(eap->Tls.TlsDataWithLength.Data, p->Eap_TlsCtx.CachedBufferSend, dataSize);
|
||||
p->Eap_TlsCtx.CachedBufferSendPntr += dataSize;
|
||||
if (!PPPSendAndRetransmitRequest(p, PPP_PROTOCOL_EAP, lcp))
|
||||
{
|
||||
PPPSetStatus(p, PPP_STATUS_FAIL);
|
||||
@ -3441,21 +3441,21 @@ void FreePPPSession(PPP_SESSION *p)
|
||||
}
|
||||
|
||||
// Freeing EAP-TLS context
|
||||
if (p->Eap_TlsCtx.cachedBufferRecv != NULL)
|
||||
if (p->Eap_TlsCtx.CachedBufferRecv != NULL)
|
||||
{
|
||||
Free(p->Eap_TlsCtx.cachedBufferRecv);
|
||||
Free(p->Eap_TlsCtx.CachedBufferRecv);
|
||||
}
|
||||
if (p->Eap_TlsCtx.cachedBufferSend != NULL)
|
||||
if (p->Eap_TlsCtx.CachedBufferSend != NULL)
|
||||
{
|
||||
Free(p->Eap_TlsCtx.cachedBufferRecv);
|
||||
Free(p->Eap_TlsCtx.CachedBufferRecv);
|
||||
}
|
||||
if (p->Eap_TlsCtx.SslPipe != NULL)
|
||||
{
|
||||
FreeSslPipe(p->Eap_TlsCtx.SslPipe);
|
||||
}
|
||||
if (p->Eap_TlsCtx.clientCert.X != NULL)
|
||||
if (p->Eap_TlsCtx.ClientCert.X != NULL)
|
||||
{
|
||||
FreeX(p->Eap_TlsCtx.clientCert.X);
|
||||
FreeX(p->Eap_TlsCtx.ClientCert.X);
|
||||
}
|
||||
if (p->Eap_TlsCtx.Dh != NULL)
|
||||
{
|
||||
|
@ -223,11 +223,11 @@ struct PPP_EAP_TLS_CONTEXT
|
||||
{
|
||||
SSL_PIPE *SslPipe;
|
||||
DH_CTX *Dh;
|
||||
struct SslClientCertInfo clientCert;
|
||||
UCHAR* cachedBufferRecv;
|
||||
UCHAR* cachedBufferRecvPntr;
|
||||
UCHAR* cachedBufferSend;
|
||||
UCHAR* cachedBufferSendPntr;
|
||||
struct SslClientCertInfo ClientCert;
|
||||
UCHAR *CachedBufferRecv;
|
||||
UCHAR *CachedBufferRecvPntr;
|
||||
UCHAR *CachedBufferSend;
|
||||
UCHAR *CachedBufferSendPntr;
|
||||
};
|
||||
|
||||
// PPP request resend
|
||||
|
Loading…
Reference in New Issue
Block a user