1 // SoftEther VPN Source Code - Developer Edition Master Branch 2 // Cedar Communication Module 3 4 5 // EtherLog.h 6 // Header of EtherLog.c 7 8 #ifndef ETHERLOG_H 9 #define ETHERLOG_H 10 11 #include "Hub.h" 12 13 // Whether this is a beta version 14 #define ELOG_IS_BETA true 15 16 // Beta expiration date 17 #define ELOG_BETA_EXPIRES_YEAR 2008 18 #define ELOG_BETA_EXPIRES_MONTH 12 19 #define ELOG_BETA_EXPIRES_DAY 2 20 21 // Version information 22 //#define EL_VER 201 23 //#define EL_BUILD 1600 24 //#define EL_BETA 1 25 #define MAX_LOGGING_QUEUE_LEN 100000 26 27 // RPC related 28 struct RPC_ADD_DEVICE 29 { 30 char DeviceName[MAX_SIZE]; // Device name 31 HUB_LOG LogSetting; // Log settings 32 bool NoPromiscuous; // Without promiscuous mode 33 }; 34 35 struct RPC_DELETE_DEVICE 36 { 37 char DeviceName[MAX_SIZE]; // Device name 38 }; 39 40 struct RPC_ENUM_DEVICE_ITEM 41 { 42 char DeviceName[MAX_SIZE]; // Device name 43 bool Active; // Running flag 44 }; 45 46 struct RPC_ENUM_DEVICE 47 { 48 UINT NumItem; // Number of items 49 RPC_ENUM_DEVICE_ITEM *Items; // Items 50 bool IsLicenseSupported; // Whether the license system is supported 51 }; 52 53 // License status of the service 54 struct RPC_EL_LICENSE_STATUS 55 { 56 bool Valid; // Enable flag 57 UINT64 SystemId; // System ID 58 UINT64 SystemExpires; // System expiration date 59 }; 60 61 // Device 62 struct EL_DEVICE 63 { 64 EL *el; // EL 65 char DeviceName[MAX_SIZE]; // Device name 66 HUB_LOG LogSetting; // Log settings 67 THREAD *Thread; // Thread 68 CANCEL *Cancel1; // Cancel 1 69 CANCEL *Cancel2; // Cancel 2 70 volatile bool Halt; // Halting flag 71 bool Active; // Running flag 72 bool NoPromiscuous; // Without promiscuous mode 73 LOG *Logger; // Logger 74 }; 75 76 // License status 77 struct EL_LICENSE_STATUS 78 { 79 bool Valid; // Enable flag 80 UINT64 SystemId; // System ID 81 UINT64 Expires; // Expiration date 82 }; 83 84 // EtherLogger 85 struct EL 86 { 87 LOCK *lock; // Lock 88 REF *ref; // Reference counter 89 CEDAR *Cedar; // Cedar 90 LIST *DeviceList; // Device list 91 CFG_RW *CfgRw; // Config R/W 92 UINT Port; // Port number 93 LISTENER *Listener; // Listener 94 UCHAR HashedPassword[SHA1_SIZE]; // Password 95 LIST *AdminThreadList; // Management thread list 96 LIST *AdminSockList; // Management socket list 97 LICENSE_SYSTEM *LicenseSystem; // License system 98 EL_LICENSE_STATUS *LicenseStatus; // License status 99 UINT64 AutoDeleteCheckDiskFreeSpaceMin; // Minimum free disk space 100 ERASER *Eraser; // Eraser 101 }; 102 103 // Function prototype 104 void ElStart(); 105 void ElStop(); 106 EL *NewEl(); 107 void ReleaseEl(EL *e); 108 void CleanupEl(EL *e); 109 void ElInitConfig(EL *e); 110 void ElFreeConfig(EL *e); 111 bool ElLoadConfig(EL *e); 112 void ElLoadConfigFromFolder(EL *e, FOLDER *root); 113 void ElSaveConfig(EL *e); 114 void ElSaveConfigToFolder(EL *e, FOLDER *root); 115 int ElCompareDevice(void *p1, void *p2); 116 bool ElAddCaptureDevice(EL *e, char *name, HUB_LOG *log, bool no_promiscuous); 117 bool ElDeleteCaptureDevice(EL *e, char *name); 118 bool ElSetCaptureDeviceLogSetting(EL *e, char *name, HUB_LOG *log); 119 void ElCaptureThread(THREAD *thread, void *param); 120 void ElStartListener(EL *e); 121 void ElStopListener(EL *e); 122 void ElListenerProc(THREAD *thread, void *param); 123 PACK *ElRpcServer(RPC *r, char *name, PACK *p); 124 void ElParseCurrentLicenseStatus(LICENSE_SYSTEM *s, EL_LICENSE_STATUS *st); 125 bool ElIsBetaExpired(); 126 127 128 UINT EtAddDevice(EL *e, RPC_ADD_DEVICE *t); 129 UINT EtDelDevice(EL *e, RPC_DELETE_DEVICE *t); 130 UINT EtSetDevice(EL *e, RPC_ADD_DEVICE *t); 131 UINT EtGetDevice(EL *e, RPC_ADD_DEVICE *t); 132 UINT EtEnumDevice(EL *e, RPC_ENUM_DEVICE *t); 133 UINT EtEnumAllDevice(EL *e, RPC_ENUM_DEVICE *t); 134 UINT EtSetPassword(EL *e, RPC_SET_PASSWORD *t); 135 UINT EtAddLicenseKey(EL *a, RPC_TEST *t); 136 UINT EtDelLicenseKey(EL *a, RPC_TEST *t); 137 UINT EtEnumLicenseKey(EL *a, RPC_ENUM_LICENSE_KEY *t); 138 UINT EtGetLicenseStatus(EL *a, RPC_EL_LICENSE_STATUS *t); 139 UINT EtGetBridgeSupport(EL *a, RPC_BRIDGE_SUPPORT *t); 140 UINT EtRebootServer(EL *a, RPC_TEST *t); 141 142 UINT EcAddDevice(RPC *r, RPC_ADD_DEVICE *t); 143 UINT EcDelDevice(RPC *r, RPC_DELETE_DEVICE *t); 144 UINT EcSetDevice(RPC *r, RPC_ADD_DEVICE *t); 145 UINT EcGetDevice(RPC *r, RPC_ADD_DEVICE *t); 146 UINT EcEnumDevice(RPC *r, RPC_ENUM_DEVICE *t); 147 UINT EcEnumAllDevice(RPC *r, RPC_ENUM_DEVICE *t); 148 UINT EcSetPassword(RPC *r, RPC_SET_PASSWORD *t); 149 UINT EcDelLicenseKey(RPC *r, RPC_TEST *t); 150 UINT EcEnumLicenseKey(RPC *r, RPC_ENUM_LICENSE_KEY *t); 151 UINT EcGetLicenseStatus(RPC *r, RPC_EL_LICENSE_STATUS *t); 152 UINT EcGetBridgeSupport(RPC *r, RPC_BRIDGE_SUPPORT *t); 153 UINT EcRebootServer(RPC *r, RPC_TEST *t); 154 155 UINT EcConnect(char *host, UINT port, char *password, RPC **rpc); 156 void EcDisconnect(RPC *rpc); 157 158 void InRpcAddDevice(RPC_ADD_DEVICE *t, PACK *p); 159 void OutRpcAddDevice(PACK *p, RPC_ADD_DEVICE *t); 160 void InRpcDeleteDevice(RPC_DELETE_DEVICE *t, PACK *p); 161 void OutRpcDeleteDevice(PACK *p, RPC_DELETE_DEVICE *t); 162 void InRpcEnumDevice(RPC_ENUM_DEVICE *t, PACK *p); 163 void OutRpcEnumDevice(PACK *p, RPC_ENUM_DEVICE *t); 164 void FreeRpcEnumDevice(RPC_ENUM_DEVICE *t); 165 void InRpcEnumLicenseKey(RPC_ENUM_LICENSE_KEY *t, PACK *p); 166 void OutRpcEnumLicenseKey(PACK *p, RPC_ENUM_LICENSE_KEY *t); 167 void FreeRpcEnumLicenseKey(RPC_ENUM_LICENSE_KEY *t); 168 void InRpcElLicenseStatus(RPC_EL_LICENSE_STATUS *t, PACK *p); 169 void OutRpcElLicenseStatus(PACK *p, RPC_EL_LICENSE_STATUS *t); 170 171 #endif // ETHERLOG_H 172 173 174