1 // SoftEther VPN Source Code - Developer Edition Master Branch 2 // Cedar Communication Module 3 // © 2020 Nokia 4 5 // Client.h 6 // Header of Client.c 7 8 #ifndef CLIENT_H 9 #define CLIENT_H 10 11 #include "Account.h" 12 #include "Session.h" 13 #include "Wpc.h" 14 15 #define CLIENT_CONFIG_PORT GC_CLIENT_CONFIG_PORT // Client port number 16 #define CLIENT_NOTIFY_PORT GC_CLIENT_NOTIFY_PORT // Client notification port number 17 #define CLIENT_WAIT_CN_READY_TIMEOUT (10 * 1000) // Standby time to start the client notification service 18 19 // Constants 20 #define CLIENT_CONFIG_FILE_NAME "$vpn_client.config" 21 #define CLIENT_DEFAULT_KEEPALIVE_HOST "keepalive.softether.org" 22 #define CLIENT_DEFAULT_KEEPALIVE_PORT 80 23 #define CLIENT_DEFAULT_KEEPALIVE_INTERVAL KEEP_INTERVAL_DEFAULT 24 25 #define CLIENT_RPC_MODE_NOTIFY 0 26 #define CLIENT_RPC_MODE_MANAGEMENT 1 27 #define CLIENT_RPC_MODE_SHORTCUT 2 28 #define CLIENT_RPC_MODE_SHORTCUT_DISCONNECT 3 29 30 #define CLIENT_MACOS_TAP_NAME "tap0" 31 32 #define CLIENT_SAVER_INTERVAL (30 * 1000) 33 34 #define CLIENT_NOTIFY_SERVICE_INSTANCENAME GC_SW_SOFTETHER_PREFIX "vpnclient_uihelper" 35 36 #define CLIENT_WIN32_EXE_FILENAME "vpnclient.exe" 37 38 #define CLIENT_CUSTOM_INI_FILENAME "$custom.ini" 39 40 #define CLIENT_GLOBAL_PULSE_NAME "clientglobalpulse" 41 42 #define CLIENT_WIN32_REGKEYNAME "Software\\" GC_REG_COMPANY_NAME "\\" CEDAR_PRODUCT_STR " VPN\\Client" 43 #define CLIENT_WIN32_REGVALUE_PORT "RpcPort" 44 #define CLIENT_WIN32_REGVALUE_PID "RpcPid" 45 46 47 // List of virtual LAN cards in UNIX 48 struct UNIX_VLAN 49 { 50 bool Enabled; // Enable flag 51 char Name[MAX_SIZE]; // Name 52 UCHAR MacAddress[6]; // MAC address 53 UCHAR Padding[2]; 54 }; 55 56 // Account 57 struct ACCOUNT 58 { 59 // Static data 60 CLIENT_OPTION *ClientOption; // Client Option 61 CLIENT_AUTH *ClientAuth; // Client authentication data 62 bool CheckServerCert; // Check the server certificate 63 bool RetryOnServerCert; // Retry on invalid server certificate 64 X *ServerCert; // Server certificate 65 bool StartupAccount; // Start-up account 66 UCHAR ShortcutKey[SHA1_SIZE]; // Key 67 UINT64 CreateDateTime; // Creation date and time 68 UINT64 UpdateDateTime; // Updating date 69 UINT64 LastConnectDateTime; // Last connection date and time 70 71 // Dynamic data 72 LOCK *lock; // Lock 73 SESSION *ClientSession; // Client session 74 CLIENT_STATUS_PRINTER *StatusPrinter; // Status indicator 75 76 SOCK *StatusWindow; // Status window 77 }; 78 79 // Client Settings 80 struct CLIENT_CONFIG 81 { 82 bool AllowRemoteConfig; // Allow the remote configuration 83 bool UseKeepConnect; // Keep connected to the Internet 84 char KeepConnectHost[MAX_HOST_NAME_LEN + 1]; // Host name 85 UINT KeepConnectPort; // Port number 86 UINT KeepConnectProtocol; // Protocol 87 UINT KeepConnectInterval; // Interval 88 bool NoChangeWcmNetworkSettingOnWindows8; // Don't change the WCM network settings on Windows 8 89 }; 90 91 // Version acquisition 92 struct RPC_CLIENT_VERSION 93 { 94 char ClientProductName[128]; // Client product name 95 char ClientVersionString[128]; // Client version string 96 char ClientBuildInfoString[128]; // Build client information string 97 UINT ClientVerInt; // Client version integer value 98 UINT ClientBuildInt; // Client build number integer value 99 UINT ProcessId; // Process ID 100 UINT OsType; // OS type 101 bool IsVLanNameRegulated; // Whether a virtual LAN card name must be "VLAN" + number 102 bool IsVgcSupported; // Whether the VPN Gate Client is supported 103 bool ShowVgcLink; // Display a VPN Gate Client link 104 char ClientId[128]; // Client OD 105 }; 106 107 // Password Setting 108 struct RPC_CLIENT_PASSWORD 109 { 110 char Password[MAX_PASSWORD_LEN + 1]; // Password 111 bool PasswordRemoteOnly; // The password is required only remote access 112 }; 113 114 // Get the password setting 115 struct RPC_CLIENT_PASSWORD_SETTING 116 { 117 bool IsPasswordPresented; // Password exists 118 bool PasswordRemoteOnly; // The password is required only remote access 119 }; 120 121 // Certificate enumeration item 122 struct RPC_CLIENT_ENUM_CA_ITEM 123 { 124 UINT Key; // Certificate key 125 wchar_t SubjectName[MAX_SIZE]; // Issued to 126 wchar_t IssuerName[MAX_SIZE]; // Issuer 127 UINT64 Expires; // Expiration date 128 }; 129 130 // Certificate enumeration 131 struct RPC_CLIENT_ENUM_CA 132 { 133 UINT NumItem; // Number of items 134 RPC_CLIENT_ENUM_CA_ITEM **Items; // Item 135 }; 136 137 // Certificate item 138 struct RPC_CERT 139 { 140 X *x; // Certificate 141 }; 142 143 // Delete the certificate 144 struct RPC_CLIENT_DELETE_CA 145 { 146 UINT Key; // Certificate key 147 }; 148 149 // Get the certificate 150 struct RPC_GET_CA 151 { 152 UINT Key; // Certificate key 153 X *x; // Certificate 154 }; 155 156 // Get the issuer 157 struct RPC_GET_ISSUER 158 { 159 X *x; // Certificate 160 X *issuer_x; // Issuer 161 }; 162 163 // Secure device enumeration item 164 struct RPC_CLIENT_ENUM_SECURE_ITEM 165 { 166 UINT DeviceId; // Device ID 167 UINT Type; // Type 168 char DeviceName[MAX_SIZE]; // Device name 169 char Manufacturer[MAX_SIZE]; // Manufacturer 170 }; 171 172 // Enumeration of secure devices 173 struct RPC_CLIENT_ENUM_SECURE 174 { 175 UINT NumItem; // Number of items 176 RPC_CLIENT_ENUM_SECURE_ITEM **Items; // Item 177 }; 178 179 // Specify a secure device 180 struct RPC_USE_SECURE 181 { 182 UINT DeviceId; // Device ID 183 }; 184 185 // Enumerate objects in the secure device 186 struct RPC_ENUM_OBJECT_IN_SECURE 187 { 188 UINT hWnd; // Window handle 189 UINT NumItem; // Number of items 190 char **ItemName; // Item name 191 bool *ItemType; // Type (true = secret key, false = public key) 192 }; 193 194 // Create a virtual LAN 195 struct RPC_CLIENT_CREATE_VLAN 196 { 197 char DeviceName[MAX_SIZE]; // Device name 198 }; 199 200 // Get a Virtual LAN information 201 struct RPC_CLIENT_GET_VLAN 202 { 203 char DeviceName[MAX_SIZE]; // Device name 204 bool Enabled; // Flag of whether it works or not 205 char MacAddress[MAX_SIZE]; // MAC address 206 char Version[MAX_SIZE]; // Version 207 char FileName[MAX_SIZE]; // Driver file name 208 char Guid[MAX_SIZE]; // GUID 209 }; 210 211 // Set the virtual LAN information 212 struct RPC_CLIENT_SET_VLAN 213 { 214 char DeviceName[MAX_SIZE]; // Device name 215 char MacAddress[MAX_SIZE]; // MAC address 216 }; 217 218 // Virtual LAN enumeration item 219 struct RPC_CLIENT_ENUM_VLAN_ITEM 220 { 221 char DeviceName[MAX_SIZE]; // Device name 222 bool Enabled; // Operation flag 223 char MacAddress[MAX_SIZE]; // MAC address 224 char Version[MAX_SIZE]; // Version 225 }; 226 227 // Enumerate the virtual LANs 228 struct RPC_CLIENT_ENUM_VLAN 229 { 230 UINT NumItem; // Item count 231 RPC_CLIENT_ENUM_VLAN_ITEM **Items; // Item 232 }; 233 234 // Create an account 235 struct RPC_CLIENT_CREATE_ACCOUNT 236 { 237 CLIENT_OPTION *ClientOption; // Client Option 238 CLIENT_AUTH *ClientAuth; // Client authentication data 239 bool StartupAccount; // Startup account 240 bool CheckServerCert; // Checking of the server certificate 241 bool RetryOnServerCert; // Retry on invalid server certificate 242 X *ServerCert; // Server certificate 243 UCHAR ShortcutKey[SHA1_SIZE]; // Shortcut Key 244 }; 245 246 // Enumeration item of account 247 struct RPC_CLIENT_ENUM_ACCOUNT_ITEM 248 { 249 wchar_t AccountName[MAX_ACCOUNT_NAME_LEN + 1]; // Account name 250 char UserName[MAX_USERNAME_LEN + 1]; // User name 251 char ServerName[MAX_HOST_NAME_LEN + 1]; // Server name 252 char DeviceName[MAX_DEVICE_NAME_LEN + 1]; // Device name 253 UINT ProxyType; // Type of proxy connection 254 char ProxyName[MAX_HOST_NAME_LEN + 1]; // Host name 255 bool Active; // Operation flag 256 bool Connected; // Connection completion flag 257 bool StartupAccount; // Startup account 258 UINT Port; // Port number (Ver 3.0 or later) 259 char HubName[MAX_HUBNAME_LEN + 1]; // Virtual HUB name (Ver 3.0 or later) 260 UINT64 CreateDateTime; // Creation date and time (Ver 3.0 or later) 261 UINT64 UpdateDateTime; // Modified date (Ver 3.0 or later) 262 UINT64 LastConnectDateTime; // Last connection date and time (Ver 3.0 or later) 263 UINT tmp1; // Temporary data 264 }; 265 266 // Enumeration of accounts 267 struct RPC_CLIENT_ENUM_ACCOUNT 268 { 269 UINT NumItem; // Item count 270 RPC_CLIENT_ENUM_ACCOUNT_ITEM **Items; // Items 271 }; 272 273 // Delete the Account 274 struct RPC_CLIENT_DELETE_ACCOUNT 275 { 276 wchar_t AccountName[MAX_ACCOUNT_NAME_LEN + 1]; // Account name 277 }; 278 279 // Change the account name 280 struct RPC_RENAME_ACCOUNT 281 { 282 wchar_t OldName[MAX_ACCOUNT_NAME_LEN + 1]; // Old name 283 wchar_t NewName[MAX_ACCOUNT_NAME_LEN + 1]; // New Name 284 }; 285 286 // Get the account 287 struct RPC_CLIENT_GET_ACCOUNT 288 { 289 wchar_t AccountName[MAX_ACCOUNT_NAME_LEN + 1]; // Account name 290 CLIENT_OPTION *ClientOption; // Client Option 291 CLIENT_AUTH *ClientAuth; // Client authentication data 292 bool StartupAccount; // Startup account 293 bool CheckServerCert; // Check the server certificate 294 bool RetryOnServerCert; // Retry on invalid server certificate 295 X *ServerCert; // Server certificate 296 UCHAR ShortcutKey[SHA1_SIZE]; // Shortcut Key 297 UINT64 CreateDateTime; // Creation date and time (Ver 3.0 or later) 298 UINT64 UpdateDateTime; // Modified date (Ver 3.0 or later) 299 UINT64 LastConnectDateTime; // Last connection date and time (Ver 3.0 or later) 300 }; 301 302 // Connection 303 struct RPC_CLIENT_CONNECT 304 { 305 wchar_t AccountName[MAX_ACCOUNT_NAME_LEN + 1]; // Account name 306 }; 307 308 // Get the Connection status 309 struct RPC_CLIENT_GET_CONNECTION_STATUS 310 { 311 wchar_t AccountName[MAX_ACCOUNT_NAME_LEN + 1]; // Account name 312 bool Active; // Operation flag 313 bool Connected; // Connected flag 314 UINT SessionStatus; // Session status 315 char ServerName[MAX_HOST_NAME_LEN + 1]; // Server name 316 UINT ServerPort; // Port number of the server 317 char ServerProductName[MAX_SIZE]; // Server product name 318 UINT ServerProductVer; // Server product version 319 UINT ServerProductBuild; // Server product build number 320 X *ServerX; // Server certificate 321 X *ClientX; // Client certificate 322 UINT64 StartTime; // Connection start time 323 /* !!! Do not correct the spelling to keep the backward protocol compatibility !!! */ 324 UINT64 FirstConnectionEstablisiedTime; // Connection completion time of the first connection 325 UINT64 CurrentConnectionEstablishTime; // Connection completion time of this connection 326 UINT NumConnectionsEstablished; // Number of connections have been established so far 327 bool HalfConnection; // Half-connection 328 bool QoS; // VoIP / QoS 329 UINT MaxTcpConnections; // Maximum number of the TCP connections 330 UINT NumTcpConnections; // Number of current TCP connections 331 UINT NumTcpConnectionsUpload; // Number of inbound connections 332 UINT NumTcpConnectionsDownload; // Number of outbound connections 333 bool UseEncrypt; // Use of encryption 334 char CipherName[32]; // Cipher algorithm name 335 char ProtocolName[64]; // Protocol name 336 bool UseCompress; // Use of compression 337 bool IsRUDPSession; // R-UDP session 338 char UnderlayProtocol[64]; // Physical communication protocol 339 char ProtocolDetails[256]; // Protocol details 340 bool IsUdpAccelerationEnabled; // The UDP acceleration is enabled 341 bool IsUsingUdpAcceleration; // Using the UDP acceleration function 342 char SessionName[MAX_SESSION_NAME_LEN + 1]; // Session name 343 char ConnectionName[MAX_CONNECTION_NAME_LEN + 1]; // Connection name 344 UCHAR SessionKey[SHA1_SIZE]; // Session key 345 POLICY Policy; // Policy 346 UINT64 TotalSendSize; // Total transmitted data size 347 UINT64 TotalRecvSize; // Total received data size 348 UINT64 TotalSendSizeReal; // Total transmitted data size (no compression) 349 UINT64 TotalRecvSizeReal; // Total received data size (no compression) 350 TRAFFIC Traffic; // Traffic data 351 bool IsBridgeMode; // Bridge Mode 352 bool IsMonitorMode; // Monitor mode 353 UINT VLanId; // VLAN ID 354 }; 355 356 357 // RPC connection 358 struct CLIENT_RPC_CONNECTION 359 { 360 struct CLIENT *Client; // Client 361 bool RpcMode; // True: RPC mode, false: notification mode 362 THREAD *Thread; // Processing thread 363 SOCK *Sock; // Socket 364 }; 365 366 // Client object 367 struct CLIENT 368 { 369 LOCK *lock; // Lock 370 LOCK *lockForConnect; // Lock to be used in the CtConnect 371 REF *ref; // Reference counter 372 CEDAR *Cedar; // Cedar 373 volatile bool Halt; // Halting flag 374 UINT Err; // Error code 375 CFG_RW *CfgRw; // Configuration file R/W 376 LIST *AccountList; // Account list 377 UCHAR EncryptedPassword[SHA1_SIZE]; // Password 378 bool PasswordRemoteOnly; // Password is required only remote access 379 UINT UseSecureDeviceId; // Secure device ID to be used 380 CLIENT_CONFIG Config; // Client Settings 381 LIST *RpcConnectionList; // RPC connection list 382 SOCK *RpcListener; // RPC listener 383 THREAD *RpcThread; // RPC thread 384 LOCK *HelperLock; // Auxiliary lock 385 THREAD *SaverThread; // Saver thread 386 EVENT *SaverHalter; // The event to stop the Saver thread 387 LIST *NotifyCancelList; // Notification event list 388 KEEP *Keep; // Keep Connection 389 LIST *UnixVLanList; // List of virtual LAN cards in UNIX 390 LOG *Logger; // Logger 391 bool DontSavePassword; // Flag for not to save the password 392 ERASER *Eraser; // Eraser 393 SOCKLIST *SockList; // Socket list 394 CM_SETTING *CmSetting; // CM configuration 395 void *GlobalPulse; // Global pulse 396 THREAD *PulseRecvThread; // Pulse reception thread 397 volatile bool HaltPulseThread; // Stop flag for the pulse reception thread 398 bool NoSaveLog; // Do not save the log 399 bool NoSaveConfig; // Do not save the settings 400 INTERNET_SETTING CommonProxySetting; // Common proxy settings 401 void *MsSuspendHandler; // MS suspend handler 402 403 }; 404 405 // Notification to the remote client 406 struct RPC_CLIENT_NOTIFY 407 { 408 UINT NotifyCode; // Code 409 }; 410 411 // Type of notification 412 #define CLIENT_NOTIFY_ACCOUNT_CHANGED 1 // Account change notification 413 #define CLIENT_NOTIFY_VLAN_CHANGED 2 // Virtual LAN card change notification 414 415 // Remote client 416 struct REMOTE_CLIENT 417 { 418 RPC *Rpc; 419 UINT OsType; 420 bool Unix; 421 UINT ProcessId; 422 UINT ClientBuildInt; 423 bool IsVgcSupported; 424 bool ShowVgcLink; 425 char ClientId[128]; 426 }; 427 428 // Notification client 429 struct NOTIFY_CLIENT 430 { 431 SOCK *Sock; 432 }; 433 434 // CM configuration 435 struct CM_SETTING 436 { 437 bool EasyMode; // Simple mode 438 bool LockMode; // Setting lock mode 439 UCHAR HashedPassword[SHA1_SIZE]; // Password 440 }; 441 442 443 444 445 // Function prototype 446 REMOTE_CLIENT *CcConnectRpc(char *server_name, char *password, bool *bad_pass, bool *no_remote, UINT wait_retry); 447 REMOTE_CLIENT *CcConnectRpcEx(char *server_name, char *password, bool *bad_pass, bool *no_remote, UCHAR *key, UINT *key_error_code, bool shortcut_disconnect, UINT wait_retry); 448 UINT CcShortcut(UCHAR *key); 449 UINT CcShortcutDisconnect(UCHAR *key); 450 void CcDisconnectRpc(REMOTE_CLIENT *rc); 451 NOTIFY_CLIENT *CcConnectNotify(REMOTE_CLIENT *rc); 452 void CcDisconnectNotify(NOTIFY_CLIENT *n); 453 void CcStopNotify(NOTIFY_CLIENT *n); 454 bool CcWaitNotify(NOTIFY_CLIENT *n); 455 UINT CcGetClientVersion(REMOTE_CLIENT *r, RPC_CLIENT_VERSION *a); 456 UINT CcSetCmSetting(REMOTE_CLIENT *r, CM_SETTING *a); 457 UINT CcGetCmSetting(REMOTE_CLIENT *r, CM_SETTING *a); 458 UINT CcSetPassword(REMOTE_CLIENT *r, RPC_CLIENT_PASSWORD *pass); 459 UINT CcGetPasswordSetting(REMOTE_CLIENT *r, RPC_CLIENT_PASSWORD_SETTING *a); 460 UINT CcEnumCa(REMOTE_CLIENT *r, RPC_CLIENT_ENUM_CA *e); 461 UINT CcAddCa(REMOTE_CLIENT *r, RPC_CERT *cert); 462 UINT CcDeleteCa(REMOTE_CLIENT *r, RPC_CLIENT_DELETE_CA *p); 463 UINT CcGetCa(REMOTE_CLIENT *r, RPC_GET_CA *get); 464 UINT CcEnumSecure(REMOTE_CLIENT *r, RPC_CLIENT_ENUM_SECURE *e); 465 UINT CcUseSecure(REMOTE_CLIENT *r, RPC_USE_SECURE *sec); 466 UINT CcGetUseSecure(REMOTE_CLIENT *r, RPC_USE_SECURE *sec); 467 UINT CcCreateVLan(REMOTE_CLIENT *r, RPC_CLIENT_CREATE_VLAN *create); 468 UINT CcUpgradeVLan(REMOTE_CLIENT *r, RPC_CLIENT_CREATE_VLAN *create); 469 UINT CcGetVLan(REMOTE_CLIENT *r, RPC_CLIENT_GET_VLAN *get); 470 UINT CcSetVLan(REMOTE_CLIENT *r, RPC_CLIENT_SET_VLAN *set); 471 UINT CcEnumVLan(REMOTE_CLIENT *r, RPC_CLIENT_ENUM_VLAN *e); 472 UINT CcDeleteVLan(REMOTE_CLIENT *r, RPC_CLIENT_CREATE_VLAN *d); 473 UINT CcEnableVLan(REMOTE_CLIENT *r, RPC_CLIENT_CREATE_VLAN *vlan); 474 UINT CcDisableVLan(REMOTE_CLIENT *r, RPC_CLIENT_CREATE_VLAN *vlan); 475 UINT CcCreateAccount(REMOTE_CLIENT *r, RPC_CLIENT_CREATE_ACCOUNT *a); 476 UINT CcEnumAccount(REMOTE_CLIENT *r, RPC_CLIENT_ENUM_ACCOUNT *e); 477 UINT CcDeleteAccount(REMOTE_CLIENT *r, RPC_CLIENT_DELETE_ACCOUNT *a); 478 UINT CcSetAccount(REMOTE_CLIENT *r, RPC_CLIENT_CREATE_ACCOUNT *a); 479 UINT CcGetAccount(REMOTE_CLIENT *r, RPC_CLIENT_GET_ACCOUNT *a); 480 UINT CcRenameAccount(REMOTE_CLIENT *r, RPC_RENAME_ACCOUNT *rename); 481 UINT CcSetClientConfig(REMOTE_CLIENT *r, CLIENT_CONFIG *o); 482 UINT CcGetClientConfig(REMOTE_CLIENT *r, CLIENT_CONFIG *o); 483 UINT CcConnect(REMOTE_CLIENT *r, RPC_CLIENT_CONNECT *connect); 484 UINT CcDisconnect(REMOTE_CLIENT *r, RPC_CLIENT_CONNECT *connect); 485 UINT CcGetAccountStatus(REMOTE_CLIENT *r, RPC_CLIENT_GET_CONNECTION_STATUS *st); 486 UINT CcSetStartupAccount(REMOTE_CLIENT *r, RPC_CLIENT_DELETE_ACCOUNT *a); 487 UINT CcRemoveStartupAccount(REMOTE_CLIENT *r, RPC_CLIENT_DELETE_ACCOUNT *a); 488 UINT CcGetIssuer(REMOTE_CLIENT *r, RPC_GET_ISSUER *a); 489 490 491 void CcSetServiceToForegroundProcess(REMOTE_CLIENT *r); 492 char *CiGetFirstVLan(CLIENT *c); 493 void CiNormalizeAccountVLan(CLIENT *c); 494 495 void CnStart(); 496 void CnListenerProc(THREAD *thread, void *param); 497 498 void CnReleaseSocket(SOCK *s, PACK *p); 499 500 void CnStatusPrinter(SOCK *s, PACK *p); 501 void Win32CnStatusPrinter(SOCK *s, PACK *p); 502 503 void CnConnectErrorDlg(SOCK *s, PACK *p); 504 void Win32CnConnectErrorDlg(SOCK *s, PACK *p); 505 void Win32CnConnectErrorDlgThreadProc(THREAD *thread, void *param); 506 507 void CnPasswordDlg(SOCK *s, PACK *p); 508 void Win32CnPasswordDlg(SOCK *s, PACK *p); 509 void Win32CnPasswordDlgThreadProc(THREAD *thread, void *param); 510 511 void CnMsgDlg(SOCK *s, PACK *p); 512 void Win32CnMsgDlg(SOCK *s, PACK *p); 513 void Win32CnMsgDlgThreadProc(THREAD *thread, void *param); 514 515 void CnNicInfo(SOCK *s, PACK *p); 516 void Win32CnNicInfo(SOCK *s, PACK *p); 517 void Win32CnNicInfoThreadProc(THREAD *thread, void *param); 518 519 void CnCheckCert(SOCK *s, PACK *p); 520 void Win32CnCheckCert(SOCK *s, PACK *p); 521 void Win32CnCheckCertThreadProc(THREAD *thread, void *param); 522 523 void CnExecDriverInstaller(SOCK *s, PACK *p); 524 void Win32CnExecDriverInstaller(SOCK *s, PACK *p); 525 526 bool CnCheckAlreadyExists(bool lock); 527 bool CnIsCnServiceReady(); 528 void CnWaitForCnServiceReady(); 529 530 void CnSecureSign(SOCK *s, PACK *p); 531 532 SOCK *CncConnect(); 533 SOCK *CncConnectEx(UINT timeout); 534 void CncReleaseSocket(); 535 void CncExit(); 536 bool CncExecDriverInstaller(char *arg); 537 SOCK *CncStatusPrinterWindowStart(SESSION *s); 538 void CncStatusPrinterWindowPrint(SOCK *s, wchar_t *str); 539 void CncStatusPrinterWindowStop(SOCK *s); 540 void CncStatusPrinterWindowThreadProc(THREAD *thread, void *param); 541 bool CncConnectErrorDlg(SESSION *session, UI_CONNECTERROR_DLG *dlg); 542 void CncConnectErrorDlgHaltThread(THREAD *thread, void *param); 543 bool CncPasswordDlg(SESSION *session, UI_PASSWORD_DLG *dlg); 544 void CncCheckCert(SESSION *session, UI_CHECKCERT *dlg); 545 void CncCheckCertHaltThread(THREAD *thread, void *param); 546 bool CncSecureSignDlg(SECURE_SIGN *sign); 547 SOCK *CncMsgDlg(UI_MSG_DLG *dlg); 548 void CndMsgDlgFree(SOCK *s); 549 SOCK *CncNicInfo(UI_NICINFO *info); 550 void CncNicInfoFree(SOCK *s); 551 552 void CtStartClient(); 553 void CtStopClient(); 554 void CtReleaseClient(CLIENT *c); 555 bool CtGetClientVersion(CLIENT *c, RPC_CLIENT_VERSION *ver); 556 bool CtGetCmSetting(CLIENT *c, CM_SETTING *s); 557 bool CtSetCmSetting(CLIENT *c, CM_SETTING *s); 558 bool CtSetPassword(CLIENT *c, RPC_CLIENT_PASSWORD *pass); 559 bool CtGetPasswordSetting(CLIENT *c, RPC_CLIENT_PASSWORD_SETTING *a); 560 bool CtEnumCa(CLIENT *c, RPC_CLIENT_ENUM_CA *e); 561 bool CtAddCa(CLIENT *c, RPC_CERT *cert); 562 bool CtDeleteCa(CLIENT *c, RPC_CLIENT_DELETE_CA *p); 563 bool CtGetCa(CLIENT *c, RPC_GET_CA *get); 564 bool CtEnumSecure(CLIENT *c, RPC_CLIENT_ENUM_SECURE *e); 565 bool CtUseSecure(CLIENT *c, RPC_USE_SECURE *sec); 566 bool CtGetUseSecure(CLIENT *c, RPC_USE_SECURE *sec); 567 bool CtEnumObjectInSecure(CLIENT *c, RPC_ENUM_OBJECT_IN_SECURE *e); 568 bool CtCreateVLan(CLIENT *c, RPC_CLIENT_CREATE_VLAN *create); 569 bool CtUpgradeVLan(CLIENT *c, RPC_CLIENT_CREATE_VLAN *create); 570 bool CtGetVLan(CLIENT *c, RPC_CLIENT_GET_VLAN *get); 571 bool CtSetVLan(CLIENT *c, RPC_CLIENT_SET_VLAN *set); 572 bool CtEnumVLan(CLIENT *c, RPC_CLIENT_ENUM_VLAN *e); 573 bool CtDeleteVLan(CLIENT *c, RPC_CLIENT_CREATE_VLAN *d); 574 bool CtEnableVLan(CLIENT *c, RPC_CLIENT_CREATE_VLAN *vlan); 575 bool CtDisableVLan(CLIENT *c, RPC_CLIENT_CREATE_VLAN *vlan); 576 bool CtCreateAccount(CLIENT *c, RPC_CLIENT_CREATE_ACCOUNT *a, bool inner); 577 bool CtEnumAccount(CLIENT *c, RPC_CLIENT_ENUM_ACCOUNT *e); 578 bool CtDeleteAccount(CLIENT *c, RPC_CLIENT_DELETE_ACCOUNT *a, bool inner); 579 bool CtSetAccount(CLIENT *c, RPC_CLIENT_CREATE_ACCOUNT *a, bool inner); 580 bool CtGetAccount(CLIENT *c, RPC_CLIENT_GET_ACCOUNT *a); 581 bool CtRenameAccount(CLIENT *c, RPC_RENAME_ACCOUNT *rename, bool inner); 582 bool CtSetClientConfig(CLIENT *c, CLIENT_CONFIG *o); 583 bool CtGetClientConfig(CLIENT *c, CLIENT_CONFIG *o); 584 bool CtConnect(CLIENT *c, RPC_CLIENT_CONNECT *connect); 585 bool CtDisconnect(CLIENT *c, RPC_CLIENT_CONNECT *connect, bool inner); 586 bool CtGetAccountStatus(CLIENT *c, RPC_CLIENT_GET_CONNECTION_STATUS *st); 587 bool CtSetStartupAccount(CLIENT *c, RPC_CLIENT_DELETE_ACCOUNT *a, bool inner); 588 bool CtRemoveStartupAccount(CLIENT *c, RPC_CLIENT_DELETE_ACCOUNT *a); 589 bool CtGetIssuer(CLIENT *c, RPC_GET_ISSUER *a); 590 bool CtGetCommonProxySetting(CLIENT *c, INTERNET_SETTING *a); 591 bool CtSetCommonProxySetting(CLIENT *c, INTERNET_SETTING *a); 592 593 594 // Internal function prototype 595 void CiSendGlobalPulse(CLIENT *c); 596 void CiPulseRecvThread(THREAD *thread, void *param); 597 void CiServerThread(THREAD *t, void *param); 598 void CiInitSaver(CLIENT *c); 599 void CiFreeSaver(CLIENT *c); 600 void CiGetSessionStatus(RPC_CLIENT_GET_CONNECTION_STATUS *st, SESSION *s); 601 PACK *CiRpcDispatch(RPC *rpc, char *name, PACK *p); 602 void CiRpcAccepted(CLIENT *c, SOCK *s); 603 void CiNotifyMain(CLIENT *c, SOCK *s); 604 void CiRpcAcceptThread(THREAD *thread, void *param); 605 void CiRpcServerThread(THREAD *thread, void *param); 606 void CiStartRpcServer(CLIENT *c); 607 void CiStopRpcServer(CLIENT *c); 608 CLIENT_OPTION *CiLoadClientOption(FOLDER *f); 609 CLIENT_AUTH *CiLoadClientAuth(FOLDER *f); 610 ACCOUNT *CiLoadClientAccount(FOLDER *f); 611 void CiLoadClientConfig(CLIENT_CONFIG *c, FOLDER *f); 612 void CiLoadAccountDatabase(CLIENT *c, FOLDER *f); 613 void CiLoadCAList(CLIENT *c, FOLDER *f); 614 void CiLoadCACert(CLIENT *c, FOLDER *f); 615 void CiLoadVLanList(CLIENT *c, FOLDER *f); 616 void CiLoadVLan(CLIENT *c, FOLDER *f); 617 bool CiReadSettingFromCfg(CLIENT *c, FOLDER *root); 618 void CiWriteAccountDatabase(CLIENT *c, FOLDER *f); 619 void CiWriteAccountData(FOLDER *f, ACCOUNT *a); 620 void CiWriteClientOption(FOLDER *f, CLIENT_OPTION *o); 621 void CiWriteClientAuth(FOLDER *f, CLIENT_AUTH *a); 622 void CiWriteClientConfig(FOLDER *cc, CLIENT_CONFIG *config); 623 void CiWriteSettingToCfg(CLIENT *c, FOLDER *root); 624 void CiWriteCAList(CLIENT *c, FOLDER *f); 625 void CiWriteCACert(CLIENT *c, FOLDER *f, X *x); 626 void CiWriteVLanList(CLIENT *c, FOLDER *f); 627 void CiWriteVLan(CLIENT *c, FOLDER *f, UNIX_VLAN *v); 628 void CiFreeClientGetConnectionStatus(RPC_CLIENT_GET_CONNECTION_STATUS *st); 629 bool CiCheckCertProc(SESSION *s, CONNECTION *c, X *server_x, bool *expired); 630 bool CiSecureSignProc(SESSION *s, CONNECTION *c, SECURE_SIGN *sign); 631 bool Win32CiSecureSign(SECURE_SIGN *sign); 632 void CiFreeClientAuth(CLIENT_AUTH *auth); 633 void CiFreeClientCreateAccount(RPC_CLIENT_CREATE_ACCOUNT *a); 634 void CiFreeClientGetAccount(RPC_CLIENT_GET_ACCOUNT *a); 635 void CiFreeClientEnumVLan(RPC_CLIENT_ENUM_VLAN *e); 636 void CiFreeClientEnumSecure(RPC_CLIENT_ENUM_SECURE *e); 637 void CiFreeClientEnumCa(RPC_CLIENT_ENUM_CA *e); 638 void CiFreeEnumObjectInSecure(RPC_ENUM_OBJECT_IN_SECURE *a); 639 void CiFreeGetCa(RPC_GET_CA *a); 640 void CiFreeGetIssuer(RPC_GET_ISSUER *a); 641 void CiFreeClientEnumAccount(RPC_CLIENT_ENUM_ACCOUNT *a); 642 void CiSetError(CLIENT *c, UINT err); 643 CLIENT *CiNewClient(); 644 void CiCleanupClient(CLIENT *c); 645 bool CiLoadConfigurationFile(CLIENT *c); 646 void CiSaveConfigurationFile(CLIENT *c); 647 void CiInitConfiguration(CLIENT *c); 648 void CiSetVLanToDefault(CLIENT *c); 649 bool CiIsVLan(CLIENT *c, char *name); 650 void CiFreeConfiguration(CLIENT *c); 651 int CiCompareAccount(void *p1, void *p2); 652 void CiFreeAccount(ACCOUNT *a); 653 void CiNotify(CLIENT *c); 654 void CiNotifyInternal(CLIENT *c); 655 void CiClientStatusPrinter(SESSION *s, wchar_t *status); 656 void CiInitKeep(CLIENT *c); 657 void CiFreeKeep(CLIENT *c); 658 int CiCompareUnixVLan(void *p1, void *p2); 659 BUF *CiAccountToCfg(RPC_CLIENT_CREATE_ACCOUNT *t); 660 RPC_CLIENT_CREATE_ACCOUNT *CiCfgToAccount(BUF *b); 661 void CiChangeAllVLanMacAddressIfCleared(CLIENT *c); 662 void CiChangeAllVLanMacAddress(CLIENT *c); 663 void CiChangeAllVLanMacAddressIfMachineChanged(CLIENT *c); 664 bool CiReadLastMachineHash(void *data); 665 bool CiWriteLastMachineHash(void *data); 666 void CiGetCurrentMachineHash(void *data); 667 void CiGetCurrentMachineHashOld(void *data); 668 void CiGetCurrentMachineHashNew(void *data); 669 LIST *CiLoadIni(); 670 void CiFreeIni(LIST *o); 671 void CiLoadIniSettings(CLIENT *c); 672 bool CiLoadConfigFilePathFromIni(char *path, UINT size); 673 int CiCompareClientAccountEnumItemByLastConnectDateTime(void *p1, void *p2); 674 bool CiIsValidVLanRegulatedName(char *name); 675 void CiGenerateVLanRegulatedName(char *name, UINT size, UINT i); 676 bool CiGetNextRecommendedVLanName(REMOTE_CLIENT *r, char *name, UINT size); 677 void CiDisableWcmNetworkMinimize(CLIENT *c); 678 bool CiTryToParseAccount(BUF *b); 679 bool CiTryToParseAccountFile(wchar_t *name); 680 bool CiEraseSensitiveInAccount(BUF *b); 681 bool CiHasAccountSensitiveInformation(BUF *b); 682 void CiApplyInnerVPNServerConfig(CLIENT *c); 683 void CiIncrementNumActiveSessions(); 684 void CiDecrementNumActiveSessions(); 685 686 BUF *EncryptPassword(char *password); 687 BUF *EncryptPassword2(char *password); 688 char *DecryptPassword(BUF *b); 689 char *DecryptPassword2(BUF *b); 690 691 void InRpcGetIssuer(RPC_GET_ISSUER *c, PACK *p); 692 void OutRpcGetIssuer(PACK *p, RPC_GET_ISSUER *c); 693 void InRpcClientVersion(RPC_CLIENT_VERSION *ver, PACK *p); 694 void OutRpcClientVersion(PACK *p, RPC_CLIENT_VERSION *ver); 695 void InRpcClientPassword(RPC_CLIENT_PASSWORD *pw, PACK *p); 696 void OutRpcClientPassword(PACK *p, RPC_CLIENT_PASSWORD *pw); 697 void InRpcClientEnumCa(RPC_CLIENT_ENUM_CA *e, PACK *p); 698 void OutRpcClientEnumCa(PACK *p, RPC_CLIENT_ENUM_CA *e); 699 void InRpcCert(RPC_CERT *c, PACK *p); 700 void OutRpcCert(PACK *p, RPC_CERT *c); 701 void InRpcClientDeleteCa(RPC_CLIENT_DELETE_CA *c, PACK *p); 702 void OutRpcClientDeleteCa(PACK *p, RPC_CLIENT_DELETE_CA *c); 703 void InRpcGetCa(RPC_GET_CA *c, PACK *p); 704 void OutRpcGetCa(PACK *p, RPC_GET_CA *c); 705 void InRpcClientEnumSecure(RPC_CLIENT_ENUM_SECURE *e, PACK *p); 706 void OutRpcClientEnumSecure(PACK *p, RPC_CLIENT_ENUM_SECURE *e); 707 void InRpcUseSecure(RPC_USE_SECURE *u, PACK *p); 708 void OutRpcUseSecure(PACK *p, RPC_USE_SECURE *u); 709 void OutRpcEnumObjectInSecure(PACK *p, RPC_ENUM_OBJECT_IN_SECURE *e); 710 void InRpcCreateVLan(RPC_CLIENT_CREATE_VLAN *v, PACK *p); 711 void OutRpcCreateVLan(PACK *p, RPC_CLIENT_CREATE_VLAN *v); 712 void InRpcClientGetVLan(RPC_CLIENT_GET_VLAN *v, PACK *p); 713 void OutRpcClientGetVLan(PACK *p, RPC_CLIENT_GET_VLAN *v); 714 void InRpcClientSetVLan(RPC_CLIENT_SET_VLAN *v, PACK *p); 715 void OutRpcClientSetVLan(PACK *p, RPC_CLIENT_SET_VLAN *v); 716 void InRpcClientEnumVLan(RPC_CLIENT_ENUM_VLAN *v, PACK *p); 717 void OutRpcClientEnumVLan(PACK *p, RPC_CLIENT_ENUM_VLAN *v); 718 void InRpcClientOption(CLIENT_OPTION *c, PACK *p); 719 void OutRpcClientOption(PACK *p, CLIENT_OPTION *c); 720 void InRpcClientAuth(CLIENT_AUTH *c, PACK *p); 721 void OutRpcClientAuth(PACK *p, CLIENT_AUTH *c); 722 void InRpcClientCreateAccount(RPC_CLIENT_CREATE_ACCOUNT *c, PACK *p); 723 void OutRpcClientCreateAccount(PACK *p, RPC_CLIENT_CREATE_ACCOUNT *c); 724 void InRpcClientEnumAccount(RPC_CLIENT_ENUM_ACCOUNT *e, PACK *p); 725 void OutRpcClientEnumAccount(PACK *p, RPC_CLIENT_ENUM_ACCOUNT *e); 726 void InRpcClientDeleteAccount(RPC_CLIENT_DELETE_ACCOUNT *a, PACK *p); 727 void OutRpcClientDeleteAccount(PACK *p, RPC_CLIENT_DELETE_ACCOUNT *a); 728 void InRpcRenameAccount(RPC_RENAME_ACCOUNT *a, PACK *p); 729 void OutRpcRenameAccount(PACK *p, RPC_RENAME_ACCOUNT *a); 730 void InRpcClientGetAccount(RPC_CLIENT_GET_ACCOUNT *c, PACK *p); 731 void OutRpcClientGetAccount(PACK *p, RPC_CLIENT_GET_ACCOUNT *c); 732 void InRpcClientConnect(RPC_CLIENT_CONNECT *c, PACK *p); 733 void OutRpcClientConnect(PACK *p, RPC_CLIENT_CONNECT *c); 734 void InRpcPolicy(POLICY *o, PACK *p); 735 void OutRpcPolicy(PACK *p, POLICY *o); 736 void InRpcClientGetConnectionStatus(RPC_CLIENT_GET_CONNECTION_STATUS *s, PACK *p); 737 void OutRpcClientGetConnectionStatus(PACK *p, RPC_CLIENT_GET_CONNECTION_STATUS *c); 738 void InRpcClientConfig(CLIENT_CONFIG *c, PACK *p); 739 void OutRpcClientConfig(PACK *p, CLIENT_CONFIG *c); 740 void InRpcClientPasswordSetting(RPC_CLIENT_PASSWORD_SETTING *a, PACK *p); 741 void OutRpcClientPasswordSetting(PACK *p, RPC_CLIENT_PASSWORD_SETTING *a); 742 void InRpcTraffic(TRAFFIC *t, PACK *p); 743 void OutRpcTraffic(PACK *p, TRAFFIC *t); 744 void InRpcTrafficEx(TRAFFIC *t, PACK *p, UINT i); 745 void OutRpcTrafficEx(TRAFFIC *t, PACK *p, UINT i, UINT num); 746 void OutRpcCmSetting(PACK *p, CM_SETTING *c); 747 void InRpcCmSetting(CM_SETTING *c, PACK *p); 748 749 #ifdef OS_WIN32 750 typedef struct MS_DRIVER_VER MS_DRIVER_VER; 751 void CiInitDriverVerStruct(MS_DRIVER_VER *ver); 752 #endif // OS_EIN32 753 754 #endif // CLIENT_H 755