function_name
stringlengths 1
80
| function
stringlengths 14
10.6k
| comment
stringlengths 12
8.02k
| normalized_comment
stringlengths 6
6.55k
|
|---|---|---|---|
FreeBlock
|
void FreeBlock(BLOCK *b)
{
// Validate arguments
if (b == NULL)
{
return;
}
Free(b->Buf);
Free(b);
}
|
/* Release of the block*/
|
Release of the block
|
NewTcpSock
|
TCPSOCK *NewTcpSock(SOCK *s)
{
TCPSOCK *ts;
// Validate arguments
if (s == NULL)
{
return NULL;
}
ts = ZeroMalloc(sizeof(TCPSOCK));
ts->Sock = s;
AddRef(s->ref);
ts->RecvFifo = NewFifo();
ts->SendFifo = NewFifo();
ts->EstablishedTick = ts->LastRecvTime = ts->LastCommTime = Tick64();
// Unset the time-out value
SetTimeout(s, TIMEOUT_INFINITE);
return ts;
}
|
/* Create a TCP socket*/
|
Create a TCP socket
|
FreeTcpSock
|
void FreeTcpSock(TCPSOCK *ts)
{
// Validate arguments
if (ts == NULL)
{
return;
}
Disconnect(ts->Sock);
ReleaseSock(ts->Sock);
ReleaseFifo(ts->RecvFifo);
ReleaseFifo(ts->SendFifo);
if (ts->SendKey)
{
FreeCrypt(ts->SendKey);
}
if (ts->RecvKey)
{
FreeCrypt(ts->RecvKey);
}
Free(ts);
}
|
/* Release of TCP socket*/
|
Release of TCP socket
|
EndTunnelingMode
|
void EndTunnelingMode(CONNECTION *c)
{
// Validate arguments
if (c == NULL)
{
return;
}
// Protocol
if (c->Protocol == CONNECTION_TCP)
{
// TCP
DisconnectTcpSockets(c);
}
else
{
// UDP
DisconnectUDPSockets(c);
}
}
|
/* Exit the tunneling mode of connection*/
|
Exit the tunneling mode of connection
|
GetMachineRand
|
UINT GetMachineRand()
{
char pcname[MAX_SIZE];
UCHAR hash[SHA1_SIZE];
Zero(pcname, sizeof(pcname));
GetMachineName(pcname, sizeof(pcname));
Sha1(hash, pcname, StrLen(pcname));
return READ_UINT(hash);
}
|
/* Generate a random value that depends on each machine*/
|
Generate a random value that depends on each machine
|
StopConnection
|
void StopConnection(CONNECTION *c, bool no_wait)
{
// Validate arguments
if (c == NULL)
{
return;
}
Debug("Stop Connection: %s\n", c->Name);
// Stop flag
c->Halt = true;
Disconnect(c->FirstSock);
if (no_wait == false)
{
// Wait until the thread terminates
WaitThread(c->Thread, INFINITE);
}
}
|
/* Stop the connection*/
|
Stop the connection
|
ReleaseConnection
|
void ReleaseConnection(CONNECTION *c)
{
// Validate arguments
if (c == NULL)
{
return;
}
if (Release(c->ref) == 0)
{
CleanupConnection(c);
}
}
|
/* Release of the connection*/
|
Release of the connection
|
CompareConnection
|
int CompareConnection(void *p1, void *p2)
{
CONNECTION *c1, *c2;
if (p1 == NULL || p2 == NULL)
{
return 0;
}
c1 = *(CONNECTION **)p1;
c2 = *(CONNECTION **)p2;
if (c1 == NULL || c2 == NULL)
{
return 0;
}
return StrCmpi(c1->Name, c2->Name);
}
|
/* Comparison of connection*/
|
Comparison of connection
|
NewClientConnection
|
CONNECTION *NewClientConnection(SESSION *s)
{
return NewClientConnectionEx(s, NULL, 0, 0);
}
|
/* Creating a Client Connection*/
|
Creating a Client Connection
|
EcDisconnect
|
void EcDisconnect(RPC *rpc)
{
// Validate arguments
if (rpc == NULL)
{
return;
}
RpcFree(rpc);
}
|
/* RPC client disconnect*/
|
RPC client disconnect
|
EiRebootServer
|
void EiRebootServer()
{
THREAD *t;
t = NewThread(EiRebootServerThread, NULL);
ReleaseThread(t);
}
|
/* Restarting the server*/
|
Restarting the server
|
EtRebootServer
|
UINT EtRebootServer(EL *a, RPC_TEST *t)
{
EiRebootServer();
return ERR_NO_ERROR;
}
|
/* RPC to restart server*/
|
RPC to restart server
|
EtGetBridgeSupport
|
UINT EtGetBridgeSupport(EL *a, RPC_BRIDGE_SUPPORT *t)
{
Zero(t, sizeof(RPC_BRIDGE_SUPPORT));
t->IsBridgeSupportedOs = IsBridgeSupported();
t->IsWinPcapNeeded = IsNeedWinPcap();
return ERR_NO_ERROR;
}
|
/* Get support information for the local bridge*/
|
Get support information for the local bridge
|
ElParseCurrentLicenseStatus
|
void ElParseCurrentLicenseStatus(LICENSE_SYSTEM *s, EL_LICENSE_STATUS *st)
{
}
|
/* Save by analyzing the status of the current license*/
|
Save by analyzing the status of the current license
|
EtGetLicenseStatus
|
UINT EtGetLicenseStatus(EL *e, RPC_EL_LICENSE_STATUS *t)
{
UINT ret = ERR_NO_ERROR;
LICENSE_SYSTEM *ls = e->LicenseSystem;
if (ls == NULL)
{
return ERR_NOT_SUPPORTED;
}
Zero(t, sizeof(RPC_EL_LICENSE_STATUS));
// Get the current license status
ElParseCurrentLicenseStatus(ls, e->LicenseStatus);
t->Valid = e->LicenseStatus->Valid;
t->SystemId = e->LicenseStatus->SystemId;
t->SystemExpires = e->LicenseStatus->Expires;
return ret;
}
|
/* Get a license status*/
|
Get a license status
|
EtEnumLicenseKey
|
UINT EtEnumLicenseKey(EL *el, RPC_ENUM_LICENSE_KEY *t)
{
return ERR_NOT_SUPPORTED;
}
|
/* Enumerate the license keys*/
|
Enumerate the license keys
|
EtAddLicenseKey
|
UINT EtAddLicenseKey(EL *e, RPC_TEST *t)
{
return ERR_NOT_SUPPORTED;
}
|
/* Add a license key*/
|
Add a license key
|
EtDelLicenseKey
|
UINT EtDelLicenseKey(EL *e, RPC_TEST *t)
{
return ERR_NOT_SUPPORTED;
}
|
/* Delete the license key*/
|
Delete the license key
|
EtAddDevice
|
UINT EtAddDevice(EL *e, RPC_ADD_DEVICE *t)
{
if (ElAddCaptureDevice(e, t->DeviceName, &t->LogSetting, t->NoPromiscuous) == false)
{
return ERR_CAPTURE_DEVICE_ADD_ERROR;
}
ElSaveConfig(e);
return ERR_NO_ERROR;
}
|
/* Add a device*/
|
Add a device
|
EtDelDevice
|
UINT EtDelDevice(EL *e, RPC_DELETE_DEVICE *t)
{
if (ElDeleteCaptureDevice(e, t->DeviceName) == false)
{
return ERR_CAPTURE_NOT_FOUND;
}
ElSaveConfig(e);
return ERR_NO_ERROR;
}
|
/* Remove the device*/
|
Remove the device
|
EtGetDevice
|
UINT EtGetDevice(EL *e, RPC_ADD_DEVICE *t)
{
UINT ret = ERR_CAPTURE_NOT_FOUND;
LockList(e->DeviceList);
{
EL_DEVICE *d, a;
Zero(&a, sizeof(a));
StrCpy(a.DeviceName, sizeof(a.DeviceName), t->DeviceName);
d = Search(e->DeviceList, &a);
if (d != NULL)
{
ret = ERR_NO_ERROR;
Copy(&t->LogSetting, &d->LogSetting, sizeof(HUB_LOG));
t->NoPromiscuous = d->NoPromiscuous;
}
}
UnlockList(e->DeviceList);
return ret;
}
|
/* Get the device*/
|
Get the device
|
ElIsBetaExpired
|
bool ElIsBetaExpired()
{
SYSTEMTIME st;
UINT64 expires64;
UINT64 now64;
if (ELOG_IS_BETA == false)
{
return false;
}
Zero(&st, sizeof(st));
st.wYear = ELOG_BETA_EXPIRES_YEAR;
st.wMonth = ELOG_BETA_EXPIRES_MONTH;
st.wDay = ELOG_BETA_EXPIRES_DAY;
expires64 = SystemToUINT64(&st);
now64 = LocalTime64();
if (now64 >= expires64)
{
return true;
}
return false;
}
|
/* Confirm whether the beta version has expired*/
|
Confirm whether the beta version has expired
|
EiWriteLicenseManager
|
void EiWriteLicenseManager(FOLDER *f, EL *s)
{
}
|
/* Write the license List*/
|
Write the license List
|
EiLoadLicenseManager
|
void EiLoadLicenseManager(EL *s, FOLDER *f)
{
}
|
/* Read the license list*/
|
Read the license list
|
ElSaveConfig
|
void ElSaveConfig(EL *e)
{
FOLDER *root;
// Validate arguments
if (e == NULL)
{
return;
}
root = CfgCreateFolder(NULL, TAG_ROOT);
ElSaveConfigToFolder(e, root);
SaveCfgRw(e->CfgRw, root);
CfgDeleteFolder(root);
}
|
/* Write the configuration*/
|
Write the configuration
|
ElCompareDevice
|
int ElCompareDevice(void *p1, void *p2)
{
EL_DEVICE *d1, *d2;
// Validate arguments
if (p1 == NULL || p2 == NULL)
{
return 0;
}
d1 = *(EL_DEVICE **)p1;
d2 = *(EL_DEVICE **)p2;
if (d1 == NULL || d2 == NULL)
{
return 0;
}
return StrCmpi(d1->DeviceName, d2->DeviceName);
}
|
/* Comparison function of the device*/
|
Comparison function of the device
|
CleanupEl
|
void CleanupEl(EL *e)
{
// Validate arguments
if (e == NULL)
{
return;
}
// Stop Eraser
FreeEraser(e->Eraser);
// Stop Listener
ElStopListener(e);
// Setting release
ElFreeConfig(e);
// Free the license system
if(e->LicenseSystem != NULL)
{
}
// Free the license status
if(e->LicenseStatus != NULL)
{
Free(e->LicenseStatus);
}
// Ethernet release
FreeEth();
ReleaseCedar(e->Cedar);
DeleteLock(e->lock);
Free(e);
}
|
/* Clean-up the EL*/
|
Clean-up the EL
|
ReleaseEl
|
void ReleaseEl(EL *e)
{
// Validate arguments
if (e == NULL)
{
return;
}
if (Release(e->ref) == 0)
{
CleanupEl(e);
}
}
|
/* Release the EL*/
|
Release the EL
|
NewEl
|
EL *NewEl()
{
EL *e;
#ifdef OS_WIN32
RegistWindowsFirewallAll();
#endif
e = ZeroMalloc(sizeof(EL));
e->lock = NewLock();
e->ref = NewRef();
e->Cedar = NewCedar(NULL, NULL);
// Ethernet initialization
InitEth();
// Setting initialization
ElInitConfig(e);
// Listener start
ElStartListener(e);
// Initialize the license status
ElParseCurrentLicenseStatus(e->LicenseSystem, e->LicenseStatus);
// Eraser start
e->Eraser = NewEraser(NULL, e->AutoDeleteCheckDiskFreeSpaceMin);
return e;
}
|
/* Create the EL*/
|
Create the EL
|
EndRpc
|
void EndRpc(RPC *rpc)
{
RpcFree(rpc);
}
|
/* End of RPC*/
|
End of RPC
|
RpcFree
|
void RpcFree(RPC *rpc)
{
RpcFreeEx(rpc, false);
}
|
/* Release the RPC*/
|
Release the RPC
|
RpcError
|
void RpcError(PACK *p, UINT err)
{
// Validate arguments
if (p == NULL)
{
return;
}
PackAddInt(p, "error", 1);
PackAddInt(p, "error_code", err);
}
|
/* Error code setting*/
|
Error code setting
|
CallRpcDispatcher
|
PACK *CallRpcDispatcher(RPC *r, PACK *p)
{
char func_name[MAX_SIZE];
// Validate arguments
if (r == NULL || p == NULL)
{
return NULL;
}
if (PackGetStr(p, "function_name", func_name, sizeof(func_name)) == false)
{
return NULL;
}
return r->Dispatch(r, func_name, p);
}
|
/* Start the RPC dispatcher*/
|
Start the RPC dispatcher
|
RpcServer
|
void RpcServer(RPC *r)
{
SOCK *s;
// Validate arguments
if (r == NULL)
{
return;
}
s = r->Sock;
while (true)
{
// Wait for the next RPC call
if (RpcRecvNextCall(r) == false)
{
// Communication error
break;
}
}
}
|
/* RPC server operation*/
|
RPC server operation
|
StartRpcServer
|
RPC *StartRpcServer(SOCK *s, RPC_DISPATCHER *dispatch, void *param)
{
RPC *r;
// Validate arguments
if (s == NULL)
{
return NULL;
}
r = ZeroMallocEx(sizeof(RPC), true);
r->Sock = s;
r->Param = param;
r->Lock = NewLock();
AddRef(s->ref);
r->ServerMode = true;
r->Dispatch = dispatch;
// Name generation
Format(r->Name, sizeof(r->Name), "RPC-%u", s->socket);
return r;
}
|
/* Start the RPC server*/
|
Start the RPC server
|
StartRpcClient
|
RPC *StartRpcClient(SOCK *s, void *param)
{
RPC *r;
// Validate arguments
if (s == NULL)
{
return NULL;
}
r = ZeroMalloc(sizeof(RPC));
r->Sock = s;
r->Param = param;
r->Lock = NewLock();
AddRef(s->ref);
r->ServerMode = false;
return r;
}
|
/* Start the RPC client*/
|
Start the RPC client
|
UtSpeedMeterDlgUpdate
|
void UtSpeedMeterDlgUpdate(HWND hWnd)
{
// Validate arguments
if (hWnd == NULL)
{
return;
}
}
|
/* Speedometer dialog control update*/
|
Speedometer dialog control update
|
UtSpeedMeterDlgInit
|
void UtSpeedMeterDlgInit(HWND hWnd)
{
// Validate arguments
if (hWnd == NULL)
{
return;
}
LvInitEx(hWnd, L_STATUS, true);
LvInsertColumn(hWnd, L_STATUS, 0, _UU("UT_SM_COLUMN_1"), 150);
LvInsertColumn(hWnd, L_STATUS, 1, _UU("UT_SM_COLUMN_2"), 290);
UtSpeedMeterDlgRefreshList(hWnd);
selected_adapter = GetTextA(hWnd, E_LIST);
UtSpeedMeterDlgRefreshStatus(hWnd);
UtSpeedMeterDlgUpdate(hWnd);
}
|
/* Speedometer dialog initialization*/
|
Speedometer dialog initialization
|
CedarIsThereAnyEapEnabledRadiusConfig
|
bool CedarIsThereAnyEapEnabledRadiusConfig(CEDAR *c)
{
bool ret = false;
UINT i;
if (c == NULL)
{
return false;
}
LockHubList(c);
{
for (i = 0;i < LIST_NUM(c->HubList);i++)
{
HUB *hub = LIST_DATA(c->HubList, i);
if (hub->RadiusConvertAllMsChapv2AuthRequestToEap)
{
ret = true;
break;
}
}
}
UnlockHubList(c);
return ret;
}
|
/* Check whether there is any EAP-enabled RADIUS configuration*/
|
Check whether there is any EAP-enabled RADIUS configuration
|
GetCurrentBuildDate
|
UINT64 GetCurrentBuildDate()
{
SYSTEMTIME st;
Zero(&st, sizeof(st));
st.wYear = BUILD_DATE_Y;
st.wMonth = BUILD_DATE_M;
st.wDay = BUILD_DATE_D;
st.wHour = BUILD_DATE_HO;
st.wMinute = BUILD_DATE_MI;
st.wSecond = BUILD_DATE_SE;
return SystemToUINT64(&st);
}
|
/* Get build date of current code*/
|
Get build date of current code
|
GetWinVer
|
void GetWinVer(RPC_WINVER *v)
{
// Validate arguments
if (v == NULL)
{
return;
}
#ifdef OS_WIN32
Win32GetWinVer(v);
#else // OS_WIN32
Zero(v, sizeof(RPC_WINVER));
StrCpy(v->Title, sizeof(v->Title), GetOsInfo()->OsProductName);
#endif // OS_WIN32
}
|
/* Get version of Windows*/
|
Get version of Windows
|
FreeTinyLog
|
void FreeTinyLog(TINY_LOG *t)
{
// Validate arguments
if (t == NULL)
{
return;
}
FileClose(t->io);
DeleteLock(t->Lock);
Free(t);
}
|
/* Close tiny log*/
|
Close tiny log
|
WriteTinyLog
|
void WriteTinyLog(TINY_LOG *t, char *str)
{
BUF *b;
char dt[MAX_PATH];
// Validate arguments
if (t == NULL)
{
return;
}
GetDateTimeStrMilli64(dt, sizeof(dt), LocalTime64());
StrCat(dt, sizeof(dt), ": ");
b = NewBuf();
WriteBuf(b, dt, StrLen(dt));
WriteBuf(b, str, StrLen(str));
WriteBuf(b, "\r\n", 2);
Lock(t->Lock);
{
FileWrite(t->io, b->Buf, b->Size);
//FileFlush(t->io);
}
Unlock(t->Lock);
FreeBuf(b);
}
|
/* Write to tiny log*/
|
Write to tiny log
|
NewTinyLog
|
TINY_LOG *NewTinyLog()
{
char name[MAX_PATH];
SYSTEMTIME st;
TINY_LOG *t;
LocalTime(&st);
MakeDir(TINY_LOG_DIRNAME);
Format(name, sizeof(name), TINY_LOG_FILENAME,
st.wYear, st.wMonth, st.wDay, st.wHour, st.wMinute, st.wSecond);
t = ZeroMalloc(sizeof(TINY_LOG));
StrCpy(t->FileName, sizeof(t->FileName), name);
t->io = FileCreate(name);
t->Lock = NewLock();
return t;
}
|
/* Initialize tiny log*/
|
Initialize tiny log
|
CompareNoSslList
|
int CompareNoSslList(void *p1, void *p2)
{
NON_SSL *n1, *n2;
if (p1 == NULL || p2 == NULL)
{
return 0;
}
n1 = *(NON_SSL **)p1;
n2 = *(NON_SSL **)p2;
if (n1 == NULL || n2 == NULL)
{
return 0;
}
return CmpIpAddr(&n1->IpAddress, &n2->IpAddress);
}
|
/* Compare entries of No-SSL connection list*/
|
Compare entries of No-SSL connection list
|
DecrementNoSsl
|
void DecrementNoSsl(CEDAR *c, IP *ip, UINT num_dec)
{
// Validate arguments
if (c == NULL || ip == NULL)
{
return;
}
LockList(c->NonSslList);
{
NON_SSL *n = SearchNoSslList(c, ip);
if (n != NULL)
{
if (n->Count >= num_dec)
{
n->Count -= num_dec;
}
}
}
UnlockList(c->NonSslList);
}
|
/* Decrement connection count of Non-SSL connection list entry */
|
Decrement connection count of Non-SSL connection list entry
|
DeleteOldNoSsl
|
void DeleteOldNoSsl(CEDAR *c)
{
UINT i;
LIST *o;
// Validate arguments
if (c == NULL)
{
return;
}
o = NewListFast(NULL);
for (i = 0;i < LIST_NUM(c->NonSslList);i++)
{
NON_SSL *n = LIST_DATA(c->NonSslList, i);
if (n->EntryExpires <= Tick64())
{
Add(o, n);
}
}
for (i = 0;i < LIST_NUM(o);i++)
{
NON_SSL *n = LIST_DATA(o, i);
Delete(c->NonSslList, n);
Free(n);
}
ReleaseList(o);
}
|
/* Delete old entries in Non-SSL connection list*/
|
Delete old entries in Non-SSL connection list
|
SearchNoSslList
|
NON_SSL *SearchNoSslList(CEDAR *c, IP *ip)
{
NON_SSL *n, t;
// Validate arguments
if (c == NULL || ip == NULL)
{
return NULL;
}
Zero(&t, sizeof(t));
Copy(&t.IpAddress, ip, sizeof(IP));
n = Search(c->NonSslList, &t);
if (n == NULL)
{
return NULL;
}
return n;
}
|
/* Search entry in Non-SSL connection list*/
|
Search entry in Non-SSL connection list
|
InitNoSslList
|
void InitNoSslList(CEDAR *c)
{
// Validate arguments
if (c == NULL)
{
return;
}
c->NonSslList = NewList(CompareNoSslList);
}
|
/* Initialize Non-SSL connection list*/
|
Initialize Non-SSL connection list
|
FreeNoSslList
|
void FreeNoSslList(CEDAR *c)
{
UINT i;
// Validate arguments
if (c == NULL)
{
return;
}
for (i = 0;i < LIST_NUM(c->NonSslList);i++)
{
NON_SSL *n = LIST_DATA(c->NonSslList, i);
Free(n);
}
ReleaseList(c->NonSslList);
c->NonSslList = NULL;
}
|
/* Free Non-SSL connection list*/
|
Free Non-SSL connection list
|
StartCedarLog
|
void StartCedarLog()
{
if (cedar_log_ref == NULL)
{
cedar_log_ref = NewRef();
}
else
{
AddRef(cedar_log_ref);
}
cedar_log = NewLog("debug_log", "debug", LOG_SWITCH_DAY);
}
|
/* Start Cedar log*/
|
Start Cedar log
|
StopCedarLog
|
void StopCedarLog()
{
if (cedar_log_ref == NULL)
{
return;
}
if (Release(cedar_log_ref) == 0)
{
FreeLog(cedar_log);
cedar_log = NULL;
cedar_log_ref = NULL;
}
}
|
/* Stop Cedar log*/
|
Stop Cedar log
|
GetTrafficPacketSize
|
UINT64 GetTrafficPacketSize(TRAFFIC *t)
{
// Validate arguments
if (t == NULL)
{
return 0;
}
return t->Recv.BroadcastBytes + t->Recv.UnicastBytes +
t->Send.BroadcastBytes + t->Send.UnicastBytes;
}
|
/* Get sum of traffic data size*/
|
Get sum of traffic data size
|
GetTrafficPacketNum
|
UINT64 GetTrafficPacketNum(TRAFFIC *t)
{
// Validate arguments
if (t == NULL)
{
return 0;
}
return t->Recv.BroadcastCount + t->Recv.UnicastCount +
t->Send.BroadcastCount + t->Send.UnicastCount;
}
|
/* Get sum of the number of packets in traffic*/
|
Get sum of the number of packets in traffic
|
CheckSignatureByCa
|
bool CheckSignatureByCa(CEDAR *cedar, X *x)
{
X *ca;
// Validate arguments
if (cedar == NULL || x == NULL)
{
return false;
}
// Get the CA which signed the certificate
ca = FindCaSignedX(cedar->CaList, x);
if (ca == NULL)
{
// Not found
return false;
}
// Found
FreeX(ca);
return true;
}
|
/* Check whether the certificate is signed by CA which is trusted by Cedar*/
|
Check whether the certificate is signed by CA which is trusted by Cedar
|
DeleteCa
|
bool DeleteCa(CEDAR *cedar, UINT ptr)
{
bool b = false;
// Validate arguments
if (cedar == NULL || ptr == 0)
{
return false;
}
LockList(cedar->CaList);
{
UINT i;
for (i = 0;i < LIST_NUM(cedar->CaList);i++)
{
X *x = LIST_DATA(cedar->CaList, i);
if (POINTER_TO_KEY(x) == ptr)
{
Delete(cedar->CaList, x);
FreeX(x);
b = true;
break;
}
}
}
UnlockList(cedar->CaList);
return b;
}
|
/* Delete trusted CA from Cedar*/
|
Delete trusted CA from Cedar
|
AddCa
|
void AddCa(CEDAR *cedar, X *x)
{
// Validate arguments
if (cedar == NULL || x == NULL)
{
return;
}
LockList(cedar->CaList);
{
UINT i;
bool ok = true;
for (i = 0;i < LIST_NUM(cedar->CaList);i++)
{
X *exist_x = LIST_DATA(cedar->CaList, i);
if (CompareX(exist_x, x))
{
ok = false;
break;
}
}
if (ok)
{
Insert(cedar->CaList, CloneX(x));
}
}
UnlockList(cedar->CaList);
}
|
/* Add trusted CA to Cedar*/
|
Add trusted CA to Cedar
|
DelConnection
|
void DelConnection(CEDAR *cedar, CONNECTION *c)
{
// Validate arguments
if (cedar == NULL || c == NULL)
{
return;
}
LockList(cedar->ConnectionList);
{
Debug("Connection %s Deleted from Cedar.\n", c->Name);
if (Delete(cedar->ConnectionList, c))
{
ReleaseConnection(c);
}
}
UnlockList(cedar->ConnectionList);
}
|
/* Delete connection from Cedar*/
|
Delete connection from Cedar
|
StopAllConnection
|
void StopAllConnection(CEDAR *c)
{
UINT num;
UINT i;
CONNECTION **connections;
// Validate arguments
if (c == NULL)
{
return;
}
LockList(c->ConnectionList);
{
connections = ToArray(c->ConnectionList);
num = LIST_NUM(c->ConnectionList);
DeleteAll(c->ConnectionList);
}
UnlockList(c->ConnectionList);
for (i = 0;i < num;i++)
{
StopConnection(connections[i], false);
ReleaseConnection(connections[i]);
}
Free(connections);
}
|
/* Stop all connections*/
|
Stop all connections
|
DelHub
|
void DelHub(CEDAR *c, HUB *h)
{
DelHubEx(c, h, false);
}
|
/* Delete a hub in Cedar*/
|
Delete a hub in Cedar
|
AddHub
|
void AddHub(CEDAR *c, HUB *h)
{
// Validate arguments
if (c == NULL || h == NULL)
{
return;
}
LockHubList(c);
{
#if 0
// We shall not check here the number of hub
if (LIST_NUM(c->HubList) >= MAX_HUBS)
{
// over limit
UnlockHubList(c);
return;
}
#endif
// Confirm there is no hub which have same name
if (IsHub(c, h->Name))
{
// exist
UnlockHubList(c);
return;
}
// Register the hub
Insert(c->HubList, h);
AddRef(h->ref);
}
UnlockHubList(c);
}
|
/* Add a new hub to Cedar*/
|
Add a new hub to Cedar
|
StopAllHub
|
void StopAllHub(CEDAR *c)
{
HUB **hubs;
UINT i, num;
// Validate arguments
if (c == NULL)
{
return;
}
LockHubList(c);
{
hubs = ToArray(c->HubList);
num = LIST_NUM(c->HubList);
DeleteAll(c->HubList);
}
UnlockHubList(c);
for (i = 0;i < num;i++)
{
StopHub(hubs[i]);
ReleaseHub(hubs[i]);
}
Free(hubs);
}
|
/* Stop all hubs in Cedar*/
|
Stop all hubs in Cedar
|
GetReverseListeningSock
|
SOCK *GetReverseListeningSock(CEDAR *c)
{
SOCK *s = NULL;
// Validate arguments
if (c == NULL)
{
return NULL;
}
LockList(c->ListenerList);
{
UINT i;
for (i = 0;i < LIST_NUM(c->ListenerList);i++)
{
LISTENER *r = LIST_DATA(c->ListenerList, i);
if (r->Protocol == LISTENER_REVERSE)
{
Lock(r->lock);
{
s = r->Sock;
AddRef(s->ref);
}
Unlock(r->lock);
break;
}
}
}
UnlockList(c->ListenerList);
return s;
}
|
/* Get reverse listener socket in Cedar*/
|
Get reverse listener socket in Cedar
|
GetInProcListeningSock
|
SOCK *GetInProcListeningSock(CEDAR *c)
{
SOCK *s = NULL;
// Validate arguments
if (c == NULL)
{
return NULL;
}
LockList(c->ListenerList);
{
UINT i;
for (i = 0;i < LIST_NUM(c->ListenerList);i++)
{
LISTENER *r = LIST_DATA(c->ListenerList, i);
if (r->Protocol == LISTENER_INPROC)
{
Lock(r->lock);
{
s = r->Sock;
if (s != NULL)
{
AddRef(s->ref);
}
}
Unlock(r->lock);
break;
}
}
}
UnlockList(c->ListenerList);
return s;
}
|
/* Get in-process listener socket in Cedar*/
|
Get in-process listener socket in Cedar
|
AddListener
|
void AddListener(CEDAR *c, LISTENER *r)
{
// Validate arguments
if (c == NULL || r == NULL)
{
return;
}
LockList(c->ListenerList);
{
Add(c->ListenerList, r);
AddRef(r->ref);
}
UnlockList(c->ListenerList);
}
|
/* Add a new listener to Cedar*/
|
Add a new listener to Cedar
|
StopAllListener
|
void StopAllListener(CEDAR *c)
{
LISTENER **array;
UINT i, num;
// Validate arguments
if (c == NULL)
{
return;
}
LockList(c->ListenerList);
{
array = ToArray(c->ListenerList);
num = LIST_NUM(c->ListenerList);
DeleteAll(c->ListenerList);
}
UnlockList(c->ListenerList);
for (i = 0;i < num;i++)
{
StopListener(array[i]);
ReleaseListener(array[i]);
}
Free(array);
}
|
/* Stop all listener in Cedar*/
|
Stop all listener in Cedar
|
CedarAddQueueBudget
|
void CedarAddQueueBudget(CEDAR *c, int diff)
{
// Validate arguments
if (c == NULL || diff == 0)
{
return;
}
Lock(c->QueueBudgetLock);
{
int v = (int)c->QueueBudget;
v += diff;
c->QueueBudget = (UINT)v;
}
Unlock(c->QueueBudgetLock);
}
|
/* Budget management functions*/
|
Budget management functions
|
CedarAddCurrentTcpQueueSize
|
void CedarAddCurrentTcpQueueSize(CEDAR *c, int diff)
{
// Validate arguments
if (c == NULL || diff == 0)
{
return;
}
Lock(c->CurrentTcpQueueSizeLock);
{
int v = (int)c->CurrentTcpQueueSize;
v += diff;
c->CurrentTcpQueueSize = (UINT)v;
}
Unlock(c->CurrentTcpQueueSizeLock);
}
|
/* Add the current TCP queue size*/
|
Add the current TCP queue size
|
CedarGetCurrentTcpQueueSize
|
UINT CedarGetCurrentTcpQueueSize(CEDAR *c)
{
// Validate arguments
if (c == NULL)
{
return 0;
}
return c->CurrentTcpQueueSize;
}
|
/* Get the current TCP queue size*/
|
Get the current TCP queue size
|
ReleaseCedar
|
void ReleaseCedar(CEDAR *c)
{
// Validate arguments
if (c == NULL)
{
return;
}
if (Release(c->ref) == 0)
{
CleanupCedar(c);
}
}
|
/* Release reference of the Cedar*/
|
Release reference of the Cedar
|
SetCedarCipherList
|
void SetCedarCipherList(CEDAR *cedar, char *name)
{
// Validate arguments
if (cedar == NULL)
{
return;
}
if (cedar->CipherList != NULL)
{
Free(cedar->CipherList);
}
if (name != NULL)
{
cedar->CipherList = CopyStr(name);
}
else
{
cedar->CipherList = NULL;
}
}
|
/* Set cipher list entry*/
|
Set cipher list entry
|
GetSvcName
|
char *GetSvcName(CEDAR *cedar, bool udp, UINT port)
{
char *ret = NULL;
NETSVC t;
// Validate arguments
if (cedar == NULL)
{
return NULL;
}
t.Udp = (udp == 0 ? false : true);
t.Port = port;
LockList(cedar->NetSvcList);
{
NETSVC *n = Search(cedar->NetSvcList, &t);
if (n != NULL)
{
ret = n->Name;
}
}
UnlockList(cedar->NetSvcList);
return ret;
}
|
/* Get net service name*/
|
Get net service name
|
FreeNetSvcList
|
void FreeNetSvcList(CEDAR *cedar)
{
UINT i;
// Validate arguments
if (cedar == NULL)
{
return;
}
for (i = 0;i < LIST_NUM(cedar->NetSvcList);i++)
{
NETSVC *n = LIST_DATA(cedar->NetSvcList, i);
Free(n->Name);
Free(n);
}
ReleaseList(cedar->NetSvcList);
}
|
/* Free net service list*/
|
Free net service list
|
SetCedarCert
|
void SetCedarCert(CEDAR *c, X *server_x, K *server_k)
{
// Validate arguments
if (server_x == NULL || server_k == NULL)
{
return;
}
Lock(c->lock);
{
if (c->ServerX != NULL)
{
FreeX(c->ServerX);
}
if (c->ServerK != NULL)
{
FreeK(c->ServerK);
}
c->ServerX = CloneX(server_x);
c->ServerK = CloneK(server_k);
}
Unlock(c->lock);
}
|
/* Change certificate of Cedar*/
|
Change certificate of Cedar
|
SetCedarVpnBridge
|
void SetCedarVpnBridge(CEDAR *c)
{
// Validate arguments
if (c == NULL)
{
return;
}
c->Bridge = true;
Free(c->ServerStr);
c->ServerStr = CopyStr(CEDAR_BRIDGE_STR);
}
|
/* Set the Cedar into VPN Bridge mode*/
|
Set the Cedar into VPN Bridge mode
|
GetCedarVersion
|
void GetCedarVersion(char *tmp, UINT size)
{
// Validate arguments
if (tmp == NULL)
{
return;
}
Format(tmp, size, "%u.%02u.%u", CEDAR_VERSION_MAJOR, CEDAR_VERSION_MINOR, CEDAR_VERSION_BUILD);
}
|
/* Get version of the Cedar*/
|
Get version of the Cedar
|
AddTraffic
|
void AddTraffic(TRAFFIC *dst, TRAFFIC *diff)
{
// Validate arguments
if (dst == NULL || diff == NULL)
{
return;
}
dst->Recv.BroadcastBytes += diff->Recv.BroadcastBytes;
dst->Recv.BroadcastCount += diff->Recv.BroadcastCount;
dst->Recv.UnicastBytes += diff->Recv.UnicastBytes;
dst->Recv.UnicastCount += diff->Recv.UnicastCount;
dst->Send.BroadcastBytes += diff->Send.BroadcastBytes;
dst->Send.BroadcastCount += diff->Send.BroadcastCount;
dst->Send.UnicastBytes += diff->Send.UnicastBytes;
dst->Send.UnicastCount += diff->Send.UnicastCount;
}
|
/* Cumulate traffic size*/
|
Cumulate traffic size
|
NewTraffic
|
TRAFFIC *NewTraffic()
{
TRAFFIC *t;
t = ZeroMalloc(sizeof(TRAFFIC));
return t;
}
|
/* Create new traffic size object*/
|
Create new traffic size object
|
FreeTraffic
|
void FreeTraffic(TRAFFIC *t)
{
// Validate arguments
if (t == NULL)
{
return;
}
Free(t);
}
|
/* Free traffic size object*/
|
Free traffic size object
|
InitCedar
|
void InitCedar()
{
if ((init_cedar_counter++) > 0)
{
return;
}
// Initialize protocol module
InitProtocol();
// Initialize third-party protocol interface
ProtoInit();
}
|
/* Initialize Cedar communication module*/
|
Initialize Cedar communication module
|
FreeCedar
|
void FreeCedar()
{
if ((--init_cedar_counter) > 0)
{
return;
}
// Free third-party protocol interface
ProtoFree();
// Free protocol module
FreeProtocol();
}
|
/* Free Cedar communication module*/
|
Free Cedar communication module
|
Win32ReleaseAllDhcp9x
|
void Win32ReleaseAllDhcp9x(bool wait)
{
TOKEN_LIST *t;
UINT i;
t = MsEnumNetworkAdapters(VLAN_ADAPTER_NAME, VLAN_ADAPTER_NAME_OLD);
if (t == NULL)
{
return;
}
for (i = 0;i < t->NumTokens;i++)
{
char *name = t->Token[i];
UINT id = GetInstanceId(name);
if (id != 0)
{
Win32ReleaseDhcp9x(id, wait);
}
}
FreeToken(t);
}
|
/* Release the DHCP addresses of all virtual LAN cards*/
|
Release the DHCP addresses of all virtual LAN cards
|
GetInstanceId
|
UINT GetInstanceId(char *name)
{
char tmp[MAX_SIZE];
UINT id = 0;
// Validate arguments
if (name == NULL)
{
return 0;
}
Format(tmp, sizeof(tmp), VLAN_ADAPTER_NAME_TAG, name);
id = GetVLanInterfaceID(tmp);
if (id != 0)
{
return id;
}
else
{
Format(tmp, sizeof(tmp), VLAN_ADAPTER_NAME_TAG_OLD, name);
id = GetVLanInterfaceID(tmp);
return id;
}
}
|
/* Get the instance ID of the virtual LAN card*/
|
Get the instance ID of the virtual LAN card
|
FreeInstanceList
|
void FreeInstanceList(INSTANCE_LIST *n)
{
UINT i;
// Validate arguments
if (n == NULL)
{
return;
}
for (i = 0;i < n->NumInstance;i++)
{
Free(n->InstanceName[i]);
}
Free(n->InstanceName);
Free(n);
}
|
/* Release the instance list*/
|
Release the instance list
|
VLanPaGetNextPacket
|
UINT VLanPaGetNextPacket(SESSION *s, void **data)
{
VLAN *v;
UINT size;
// Validate arguments
if (data == NULL || (s == NULL) || ((v = s->PacketAdapter->Param) == NULL))
{
return 0;
}
RouteTrackingMain(s);
if (VLanGetNextPacket(v, data, &size) == false)
{
return INFINITE;
}
return size;
}
|
/* Get the next packet*/
|
Get the next packet
|
VLanGetPacketAdapter
|
PACKET_ADAPTER *VLanGetPacketAdapter()
{
PACKET_ADAPTER *pa;
pa = NewPacketAdapter(VLanPaInit, VLanPaGetCancel,
VLanPaGetNextPacket, VLanPaPutPacket, VLanPaFree);
if (pa == NULL)
{
return NULL;
}
pa->Id = PACKET_ADAPTER_ID_VLAN_WIN32;
return pa;
}
|
/* Get the packet adapter of the VLAN*/
|
Get the packet adapter of the VLAN
|
VLanGetCancel
|
CANCEL *VLanGetCancel(VLAN *v)
{
CANCEL *c;
// Validate arguments
if (v == NULL)
{
return NULL;
}
// Create a cancel object
c = NewCancel();
c->SpecialFlag = true;
CloseHandle(c->hEvent);
c->hEvent = v->Event;
return c;
}
|
/* Get the cancel object*/
|
Get the cancel object
|
FreeVLan
|
void FreeVLan(VLAN *v)
{
// Validate arguments
if (v == NULL)
{
return;
}
// Close the handle
CloseHandle(v->Event);
CloseHandle(v->Handle);
// Memory release
Free(v->InstanceName);
Free(v->EventNameWin32);
Free(v->DeviceNameWin32);
Free(v->PutBuffer);
Free(v->GetBuffer);
Free(v);
}
|
/* Release the VLAN object*/
|
Release the VLAN object
|
IsProxyPrivateIp
|
bool IsProxyPrivateIp(INTERNET_SETTING *s)
{
IP ip;
// Validate arguments
if (s == NULL)
{
return false;
}
if (s->ProxyType == PROXY_DIRECT)
{
return false;
}
if (GetIP(&ip, s->ProxyHostName) == false)
{
return false;
}
if (IsIPPrivate(&ip))
{
return true;
}
if (IsIPMyHost(&ip))
{
return true;
}
if (IsLocalHostIP(&ip))
{
return true;
}
return false;
}
|
/* Get whether the proxy server is specified by a private IP*/
|
Get whether the proxy server is specified by a private IP
|
WpcFreePacket
|
void WpcFreePacket(WPC_PACKET *packet)
{
// Validate arguments
if (packet == NULL)
{
return;
}
FreePack(packet->Pack);
FreeX(packet->Cert);
}
|
/* Release the packet*/
|
Release the packet
|
WpcDataEntryToBuf
|
BUF *WpcDataEntryToBuf(WPC_ENTRY *e)
{
void *data;
UINT data_size;
UINT size;
BUF *b;
// Validate arguments
if (e == NULL)
{
return NULL;
}
data_size = e->Size + 4096;
data = Malloc(data_size);
size = DecodeSafe64(data, e->Data, e->Size);
b = NewBuf();
WriteBuf(b, data, size);
SeekBuf(b, 0, 0);
Free(data);
return b;
}
|
/* Decode the buffer from WPC_ENTRY*/
|
Decode the buffer from WPC_ENTRY
|
WpcFindDataEntry
|
WPC_ENTRY *WpcFindDataEntry(LIST *o, char *name)
{
UINT i;
char name_str[WPC_DATA_ENTRY_SIZE];
// Validate arguments
if (o == NULL || name == NULL)
{
return NULL;
}
WpcFillEntryName(name_str, name);
for (i = 0;i < LIST_NUM(o);i++)
{
WPC_ENTRY *e = LIST_DATA(o, i);
if (Cmp(e->EntryName, name_str, WPC_DATA_ENTRY_SIZE) == 0)
{
return e;
}
}
return NULL;
}
|
/* Search for the data entry*/
|
Search for the data entry
|
WpcFreeDataEntryList
|
void WpcFreeDataEntryList(LIST *o)
{
UINT i;
// Validate arguments
if (o == NULL)
{
return;
}
for (i = 0;i < LIST_NUM(o);i++)
{
WPC_ENTRY *e = LIST_DATA(o, i);
Free(e);
}
ReleaseList(o);
}
|
/* Release the data entry list*/
|
Release the data entry list
|
WpcFillEntryName
|
void WpcFillEntryName(char *dst, char *name)
{
UINT i, len;
char tmp[MAX_SIZE];
// Validate arguments
if (dst == NULL || name == NULL)
{
return;
}
StrCpy(tmp, sizeof(tmp), name);
StrUpper(tmp);
len = StrLen(tmp);
for (i = 0;i < WPC_DATA_ENTRY_SIZE;i++)
{
dst[i] = ' ';
}
if (len <= WPC_DATA_ENTRY_SIZE)
{
Copy(dst, tmp, len);
}
else
{
Copy(dst, tmp, WPC_DATA_ENTRY_SIZE);
}
}
|
/* Generate a entry name*/
|
Generate a entry name
|
WpcAddDataEntryBin
|
void WpcAddDataEntryBin(BUF *b, char *name, void *data, UINT size)
{
char *str;
// Validate arguments
if (b == NULL || name == NULL || (data == NULL && size != 0))
{
return;
}
str = Malloc(size * 2 + 64);
EncodeSafe64(str, data, size);
WpcAddDataEntry(b, name, str, StrLen(str));
Free(str);
}
|
/* Add the data entry (binary)*/
|
Add the data entry (binary)
|
WpcAddDataEntry
|
void WpcAddDataEntry(BUF *b, char *name, void *data, UINT size)
{
char entry_name[WPC_DATA_ENTRY_SIZE];
char size_str[11];
// Validate arguments
if (b == NULL || name == NULL || (data == NULL && size != 0))
{
return;
}
WpcFillEntryName(entry_name, name);
WriteBuf(b, entry_name, WPC_DATA_ENTRY_SIZE);
Format(size_str, sizeof(size_str), "%010u", size);
WriteBuf(b, size_str, 10);
WriteBuf(b, data, size);
}
|
/* Add the data entry*/
|
Add the data entry
|
GetNullInternetSetting
|
INTERNET_SETTING *GetNullInternetSetting()
{
static INTERNET_SETTING ret;
Zero(&ret, sizeof(ret));
return &ret;
}
|
/* Get the empty INTERNET_SETTING*/
|
Get the empty INTERNET_SETTING
|
HttpRequest
|
BUF *HttpRequest(URL_DATA *data, INTERNET_SETTING *setting,
UINT timeout_connect, UINT timeout_comm,
UINT *error_code, bool check_ssl_trust, char *post_data,
WPC_RECV_CALLBACK *recv_callback, void *recv_callback_param, void *sha1_cert_hash)
{
return HttpRequestEx(data, setting, timeout_connect, timeout_comm,
error_code, check_ssl_trust, post_data,
recv_callback, recv_callback_param, sha1_cert_hash, NULL, 0);
}
|
/* Handle the HTTP request*/
|
Handle the HTTP request
|
CreateUrl
|
void CreateUrl(char *url, UINT url_size, URL_DATA *data)
{
char *protocol;
// Validate arguments
if (url == NULL || data == NULL)
{
return;
}
if (data->Secure == false)
{
protocol = "http://";
}
else
{
protocol = "https://";
}
Format(url, url_size, "%s%s%s", protocol, data->HeaderHostName, data->Target);
}
|
/* Generate the URL*/
|
Generate the URL
|
DecodeSafe64
|
UINT DecodeSafe64(void *dst, char *src, UINT src_strlen)
{
char *tmp;
UINT ret;
if (dst == NULL || src == NULL)
{
return 0;
}
if (src_strlen == 0)
{
src_strlen = StrLen(src);
}
tmp = Malloc(src_strlen + 1);
Copy(tmp, src, src_strlen);
tmp[src_strlen] = 0;
Safe64ToBase64(tmp);
ret = B64_Decode(dst, tmp, src_strlen);
Free(tmp);
return ret;
}
|
/* Decode from Safe64*/
|
Decode from Safe64
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.