Leaked source code of windows server 2003
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.

1101 lines
26 KiB

  1. //+--------------------------------------------------------------------------
  2. //
  3. // Copyright (c) 1997-1999 Microsoft Corporation
  4. //
  5. // File: tlsjob.h
  6. //
  7. // Contents:
  8. //
  9. // History:
  10. //
  11. //---------------------------------------------------------------------------
  12. #ifndef __TLSJOB_H__
  13. #define __TLSJOB_H__
  14. #include "server.h"
  15. #include "jobmgr.h"
  16. #include "workitem.h"
  17. #include "locks.h"
  18. //
  19. // Default interval time is one hour for session and
  20. // persistent job.
  21. //
  22. #ifndef __TEST_WORKMGR__
  23. #define DEFAULT_JOB_INTERVAL 60*60 // Retry every hour
  24. #define DEFAULT_JOB_RETRYTIMES 60*60*60 // 60 days
  25. #define DEFAULT_PERSISTENT_JOB_INTERVAL 4*60*60 // 4 hour interval
  26. #define DEFAULT_PERSISTENT_JOB_RETRYTIMES 6 * 60 // 60 days.
  27. #else
  28. #define DEFAULT_JOB_INTERVAL 2 // 10 seconds
  29. #define DEFAULT_JOB_RETRYTIMES 6000
  30. #endif
  31. #define MAX_JOB_DESCRIPTION 254
  32. //--------------------------------------------------------------
  33. //
  34. // currently defined type of work
  35. //
  36. #define WORKTYPE_PROCESSING 0x80000000
  37. #define WORKTYPE_UNKNOWN 0x00000000
  38. #define WORKTYPE_ANNOUNCE_SERVER 0x00000001
  39. #define WORKTYPE_ANNOUNCETOESERVER 0x00000002
  40. #define WORKTYPE_ANNOUNCE_RESPONSE 0x00000003
  41. #define WORKTYPE_ANNOUNCE_LKP 0x00000004
  42. #define WORKTYPE_SYNC_LKP 0x00000005
  43. #define WORKTYPE_RETURN_LKP 0x00000006
  44. #define WORKTYPE_RETURN_LICENSE 0x00000007
  45. typedef enum {
  46. TLS_WORKOBJECT_RUNONCE=0,
  47. TLS_WORKOBJECT_SESSION,
  48. TLS_WORKOBJECT_PERSISTENT
  49. } TLSWORKOBJECTTYPE;
  50. //------------------------------------------------
  51. template < class T,
  52. DWORD WORKTYPE,
  53. TLSWORKOBJECTTYPE WORKOBJECTTYPE,
  54. DWORD WORKINTERVAL = DEFAULT_JOB_INTERVAL,
  55. DWORD WORKRESTARTTIME = INFINITE,
  56. DWORD RETRYTIMES = 0,
  57. DWORD MAXJOBDESCSIZE = MAX_JOB_DESCRIPTION >
  58. class CTLSWorkObject : public virtual CWorkObject {
  59. protected:
  60. TCHAR m_szJobDescription[MAXJOBDESCSIZE + 1];
  61. T* m_pbWorkData; // Work related data.
  62. DWORD m_cbWorkData; // size of work related data.
  63. DWORD m_dwRetryTimes; // number of retry times.
  64. DWORD m_dwWorkInterval; // work interval
  65. DWORD m_dwWorkRestartTime; // work restart time.
  66. //
  67. // Max. JetBlue bookmark - esent.h
  68. //
  69. BYTE m_pbStorageJobId[JET_cbBookmarkMost+1];
  70. DWORD m_cbStorageJobId;
  71. typedef CTLSWorkObject<
  72. T,
  73. WORKTYPE,
  74. WORKOBJECTTYPE,
  75. WORKINTERVAL,
  76. WORKRESTARTTIME,
  77. RETRYTIMES,
  78. MAXJOBDESCSIZE
  79. > BASECAST;
  80. public:
  81. //---------------------------------------------------------------
  82. static BOOL WINAPI
  83. DeleteWorkObject(
  84. IN CWorkObject* ptr
  85. )
  86. /*++
  87. Abstract:
  88. Class static function to delete a job and free its memory.
  89. Parameter:
  90. ptr : Pointer to CWorkObject.
  91. Return:
  92. TRUE/FALSE.
  93. Note:
  94. Both work manager and work storage operate on
  95. CWorkObject class and its has no idea the actual derive
  96. class, pointer to CWorkObject is not the actual pointer to
  97. our derived class, trying to delete will cause error from
  98. heap manager.
  99. --*/
  100. {
  101. BASECAST* pJob = NULL;
  102. //
  103. // Cast it to our class to get the right
  104. // memory pointer, dynamic_cast will throw
  105. // exception if it can't cast to what we want.
  106. //
  107. pJob = dynamic_cast<BASECAST *>(ptr);
  108. pJob->EndJob();
  109. delete pJob;
  110. return ERROR_SUCCESS;
  111. }
  112. //---------------------------------------------
  113. virtual T*
  114. GetWorkData() { return m_pbWorkData; }
  115. virtual DWORD
  116. GetWorkDataSize() { return m_cbWorkData; }
  117. //---------------------------------------------
  118. CTLSWorkObject(
  119. IN DWORD bDestructorDelete = TRUE,
  120. IN T* pbData = NULL,
  121. IN DWORD cbData = 0
  122. ) :
  123. CWorkObject(bDestructorDelete),
  124. m_dwWorkInterval(WORKINTERVAL),
  125. m_pbWorkData(NULL),
  126. m_cbWorkData(0),
  127. m_dwRetryTimes(RETRYTIMES),
  128. m_dwWorkRestartTime(WORKRESTARTTIME),
  129. m_cbStorageJobId(0)
  130. /*++
  131. Abstract:
  132. Class constructor
  133. Parameter:
  134. See parameter list.
  135. Return:
  136. None or exception.
  137. --*/
  138. {
  139. DWORD dwStatus;
  140. BOOL bSuccess = FALSE;
  141. memset(m_pbStorageJobId, 0, sizeof(m_pbStorageJobId));
  142. if(pbData != NULL && cbData != 0)
  143. {
  144. bSuccess = SetWorkObjectData(
  145. pbData,
  146. cbData
  147. );
  148. if(bSuccess == FALSE)
  149. {
  150. dwStatus = GetLastError();
  151. TLSASSERT(FALSE);
  152. RaiseException(
  153. dwStatus,
  154. 0,
  155. 0,
  156. NULL
  157. );
  158. }
  159. }
  160. }
  161. //---------------------------------------------
  162. ~CTLSWorkObject()
  163. {
  164. Cleanup();
  165. }
  166. //------------------------------------------------------------
  167. //
  168. virtual BOOL
  169. IsWorkPersistent()
  170. {
  171. return (WORKOBJECTTYPE == TLS_WORKOBJECT_PERSISTENT);
  172. }
  173. //------------------------------------------------------------
  174. //
  175. virtual BOOL
  176. IsValid()
  177. /*++
  178. Abstract:
  179. Verify if current work object is valid.
  180. Parameter:
  181. None.
  182. Return:
  183. TRUE/FALSE.
  184. --*/
  185. {
  186. if(VerifyWorkObjectData(TRUE, m_pbWorkData, m_cbWorkData) == FALSE)
  187. {
  188. return FALSE;
  189. }
  190. return CWorkObject::IsValid();
  191. }
  192. //------------------------------------------------------------
  193. //
  194. virtual void
  195. Cleanup()
  196. /*++
  197. Abstract:
  198. Clean up/free memory allocated inside of this work object.
  199. Parameter:
  200. None.
  201. Returns:
  202. None.
  203. --*/
  204. {
  205. if(m_pbWorkData != NULL && m_cbWorkData != 0)
  206. {
  207. //
  208. // Call derive class cleanup routine.
  209. //
  210. CleanupWorkObjectData(
  211. &m_pbWorkData,
  212. &m_cbWorkData
  213. );
  214. }
  215. m_pbWorkData = NULL;
  216. m_cbWorkData = 0;
  217. memset(m_pbStorageJobId, 0, sizeof(m_pbStorageJobId));
  218. m_cbStorageJobId = 0;
  219. CWorkObject::Cleanup();
  220. }
  221. //------------------------------------------------------------
  222. //
  223. virtual DWORD
  224. GetWorkType()
  225. {
  226. return WORKTYPE;
  227. }
  228. //-----------------------------------------------------------
  229. //
  230. virtual BOOL
  231. SetWorkObjectData(
  232. IN T* pbData,
  233. IN DWORD cbData
  234. )
  235. /*++
  236. Abstract:
  237. Set work object associated data.
  238. Parameter:
  239. pbData : Pointer to data.
  240. cbData : size of data.
  241. Return:
  242. TRUE/FALSE.
  243. Note:
  244. This routine calls derive class supplied CopyWorkObjectData()
  245. to copy the data, how it allocate memory is derived class specific
  246. --*/
  247. {
  248. BOOL bSuccess = TRUE;
  249. if(pbData == NULL || cbData == 0)
  250. {
  251. bSuccess = FALSE;
  252. SetLastError(ERROR_INVALID_PARAMETER);
  253. }
  254. if(bSuccess == TRUE)
  255. {
  256. bSuccess = VerifyWorkObjectData(
  257. FALSE,
  258. pbData,
  259. cbData
  260. );
  261. }
  262. if(bSuccess == TRUE && m_pbWorkData != NULL && m_cbWorkData != 0)
  263. {
  264. bSuccess = CleanupWorkObjectData(
  265. &m_pbWorkData,
  266. &m_cbWorkData
  267. );
  268. }
  269. if(bSuccess == TRUE)
  270. {
  271. bSuccess = CopyWorkObjectData(
  272. &m_pbWorkData,
  273. &m_cbWorkData,
  274. pbData,
  275. cbData
  276. );
  277. }
  278. return bSuccess;
  279. }
  280. //--------------------------------------------------------------
  281. virtual BOOL
  282. SelfDestruct()
  283. /*++
  284. Abstract:
  285. Clean up and delete memory associated with this work object.
  286. Parameters:
  287. None.
  288. Return:
  289. TRUE/FALSE, use GetLastError() to get the error code.
  290. --*/
  291. {
  292. return DeleteWorkObject(this);
  293. }
  294. //--------------------------------------------------------------
  295. virtual BOOL
  296. SetJobId(
  297. IN PBYTE pbData,
  298. IN DWORD cbData
  299. )
  300. /*++
  301. Abstract:
  302. Set work storage assigned Job ID to this work object, for
  303. session/run once work object, this routine will never be invoked
  304. Parameters:
  305. pbData : Work storage assigned Job ID.
  306. cbData : size of Job ID.
  307. Return:
  308. TRUE/FALSE.
  309. --*/
  310. {
  311. BOOL bSuccess = TRUE;
  312. if(cbData >= JET_cbBookmarkMost)
  313. {
  314. TLSASSERT(cbData < JET_cbBookmarkMost);
  315. bSuccess = FALSE;
  316. }
  317. else
  318. {
  319. memcpy(m_pbStorageJobId, pbData, cbData);
  320. m_cbStorageJobId = cbData;
  321. }
  322. return bSuccess;
  323. }
  324. //-----------------------------------------------------------
  325. virtual BOOL
  326. GetJobId(
  327. OUT PBYTE* ppbData,
  328. OUT PDWORD pcbData
  329. )
  330. /*++
  331. Abstract:
  332. Get work storage assigned job ID.
  333. Parameter:
  334. ppbData : Pointer to pointer to buffer to receive the job ID.
  335. pcbData : Pointer to DWORD to receive size of data.
  336. Returns:
  337. TRUE/FALSE.
  338. Note:
  339. Base class simply return the pointer to object's job ID pointer,
  340. do not free the returned pointer.
  341. --*/
  342. {
  343. BOOL bSuccess = TRUE;
  344. if(ppbData != NULL && pcbData != NULL)
  345. {
  346. *ppbData = (m_cbStorageJobId > 0) ? m_pbStorageJobId : NULL;
  347. *pcbData = m_cbStorageJobId;
  348. }
  349. else
  350. {
  351. TLSASSERT(ppbData != NULL && pcbData != NULL);
  352. bSuccess = FALSE;
  353. }
  354. return bSuccess;
  355. }
  356. //-----------------------------------------------------------
  357. //
  358. virtual BOOL
  359. GetWorkObjectData(
  360. IN OUT PBYTE* ppbData,
  361. IN OUT PDWORD pcbData
  362. )
  363. /*++
  364. Abstract:
  365. See GetWorkObjectData().
  366. Note:
  367. Needed by CWorkObject.
  368. --*/
  369. {
  370. return GetWorkObjectData(
  371. (T **)ppbData,
  372. pcbData
  373. );
  374. }
  375. //-----------------------------------------------------------
  376. //
  377. virtual BOOL
  378. SetWorkObjectData(
  379. IN PBYTE pbData,
  380. IN DWORD cbData
  381. )
  382. /*++
  383. Abstract:
  384. See SetWorkObjectData().
  385. Note:
  386. Needed by CWorkObject.
  387. --*/
  388. {
  389. return CopyWorkObjectData(
  390. &m_pbWorkData,
  391. &m_cbWorkData,
  392. (T *)pbData,
  393. cbData
  394. );
  395. }
  396. //-----------------------------------------------------------
  397. //
  398. virtual BOOL
  399. GetWorkObjectData(
  400. IN OUT T** ppbData,
  401. IN OUT PDWORD pcbData
  402. )
  403. /*++
  404. Abstract:
  405. Return work object related data.
  406. Parameter:
  407. ppbData :
  408. pcbData :
  409. return:
  410. Always TRUE.
  411. Note:
  412. Simply return pointer to object's work data, do not free
  413. the return pointer.
  414. --*/
  415. {
  416. if(ppbData != NULL)
  417. {
  418. *ppbData = m_pbWorkData;
  419. }
  420. if(pcbData != NULL)
  421. {
  422. *pcbData = m_cbWorkData;
  423. }
  424. return TRUE;
  425. }
  426. //----------------------------------------------------------
  427. virtual void
  428. EndJob()
  429. /*++
  430. Abstract:
  431. End of job processing, work manager or storage manager will
  432. invoke object's EndJob() to inform it that job has completed.
  433. Parameter:
  434. None.
  435. Returns:
  436. None.
  437. --*/
  438. {
  439. Cleanup();
  440. }
  441. //----------------------------------------------------------
  442. virtual BOOL
  443. IsJobCompleted()
  444. /*++
  445. Abstract:
  446. Return whether work manager or work storage manager can delete
  447. this job from its queue.
  448. Parameter:
  449. None.
  450. Returns:
  451. TRUE/FALSE
  452. --*/
  453. {
  454. return IsJobCompleted(
  455. m_pbWorkData,
  456. m_cbWorkData
  457. );
  458. }
  459. //----------------------------------------------------------
  460. virtual DWORD
  461. GetSuggestedScheduledTime()
  462. /*++
  463. Abstract:
  464. Return next time to invoke this job again.
  465. Parameter:
  466. None:
  467. Returns:
  468. Time relative to current time or INFINITE if no additional
  469. processing of this job is requred.
  470. --*/
  471. {
  472. return (IsJobCompleted() == TRUE) ? INFINITE : m_dwWorkInterval;
  473. }
  474. //----------------------------------------------------------
  475. virtual DWORD
  476. GetJobRestartTime()
  477. {
  478. return m_dwWorkRestartTime;
  479. }
  480. //----------------------------------------------------------
  481. virtual void
  482. SetJobRestartTime(
  483. DWORD dwTime
  484. )
  485. /*++
  486. --*/
  487. {
  488. m_dwWorkRestartTime = dwTime;
  489. }
  490. //----------------------------------------------------------
  491. virtual void
  492. SetJobInterval(
  493. IN DWORD dwInterval
  494. )
  495. /*++
  496. Abstract:
  497. Set work interval.
  498. Parameter:
  499. dwInterval : new work interval.
  500. Returns:
  501. None.
  502. --*/
  503. {
  504. m_dwWorkInterval = dwInterval;
  505. return;
  506. }
  507. //---------------------------------------------------------
  508. virtual DWORD
  509. GetJobInterval()
  510. /*++
  511. Abstract:
  512. Retrive work interval, in second, associated with this job.
  513. Parameter:
  514. None.
  515. Returns:
  516. Job interval associated with this job.
  517. --*/
  518. {
  519. return m_dwWorkInterval;
  520. }
  521. //--------------------------------------------------------
  522. virtual void
  523. SetJobRetryTimes(
  524. IN DWORD dwRetries
  525. )
  526. /*++
  527. --*/
  528. {
  529. m_dwRetryTimes = dwRetries;
  530. return;
  531. }
  532. //--------------------------------------------------------
  533. virtual DWORD
  534. GetJobRetryTimes() { return m_dwRetryTimes; }
  535. //------------------------------------------------------------
  536. //
  537. // General Execute() function, derived class should supply
  538. // its own UpdateJobNextScheduleTime() to update run interval
  539. //
  540. virtual DWORD
  541. Execute()
  542. {
  543. DWORD dwStatus = ERROR_SUCCESS;
  544. dwStatus = ExecuteJob( m_pbWorkData, m_cbWorkData );
  545. return dwStatus;
  546. }
  547. //------------------------------------------------------------
  548. //
  549. // Each Derived Class must supply following
  550. //
  551. virtual BOOL
  552. VerifyWorkObjectData(
  553. IN BOOL bCallbyIsValid,
  554. IN T* pbData,
  555. IN DWORD cbData
  556. );
  557. virtual BOOL
  558. CopyWorkObjectData(
  559. OUT T** ppbDest,
  560. OUT DWORD* pcbDest,
  561. IN T* pbSrc,
  562. IN DWORD cbSrc
  563. );
  564. virtual BOOL
  565. CleanupWorkObjectData(
  566. IN OUT T** ppbData,
  567. IN OUT DWORD* pcbData
  568. );
  569. virtual BOOL
  570. IsJobCompleted(
  571. IN T* pbData,
  572. IN DWORD cbData
  573. );
  574. virtual DWORD
  575. ExecuteJob(
  576. IN T* pbData,
  577. IN DWORD cbData
  578. );
  579. virtual LPCTSTR
  580. GetJobDescription();
  581. };
  582. //-----------------------------------------------------------------------------
  583. //
  584. //
  585. // CWorkObject
  586. // |
  587. // +---- CTLSWorkObject <-- template class
  588. // |
  589. // +---- CAnnounceLserver (Announce License Server)
  590. // |
  591. // +---- CAnnounceToEServer (Announe server to enterprise server)
  592. // |
  593. // +---- CSsyncLicensePack (Synchronize Local License Pack)
  594. // |
  595. // +---- CReturnLicense (Return/Revoke Client License)
  596. // |
  597. // +---- CAnnounceResponse (Reponse to server announcement)
  598. //
  599. // CAnnounceLS, CSyncLKP, CAnnounceLKP is run once.
  600. // CAnnounceLSToEServer is session work object
  601. //
  602. //-----------------------------------------------------------
  603. //
  604. // Announce License Server to other license server.
  605. //
  606. #define CURRENT_ANNOUNCESERVEWO_STRUCT_VER 0x00010000
  607. #define ANNOUNCESERVER_DESCRIPTION _TEXT("Announce License Server")
  608. #define TLSERVER_ENUM_TIMEOUT 5*1000
  609. #define TLS_ANNOUNCESERVER_INTERVAL 60 // one min. interval
  610. #define TLS_ANNOUNCESERVER_RETRYTIMES 3
  611. typedef struct __AnnounceServerWO {
  612. DWORD dwStructVersion;
  613. DWORD dwStructSize;
  614. DWORD dwRetryTimes;
  615. TCHAR m_szServerId[LSERVER_MAX_STRING_SIZE+2];
  616. TCHAR m_szScope[LSERVER_MAX_STRING_SIZE+2];
  617. TCHAR m_szServerName[LSERVER_MAX_STRING_SIZE+2];
  618. FILETIME m_ftLastShutdownTime;
  619. } ANNOUNCESERVERWO, *PANNOUNCESERVERWO, *LPANNOUNCESERVERWO;
  620. typedef CTLSWorkObject<
  621. ANNOUNCESERVERWO,
  622. WORKTYPE_ANNOUNCE_SERVER,
  623. TLS_WORKOBJECT_SESSION,
  624. TLS_ANNOUNCESERVER_INTERVAL,
  625. INFINITE,
  626. TLS_ANNOUNCESERVER_RETRYTIMES
  627. > CAnnounceLserver;
  628. //-----------------------------------------------------------
  629. //
  630. // Announce License Server to Enterprise server
  631. //
  632. #define CURRENT_ANNOUNCETOESERVEWO_STRUCT_VER 0x00010000
  633. #define ANNOUNCETOESERVER_DESCRIPTION _TEXT("Announce License Server to Enterprise server")
  634. typedef struct __AnnounceToEServerWO {
  635. DWORD dwStructVersion;
  636. DWORD dwStructSize;
  637. BOOL bCompleted;
  638. TCHAR m_szServerId[LSERVER_MAX_STRING_SIZE+2];
  639. TCHAR m_szServerName[LSERVER_MAX_STRING_SIZE+2];
  640. TCHAR m_szScope[LSERVER_MAX_STRING_SIZE+2];
  641. FILETIME m_ftLastShutdownTime;
  642. } ANNOUNCETOESERVERWO, *PANNOUNCETOESERVERWO, *LPANNOUNCETOESERVERWO;
  643. typedef CTLSWorkObject<
  644. ANNOUNCETOESERVERWO,
  645. WORKTYPE_ANNOUNCETOESERVER,
  646. TLS_WORKOBJECT_SESSION, // session work object
  647. DEFAULT_JOB_INTERVAL // retry every hour
  648. > CAnnounceToEServer;
  649. //-----------------------------------------------------------
  650. //
  651. // Response To Server Announce
  652. //
  653. #define CURRENT_ANNOUNCERESPONSEWO_STRUCT_VER 0x00010000
  654. #define ANNOUNCERESPONSE_DESCRIPTION _TEXT("Response Announce to %s")
  655. typedef struct __AnnounceResponseWO {
  656. DWORD dwStructVersion;
  657. DWORD dwStructSize;
  658. BOOL bCompleted;
  659. TCHAR m_szTargetServerId[LSERVER_MAX_STRING_SIZE+2];
  660. TCHAR m_szLocalServerId[LSERVER_MAX_STRING_SIZE+2];
  661. TCHAR m_szLocalServerName[LSERVER_MAX_STRING_SIZE+2];
  662. TCHAR m_szLocalScope[LSERVER_MAX_STRING_SIZE+2];
  663. FILETIME m_ftLastShutdownTime;
  664. } ANNOUNCERESPONSEWO, *PANNOUNCERESPONSEWO, *LPANNOUNCERESPONSEWO;
  665. typedef CTLSWorkObject<
  666. ANNOUNCERESPONSEWO,
  667. WORKTYPE_ANNOUNCE_RESPONSE,
  668. TLS_WORKOBJECT_RUNONCE
  669. > CAnnounceResponse;
  670. //---------------------------------------------------------
  671. //
  672. // Sync. license pack to remote server, this is used in
  673. // announce newly registered license pack and push sync.
  674. // local license pack to a newly startup server.
  675. //
  676. //
  677. #define CURRENT_SSYNCLICENSEKEYPACK_STRUCT_VER 0x00010000
  678. #define SSYNCLICENSEKEYPACK_DESCRIPTION _TEXT("Sync %s LKP with remote server %s")
  679. #define SSYNCLKP_MAX_TARGET 10
  680. #define SSYNC_DBWORKSPACE_TIMEOUT 60*60*1000 // wait one hour for handle
  681. typedef enum {
  682. SSYNC_ALL_LKP=1,
  683. SSYNC_ONE_LKP
  684. } SSYNC_TYPE;
  685. typedef struct __SsyncLocalLkpWO {
  686. DWORD dwStructVersion;
  687. DWORD dwStructSize;
  688. // Has job completed.
  689. BOOL bCompleted;
  690. // local server ID
  691. TCHAR m_szServerId[LSERVER_MAX_STRING_SIZE+2];
  692. // local server name.
  693. TCHAR m_szServerName[LSERVER_MAX_STRING_SIZE+2];
  694. // type of sync, single license pack or all license pack
  695. SSYNC_TYPE dwSyncType;
  696. // number of license server to push sync.
  697. DWORD dwNumServer;
  698. // list of remote server
  699. TCHAR m_szTargetServer[SSYNCLKP_MAX_TARGET][MAX_COMPUTERNAME_LENGTH+2];
  700. // remote server sync. status, TRUE if skip this server
  701. // FALSE otherwise.
  702. BOOL m_bSsync[SSYNCLKP_MAX_TARGET];
  703. union {
  704. // remote server's last sync (shutdown) time
  705. FILETIME m_ftStartSyncTime;
  706. // license keypack internal tracking ID if this job is
  707. // to push sync. one license pack
  708. DWORD dwKeyPackId;
  709. };
  710. } SSYNCLICENSEPACK, *PSSYNCLICENSEPACK, *LPSSYNCLICENSEPACK;
  711. typedef CTLSWorkObject<
  712. SSYNCLICENSEPACK,
  713. WORKTYPE_SYNC_LKP,
  714. TLS_WORKOBJECT_SESSION,
  715. DEFAULT_JOB_INTERVAL
  716. > CSsyncLicensePack;
  717. //---------------------------------------------------------
  718. //
  719. // Return license work object. This is a persistent job
  720. //
  721. #define CURRENT_RETURNLICENSEWO_STRUCT_VER 0x00010000
  722. #define RETURNLICENSE_RETRY_TIMES DEFAULT_PERSISTENT_JOB_RETRYTIMES
  723. #define RETURNLICENSE_DESCSIZE 512
  724. #define RETURNLICENSE_DESCRIPTION _TEXT("%d Return License %d %d to %s")
  725. #define RETURNLICENSE_RESTARTTIME 60 // default restart time in 1 min.
  726. #define LICENSERETURN_UPGRADE 0x00000001
  727. #define LICENSERETURN_REVOKED 0x00000002
  728. #define LICENSERETURN_REVOKE_LKP 0x00000003
  729. typedef struct __ReturnLicenseWO {
  730. DWORD dwStructVersion;
  731. DWORD dwStructSize;
  732. // number of retry.
  733. DWORD dwNumRetry;
  734. // remote server setup ID.
  735. TCHAR szTargetServerId[LSERVER_MAX_STRING_SIZE+2];
  736. // remote server name.
  737. TCHAR szTargetServerName[LSERVER_MAX_STRING_SIZE+2];
  738. // number of licenses in client's license
  739. DWORD dwQuantity;
  740. // internal keypack ID this license is allocated from.
  741. DWORD dwKeyPackId;
  742. // license internal tracking ID.
  743. DWORD dwLicenseId;
  744. // Reason for return, currently ignored.
  745. DWORD dwReturnReason;
  746. // product version.
  747. DWORD dwProductVersion;
  748. // client platform ID
  749. DWORD dwPlatformId;
  750. // Product family code.
  751. TCHAR szOrgProductID[LSERVER_MAX_STRING_SIZE + 2];
  752. // client's encrypted HWID
  753. DWORD cbEncryptedHwid;
  754. BYTE pbEncryptedHwid[1024]; // max. client HWID size
  755. // product company
  756. TCHAR szCompanyName[LSERVER_MAX_STRING_SIZE + 2];
  757. // product ID.
  758. TCHAR szProductId[LSERVER_MAX_STRING_SIZE + 2];
  759. // user name that license was issued to.
  760. TCHAR szUserName[ MAXCOMPUTERNAMELENGTH + 2 ];
  761. // machine that license was issued to.
  762. TCHAR szMachineName[ MAXUSERNAMELENGTH + 2 ];
  763. } RETURNLICENSEWO, *PRETURNLICENSEWO, *LPRETURNLICENSEWO;
  764. typedef CTLSWorkObject<
  765. RETURNLICENSEWO,
  766. WORKTYPE_RETURN_LICENSE,
  767. TLS_WORKOBJECT_PERSISTENT,
  768. DEFAULT_PERSISTENT_JOB_INTERVAL,
  769. RETURNLICENSE_RESTARTTIME,
  770. DEFAULT_PERSISTENT_JOB_RETRYTIMES,
  771. RETURNLICENSE_DESCSIZE
  772. > CReturnLicense;
  773. //----------------------------------------------------
  774. #ifdef __cplusplus
  775. extern "C" {
  776. #endif
  777. CWorkObject* WINAPI
  778. InitializeCReturnWorkObject(
  779. IN CWorkManager* pWkMgr,
  780. IN PBYTE pbWorkData,
  781. IN DWORD cbWorkData
  782. );
  783. DWORD
  784. TLSWorkManagerSchedule(
  785. IN DWORD dwTime,
  786. IN CWorkObject* pJob
  787. );
  788. void
  789. TLSWorkManagerShutdown();
  790. DWORD
  791. TLSWorkManagerInit();
  792. BOOL
  793. TLSWorkManagerSetJobDefaults(
  794. CWorkObject* pJob
  795. );
  796. DWORD
  797. TLSPushSyncLocalLkpToServer(
  798. IN LPTSTR pszSetupId,
  799. IN LPTSTR pszDomainName,
  800. IN LPTSTR pszLserverName,
  801. IN FILETIME* pSyncTime
  802. );
  803. DWORD
  804. TLSStartAnnounceToEServerJob(
  805. IN LPCTSTR pszServerId,
  806. IN LPCTSTR pszServerDomain,
  807. IN LPCTSTR pszServerName,
  808. IN FILETIME* pftFileTime
  809. );
  810. DWORD
  811. TLSStartAnnounceLicenseServerJob(
  812. IN LPCTSTR pszServerId,
  813. IN LPCTSTR pszServerDomain,
  814. IN LPCTSTR pszServerName,
  815. IN FILETIME* pftFileTime
  816. );
  817. DWORD
  818. TLSStartAnnounceResponseJob(
  819. IN LPTSTR pszTargetServerId,
  820. IN LPTSTR pszTargetServerDomain,
  821. IN LPTSTR pszTargetServerName,
  822. IN FILETIME* pftTime
  823. );
  824. BOOL
  825. TLSIsServerCompatible(
  826. IN DWORD dwLocalServerVersion,
  827. IN DWORD dwTargetServerVersion
  828. );
  829. BOOL
  830. TLSCanPushReplicateData(
  831. IN DWORD dwLocalServerVersion,
  832. IN DWORD dwTargetServerVersion
  833. );
  834. BOOL
  835. IsLicensePackRepl(
  836. TLSLICENSEPACK* pLicensePack
  837. );
  838. #ifdef __cplusplus
  839. }
  840. #endif
  841. #endif