mirror of
https://github.com/SoftEtherVPN/SoftEtherVPN.git
synced 2025-07-07 00:04:57 +03:00
Compare commits
6 Commits
027ae33ba3
...
5.02.5184
Author | SHA1 | Date | |
---|---|---|---|
9378c341f7 | |||
99e277aa71 | |||
bcb896b178 | |||
6e5395cc8d | |||
7f074d0c0b | |||
f8c5fa5384 |
@ -53,7 +53,7 @@ if(UNIX)
|
||||
#
|
||||
# use rpath for locating installed libraries
|
||||
#
|
||||
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
|
||||
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}")
|
||||
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
|
||||
|
||||
include(CheckIncludeFile)
|
||||
|
@ -2103,7 +2103,7 @@ void StopL2TPThread(L2TP_SERVER *l2tp, L2TP_TUNNEL *t, L2TP_SESSION *s)
|
||||
// Interrupt processing of L2TP server
|
||||
void L2TPProcessInterrupts(L2TP_SERVER *l2tp)
|
||||
{
|
||||
UINT i, j, k;
|
||||
UINT i, j;
|
||||
LIST *delete_tunnel_list = NULL;
|
||||
// Validate arguments
|
||||
if (l2tp == NULL)
|
||||
@ -2138,9 +2138,9 @@ void L2TPProcessInterrupts(L2TP_SERVER *l2tp)
|
||||
UINT64 l2tpTimeout = L2TP_TUNNEL_TIMEOUT;
|
||||
|
||||
// If we got on ANY session a higher timeout than the default L2TP tunnel timeout, increase it
|
||||
for (k = 0; k < LIST_NUM(t->SessionList); k++)
|
||||
for (i = 0; i < LIST_NUM(t->SessionList); i++)
|
||||
{
|
||||
L2TP_SESSION* s = LIST_DATA(t->SessionList, k);
|
||||
L2TP_SESSION* s = LIST_DATA(t->SessionList, i);
|
||||
|
||||
if (s->TubeRecv != NULL && s->TubeRecv->DataTimeout > l2tpTimeout)
|
||||
{
|
||||
|
@ -9340,20 +9340,75 @@ UINT ServeDhcpDiscoverEx(VH *v, UCHAR *mac, UINT request_ip, bool is_static_ip)
|
||||
return 0;
|
||||
}
|
||||
|
||||
UINT ret = 0;
|
||||
DHCP_LEASE *d = SearchDhcpLeaseByIp(v, request_ip);
|
||||
|
||||
if (d != NULL)
|
||||
{
|
||||
// The requested IP address is used already
|
||||
return 0;
|
||||
}
|
||||
|
||||
// For static IP, the requested IP address must NOT be within the range of the DHCP pool
|
||||
if (Endian32(request_ip) < Endian32(v->DhcpIpStart) || Endian32(request_ip) > Endian32(v->DhcpIpEnd))
|
||||
// If an entry for the same IP address already exists,
|
||||
// check whether it is a request from the same MAC address
|
||||
if (Cmp(mac, d->MacAddress, 6) == 0)
|
||||
{
|
||||
return request_ip;
|
||||
// Examine whether the specified IP address is within the range of assignment
|
||||
if (Endian32(v->DhcpIpStart) > Endian32(request_ip) ||
|
||||
Endian32(request_ip) > Endian32(v->DhcpIpEnd))
|
||||
{
|
||||
// Accept if within the range
|
||||
ret = request_ip;
|
||||
}
|
||||
}
|
||||
else {
|
||||
// Duplicated IPV4 address found. The DHCP server replies to DHCPREQUEST with DHCP NAK.
|
||||
char ipstr[MAX_HOST_NAME_LEN + 1] = { 0 };
|
||||
char macstr[128] = { 0 };
|
||||
IPToStr32(ipstr, sizeof(ipstr), request_ip);
|
||||
BinToStr(macstr, sizeof(macstr), d->MacAddress, 6);
|
||||
Debug("Virtual DHC Server: Duplicated IP address detected. Static IP: %s, Used by MAC:%s\n", ipstr, macstr);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Examine whether the specified IP address is within the range of assignment
|
||||
if (Endian32(v->DhcpIpStart) > Endian32(request_ip) ||
|
||||
Endian32(request_ip) > Endian32(v->DhcpIpEnd))
|
||||
{
|
||||
// Accept if within the range
|
||||
ret = request_ip;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Propose an IP in the range since it's a Discover although It is out of range
|
||||
}
|
||||
}
|
||||
if (ret == 0)
|
||||
{
|
||||
// If there is any entry with the same MAC address
|
||||
// that are already registered, use it with priority
|
||||
DHCP_LEASE *d = SearchDhcpLeaseByMac(v, mac);
|
||||
|
||||
if (d != NULL)
|
||||
{
|
||||
// Examine whether the found IP address is in the allocation region
|
||||
if (Endian32(v->DhcpIpStart) > Endian32(d->IpAddress) ||
|
||||
Endian32(d->IpAddress) > Endian32(v->DhcpIpEnd))
|
||||
{
|
||||
// Use the IP address if it's found within the range
|
||||
ret = d->IpAddress;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (ret == 0)
|
||||
{
|
||||
// For static IP, the requested IP address must NOT be within the range of the DHCP pool
|
||||
if (Endian32(v->DhcpIpStart) > Endian32(request_ip) ||
|
||||
Endian32(request_ip) > Endian32(v->DhcpIpEnd))
|
||||
{
|
||||
ret = request_ip;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
return ret;
|
||||
}
|
||||
|
||||
// Take an appropriate IP addresses that can be assigned newly
|
||||
@ -9709,6 +9764,9 @@ void VirtualDhcpServer(VH *v, PKT *p)
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Reply of DHCP_REQUEST must be either DHCP_ACK or DHCP_NAK.
|
||||
if (opt->Opcode == DHCP_REQUEST)
|
||||
{
|
||||
// There is no IP address that can be provided
|
||||
DHCP_OPTION_LIST ret;
|
||||
@ -9743,6 +9801,7 @@ void VirtualDhcpServer(VH *v, PKT *p)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Release the memory
|
||||
Free(opt);
|
||||
|
Reference in New Issue
Block a user