function_name
stringlengths 1
80
| function
stringlengths 14
10.6k
| comment
stringlengths 12
8.02k
| normalized_comment
stringlengths 6
6.55k
|
|---|---|---|---|
AddCancelList
|
void AddCancelList(LIST *o, CANCEL *c)
{
UINT i;
// Validate arguments
if (o == NULL || c == NULL)
{
return;
}
for (i = 0;i < LIST_NUM(o);i++)
{
CANCEL *t = LIST_DATA(o, i);
if (t == c)
{
return;
}
}
AddRef(c->ref);
Add(o, c);
}
|
/* Add a Cancel to the cancellation list*/
|
Add a Cancel to the cancellation list
|
CancelList
|
void CancelList(LIST *o)
{
UINT i;
// Validate arguments
if (o == NULL)
{
return;
}
for (i = 0;i < LIST_NUM(o);i++)
{
CANCEL *c = LIST_DATA(o, i);
Cancel(c);
ReleaseCancel(c);
}
DeleteAll(o);
}
|
/* Issue all cancellations in the cancellation list*/
|
Issue all cancellations in the cancellation list
|
ReleaseCancelList
|
void ReleaseCancelList(LIST *o)
{
UINT i;
// Validate arguments
if (o == NULL)
{
return;
}
for (i = 0;i < LIST_NUM(o);i++)
{
CANCEL *c = LIST_DATA(o, i);
ReleaseCancel(c);
}
ReleaseList(o);
}
|
/* Release the cancellation list*/
|
Release the cancellation list
|
Notify
|
void Notify(SESSION *s, UINT code)
{
// Validate arguments
if (s == NULL || s->Account == NULL || s->Cedar->Client == NULL)
{
return;
}
CiNotify(s->Cedar->Client);
}
|
/* Notify to the client*/
|
Notify to the client
|
SnFreeSecureNAT
|
void SnFreeSecureNAT(SNAT *s)
{
// Validate arguments
if (s == NULL)
{
return;
}
// Stop the session
StopSession(s->Session);
ReleaseSession(s->Session);
// Virtual machine release
Virtual_Free(s->Nat->Virtual);
// NAT release
NiFreeNat(s->Nat);
DeleteLock(s->lock);
Free(s);
}
|
/* Release the SecureNAT*/
|
Release the SecureNAT
|
SnNewSecureNAT
|
SNAT *SnNewSecureNAT(HUB *h, VH_OPTION *o)
{
SNAT *s;
THREAD *t;
// Validate arguments
if (h == NULL || o == NULL)
{
return NULL;
}
s = ZeroMalloc(sizeof(SNAT));
s->Cedar = h->Cedar;
s->Hub = h;
s->lock = NewLock();
// Create a NAT
s->Nat = NiNewNatEx(s, o);
// Initialize the virtual machine
VirtualInit(s->Nat->Virtual);
// Create a thread
t = NewThread(SnSecureNATThread, s);
WaitThreadInit(t);
ReleaseThread(t);
return s;
}
|
/* Create a new SecureNAT*/
|
Create a new SecureNAT
|
FreeL2TPAVP
|
void FreeL2TPAVP(L2TP_AVP *a)
{
// Validate arguments
if (a == NULL)
{
return;
}
if (a->Data != NULL)
{
Free(a->Data);
}
Free(a);
}
|
/* Release the L2TP AVP value*/
|
Release the L2TP AVP value
|
FreeL2TPPacket
|
void FreeL2TPPacket(L2TP_PACKET *p)
{
UINT i;
// Validate arguments
if (p == NULL)
{
return;
}
if (p->AvpList != NULL)
{
for (i = 0;i < LIST_NUM(p->AvpList);i++)
{
L2TP_AVP *a = LIST_DATA(p->AvpList, i);
FreeL2TPAVP(a);
}
ReleaseList(p->AvpList);
}
if (p->Data != NULL)
{
Free(p->Data);
}
Free(p);
}
|
/* Release the L2TP packet*/
|
Release the L2TP packet
|
L2TPAddInterrupt
|
void L2TPAddInterrupt(L2TP_SERVER *l2tp, UINT64 next_tick)
{
// Validate arguments
if (l2tp == NULL || next_tick == 0)
{
return;
}
AddInterrupt(l2tp->Interrupts, next_tick);
}
|
/* Specify the interrupt occurrence time of the next*/
|
Specify the interrupt occurrence time of the next
|
SendL2TPControlPacketMain
|
void SendL2TPControlPacketMain(L2TP_SERVER *l2tp, L2TP_TUNNEL *t, L2TP_QUEUE *q)
{
UDPPACKET *p;
// Validate arguments
if (l2tp == NULL || t == NULL || q == NULL)
{
return;
}
p = NewUdpPacket(&t->ServerIp, t->ServerPort, &t->ClientIp, t->ClientPort,
Clone(q->Buf->Buf, q->Buf->Size), q->Buf->Size);
// Update the received sequence number
WRITE_USHORT(((UCHAR *)p->Data) + (p->SrcPort == IPSEC_PORT_L2TPV3_VIRTUAL ? 14 : 10), t->LastNr + 1);
L2TPSendUDP(l2tp, p);
}
|
/* L2TP packet transmission main*/
|
L2TP packet transmission main
|
L2TPSendUDP
|
void L2TPSendUDP(L2TP_SERVER *l2tp, UDPPACKET *p)
{
// Validate arguments
if (l2tp == NULL || p == NULL)
{
return;
}
Add(l2tp->SendPacketList, p);
}
|
/* Send a UDP packet*/
|
Send a UDP packet
|
GetAVPValue
|
L2TP_AVP *GetAVPValue(L2TP_PACKET *p, UINT type)
{
return GetAVPValueEx(p, type, 0);
}
|
/* Get the AVP value*/
|
Get the AVP value
|
FreeL2TPQueue
|
void FreeL2TPQueue(L2TP_QUEUE *q)
{
// Validate arguments
if (q == NULL)
{
return;
}
FreeBuf(q->Buf);
FreeL2TPPacket(q->L2TPPacket);
Free(q);
}
|
/* Release the L2TP transmission queue*/
|
Release the L2TP transmission queue
|
CmpL2TPQueueForRecv
|
int CmpL2TPQueueForRecv(void *p1, void *p2)
{
L2TP_QUEUE *q1, *q2;
// Validate arguments
if (p1 == NULL || p2 == NULL)
{
return 0;
}
q1 = *(L2TP_QUEUE **)p1;
q2 = *(L2TP_QUEUE **)p2;
if (q1 == NULL || q2 == NULL)
{
return 0;
}
if (L2TP_SEQ_LT(q1->Ns, q2->Ns))
{
return -1;
}
else if (q1->Ns == q2->Ns)
{
return 0;
}
else
{
return 1;
}
}
|
/* Sort function of L2TP reception queue*/
|
Sort function of L2TP reception queue
|
GetTunnelFromId
|
L2TP_TUNNEL *GetTunnelFromId(L2TP_SERVER *l2tp, IP *client_ip, UINT tunnel_id, bool is_v3)
{
UINT i;
// Validate arguments
if (l2tp == NULL || client_ip == 0 || tunnel_id == 0)
{
return NULL;
}
for (i = 0;i < LIST_NUM(l2tp->TunnelList);i++)
{
L2TP_TUNNEL *t = LIST_DATA(l2tp->TunnelList, i);
if (t->TunnelId2 == tunnel_id && CmpIpAddr(&t->ClientIp, client_ip) == 0)
{
if (EQUAL_BOOL(t->IsV3, is_v3))
{
return t;
}
}
}
return NULL;
}
|
/* Search a tunnel*/
|
Search a tunnel
|
GetTunnelFromIdOfAssignedByClient
|
L2TP_TUNNEL *GetTunnelFromIdOfAssignedByClient(L2TP_SERVER *l2tp, IP *client_ip, UINT tunnel_id)
{
UINT i;
// Validate arguments
if (l2tp == NULL || client_ip == 0 || tunnel_id == 0)
{
return NULL;
}
for (i = 0;i < LIST_NUM(l2tp->TunnelList);i++)
{
L2TP_TUNNEL *t = LIST_DATA(l2tp->TunnelList, i);
if (t->TunnelId1 == tunnel_id && CmpIpAddr(&t->ClientIp, client_ip) == 0)
{
return t;
}
}
return NULL;
}
|
/* Search the tunnel by the tunnel ID that is assigned by the client*/
|
Search the tunnel by the tunnel ID that is assigned by the client
|
GenerateNewTunnelId
|
UINT GenerateNewTunnelId(L2TP_SERVER *l2tp, IP *client_ip)
{
return GenerateNewTunnelIdEx(l2tp, client_ip, false);
}
|
/* Create a new tunnel ID*/
|
Create a new tunnel ID
|
NewAVP
|
L2TP_AVP *NewAVP(USHORT type, bool mandatory, USHORT vendor_id, void *data, UINT data_size)
{
L2TP_AVP *a;
// Validate arguments
if (data_size != 0 && data == NULL)
{
return NULL;
}
a = ZeroMalloc(sizeof(L2TP_AVP));
a->Type = type;
a->Mandatory = mandatory;
a->VendorID = vendor_id;
a->Data = Clone(data, data_size);
a->DataSize = data_size;
return a;
}
|
/* Create a new AVP value*/
|
Create a new AVP value
|
DisconnectL2TPTunnel
|
void DisconnectL2TPTunnel(L2TP_TUNNEL *t)
{
// Validate arguments
if (t == NULL)
{
return;
}
if (/*t->Established && */t->Disconnecting == false && t->WantToDisconnect == false)
{
UINT i;
Debug("Trying to Disconnect Tunnel ID %u/%u\n", t->TunnelId1, t->TunnelId2);
t->WantToDisconnect = true;
// Disconnect all sessions within the tunnel
for (i = 0;i < LIST_NUM(t->SessionList);i++)
{
L2TP_SESSION *s = LIST_DATA(t->SessionList, i);
DisconnectL2TPSession(t, s);
}
}
}
|
/* Disconnect the L2TP tunnel*/
|
Disconnect the L2TP tunnel
|
DisconnectL2TPSession
|
void DisconnectL2TPSession(L2TP_TUNNEL *t, L2TP_SESSION *s)
{
// Validate arguments
if (t == NULL || s == NULL)
{
return;
}
if (s->Established && s->Disconnecting == false && s->WantToDisconnect == false)
{
Debug("Trying to Disconnect Session ID %u/%u on Tunnel %u/%u\n", s->SessionId1, s->SessionId2,
t->TunnelId1, t->TunnelId2);
s->WantToDisconnect = true;
}
}
|
/* Disconnect the L2TP session*/
|
Disconnect the L2TP session
|
GenerateNewSessionId
|
UINT GenerateNewSessionId(L2TP_TUNNEL *t)
{
return GenerateNewSessionIdEx(t, false);
}
|
/* Create a new session ID*/
|
Create a new session ID
|
FreeL2TPSession
|
void FreeL2TPSession(L2TP_SESSION *s)
{
// Validate arguments
if (s == NULL)
{
return;
}
Free(s);
}
|
/* Release the session*/
|
Release the session
|
GetSessionFromId
|
L2TP_SESSION *GetSessionFromId(L2TP_TUNNEL *t, UINT session_id)
{
UINT i;
// Validate arguments
if (t == NULL || session_id == 0)
{
return NULL;
}
for (i = 0;i < LIST_NUM(t->SessionList);i++)
{
L2TP_SESSION *s = LIST_DATA(t->SessionList, i);
if (s->SessionId2 == session_id)
{
return s;
}
}
return NULL;
}
|
/* Search a session from the session ID*/
|
Search a session from the session ID
|
GetSessionFromIdAssignedByClient
|
L2TP_SESSION *GetSessionFromIdAssignedByClient(L2TP_TUNNEL *t, UINT session_id)
{
UINT i;
// Validate arguments
if (t == NULL || session_id == 0)
{
return NULL;
}
for (i = 0;i < LIST_NUM(t->SessionList);i++)
{
L2TP_SESSION *s = LIST_DATA(t->SessionList, i);
if (s->SessionId1 == session_id)
{
return s;
}
}
return NULL;
}
|
/* Search a session from the session ID (Search by ID assigned from the client side)*/
|
Search a session from the session ID (Search by ID assigned from the client side)
|
GetNumL2TPTunnelsByClientIP
|
UINT GetNumL2TPTunnelsByClientIP(L2TP_SERVER *l2tp, IP *client_ip)
{
UINT i, ret;
// Validate arguments
if (l2tp == NULL || client_ip == NULL)
{
return 0;
}
ret = 0;
for (i = 0;i < LIST_NUM(l2tp->TunnelList);i++)
{
L2TP_TUNNEL *t = LIST_DATA(l2tp->TunnelList, i);
if (CmpIpAddr(&t->ClientIp, client_ip) == 0)
{
ret++;
}
}
return ret;
}
|
/* Get the number of L2TP sessions connected from the client IP address*/
|
Get the number of L2TP sessions connected from the client IP address
|
NewL2TPServer
|
L2TP_SERVER *NewL2TPServer(CEDAR *cedar)
{
return NewL2TPServerEx(cedar, NULL, false, 0);
}
|
/* Create a new L2TP server*/
|
Create a new L2TP server
|
SetL2TPServerSockEvent
|
void SetL2TPServerSockEvent(L2TP_SERVER *l2tp, SOCK_EVENT *e)
{
// Validate arguments
if (l2tp == NULL)
{
return;
}
if (e != NULL)
{
AddRef(e->ref);
}
if (l2tp->SockEvent != NULL)
{
ReleaseSockEvent(l2tp->SockEvent);
l2tp->SockEvent = NULL;
}
l2tp->SockEvent = e;
}
|
/* Set a SockEvent to the L2TP server*/
|
Set a SockEvent to the L2TP server
|
SiTooManyUserObjectsInServer
|
bool SiTooManyUserObjectsInServer(SERVER *s, bool oneMore)
{
return false;
}
|
/* Get whether the number of user objects that are registered in the VPN Server is too many*/
|
Get whether the number of user objects that are registered in the VPN Server is too many
|
SiDebugLog
|
void SiDebugLog(SERVER *s, char *msg)
{
// Validate arguments
if (s == NULL || msg == NULL)
{
return;
}
if (s->DebugLog != NULL)
{
WriteTinyLog(s->DebugLog, msg);
}
}
|
/* Write the debug log*/
|
Write the debug log
|
SiDeadLockCheckThread
|
void SiDeadLockCheckThread(THREAD *t, void *param)
{
SERVER *s = (SERVER *)param;
// Validate arguments
if (s == NULL || t == NULL)
{
return;
}
while (true)
{
Wait(s->DeadLockWaitEvent, SERVER_DEADLOCK_CHECK_SPAN);
if (s->HaltDeadLockThread)
{
break;
}
SiCheckDeadLockMain(s, SERVER_DEADLOCK_CHECK_TIMEOUT);
}
}
|
/* Deadlock check thread*/
|
Deadlock check thread
|
SiInitDeadLockCheck
|
void SiInitDeadLockCheck(SERVER *s)
{
// Validate arguments
if (s == NULL)
{
return;
}
if (s->DisableDeadLockCheck)
{
return;
}
s->HaltDeadLockThread = false;
s->DeadLockWaitEvent = NewEvent();
s->DeadLockCheckThread = NewThread(SiDeadLockCheckThread, s);
}
|
/* Initialize the deadlock check*/
|
Initialize the deadlock check
|
SiFreeDeadLockCheck
|
void SiFreeDeadLockCheck(SERVER *s)
{
// Validate arguments
if (s == NULL)
{
return;
}
if (s->DeadLockCheckThread == NULL)
{
return;
}
s->HaltDeadLockThread = true;
Set(s->DeadLockWaitEvent);
WaitThread(s->DeadLockCheckThread, INFINITE);
ReleaseThread(s->DeadLockCheckThread);
s->DeadLockCheckThread = NULL;
ReleaseEvent(s->DeadLockWaitEvent);
s->DeadLockWaitEvent = NULL;
s->HaltDeadLockThread = false;
}
|
/* Release the deadlock check*/
|
Release the deadlock check
|
SiIsHubRegistedOnCreateHistory
|
bool SiIsHubRegistedOnCreateHistory(SERVER *s, char *name)
{
UINT i;
bool ret = false;
// Validate arguments
if (s == NULL || name == NULL)
{
return false;
}
SiDeleteOldHubCreateHistory(s);
LockList(s->HubCreateHistoryList);
{
for (i = 0;i < LIST_NUM(s->HubCreateHistoryList);i++)
{
SERVER_HUB_CREATE_HISTORY *h = LIST_DATA(s->HubCreateHistoryList, i);
if (StrCmpi(h->HubName, name) == 0)
{
ret = true;
break;
}
}
}
UnlockList(s->HubCreateHistoryList);
return ret;
}
|
/* Check whether the specified virtual HUB has been registered to creation history*/
|
Check whether the specified virtual HUB has been registered to creation history
|
SiDelHubCreateHistory
|
void SiDelHubCreateHistory(SERVER *s, char *name)
{
UINT i;
// Validate arguments
if (s == NULL || name == NULL)
{
return;
}
LockList(s->HubCreateHistoryList);
{
SERVER_HUB_CREATE_HISTORY *hh = NULL;
for (i = 0;i < LIST_NUM(s->HubCreateHistoryList);i++)
{
SERVER_HUB_CREATE_HISTORY *h = LIST_DATA(s->HubCreateHistoryList, i);
if (StrCmpi(h->HubName, name) == 0)
{
Delete(s->HubCreateHistoryList, h);
Free(h);
break;
}
}
}
UnlockList(s->HubCreateHistoryList);
SiDeleteOldHubCreateHistory(s);
}
|
/* Delete the Virtual HUB creation history*/
|
Delete the Virtual HUB creation history
|
SiInitHubCreateHistory
|
void SiInitHubCreateHistory(SERVER *s)
{
// Validate arguments
if (s == NULL)
{
return;
}
s->HubCreateHistoryList = NewList(NULL);
}
|
/* Initialize the Virtual HUB creation history*/
|
Initialize the Virtual HUB creation history
|
SiFreeHubCreateHistory
|
void SiFreeHubCreateHistory(SERVER *s)
{
UINT i;
// Validate arguments
if (s == NULL)
{
return;
}
for (i = 0;i < LIST_NUM(s->HubCreateHistoryList);i++)
{
SERVER_HUB_CREATE_HISTORY *h = LIST_DATA(s->HubCreateHistoryList, i);
Free(h);
}
ReleaseList(s->HubCreateHistoryList);
s->HubCreateHistoryList = NULL;
}
|
/* Release the Virtual HUB creation history*/
|
Release the Virtual HUB creation history
|
IsAdminPackSupportedServerProduct
|
bool IsAdminPackSupportedServerProduct(char *name)
{
return true;
}
|
/* created by the installer creating kit of Admin Pack*/
|
created by the installer creating kit of Admin Pack
|
SiGetSysLogSaveStatus
|
UINT SiGetSysLogSaveStatus(SERVER *s)
{
SYSLOG_SETTING set;
// Validate arguments
if (s == NULL)
{
return SYSLOG_NONE;
}
SiGetSysLogSetting(s, &set);
return set.SaveType;
}
|
/* Get the saving status of syslog*/
|
Get the saving status of syslog
|
SiSetSysLogSetting
|
void SiSetSysLogSetting(SERVER *s, SYSLOG_SETTING *setting)
{
SYSLOG_SETTING set;
// Validate arguments
if (s == NULL || setting == NULL)
{
return;
}
Zero(&set, sizeof(set));
Copy(&set, setting, sizeof(SYSLOG_SETTING));
if (IsEmptyStr(set.Hostname) || set.Port == 0)
{
set.SaveType = SYSLOG_NONE;
}
Lock(s->SyslogLock);
{
Copy(&s->SyslogSetting, &set, sizeof(SYSLOG_SETTING));
SetSysLog(s->Syslog, set.Hostname, set.Port);
}
Unlock(s->SyslogLock);
}
|
/* Write the syslog configuration*/
|
Write the syslog configuration
|
SiGetSysLogSetting
|
void SiGetSysLogSetting(SERVER *s, SYSLOG_SETTING *setting)
{
// Validate arguments
if (s == NULL || setting == NULL)
{
return;
}
//Lock(s->SyslogLock);
{
Copy(setting, &s->SyslogSetting, sizeof(SYSLOG_SETTING));
}
//Unlock(s->SyslogLock);
}
|
/* Read the syslog configuration*/
|
Read the syslog configuration
|
GetServerProductName
|
void GetServerProductName(SERVER *s, char *name, UINT size)
{
char *cpu;
// Validate arguments
if (s == NULL || name == NULL)
{
return;
}
GetServerProductNameInternal(s, name, size);
#ifdef CPU_64
cpu = " (64 bit)";
#else // CPU_64
cpu = " (32 bit)";
#endif // CPU_64
StrCat(name, size, cpu);
StrCat(name, size, " (Open Source)");
}
|
/* Get the server product name*/
|
Get the server product name
|
CheckLogFileNameFromEnumList
|
bool CheckLogFileNameFromEnumList(LIST *o, char *name, char *server_name)
{
LOG_FILE t;
// Validate arguments
if (o == NULL || name == NULL || server_name == NULL)
{
return false;
}
Zero(&t, sizeof(t));
StrCpy(t.Path, sizeof(t.Path), name);
StrCpy(t.ServerName, sizeof(t.ServerName), server_name);
if (Search(o, &t) == NULL)
{
return false;
}
return true;
}
|
/* Check whether the log file with the specified name is contained in the enumerated list*/
|
Check whether the log file with the specified name is contained in the enumerated list
|
FreeEnumLogFile
|
void FreeEnumLogFile(LIST *o)
{
UINT i;
// Validate arguments
if (o == NULL)
{
return;
}
for (i = 0;i < LIST_NUM(o);i++)
{
LOG_FILE *f = LIST_DATA(o, i);
Free(f);
}
ReleaseList(o);
}
|
/* Release the log file enumeration*/
|
Release the log file enumeration
|
CmpLogFile
|
int CmpLogFile(void *p1, void *p2)
{
LOG_FILE *f1, *f2;
UINT i;
if (p1 == NULL || p2 == NULL)
{
return 0;
}
f1 = *(LOG_FILE **)p1;
f2 = *(LOG_FILE **)p2;
if (f1 == NULL || f2 == NULL)
{
return 0;
}
i = StrCmpi(f1->Path, f2->Path);
if (i != 0)
{
return i;
}
return StrCmpi(f1->ServerName, f2->ServerName);
}
|
/* Log file list entry comparison*/
|
Log file list entry comparison
|
GetServerCapsInt
|
UINT GetServerCapsInt(SERVER *s, char *name)
{
CAPSLIST t;
UINT ret;
// Validate arguments
if (s == NULL || name == NULL)
{
return 0;
}
Zero(&t, sizeof(t));
GetServerCaps(s, &t);
ret = GetCapsInt(&t, name);
return ret;
}
|
/* Get the Caps of the server*/
|
Get the Caps of the server
|
InitServerCapsCache
|
void InitServerCapsCache(SERVER *s)
{
// Validate arguments
if (s == NULL)
{
return;
}
s->CapsCacheLock = NewLock();
s->CapsListCache = NULL;
}
|
/* Initialize the Caps cache of the server*/
|
Initialize the Caps cache of the server
|
FreeServerCapsCache
|
void FreeServerCapsCache(SERVER *s)
{
// Validate arguments
if (s == NULL)
{
return;
}
if (s->CapsListCache != NULL)
{
FreeCapsList(s->CapsListCache);
s->CapsListCache = NULL;
}
DeleteLock(s->CapsCacheLock);
}
|
/* Release the Caps cache of the server*/
|
Release the Caps cache of the server
|
DestroyServerCapsCache
|
void DestroyServerCapsCache(SERVER *s)
{
// Validate arguments
if (s == NULL)
{
return;
}
Lock(s->CapsCacheLock);
{
if (s->CapsListCache != NULL)
{
FreeCapsList(s->CapsListCache);
s->CapsListCache = NULL;
}
}
Unlock(s->CapsCacheLock);
}
|
/* Dispose the Caps cache of the server*/
|
Dispose the Caps cache of the server
|
FlushServerCaps
|
void FlushServerCaps(SERVER *s)
{
CAPSLIST t;
// Validate arguments
if (s == NULL)
{
return;
}
DestroyServerCapsCache(s);
Zero(&t, sizeof(t));
GetServerCaps(s, &t);
}
|
/* Flush the Caps list for this server*/
|
Flush the Caps list for this server
|
GetServerCaps
|
void GetServerCaps(SERVER *s, CAPSLIST *t)
{
// Validate arguments
if (s == NULL || t == NULL)
{
return;
}
Lock(s->CapsCacheLock);
{
if (s->CapsListCache == NULL)
{
s->CapsListCache = ZeroMalloc(sizeof(CAPSLIST));
GetServerCapsMain(s, s->CapsListCache);
}
Copy(t, s->CapsListCache, sizeof(CAPSLIST));
}
Unlock(s->CapsCacheLock);
}
|
/* Get the Caps list for this server*/
|
Get the Caps list for this server
|
UpdateGlobalServerFlags
|
void UpdateGlobalServerFlags(SERVER *s, CAPSLIST *t)
{
bool is_restricted = false;
// Validate arguments
if (s == NULL || t == NULL)
{
return;
}
is_restricted = SiIsEnterpriseFunctionsRestrictedOnOpenSource(s->Cedar);
SetGlobalServerFlag(GSF_DISABLE_PUSH_ROUTE, is_restricted);
SetGlobalServerFlag(GSF_DISABLE_RADIUS_AUTH, is_restricted);
SetGlobalServerFlag(GSF_DISABLE_CERT_AUTH, is_restricted);
SetGlobalServerFlag(GSF_DISABLE_DEEP_LOGGING, is_restricted);
SetGlobalServerFlag(GSF_DISABLE_AC, is_restricted);
SetGlobalServerFlag(GSF_DISABLE_SYSLOG, is_restricted);
}
|
/* Update the global server flags*/
|
Update the global server flags
|
SetGlobalServerFlag
|
void SetGlobalServerFlag(UINT index, UINT value)
{
// Validate arguments
if (index >= NUM_GLOBAL_SERVER_FLAGS)
{
return;
}
global_server_flags[index] = value;
}
|
/* Set a global server flag*/
|
Set a global server flag
|
GetGlobalServerFlag
|
UINT GetGlobalServerFlag(UINT index)
{
// Validate arguments
if (index >= NUM_GLOBAL_SERVER_FLAGS)
{
return 0;
}
return global_server_flags[index];
}
|
/* Get a global server flag*/
|
Get a global server flag
|
AddCapsBool
|
void AddCapsBool(CAPSLIST *caps, char *name, bool b)
{
CAPS *c;
// Validate arguments
if (caps == NULL || name == NULL)
{
return;
}
c = NewCaps(name, b == false ? 0 : 1);
AddCaps(caps, c);
}
|
/* Add a bool type to Caps list*/
|
Add a bool type to Caps list
|
AddCapsInt
|
void AddCapsInt(CAPSLIST *caps, char *name, UINT i)
{
CAPS *c;
// Validate arguments
if (caps == NULL || name == NULL)
{
return;
}
c = NewCaps(name, i);
AddCaps(caps, c);
}
|
/* Add the int type to Caps list*/
|
Add the int type to Caps list
|
GetCapsInt
|
UINT GetCapsInt(CAPSLIST *caps, char *name)
{
CAPS *c;
// Validate arguments
if (caps == NULL || name == NULL)
{
return 0;
}
c = GetCaps(caps, name);
if (c == NULL)
{
return 0;
}
return c->Value;
}
|
/* Get the int type from the Caps list*/
|
Get the int type from the Caps list
|
GetCapsBool
|
bool GetCapsBool(CAPSLIST *caps, char *name)
{
CAPS *c;
// Validate arguments
if (caps == NULL || name == NULL)
{
return false;
}
c = GetCaps(caps, name);
if (c == NULL)
{
return false;
}
return c->Value == 0 ? false : true;
}
|
/* Get bool type from the Caps list*/
|
Get bool type from the Caps list
|
FreeCapsList
|
void FreeCapsList(CAPSLIST *caps)
{
UINT i;
// Validate arguments
if (caps == NULL)
{
return;
}
for (i = 0;i < LIST_NUM(caps->CapsList);i++)
{
CAPS *c = LIST_DATA(caps->CapsList, i);
FreeCaps(c);
}
ReleaseList(caps->CapsList);
Free(caps);
}
|
/* Release the Caps list*/
|
Release the Caps list
|
GetCaps
|
CAPS *GetCaps(CAPSLIST *caps, char *name)
{
UINT i;
// Validate arguments
if (caps == NULL || name == NULL)
{
return NULL;
}
for (i = 0;i < LIST_NUM(caps->CapsList);i++)
{
CAPS *c = LIST_DATA(caps->CapsList, i);
if (StrCmpi(c->Name, name) == 0)
{
return c;
}
}
return NULL;
}
|
/* Get the Caps*/
|
Get the Caps
|
AddCaps
|
void AddCaps(CAPSLIST *caps, CAPS *c)
{
// Validate arguments
if (caps == NULL || c == NULL)
{
return;
}
Insert(caps->CapsList, c);
}
|
/* Add to the Caps*/
|
Add to the Caps
|
CompareCaps
|
int CompareCaps(void *p1, void *p2)
{
CAPS *c1, *c2;
if (p1 == NULL || p2 == NULL)
{
return 0;
}
c1 = *(CAPS **)p1;
c2 = *(CAPS **)p2;
if (c1 == NULL || c2 == NULL)
{
return 0;
}
return StrCmpi(c1->Name, c2->Name);
}
|
/* Comparison of Caps*/
|
Comparison of Caps
|
NewCapsList
|
CAPSLIST *NewCapsList()
{
CAPSLIST *caps = ZeroMalloc(sizeof(CAPSLIST));
caps->CapsList = NewListFast(CompareCaps);
return caps;
}
|
/* Create a Caps list*/
|
Create a Caps list
|
FreeCaps
|
void FreeCaps(CAPS *c)
{
// Validate arguments
if (c == NULL)
{
return;
}
Free(c->Name);
Free(c);
}
|
/* Release the Caps*/
|
Release the Caps
|
NewCaps
|
CAPS *NewCaps(char *name, UINT value)
{
CAPS *c;
// Validate arguments
if (name == NULL)
{
return NULL;
}
c = ZeroMalloc(sizeof(CAPS));
c->Name = CopyStr(name);
c->Value = value;
return c;
}
|
/* Create a Caps*/
|
Create a Caps
|
SiCalcPoint
|
UINT SiCalcPoint(SERVER *s, UINT num, UINT weight)
{
UINT server_max_sessions = SERVER_MAX_SESSIONS;
if (s == NULL)
{
return 0;
}
if (weight == 0)
{
weight = 100;
}
server_max_sessions = GetServerCapsInt(s, "i_max_sessions");
if (server_max_sessions == 0)
{
// Avoid divide by zero
server_max_sessions = 1;
}
return (UINT)(((double)server_max_sessions -
MIN((double)num * 100.0 / (double)weight, (double)server_max_sessions))
* (double)FARM_BASE_POINT / (double)server_max_sessions);
}
|
/* Calculate the score from the current number of connections and weight*/
|
Calculate the score from the current number of connections and weight
|
SiGetPoint
|
UINT SiGetPoint(SERVER *s)
{
UINT num_session;
// Validate arguments
if (s == NULL)
{
return 0;
}
num_session = Count(s->Cedar->CurrentSessions);
return SiCalcPoint(s, num_session, s->Weight);
}
|
/* Get the server score*/
|
Get the server score
|
SiGenerateDefaultCert
|
void SiGenerateDefaultCert(X **server_x, K **server_k)
{
SiGenerateDefaultCertEx(server_x, server_k, NULL);
}
|
/* Generate the default certificate*/
|
Generate the default certificate
|
SiInitDefaultServerCert
|
void SiInitDefaultServerCert(SERVER *s)
{
X *x = NULL;
K *k = NULL;
// Validate arguments
if (s == NULL)
{
return;
}
// Generate a server certificate and private key
SiGenerateDefaultCert(&x, &k);
// Configure
SetCedarCert(s->Cedar, x, k);
FreeX(x);
FreeK(k);
}
|
/* Set the server certificate to default*/
|
Set the server certificate to default
|
SiInitCipherName
|
void SiInitCipherName(SERVER *s)
{
// Validate arguments
if (s == NULL)
{
return;
}
SetCedarCipherList(s->Cedar, SERVER_DEFAULT_CIPHER_NAME);
}
|
/* Set the encryption algorithm name to default*/
|
Set the encryption algorithm name to default
|
SiInitListenerList
|
void SiInitListenerList(SERVER *s)
{
// Validate arguments
if (s == NULL)
{
return;
}
SiLockListenerList(s);
{
{
// Register the 4 ports (443, 992, 1194, 8888) as the default port
SiAddListener(s, SERVER_DEF_PORTS_1, true);
SiAddListener(s, SERVER_DEF_PORTS_2, true);
SiAddListener(s, SERVER_DEF_PORTS_3, true);
SiAddListener(s, SERVER_DEF_PORTS_4, true);
}
}
SiUnlockListenerList(s);
}
|
/* Initialize the listener list*/
|
Initialize the listener list
|
SiDeleteListener
|
bool SiDeleteListener(SERVER *s, UINT port)
{
SERVER_LISTENER *e;
// Validate arguments
if (s == NULL || port == 0)
{
return false;
}
e = SiGetListener(s, port);
if (e == NULL)
{
return false;
}
// Stop if still alive
SiDisableListener(s, port);
if (e->Listener != NULL)
{
ReleaseListener(e->Listener);
}
Delete(s->ServerListenerList, e);
Free(e);
return true;
}
|
/* Remove the listener*/
|
Remove the listener
|
CompareServerListener
|
int CompareServerListener(void *p1, void *p2)
{
SERVER_LISTENER *s1, *s2;
if (p1 == NULL || p2 == NULL)
{
return 0;
}
s1 = *(SERVER_LISTENER **)p1;
s2 = *(SERVER_LISTENER **)p2;
if (s1 == NULL || s2 == NULL)
{
return 0;
}
if (s1->Port > s2->Port)
{
return 1;
}
else if (s1->Port < s2->Port)
{
return -1;
}
else
{
return 0;
}
}
|
/* Compare the SERVER_LISTENER*/
|
Compare the SERVER_LISTENER
|
SiDisableListener
|
bool SiDisableListener(SERVER *s, UINT port)
{
SERVER_LISTENER *e;
// Validate arguments
if (s == NULL || port == 0)
{
return false;
}
// Get the listener
e = SiGetListener(s, port);
if (e == NULL)
{
return false;
}
if (e->Enabled == false || e->Listener == NULL)
{
// Already stopped
return true;
}
// Stop the listener
StopListener(e->Listener);
// Release the listener
ReleaseListener(e->Listener);
e->Listener = NULL;
e->Enabled = false;
return true;
}
|
/* Stop the listener*/
|
Stop the listener
|
SiEnableListener
|
bool SiEnableListener(SERVER *s, UINT port)
{
SERVER_LISTENER *e;
// Validate arguments
if (s == NULL || port == 0)
{
return false;
}
// Get the listener
e = SiGetListener(s, port);
if (e == NULL)
{
return false;
}
if (e->Enabled)
{
// It has already started
return true;
}
// Create a listener
e->Listener = NewListener(s->Cedar, LISTENER_TCP, e->Port);
if (e->Listener == NULL)
{
// Failure
return false;
}
e->Listener->DisableDos = e->DisableDos;
e->Enabled = true;
return true;
}
|
/* Start the listener*/
|
Start the listener
|
SiGetListener
|
SERVER_LISTENER *SiGetListener(SERVER *s, UINT port)
{
UINT i;
// Validate arguments
if (s == NULL || port == 0)
{
return NULL;
}
for (i = 0;i < LIST_NUM(s->ServerListenerList);i++)
{
SERVER_LISTENER *e = LIST_DATA(s->ServerListenerList, i);
if (e->Port == port)
{
return e;
}
}
return NULL;
}
|
/* Get the listener*/
|
Get the listener
|
SiAddListener
|
bool SiAddListener(SERVER *s, UINT port, bool enabled)
{
return SiAddListenerEx(s, port, enabled, false);
}
|
/* Add a listener*/
|
Add a listener
|
SiLockListenerList
|
void SiLockListenerList(SERVER *s)
{
// Validate arguments
if (s == NULL)
{
return;
}
LockList(s->ServerListenerList);
}
|
/* Lock the listener list*/
|
Lock the listener list
|
SiUnlockListenerList
|
void SiUnlockListenerList(SERVER *s)
{
// Validate arguments
if (s == NULL)
{
return;
}
UnlockList(s->ServerListenerList);
}
|
/* Unlock the listener list*/
|
Unlock the listener list
|
SiSetDefaultHubOption
|
void SiSetDefaultHubOption(HUB_OPTION *o)
{
// Validate arguments
if (o == NULL)
{
return;
}
o->MaxSession = 0;
o->VlanTypeId = MAC_PROTO_TAGVLAN;
o->NoIPv6DefaultRouterInRAWhenIPv6 = true;
o->ManageOnlyPrivateIP = true;
o->ManageOnlyLocalUnicastIPv6 = true;
o->NoMacAddressLog = true;
o->NoDhcpPacketLogOutsideHub = true;
o->AccessListIncludeFileCacheLifetime = ACCESS_LIST_INCLUDE_FILE_CACHE_LIFETIME;
o->RemoveDefGwOnDhcpForLocalhost = true;
o->FloodingSendQueueBufferQuota = DEFAULT_FLOODING_QUEUE_LENGTH;
}
|
/* Set the default value of the Virtual HUB options*/
|
Set the default value of the Virtual HUB options
|
SiSetDefaultLogSetting
|
void SiSetDefaultLogSetting(HUB_LOG *g)
{
// Validate arguments
if (g == NULL)
{
return;
}
Zero(g, sizeof(HUB_LOG));
g->SaveSecurityLog = true;
g->SecurityLogSwitchType = LOG_SWITCH_DAY;
g->SavePacketLog = true;
g->PacketLogSwitchType = LOG_SWITCH_DAY;
g->PacketLogConfig[PACKET_LOG_TCP_CONN] =
g->PacketLogConfig[PACKET_LOG_DHCP] = PACKET_LOG_HEADER;
}
|
/* Set the log settings to default*/
|
Set the log settings to default
|
SiCanOpenVpnOverIcmpPort
|
bool SiCanOpenVpnOverIcmpPort()
{
// Whether the ICMP can be opened
SOCK *s = NewUDP(MAKE_SPECIAL_PORT(IP_PROTO_ICMPV4));
if (s == NULL)
{
// Failure
return false;
}
Disconnect(s);
ReleaseSock(s);
return true;
}
|
/* Check whether the ports required for VPN-over-ICMP can be opened*/
|
Check whether the ports required for VPN-over-ICMP can be opened
|
SiCanOpenVpnOverDnsPort
|
bool SiCanOpenVpnOverDnsPort()
{
// Whether UDP Port 53 can be listen on
SOCK *s = NewUDP(53);
if (s == NULL)
{
// Listening failure
return false;
}
Disconnect(s);
ReleaseSock(s);
return true;
}
|
/* Check whether the ports required for VPN-over-DNS can be opened*/
|
Check whether the ports required for VPN-over-DNS can be opened
|
SiLoadConfigurationFileMain
|
bool SiLoadConfigurationFileMain(SERVER *s, FOLDER *root)
{
// Validate arguments
if (s == NULL || root == NULL)
{
return false;
}
return SiLoadConfigurationCfg(s, root);
}
|
/* Read the configuration file (main)*/
|
Read the configuration file (main)
|
SiLoadConfigurationFile
|
bool SiLoadConfigurationFile(SERVER *s)
{
// Validate arguments
bool ret = false;
FOLDER *root;
char *server_config_filename = SERVER_CONFIG_FILE_NAME;
if (s == NULL)
{
return false;
}
s->CfgRw = NewCfgRwEx2A(&root,
s->Cedar->Bridge == false ? server_config_filename : BRIDGE_CONFIG_FILE_NAME, false,
s->Cedar->Bridge == false ? SERVER_CONFIG_TEMPLATE_NAME : BRIDGE_CONFIG_TEMPLATE_NAME);
if (server_reset_setting)
{
CfgDeleteFolder(root);
root = NULL;
server_reset_setting = false;
}
if (root == NULL)
{
return false;
}
ret = SiLoadConfigurationFileMain(s, root);
CfgDeleteFolder(root);
return ret;
}
|
/* Read the configuration file*/
|
Read the configuration file
|
SiSetAzureEnable
|
void SiSetAzureEnable(SERVER *s, bool enabled)
{
// Validate arguments
if (s == NULL)
{
return;
}
if (s->AzureClient != NULL)
{
AcSetEnable(s->AzureClient, enabled);
}
s->EnableVpnAzure = enabled;
}
|
/* Set the state of Enabled / Disabled of Azure Client*/
|
Set the state of Enabled / Disabled of Azure Client
|
SiApplyAzureConfig
|
void SiApplyAzureConfig(SERVER *s, DDNS_CLIENT_STATUS *ddns_status)
{
// Validate arguments
if (s == NULL)
{
return;
}
AcApplyCurrentConfig(s->AzureClient, ddns_status);
}
|
/* Apply the Config to the Azure Client*/
|
Apply the Config to the Azure Client
|
SiIsAzureEnabled
|
bool SiIsAzureEnabled(SERVER *s)
{
// Validate arguments
if (s == NULL)
{
return false;
}
if (s->AzureClient == NULL)
{
return false;
}
return s->EnableVpnAzure;
}
|
/* Get whether the Azure Client is enabled*/
|
Get whether the Azure Client is enabled
|
SiIsAzureSupported
|
bool SiIsAzureSupported(SERVER *s)
{
// Validate arguments
if (s == NULL)
{
return false;
}
if (s->AzureClient == NULL)
{
return false;
}
return true;
}
|
/* Get whether the Azure Client is supported*/
|
Get whether the Azure Client is supported
|
SiWriteListenerCfg
|
void SiWriteListenerCfg(FOLDER *f, SERVER_LISTENER *r)
{
// Validate arguments
if (f == NULL || r == NULL)
{
return;
}
CfgAddBool(f, "Enabled", r->Enabled);
CfgAddInt(f, "Port", r->Port);
CfgAddBool(f, "DisableDos", r->DisableDos);
}
|
/* Write the listener configuration*/
|
Write the listener configuration
|
SiLoadListenerCfg
|
void SiLoadListenerCfg(SERVER *s, FOLDER *f)
{
bool enable;
UINT port;
bool disable_dos;
// Validate arguments
if (s == NULL || f == NULL)
{
return;
}
enable = CfgGetBool(f, "Enabled");
port = CfgGetInt(f, "Port");
disable_dos = CfgGetBool(f, "DisableDos");
if (port == 0)
{
return;
}
SiAddListenerEx(s, port, enable, disable_dos);
}
|
/* Read the listener configuration*/
|
Read the listener configuration
|
SiLoadListeners
|
void SiLoadListeners(SERVER *s, FOLDER *f)
{
TOKEN_LIST *t;
UINT i;
// Validate arguments
if (s == NULL || f == NULL)
{
return;
}
t = CfgEnumFolderToTokenList(f);
for (i = 0;i < t->NumTokens;i++)
{
FOLDER *ff = CfgGetFolder(f, t->Token[i]);
if (ff != NULL)
{
SiLoadListenerCfg(s, ff);
}
}
FreeToken(t);
}
|
/* Read the listener list*/
|
Read the listener list
|
SiWriteListeners
|
void SiWriteListeners(FOLDER *f, SERVER *s)
{
// Validate arguments
if (f == NULL || s == NULL)
{
return;
}
LockList(s->ServerListenerList);
{
UINT i;
for (i = 0;i < LIST_NUM(s->ServerListenerList);i++)
{
SERVER_LISTENER *r = LIST_DATA(s->ServerListenerList, i);
char name[MAX_SIZE];
Format(name, sizeof(name), "Listener%u", i);
SiWriteListenerCfg(CfgCreateFolder(f, name), r);
}
}
UnlockList(s->ServerListenerList);
}
|
/* Write the listener list*/
|
Write the listener list
|
SiLoadLocalBridges
|
void SiLoadLocalBridges(SERVER *s, FOLDER *f)
{
TOKEN_LIST *t;
UINT i;
// Validate arguments
if (s == NULL || f == NULL)
{
return;
}
#ifdef OS_WIN32
Win32EthSetShowAllIf(CfgGetBool(f, "ShowAllInterfaces"));
#endif // OS_WIN32
#ifdef UNIX_LINUX
SetGlobalServerFlag(GSF_LOCALBRIDGE_NO_DISABLE_OFFLOAD, CfgGetBool(f, "DoNotDisableOffloading"));
#endif // UNIX_LINUX
t = CfgEnumFolderToTokenList(f);
for (i = 0;i < t->NumTokens;i++)
{
char *name = t->Token[i];
SiLoadLocalBridgeCfg(s, CfgGetFolder(f, name));
}
FreeToken(t);
}
|
/* Read the bridge list*/
|
Read the bridge list
|
IncrementServerConfigRevision
|
void IncrementServerConfigRevision(SERVER *s)
{
// Validate arguments
if (s == NULL)
{
return;
}
s->ConfigRevision++;
}
|
/* Increment the configuration revision of the server*/
|
Increment the configuration revision of the server
|
SiWriteSecureNAT
|
void SiWriteSecureNAT(HUB *h, FOLDER *f)
{
// Validate arguments
if (h == NULL || f == NULL)
{
return;
}
CfgAddBool(f, "Disabled", h->EnableSecureNAT ? false : true);
NiWriteVhOptionEx(h->SecureNATOption, f);
}
|
/* Write the SecureNAT of the Virtual HUB*/
|
Write the SecureNAT of the Virtual HUB
|
SiWriteHubAdminOptions
|
void SiWriteHubAdminOptions(FOLDER *f, HUB *h)
{
// Validate arguments
if (f == NULL || h == NULL)
{
return;
}
LockList(h->AdminOptionList);
{
UINT i;
for (i = 0;i < LIST_NUM(h->AdminOptionList);i++)
{
ADMIN_OPTION *a = LIST_DATA(h->AdminOptionList, i);
CfgAddInt(f, a->Name, a->Value);
}
}
UnlockList(h->AdminOptionList);
}
|
/* Write the administration options for the virtual HUB*/
|
Write the administration options for the virtual HUB
|
SiWriteHubLinks
|
void SiWriteHubLinks(FOLDER *f, HUB *h)
{
// Validate arguments
if (f == NULL || h == NULL)
{
return;
}
LockList(h->LinkList);
{
UINT i;
for (i = 0;i < LIST_NUM(h->LinkList);i++)
{
LINK *k = LIST_DATA(h->LinkList, i);
char name[MAX_SIZE];
Format(name, sizeof(name), "Cascade%u", i);
SiWriteHubLinkCfg(CfgCreateFolder(f, name), k);
}
}
UnlockList(h->LinkList);
}
|
/* Write the link list of the Virtual HUB*/
|
Write the link list of the Virtual HUB
|
SiLoadHubLinks
|
void SiLoadHubLinks(HUB *h, FOLDER *f)
{
TOKEN_LIST *t;
UINT i;
// Validate arguments
if (h == NULL || f == NULL)
{
return;
}
t = CfgEnumFolderToTokenList(f);
for (i = 0;i < t->NumTokens;i++)
{
char *name = t->Token[i];
SiLoadHubLinkCfg(CfgGetFolder(f, name), h);
}
FreeToken(t);
}
|
/* Read the link list*/
|
Read the link list
|
SiWriteHubAccessLists
|
void SiWriteHubAccessLists(FOLDER *f, HUB *h)
{
// Validate arguments
if (f == NULL || h == NULL)
{
return;
}
LockList(h->AccessList);
{
UINT i;
for (i = 0;i < LIST_NUM(h->AccessList);i++)
{
ACCESS *a = LIST_DATA(h->AccessList, i);
char name[MAX_SIZE];
ToStr(name, a->Id);
SiWriteHubAccessCfg(CfgCreateFolder(f, name), a);
}
}
UnlockList(h->AccessList);
}
|
/* Write the access list*/
|
Write the access list
|
SiLoadHubAccessLists
|
void SiLoadHubAccessLists(HUB *h, FOLDER *f)
{
TOKEN_LIST *t;
UINT i;
// Validate arguments
if (f == NULL || h == NULL)
{
return;
}
t = CfgEnumFolderToTokenList(f);
for (i = 0;i < t->NumTokens;i++)
{
char *name = t->Token[i];
SiLoadHubAccessCfg(h, CfgGetFolder(f, name));
}
FreeToken(t);
}
|
/* Read the access list*/
|
Read the access list
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.