mirror of
https://github.com/SoftEtherVPN/SoftEtherVPN.git
synced 2025-07-08 08:44:57 +03:00
Add interface for easy protocol implementation
This commit adds a protocol interface to the server, its purpose is to manage TCP connections and the various third-party protocols. More specifically, ProtoHandleConnection() takes care of exchanging the packets between the local and remote endpoint; the protocol implementation only has to parse them and act accordingly. The interface knows which protocol is the connection for by calling IsPacketForMe(), a function implemented for each protocol.
This commit is contained in:
@ -18980,6 +18980,40 @@ UDPLISTENER_SOCK *DetermineUdpSocketForSending(UDPLISTENER *u, UDPPACKET *p)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void FreeTcpRawData(TCP_RAW_DATA *trd)
|
||||
{
|
||||
// Validate arguments
|
||||
if (trd == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
ReleaseFifo(trd->Data);
|
||||
Free(trd);
|
||||
}
|
||||
|
||||
TCP_RAW_DATA *NewTcpRawData(IP *src_ip, UINT src_port, IP *dst_ip, UINT dst_port)
|
||||
{
|
||||
TCP_RAW_DATA *trd;
|
||||
// Validate arguments
|
||||
if (dst_ip == NULL || dst_port == 0)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
trd = ZeroMalloc(sizeof(TCP_RAW_DATA));
|
||||
|
||||
Copy(&trd->SrcIP, src_ip, sizeof(IP));
|
||||
trd->SrcPort = src_port;
|
||||
|
||||
Copy(&trd->DstIP, dst_ip, sizeof(IP));
|
||||
trd->DstPort = dst_port;
|
||||
|
||||
trd->Data = NewFifoFast();
|
||||
|
||||
return trd;
|
||||
}
|
||||
|
||||
// Release of the UDP packet
|
||||
void FreeUdpPacket(UDPPACKET *p)
|
||||
{
|
||||
|
Reference in New Issue
Block a user