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.

875 lines
21 KiB

  1. /*++
  2. Copyright (c) 1997-1999 Microsoft Corporation.
  3. All rights reserved.
  4. MODULE NAME:
  5. ismapi.h
  6. ABSTRACT:
  7. Service-to-ISM (Intersite Messaging) service API and
  8. ISM-to-plug-in-transport API.
  9. DETAILS:
  10. CREATED:
  11. 97/11/26 Jeff Parham (jeffparh)
  12. REVISION HISTORY:
  13. --*/
  14. #ifndef __ISMAPI_H__
  15. #define __ISMAPI_H__
  16. #if _MSC_VER > 1000
  17. #pragma once
  18. #endif
  19. // User-defined control
  20. #define ISM_SERVICE_CONTROL_REMOVE_STOP 0x00000080
  21. #ifndef ISM_STRUCTS_DEFINED
  22. #define ISM_STRUCTS_DEFINED
  23. //==============================================================================
  24. //
  25. // ISM_MSG structure contains the message data (as a byte blob).
  26. //
  27. // Note: pszSubject is permitted to be NULL
  28. typedef struct _ISM_MSG {
  29. DWORD cbData;
  30. #ifdef MIDL_PASS
  31. [ref,size_is(cbData)] BYTE * pbData;
  32. [string] LPWSTR pszSubject;
  33. #else
  34. BYTE * pbData;
  35. LPWSTR pszSubject;
  36. #endif
  37. } ISM_MSG, *PISM_MSG;
  38. typedef ISM_MSG ISM_MSG_V1, *PISM_MSG_V1;
  39. ////////////////////////////////////////////////////////////////////////////////
  40. //
  41. // ISM_SITE_CONNECTIVITY structure describes how sites are interconnected via
  42. // a specific transport.
  43. //
  44. // The pulCosts element should be interpreted as a multidimensional array.
  45. // pLinkValues[i*cNumSites + j].ulCost is the cost of communication from site
  46. // pSiteDNs[i] to site pSiteDNs[j].
  47. //
  48. typedef struct _ISM_LINK {
  49. ULONG ulCost;
  50. ULONG ulReplicationInterval;
  51. ULONG ulOptions;
  52. } ISM_LINK, *PISM_LINK;
  53. typedef struct _ISM_CONNECTIVITY {
  54. ULONG cNumSites;
  55. #ifdef MIDL_PASS
  56. [ref, string, size_is(cNumSites)] LPWSTR * ppSiteDNs;
  57. [ref, size_is(cNumSites * cNumSites)] ISM_LINK * pLinkValues;
  58. #else
  59. LPWSTR * ppSiteDNs;
  60. ISM_LINK * pLinkValues;
  61. #endif
  62. } ISM_CONNECTIVITY, *PISM_CONNECTIVITY;
  63. ////////////////////////////////////////////////////////////////////////////////
  64. //
  65. // ISM_SERVER_LIST structure describes a set of servers, identified by DN.
  66. //
  67. typedef struct _ISM_SERVER_LIST {
  68. DWORD cNumServers;
  69. #ifdef MIDL_PASS
  70. [ref, string, size_is(cNumServers)]
  71. LPWSTR * ppServerDNs;
  72. #else
  73. LPWSTR * ppServerDNs;
  74. #endif
  75. } ISM_SERVER_LIST, *PISM_SERVER_LIST;
  76. ////////////////////////////////////////////////////////////////////////////////
  77. //
  78. // ISM_SCHEDULE structure describes a schedule on which two sites are
  79. // connected. The byte stream should be interpreted as a SCHEDULE structure,
  80. // as defined in \nt\public\sdk\inc\schedule.h.
  81. //
  82. typedef struct _ISM_SCHEDULE {
  83. DWORD cbSchedule;
  84. #ifdef MIDL_PASS
  85. [ref, size_is(cbSchedule)] BYTE * pbSchedule;
  86. #else
  87. BYTE * pbSchedule;
  88. #endif
  89. } ISM_SCHEDULE, *PISM_SCHEDULE;
  90. ////////////////////////////////////////////////////////////////////////////////
  91. //
  92. // ISM_SITE_COST_INFO structure gives the cost between two sites and an error
  93. // code. If the error code is non-zero, the cost should be considered invalid.
  94. //
  95. // ISM_SITE_COST_INFO_ARRAY is a simple wrapper for an array of
  96. // ISM_SITE_COST_INFO structures which includes the length.
  97. //
  98. typedef struct _ISM_SITE_COST_INFO {
  99. DWORD dwErrorCode;
  100. DWORD dwCost;
  101. } ISM_SITE_COST_INFO, *PISM_SITE_COST_INFO;
  102. typedef struct _ISM_SITE_COST_INFO_ARRAY {
  103. DWORD cToSites;
  104. #ifdef MIDL_PASS
  105. [ref,size_is(cToSites)] ISM_SITE_COST_INFO* rgCostInfo;
  106. #else
  107. ISM_SITE_COST_INFO* rgCostInfo;
  108. #endif
  109. DWORD dwFlags;
  110. } ISM_SITE_COST_INFO_ARRAY, *PISM_SITE_COST_INFO_ARRAY;
  111. ////////////////////////////////////////////////////////////////////////////////
  112. // Refresh reason codes
  113. typedef enum _ISM_REFRESH_REASON_CODE {
  114. ISM_REFRESH_REASON_RESERVED = 0,
  115. ISM_REFRESH_REASON_TRANSPORT,
  116. ISM_REFRESH_REASON_SITE,
  117. ISM_REFRESH_REASON_MAX // always last
  118. } ISM_REFRESH_REASON_CODE;
  119. // Shutdown reason codes
  120. typedef enum _ISM_SHUTDOWN_REASON_CODE {
  121. ISM_SHUTDOWN_REASON_RESERVED = 0,
  122. ISM_SHUTDOWN_REASON_NORMAL,
  123. ISM_SHUTDOWN_REASON_REMOVAL,
  124. ISM_SHUTDOWN_REASON_MAX // always last
  125. } ISM_SHUTDOWN_REASON_CODE;
  126. #endif // #ifndef ISM_STRUCTS_DEFINED
  127. #ifdef __cplusplus
  128. extern "C" {
  129. #endif
  130. #ifndef MIDL_PASS
  131. //==============================================================================
  132. //
  133. // Service-to-ISM (Intersite Messaging) service API.
  134. //
  135. DWORD
  136. I_ISMSend(
  137. IN const ISM_MSG * pMsg,
  138. IN LPCWSTR pszServiceName,
  139. IN LPCWSTR pszTransportDN,
  140. IN LPCWSTR pszTransportAddress
  141. );
  142. /*++
  143. Routine Description:
  144. Sends a message to a service on a remote machine. If the client specifies a
  145. NULL transport, the lowest cost transport will be used.
  146. Arguments:
  147. pMsg (IN) - The data to send.
  148. pszServiceName (IN) - Service to which to send the message.
  149. pszTransportDN (IN) - The DN of the Inter-Site-Transport object
  150. corresponding to the transport by which the message should be sent.
  151. pszTransportAddress (IN) - The transport-specific address to which to send
  152. the message.
  153. Return Values:
  154. NO_ERROR - Message successfully queued for send.
  155. other - Failure.
  156. --*/
  157. DWORD
  158. I_ISMReceive(
  159. IN LPCWSTR pszServiceName,
  160. IN DWORD dwMsecToWait,
  161. OUT ISM_MSG ** ppMsg
  162. );
  163. /*++
  164. Routine Description:
  165. Receives a message addressed to the given service on the local machine.
  166. If successful and no message is waiting, immediately returns a NULL message.
  167. If a non-NULL message is returned, the caller is responsible for eventually
  168. calling I_ISMFree()'ing the returned message.
  169. Arguments:
  170. pszServiceName (IN) - Service for which to receive the message.
  171. dwMsecToWait (IN) - Milliseconds to wait for message if none is immediately
  172. available; in the range [0, INFINITE].
  173. ppMsg (OUT) - On successful return, holds a pointer to the received message
  174. or NULL.
  175. Return Values:
  176. NO_ERROR - Message successfully returned (or NULL was returned,
  177. indicating no message is waiting).
  178. other - Failure.
  179. --*/
  180. void
  181. I_ISMFree(
  182. IN VOID * pv
  183. );
  184. /*++
  185. Routine Description:
  186. Frees memory allocated on the behalf of the client by I_ISM* APIs.
  187. Arguments:
  188. pv (IN) - Memory to free.
  189. Return Values:
  190. None.
  191. --*/
  192. DWORD
  193. I_ISMGetConnectivity(
  194. IN LPCWSTR pszTransportDN,
  195. OUT ISM_CONNECTIVITY ** ppConnectivity
  196. );
  197. /*++
  198. Routine Description:
  199. Compute the costs associated with transferring data amongst sites via a
  200. specific transport.
  201. On successful return, it is the client's responsibility to eventually call
  202. I_ISMFree(*ppConnectivity);
  203. Arguments:
  204. pszTransportDN (IN) - The transport for which to query costs.
  205. ppConnectivity (OUT) - On successful return, holds a pointer to the
  206. ISM_CONNECTIVITY structure describing the interconnection of sites
  207. along the given transport.
  208. Return Values:
  209. NO_ERROR - Success.
  210. ERROR_* - Failure.
  211. --*/
  212. DWORD
  213. I_ISMGetTransportServers(
  214. IN LPCWSTR pszTransportDN,
  215. IN LPCWSTR pszSiteDN,
  216. OUT ISM_SERVER_LIST ** ppServerList
  217. );
  218. /*++
  219. Routine Description:
  220. Retrieve the DNs of servers in a given site that are capable of sending and
  221. receiving data via a specific transport.
  222. On successful return, it is the client's responsibility to eventually call
  223. I_ISMFree(*ppServerList);
  224. Arguments:
  225. pszTransportDN (IN) - Transport to query.
  226. pszSiteDN (IN) - Site to query.
  227. ppServerList - On successful return, holds a pointer to a structure
  228. containing the DNs of the appropriate servers or NULL. If NULL, any
  229. server with a value for the transport address type attribute can be
  230. used.
  231. Return Values:
  232. NO_ERROR - Success.
  233. ERROR_* - Failure.
  234. --*/
  235. DWORD
  236. I_ISMGetConnectionSchedule(
  237. LPCWSTR pszTransportDN,
  238. LPCWSTR pszSite1DN,
  239. LPCWSTR pszSite2DN,
  240. ISM_SCHEDULE ** ppSchedule
  241. );
  242. /*++
  243. Routine Description:
  244. Retrieve the schedule by which two given sites are connected via a specific
  245. transport.
  246. On successful return, it is the client's responsibility to eventually call
  247. I_ISMFree(*ppSchedule);
  248. Arguments:
  249. pszTransportDN (IN) - Transport to query.
  250. pszSite1DN, pszSite2DN (IN) - Sites to query.
  251. ppSchedule - On successful return, holds a pointer to a structure
  252. describing the schedule by which the two given sites are connected via
  253. the transport, or NULL if the sites are always connected.
  254. Return Values:
  255. NO_ERROR - Success.
  256. ERROR_* - Failure.
  257. --*/
  258. DWORD
  259. I_ISMQuerySitesByCost(
  260. LPCWSTR pszTransportDN, // in
  261. LPCWSTR pszFromSite, // in
  262. DWORD cToSites, // in
  263. LPCWSTR* rgszToSites, // in
  264. DWORD dwFlags, // in
  265. ISM_SITE_COST_INFO_ARRAY** prgSiteInfo // out
  266. );
  267. /*++
  268. Routine Description:
  269. Determine the individual costs between the From site and the To sites.
  270. On successful return, it is the client's responsibility to eventually call
  271. I_ISMFree(*prgSiteInfo);
  272. Arguments:
  273. pszTransportDN (IN) - Transport to query.
  274. pszFromSite (IN) - The distinguished name of the From site.
  275. rgszToSites (IN) - An array containing the distinguished names of the To sites.
  276. cToSites (IN) - The number of entries in the rgszToSites array.
  277. dwFlags (IN) - Unused.
  278. prgSiteInfo (IN) - On successful return, holds a pointer to a structure
  279. containing the costs between the From site and the To sites.
  280. Return Values:
  281. NO_ERROR - Success.
  282. ERROR_* - Failure.
  283. --*/
  284. //==============================================================================
  285. //
  286. // ISM-to-plug-in-transport API.
  287. //
  288. typedef void ISM_NOTIFY(
  289. IN HANDLE hNotify,
  290. IN LPCWSTR pszServiceName
  291. );
  292. /*++
  293. Routine Description:
  294. Called by the plug-in to notify the ISM service that a message has been
  295. received for the given service.
  296. Arguments:
  297. hNotify (IN) - Notification handle, as passed to the plug-in in the
  298. IsmStartup() call.
  299. pszServiceName (IN) - Service for which a message was received.
  300. Return Values:
  301. None.
  302. --*/
  303. typedef DWORD ISM_STARTUP(
  304. IN LPCWSTR pszTransportDN,
  305. IN ISM_NOTIFY * pNotifyFunction,
  306. IN HANDLE hNotify,
  307. OUT HANDLE *phIsm
  308. );
  309. ISM_STARTUP IsmStartup;
  310. /*++
  311. Routine Description:
  312. Initialize the plug-in.
  313. Arguments:
  314. pszTransportDN (IN) - The DN of the Inter-Site-Transport that named this
  315. DLL as its plug-in. The DS object may contain additional configuration
  316. information for the transport (e.g., the name of an SMTP server for
  317. an SMTP transport).
  318. pNotifyFunction (IN) - Function to call to notify the ISM service of pending
  319. messages.
  320. hNotify (IN) - Parameter to supply to the notify function.
  321. phIsm (OUT) - On successful return, holds a handle to be used in
  322. future calls to the plug-in for the named Inter-Site-Transport. Note
  323. that it is possible for more than one Inter-Site-Transport object to
  324. name a given DLL as its plug-in, in which case IsmStartup() will be
  325. called for each such object.
  326. Return Values:
  327. NO_ERROR - Successfully initialized.
  328. other - Failure.
  329. --*/
  330. typedef DWORD ISM_REFRESH(
  331. IN HANDLE hIsm,
  332. IN ISM_REFRESH_REASON_CODE eReason,
  333. IN LPCWSTR pszObjectDN OPTIONAL
  334. );
  335. ISM_REFRESH IsmRefresh;
  336. /*++
  337. Routine Description:
  338. Called whenever changes occur according to the reason code.
  339. One reason is to the Inter-Site-Transport object specified in the
  340. IsmStartup() call.
  341. Another is a change to a site in the sites container.
  342. Arguments:
  343. hIsm (IN) - Handle returned by a prior call to IsmStartup().
  344. dwReason (IN) - Dword indicating the reason we were called
  345. pszObjectDN (IN) - Object DN relating to the reason
  346. (Current) DN of the Inter-Site-Transport object that
  347. named this DLL as its plug-in. Note that this DN will differ from that
  348. specified in IsmStartup() if the transport DN has been renamed.
  349. Site DN of site that was added, renamed or deleted
  350. Return Values:
  351. NO_ERROR - Successfully updated.
  352. other - Failure. A failure return implies the plug-in has shut down (i.e.,
  353. no further calls will be made on hIsm, including an
  354. IsmShutdown()).
  355. --*/
  356. typedef DWORD ISM_SEND(
  357. IN HANDLE hIsm,
  358. IN LPCWSTR pszRemoteTransportAddress,
  359. IN LPCWSTR pszServiceName,
  360. IN const ISM_MSG * pMsg
  361. );
  362. ISM_SEND IsmSend;
  363. /*++
  364. Routine Description:
  365. Send a message over this transport.
  366. Arguments:
  367. hIsm (IN) - Handle returned by a prior call to IsmStartup().
  368. pszRemoteTransportAddress (IN) - Transport address of the destination
  369. server.
  370. pszServiceName (IN) - Name of the service on the remote machine that is the
  371. intended receiver of the message.
  372. pMsg (IN) - Message to send.
  373. Return Values:
  374. NO_ERROR - Message successfully queued for send.
  375. other - Failure.
  376. --*/
  377. typedef DWORD ISM_RECEIVE(
  378. IN HANDLE hIsm,
  379. IN LPCWSTR pszServiceName,
  380. OUT ISM_MSG ** ppMsg
  381. );
  382. ISM_RECEIVE IsmReceive;
  383. /*++
  384. Routine Description:
  385. Return the next waiting message (if any). If no message is waiting, a NULL
  386. message is returned. If a non-NULL message is returned, the ISM service
  387. is responsible for calling IsmFreeMsg(hIsm, *ppMsg) when the message is no
  388. longer needed.
  389. If a non-NULL message is returned, it is immediately dequeued. (I.e., once
  390. a message is returned through IsmReceive(), the transport is free to destroy
  391. it.)
  392. Arguments:
  393. hIsm (IN) - Handle returned by a prior call to IsmStartup().
  394. ppMsg (OUT) - On successful return, holds a pointer to the received message
  395. or NULL.
  396. Return Values:
  397. NO_ERROR - Message successfully returned (or NULL was returned,
  398. indicating no message is waiting).
  399. other - Failure.
  400. --*/
  401. typedef void ISM_FREE_MSG(
  402. IN HANDLE hIsm,
  403. IN ISM_MSG * pMsg
  404. );
  405. ISM_FREE_MSG IsmFreeMsg;
  406. /*++
  407. Routine Description:
  408. Frees a message returned by IsmReceive().
  409. Arguments:
  410. hIsm (IN) - Handle returned by a prior call to IsmStartup().
  411. pMsg (IN) - Message to free.
  412. Return Values:
  413. None.
  414. --*/
  415. typedef DWORD ISM_GET_CONNECTIVITY(
  416. IN HANDLE hIsm,
  417. OUT ISM_CONNECTIVITY ** ppConnectivity
  418. );
  419. ISM_GET_CONNECTIVITY IsmGetConnectivity;
  420. /*++
  421. Routine Description:
  422. Compute the costs associated with transferring data amongst sites.
  423. On successful return, the ISM service will eventually call
  424. IsmFreeConnectivity(hIsm, *ppConnectivity);
  425. Arguments:
  426. hIsm (IN) - Handle returned by a prior call to IsmStartup().
  427. ppConnectivity (OUT) - On successful return, holds a pointer to the
  428. ISM_CONNECTIVITY structure describing the interconnection of sites
  429. along this transport.
  430. Return Values:
  431. NO_ERROR - Success.
  432. ERROR_* - Failure.
  433. --*/
  434. typedef void ISM_FREE_CONNECTIVITY(
  435. IN HANDLE hIsm,
  436. IN ISM_CONNECTIVITY * pConnectivity
  437. );
  438. ISM_FREE_CONNECTIVITY IsmFreeConnectivity;
  439. /*++
  440. Routine Description:
  441. Frees the structure returned by IsmGetConnectivity().
  442. Arguments:
  443. hIsm (IN) - Handle returned by a prior call to IsmStartup().
  444. pSiteConnectivity (IN) - Structure to free.
  445. Return Values:
  446. None.
  447. --*/
  448. typedef DWORD ISM_GET_TRANSPORT_SERVERS(
  449. IN HANDLE hIsm,
  450. IN LPCWSTR pszSiteDN,
  451. OUT ISM_SERVER_LIST ** ppServerList
  452. );
  453. ISM_GET_TRANSPORT_SERVERS IsmGetTransportServers;
  454. /*++
  455. Routine Description:
  456. Retrieve the DNs of servers in a given site that are capable of sending and
  457. receiving data via this transport.
  458. On successful return of a non-NULL list, the ISM service will eventually call
  459. IsmFreeTransportServers(hIsm, *ppServerList);
  460. Arguments:
  461. hIsm (IN) - Handle returned by a prior call to IsmStartup().
  462. pszSiteDN (IN) - Site to query.
  463. ppServerList - On successful return, holds a pointer to a structure
  464. containing the DNs of the appropriate servers or NULL. If NULL, any
  465. server with a value for the transport address type attribute can be
  466. used.
  467. Return Values:
  468. NO_ERROR - Success.
  469. ERROR_* - Failure.
  470. --*/
  471. typedef void ISM_FREE_TRANSPORT_SERVERS(
  472. IN HANDLE hIsm,
  473. IN ISM_SERVER_LIST * pServerList
  474. );
  475. ISM_FREE_TRANSPORT_SERVERS IsmFreeTransportServers;
  476. /*++
  477. Routine Description:
  478. Frees the structure returned by IsmGetTransportServers().
  479. Arguments:
  480. hIsm (IN) - Handle returned by a prior call to IsmStartup().
  481. pServerList (IN) - Structure to free.
  482. Return Values:
  483. None.
  484. --*/
  485. typedef DWORD ISM_GET_CONNECTION_SCHEDULE(
  486. IN HANDLE hIsm,
  487. IN LPCWSTR pszSite1DN,
  488. IN LPCWSTR pszSite2DN,
  489. OUT ISM_SCHEDULE ** ppSchedule
  490. );
  491. ISM_GET_CONNECTION_SCHEDULE IsmGetConnectionSchedule;
  492. /*++
  493. Routine Description:
  494. Retrieve the schedule by which two given sites are connected via this
  495. transport.
  496. On successful return, it is the ISM service's responsibility to eventually
  497. call IsmFreeSchedule(*ppSchedule);
  498. Arguments:
  499. hIsm (IN) - Handle returned by a prior call to IsmStartup().
  500. pszSite1DN, pszSite2DN (IN) - Sites to query.
  501. ppSchedule - On successful return, holds a pointer to a structure
  502. describing the schedule by which the two given sites are connected via
  503. the transport, or NULL if the sites are always connected.
  504. Return Values:
  505. NO_ERROR - Success.
  506. ERROR_* - Failure.
  507. --*/
  508. typedef void ISM_FREE_CONNECTION_SCHEDULE(
  509. IN HANDLE hIsm,
  510. IN ISM_SCHEDULE * pSchedule
  511. );
  512. ISM_FREE_CONNECTION_SCHEDULE IsmFreeConnectionSchedule;
  513. /*++
  514. Routine Description:
  515. Frees the structure returned by IsmGetTransportServers().
  516. Arguments:
  517. hIsm (IN) - Handle returned by a prior call to IsmStartup().
  518. pSchedule (IN) - Structure to free.
  519. Return Values:
  520. None.
  521. --*/
  522. typedef void ISM_SHUTDOWN(
  523. IN HANDLE hIsm,
  524. IN ISM_SHUTDOWN_REASON_CODE eReason
  525. );
  526. ISM_SHUTDOWN IsmShutdown;
  527. /*++
  528. Routine Description:
  529. Uninitialize transport plug-in.
  530. Arguments:
  531. hIsm (IN) - Handle returned by a prior call to IsmStartup().
  532. Return Values:
  533. None.
  534. --*/
  535. typedef DWORD ISM_QUERY_SITES_BY_COST(
  536. IN HANDLE hIsm,
  537. IN LPCWSTR pszFromSite,
  538. IN DWORD cToSites,
  539. IN LPCWSTR* rgszToSites,
  540. IN DWORD dwFlags,
  541. OUT ISM_SITE_COST_INFO_ARRAY** prgSiteInfo
  542. );
  543. /*++
  544. Routine Description:
  545. Determine the individual costs between the From site and the To sites.
  546. Arguments:
  547. pszFromSite (IN) - The distinguished name of the From site.
  548. rgszToSites (IN) - An array containing the distinguished names of the To sites.
  549. cToSites (IN) - The number of entries in the rgszToSites array.
  550. dwFlags (IN) - Unused.
  551. prgSiteInfo (IN) - On successful return, holds a pointer to a structure
  552. containing the costs between the From site and the To sites.
  553. Return Values:
  554. NO_ERROR - Success.
  555. ERROR_* - Failure.
  556. --*/
  557. typedef void ISM_FREE_SITE_COST_INFO(
  558. IN HANDLE hIsm,
  559. IN ISM_SITE_COST_INFO_ARRAY *rgSiteCostInfo
  560. );
  561. /*++
  562. Routine Description:
  563. Frees the structure returned by ISM_QUERY_SITES_BY_COST().
  564. Arguments:
  565. hIsm (IN) - Handle returned by a prior call to IsmStartup().
  566. rgSiteCostInfo (IN) - Structure to free.
  567. Return Values:
  568. None.
  569. --*/
  570. #endif // #ifndef MIDL_PASS
  571. #ifdef __cplusplus
  572. }
  573. #endif
  574. #endif // __ISMAPI_H__