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.

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