Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

477 lines
16 KiB

  1. //+--------------------------------------------------------------------------
  2. //
  3. // Copyright (c) 1997-1999 Microsoft Corporation
  4. //
  5. // File : srvdef.h
  6. //
  7. // Contents:
  8. //
  9. // History:
  10. //
  11. //---------------------------------------------------------------------------
  12. #ifndef __TLSERVER_DEF_H__
  13. #define __TLSERVER_DEF_H__
  14. #include "ntverp.h"
  15. //----------------------------------------------
  16. // #define TLS_CURRENT_VERSION (MAKELONG(0, HIBYTE(VER_PRODUCTVERSION_W)))
  17. //
  18. // Bit 31 - 1 if enterprise server, 0 if domain/workgroup license server
  19. // Bit 30 - 1 if enforce license server, 0 if non-enforce.
  20. // Bit 29 - 1 if RTM version, 0 if beta
  21. //
  22. #if defined(ENFORCE_LICENSING)
  23. #define TLS_ENFORCE_VERSION 0x4000
  24. #else
  25. #define TLS_ENFORCE_VERSION 0x0000
  26. #endif
  27. #define TLS_RTM_VERSION 0x2000
  28. //-----------------------------------------------------------------
  29. //
  30. // License Server Version
  31. //
  32. // 5.0 W2K license server version.
  33. // 5.1 Add LKP replication.
  34. // 5.2 Post W2K Beta 3 check in.
  35. // 5.3 Turn on enforce build, TLSAPI enumeration will skip 5.2 non-enforce
  36. // 5.4 Depends on platform challenge response from client, issue long or short cert cain
  37. //
  38. #define TLS_MINOR_VERSION 0x04
  39. #define TLS_CURRENT_VERSION (MAKELONG(MAKEWORD(TLS_MINOR_VERSION, HIBYTE(VER_PRODUCTVERSION_W)), TLS_ENFORCE_VERSION))
  40. #define TLS_CURRENT_VERSION_RTM (MAKELONG(MAKEWORD(TLS_MINOR_VERSION, HIBYTE(VER_PRODUCTVERSION_W)), TLS_ENFORCE_VERSION | TLS_RTM_VERSION))
  41. #define GET_SERVER_MAJOR_VERSION(version) HIBYTE(LOWORD(version))
  42. #define GET_SERVER_MINOR_VERSION(version) LOBYTE(LOWORD(version))
  43. #define IS_ENTERPRISE_SERVER(version) ((version & TLS_VERSION_ENTERPRISE_BIT) > 0)
  44. #define IS_ENFORCE_SERVER(version) \
  45. ((version & 0x40000000) > 0)
  46. //----------------------------------------------
  47. //
  48. // Service Manager Error Code
  49. //
  50. //----------------------------------------------
  51. //#define TLS_E_SERVICE_STARTUP_GENERAL 0x1
  52. //#define TLS_E_SERVICE_STARTUP_CREATE_THREAD 0x2
  53. //#define TLS_E_SERVICE_STARTUP_REPORT_SCM 0x3
  54. //#define TLS_E_SERVICE_STARTUP_RPC_THREAD_ERROR 0x4
  55. //#define TLS_E_SERVICE_STARTUP_INIT_THREAD_ERROR 0x5
  56. //#define TLS_E_SERVICE_STARTUP_POST_INIT 0x6
  57. //#define TLS_E_SERVICE_RPC_LISTEN 0x7
  58. //#define TLS_E_SERVICE_LOAD_POLICY 0x8
  59. //#define TLS_I_SERVICE_WARNING 0x9
  60. #define SET_JB_ERROR(err) (TLS_E_JB_BASE | abs(err))
  61. #define IS_JB_ERROR(err) ((err & (FACILITY_JETBLUE_BASE << 16)))
  62. // JetBlue error code are in negative
  63. #define GET_JB_ERROR_CODE(err) (-((LONG)(err & ~(FACILITY_JETBLUE_BASE << 16))))
  64. #ifndef USE_MULTIPLE_WORKSPACE
  65. #define ALLOCATEDBHANDLE(stmt, timeout) \
  66. AcquireRPCExclusiveLock(timeout) \
  67. #define FREEDBHANDLE(stmt) \
  68. g_DbWorkSpace->Cleanup(); \
  69. ReleaseRPCExclusiveLock()
  70. #define BEGIN_TRANSACTION(stmt) \
  71. g_DbWorkSpace->BeginTransaction();
  72. #define COMMIT_TRANSACTION(stmt) \
  73. g_DbWorkSpace->CommitTransaction();
  74. #define ROLLBACK_TRANSACTION(stmt) \
  75. g_DbWorkSpace->RollbackTransaction();
  76. #define CLEANUPSTMT \
  77. g_DbWorkSpace->Cleanup()
  78. #define USEHANDLE(stmt) \
  79. g_DbWorkSpace
  80. #define RPCCALL_LOCK(timeout) \
  81. AcquireRPCExclusiveLock(timeout)
  82. #define RPCCALL_UNLOCK \
  83. ReleaseRPCExclusiveLock()
  84. #else
  85. //
  86. // Not tested yet!!!
  87. //
  88. #define ALLOCATEDBHANDLE(pStmt, timeout) \
  89. pStmt = AllocateWorkSpace(timeout)
  90. #define FREEDBHANDLE(pStmt) \
  91. pStmt->Cleanup(); \
  92. ReleaseWorkSpace(pStmt);
  93. #define BEGIN_TRANSACTION(pStmt) \
  94. pStmt->BeginTransaction();
  95. #define COMMIT_TRANSACTION(pStmt) \
  96. pStmt->CommitTransaction();
  97. #define ROLLBACK_TRANSACTION(pStmt) \
  98. pStmt->RollbackTransaction();
  99. #define CLEANUPSTMT \
  100. pStmt->Cleanup()
  101. #define USEHANDLE(pStmt) \
  102. pStmt
  103. #define RPCCALL_LOCK(timeout) \
  104. AcquireRPCExclusiveLock(timeout)
  105. #define RPCCALL_UNLOCK \
  106. ReleaseRPCExclusiveLock()
  107. #endif
  108. //----------------------------------------------------------------------
  109. //
  110. //
  111. #ifndef SPC_CERT_EXTENSIONS_OBJID
  112. #define SPC_CERT_EXTENSIONS_OBJID "1.3.6.1.4.1.311.2.1.14"
  113. #endif
  114. //---------------------------------------------------------------------------
  115. // Server specified Registry Entry
  116. //
  117. #define LSERVER_REGISTRY_BASE _TEXT("SYSTEM\\CurrentControlSet\\Services\\")
  118. #define LSERVER_PARAMETERS _TEXT("Parameters")
  119. #define LSERVER_PARAMETERS_SCOPE _TEXT("Scope")
  120. #define LSERVER_PARAMETERS_DBPATH _TEXT("DBPath") // database file
  121. #define LSERVER_PARAMETERS_DBFILE _TEXT("DBFile") // database file
  122. #define LSERVER_PARAMETERS_USER _TEXT("User")
  123. #define LSERVER_PARAMETERS_PWD _TEXT("Pwd")
  124. #define LSERVER_PARAMETERS_LOGLEVEL _TEXT("Log Level")
  125. #define LSERVER_PARAMETERS_CONSOLE _TEXT("Console")
  126. #define LSERVER_PARAMETERS_ROLE _TEXT("Role")
  127. #define LSERVER_PARAMETERS_ESENTMAXCACHESIZE _TEXT("MaxCacheSize")
  128. #define LSERVER_PARAMETERS_ESENTSTARTFLUSH _TEXT("StartFlushThreshold")
  129. #define LSERVER_PARAMETERS_ESENTSTOPFLUSH _TEXT("StopFlushThreshold")
  130. #define LSERVER_PARAMETERS_LEASE_MIN _TEXT("LeaseMinimum")
  131. #define LSERVER_PARAMETERS_LEASE_RANGE _TEXT("LeaseRange")
  132. #define LSERVER_PARAMETERS_LEASE_LEEWAY _TEXT("LeaseLeeway")
  133. #define LSERVER_PARAMETERS_EXPIRE_THREAD_SLEEP _TEXT("ExpireThreadSleep")
  134. //
  135. // JET_paramCacheSizeMax is expressed in pages,
  136. // default 4K per page.
  137. //
  138. #define LSERVER_PARAMETERS_ESENTMAXCACHESIZE_DEFAULT 256
  139. //#define LSERVER_PARAMETERS_ESENTMINCACHESIZE_DEFAULT 16
  140. #define LSERVER_PARAMETERS_ESENTSTARTFLUSH_DEFAULT 100
  141. #define LSERVER_PARAMETERS_ESENTSTOPFLUSH_DEFAULT 200
  142. #define LSERVER_PARAMETERS_ESENTMAXCACHESIZE_MAX 512
  143. #define LSERVER_PARAMETERS_ESENTSTARTFLUSH_MAX 100
  144. #define LSERVER_PARAMETERS_ESENTSTOPFLUSH_MAX 400
  145. #define LSERVER_PARAMETERS_ESENTMAXCACHESIZE_MIN 64
  146. #define LSERVER_PARAMETERS_ESENTSTARTFLUSH_MIN 16
  147. #define LSERVER_PARAMETERS_ESENTSTOPFLUSH_MIN 32
  148. //
  149. // MaxCacheSize is set to 0xFFFFFFFF, we just let ESENT pick its number
  150. //
  151. #define LSERVER_PARAMETERS_USE_ESENTDEFAULT 0xFFFFFFFF
  152. #define LSERVER_PARAMETERS_KEY \
  153. LSERVER_REGISTRY_BASE _TEXT(SZSERVICENAME) _TEXT("\\") LSERVER_PARAMETERS
  154. #define LSERVER_SECRET _TEXT("Security")
  155. #define LSERVER_SECRET_KEY _TEXT("Secret Key")
  156. #define LSERVER_SIGNATURE_CERTIFICATE_KEY _TEXT("Signature Certificate")
  157. #define LSERVER_EXCHANGE_CERTIFICATE_KEY _TEXT("Exchange Certificate")
  158. #define LSERVER_LSA_PRIVATEKEY_SIGNATURE _TEXT("TermServLiceningSignKey-12d4b7c8-77d5-11d1-8c24-00c04fa3080d")
  159. #define LSERVER_LSA_PRIVATEKEY_EXCHANGE _TEXT("TermServLicensingExchKey-12d4b7c8-77d5-11d1-8c24-00c04fa3080d")
  160. #define LSERVER_LSA_LSERVERID _TEXT("TermServLicensingServerId-12d4b7c8-77d5-11d1-8c24-00c04fa3080d")
  161. #define TLSERVER_SERVER_ID_VERSION 0x00010001
  162. typedef struct _TlsLsaServerId {
  163. DWORD dwVersion; // structure version
  164. DWORD dwUniqueId; // TLServer 5 digit unique ID
  165. DWORD dwServerPid; // TLServer PID
  166. DWORD dwServerSPK; // TLServer's SPK if any.
  167. DWORD dwExtensions; // Size of encoded certificate entension.
  168. BYTE pbVariableStart[1]; // UniqueId follow by ServerPid then ServerSPK.
  169. } TLSLSASERVERID, *PTLSLSASERVERID, *LPTLSLSASERVERID;
  170. //----------------------------------------------------------------------
  171. //
  172. // Registry key for License Server certificate issued by CA
  173. //
  174. //----------------------------------------------------------------------
  175. #define LSERVER_SOFTWARE_REGBASE \
  176. _TEXT("SOFTWARE\\Microsoft\\") _TEXT(SZSERVICENAME)
  177. #define LSERVER_CERTIFICATE_STORE _TEXT("Certificates")
  178. #define LSERVER_CERTIFICATE_STORE_BACKUP1 _TEXT("Certificates.000")
  179. #define LSERVER_CERTIFICATE_STORE_BACKUP2 _TEXT("Certificates.001")
  180. #define LSERVER_SELFSIGN_CERTIFICATE_REGKEY \
  181. LSERVER_REGISTRY_BASE _TEXT(SZSERVICENAME) _TEXT("\\") LSERVER_SECRET
  182. #define LSERVER_SERVER_CERTIFICATE_REGKEY \
  183. LSERVER_SOFTWARE_REGBASE _TEXT("\\") LSERVER_CERTIFICATE_STORE
  184. #define LSERVER_SERVER_CERTIFICATE_REGKEY_BACKUP1 \
  185. LSERVER_PARAMETERS_KEY _TEXT("\\") LSERVER_CERTIFICATE_STORE_BACKUP1
  186. #define LSERVER_SERVER_CERTIFICATE_REGKEY_BACKUP2 \
  187. LSERVER_PARAMETERS_KEY _TEXT("\\") LSERVER_CERTIFICATE_STORE_BACKUP2
  188. #define LSERVER_PARAMETERS_GRACEPERIOD _TEXT("GracePeriod")
  189. #define LSERVER_PARAMETERS_LOWLICENSEWARNING _TEXT("Low License Warning")
  190. #define LSERVER_PARAMETERS_ISSUETEMPLICENSE _TEXT("IssueTemporaryLicenses")
  191. #define LSERVER_PARAMETERS_WORKINTERVAL _TEXT("DefaultJobInterval")
  192. #define LSERVER_PARAMETERS_RETRYTIMES _TEXT("DefaultJobRetryTimes")
  193. #define LSERVER_PARAMETERS_WORKRESTART _TEXT("DefaultJobRestartTime")
  194. #define LSERVER_CLIENT_CERTIFICATE_ISSUER _TEXT("Parm0")
  195. #define LSERVER_SIGNATURE_CERT_KEY _TEXT("Parm1")
  196. #define LSERVER_EXCHANGE_CERT_KEY _TEXT("Parm2")
  197. #define LSERVER_SIGNATURE_CERTCHAIN_KEY _TEXT("Parm3")
  198. #define LSERVER_POLICY_REGKEY _TEXT("Policy")
  199. #define LSERVER_POLICY_DLLPATH _TEXT("Dll")
  200. #define LSERVER_POLICY_DLLFLAG _TEXT("Flags")
  201. #define LSERVER_POLICY_REGBASE \
  202. LSERVER_SOFTWARE_REGBASE _TEXT("\\") LSERVER_POLICY_REGKEY
  203. #define TLS_ERROR(dwErrCode) ((dwErrCode & 0xC0000000) == 0xC0000000)
  204. //---------------------------------------------------------------------
  205. #define MAXTCPNAME MAXGETHOSTSTRUCT
  206. #define FIRSTTIME_STARTUP_REGBASE _TEXT("Software\\Microsoft\\MSLicensing\\Startup")
  207. //------------------------------------------------------------------------------------------------
  208. // Hydra Specific Product SKU
  209. //
  210. // 236-4.00-S Windows NT Workstation 4.0 Full Version Non Windows and Non NT Client
  211. // 236-4.00-VU Windows NT Workstation 4.0 Version Upgrade Windows NT 3.51 Client
  212. // 236-4.00-EX Existing Windows NT Workstation 4.0 License Windows NT 4.0 and 5.0 Client
  213. //
  214. #define HYDRA_PRODUCTID_SKU "236"
  215. #define HYDRA_FULLVERSION_POSTFIX "S"
  216. #define HYDRA_UPGRADE_POSTFIX "VU"
  217. #define HYDRA_EXISTING "EX"
  218. #define HYDRAPRODUCT_FULLVERSION_SKU _TEXT("236-4.00-S")
  219. #define HYDRAPRODUCT_UPGRADE_SKU _TEXT("236-4.00-VU")
  220. #define HYDRAPRODUCT_EXISTING_SKU _TEXT("236-4.00-EX")
  221. //
  222. // 236 Product ID
  223. //
  224. #define PLATFORMID_UPGRADE 1
  225. #define PLATFORMID_FREE 2
  226. #define PLATFORMID_OTHERS 0xFF
  227. #define TERMSERV_PRODUCTID_SKU _TEXT("A02")
  228. #define TERMSERV_PRODUCTID_INTERNET_SKU _TEXT("B96")
  229. #define TERMSERV_PRODUCTID_CONCURRENT_SKU _TEXT("C50")
  230. #define TERMSERV_FULLVERSION_TYPE _TEXT("S")
  231. #define TERMSERV_FREE_TYPE _TEXT("EX")
  232. #define TERMSERV_INTERNET_TYPE _TEXT("I")
  233. #define TERMSERV_CONCURRENT_TYPE _TEXT("C")
  234. #define TERMSERV_PRODUCTID_FORMAT _TEXT("%3s-%ld.%02ld-%s")
  235. #define MAX_TERMSRV_PRODUCTID LSERVER_MAX_STRING_SIZE
  236. #define MAX_SKU_PREFIX 10
  237. #define MAX_SKU_POSTFIX 10
  238. //
  239. // Following two are info. for special key pack that
  240. // will be used for issuing certificate to hydra server.
  241. //
  242. #define HYDRAPRODUCT_HS_CERTIFICATE_SKU \
  243. _TEXT("3d267954-eeb7-11d1-b94e-00c04fa3080d")
  244. #define HYDRAPRODUCT_HS_CERTIFICATE_KEYPACKID \
  245. _TEXT("3d267954-eeb7-11d1-b94e-00c04fa3080d")
  246. #define HYDRACERT_PRODUCT_VERSION 0x0001000
  247. // Windows NT Upgrade=1, Windows NT Free=2, Others=3
  248. #define CLIENT_PLATFORMID_WINDOWS_NT_UPGRADE 1
  249. #define CLIENT_PLATFORMID_WINDOWS_NT_FREE 2
  250. #define CLIENT_PLATFORMID_OTHERS 3
  251. //---------------------------------------------------------------------------
  252. //
  253. // Common Define
  254. //
  255. #define LICENSE_MIN_MATCH 3
  256. #define RPC_MINIMUMCALLTHREADS 1
  257. #define RPC_MAXIMUMCALLTHREADS RPC_C_LISTEN_MAX_CALLS_DEFAULT
  258. #define SC_WAITHINT 3000
  259. #define ODBC_MAX_SQL_STRING 8196 // max. sql string
  260. #define DEFAULT_CONNECTION_TIMEOUT 5*60*1000 // odbc.h
  261. #define DB_ENUM_WAITTIMEOUT 10*1000 // 10 second time out
  262. // for enumeration handle
  263. #define MAX_LICENSE_SIZE 4096
  264. #define GRACE_PERIOD 90 // default to 90 days
  265. #define DEFAULT_DB_CONNECTIONS 4
  266. #define LSERVER_PARAMETERS_DBTIMEOUT _TEXT("Db ConnectionTimeout")
  267. #define LSERVER_PARAMETERS_EDBTIMEOUT _TEXT("Enum DbConnection Timeout")
  268. #define LSERVER_PARAMETERS_MAXDBHANDLES _TEXT("Max DB Handles")
  269. #define DB_MAX_CONNECTIONS 20
  270. #define DB_MIN_HANDLE_NEEDED 3 // keypack enumeration uses two handle
  271. // need odd number to prevent deadlock
  272. //---------------------------------------------------------------------------
  273. //
  274. // draft-ietf-pkix-ipki-part1-06.txt section 4.1.2.5.1
  275. // where year is greater or equal to 50, the year shall be interpreted as 19YY; and
  276. // where year is less than 50, the year shall be interpreted as 20YY
  277. //
  278. #define PERMANENT_CERT_EXPIRE_DATE 2049
  279. //---------------------------------------------------------------------------
  280. //
  281. // Internal specific not export to RPC
  282. //
  283. #define LSKEYPACKSTATUS_DELETE 0xF
  284. #define LSLICENSESTATUS_DELETE 0xF
  285. #define LSKEYPACKSTATUS_BETA 0x10
  286. #define LSKEYPACKSTATUS_HIDDEN 0x20
  287. #define LSKEYPACKSTATUS_LOCAL 0x40
  288. #define LSKEYPACKSTATUS_REMOTE 0x80
  289. #define LSKEYPACKSTATUS_RESERVED 0xF0
  290. #define LSKEYPACK_REMOTE_TYPE 0x80
  291. #define LSKEYPACK_LOCAL_TYPE 0x40
  292. #define LSKEYPACK_HIDDEN_TYPE 0x20
  293. #define LSKEYPACK_RESERVED_TYPE 0xF0
  294. #define LSKEYPACK_PLATFORM_REMOTE 0x80000000
  295. //----------------------------------------------------------------------------
  296. //
  297. // KeyPackDesc Table specific
  298. //
  299. #define KEYPACKDESC_SEARCH_NONE 0x00000000
  300. #define KEYPACKDESC_SEARCH_ALL 0xFFFFFFFF
  301. #define KEYPACKDESC_SET_ADD_ENTRY 0x00010000
  302. #define KEYPACKDESC_SET_DELETE_ENTRY 0x00020000
  303. //---------------------------------------------------------------------------
  304. #ifndef AllocateMemory
  305. #define AllocateMemory(size) \
  306. LocalAlloc(LPTR, size)
  307. #endif
  308. #ifndef FreeMemory
  309. #define FreeMemory(ptr) \
  310. if(ptr) \
  311. { \
  312. LocalFree(ptr); \
  313. ptr=NULL; \
  314. }
  315. #endif
  316. #ifndef ReallocateMemory
  317. #define ReallocateMemory(ptr, size) \
  318. LocalReAlloc(ptr, size, LMEM_ZEROINIT)
  319. #endif
  320. #ifndef SAFESTRCPY
  321. #define SAFESTRCPY(dest, source) \
  322. _tcsncpy(dest, source, min(_tcslen(source), sizeof(dest)/sizeof(TCHAR))); \
  323. dest[min(_tcslen(source), (sizeof(dest)/sizeof(TCHAR) -1))] = _TEXT('\0');
  324. #endif
  325. //---------------------------------------------------------------------------
  326. //
  327. // Return code from LSWaitForService()
  328. //
  329. #define WAIT_SERVICE_UNKNOWN 0
  330. #define WAIT_SERVICE_ERROR 1
  331. #define WAIT_SERVICE_ALREADY_RUNNING 2
  332. #define WAIT_SERVICE_MANUALLY_STARTED 3
  333. #define WAIT_SERVICE_NOT_EXIST 4
  334. #define WAIT_SERVICE_DISABLED 5
  335. #define WAIT_SERVICE_READY 6
  336. #define LICENSE_TABLE_EXTERN_SEARCH_MASK \
  337. (LSLICENSE_SEARCH_LICENSEID | LSLICENSE_SEARCH_KEYPACKID | \
  338. LSLICENSE_SEARCH_MACHINENAME | \
  339. LSLICENSE_SEARCH_USERNAME | \
  340. LSLICENSE_SEARCH_ISSUEDATE | LSLICENSE_SEARCH_NUMLICENSES | \
  341. LSLICENSE_SEARCH_EXPIREDATE | LSLICENSE_EXSEARCH_LICENSESTATUS)
  342. //
  343. // The original style permanent license will never expire. The leased license
  344. // will expire in a random period between 52 and 89 days.
  345. //
  346. #define PERMANENT_LICENSE_EXPIRE_DATE INT_MAX
  347. //#define PERMANENT_LICENSE_LEASE_EXPIRE_MIN (3*60) // testing: 3 min
  348. //#define PERMANENT_LICENSE_LEASE_EXPIRE_RANGE (60) // testing: 1 min
  349. //#define EXPIRE_THREAD_SLEEP_TIME (1000*60*5) /* five min */
  350. #define PERMANENT_LICENSE_LEASE_EXPIRE_MIN (52 * 24 * 60 * 60)
  351. #define PERMANENT_LICENSE_LEASE_EXPIRE_RANGE (37 * 24 * 60 * 60)
  352. #define EXPIRE_THREAD_SLEEP_TIME (1000*60*60*24) /* one day */
  353. #define TLSERVER_CHALLENGE_CONTEXT 0xFFFFFFFF
  354. #define TLSERVER_ENTERPRISE_SERVER 0x00000001
  355. #define DEFAULT_CSP MS_DEF_PROV
  356. #define PROVIDER_TYPE PROV_RSA_FULL
  357. #define CRYPTOINIT_ALREADY_EXIST 0x00000000
  358. #define CRYPTOINIT_CREATE_CONTAINER 0x00000001
  359. #define CRYPTOINIT_CREATE_SIGNKEY 0x00000002
  360. #define CRYPTOINIT_CREATE_EXCHKEY 0x00000004
  361. #define TLSBACKUP_EXPORT_DIR _TEXT("Export")
  362. #endif