// Create the EL 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 a new stack NATIVE_STACK *NewNativeStack(CEDAR *cedar, char *device_name, char *mac_address_seed) { ETH *eth; NATIVE_STACK *a; IP localhost; char tmp[64]; bool release_cedar = false; // Validate arguments if (device_name == NULL || mac_address_seed == NULL) { return NULL; } GetLocalHostIP4(&localhost); // Open the Eth device eth = OpenEth(device_name, false, false, NULL); if (eth == NULL) { return NULL; } if (cedar == NULL) { cedar = NewCedar(NULL, NULL); release_cedar = true; } a = ZeroMalloc(sizeof(NATIVE_STACK)); NewSocketPair(&a->Sock1, &a->Sock2, &localhost, 1, &localhost, 1); a->Cedar = cedar; AddRef(a->Cedar->ref); NsGenMacAddress(a->MacAddress, mac_address_seed, device_name); BinToStr(tmp, sizeof(tmp), a->MacAddress, sizeof(a->MacAddress)); Debug("NewNativeStack: MAC Address = %s\n", tmp); a->Ipc = NewIPCBySock(cedar, a->Sock2, a->MacAddress); StrCpy(a->DeviceName, sizeof(a->DeviceName), device_name); a->Eth = eth; a->Cancel = EthGetCancel(eth); a->MainThread = NewThread(NsMainThread, a); if (release_cedar) { ReleaseCedar(cedar); } a->IsIpRawMode = a->Eth->IsRawIpMode; return a; }
// Initialize void InitNM() { if (nm != NULL) { // Already initialized return; } nm = ZeroMalloc(sizeof(NM)); InitWinUi(_UU("NM_TITLE"), _SS("DEFAULT_FONT"), _II("DEFAULT_FONT_SIZE")); nm->Cedar = NewCedar(NULL, NULL); InitCM(false); InitSM(); }
// Remote connection dialog procedure UINT EmRemoteDlgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam, void *param) { WINUI_REMOTE *r = (WINUI_REMOTE *)param; CEDAR *c; // Validate arguments if (hWnd == NULL) { return 0; } switch (msg) { case WM_INITDIALOG: RemoteDlgInit(hWnd, r); SetTimer(hWnd, 1, 100, NULL); break; case WM_TIMER: switch (wParam) { case 1: KillTimer(hWnd, 1); RemoteDlgRefresh(hWnd, r); SetTimer(hWnd, 1, 100, NULL); break; } break; case WM_COMMAND: switch (wParam) { case R_LOCAL: if (IsChecked(hWnd, R_LOCAL) == false) { SetTextA(hWnd, C_HOSTNAME, ""); RemoteDlgRefresh(hWnd, r); FocusEx(hWnd, C_HOSTNAME); } else { SetTextA(hWnd, C_HOSTNAME, "localhost"); RemoteDlgRefresh(hWnd, r); Focus(hWnd, IDOK); } break; case IDCANCEL: Close(hWnd); break; case IDOK: RemoteDlgOnOk(hWnd, r); break; case B_ABOUT: c = NewCedar(NULL, NULL); About(hWnd, c, _UU("PRODUCT_NAME_ELOGMGR")); ReleaseCedar(c); } switch (LOWORD(wParam)) { case R_LOCAL: case C_HOSTNAME: RemoteDlgRefresh(hWnd, r); break; } break; case WM_CLOSE: FreeCandidateList(r->CandidateList); EndDialog(hWnd, false); break; } return 0; }