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.

401 lines
9.0 KiB

  1. /*++
  2. Copyright (c) 1994 Microsoft Corporation
  3. Module Name:
  4. svcloc.h
  5. Abstract:
  6. contains proto-type and data-type definitions for service location
  7. APIs
  8. Author:
  9. Madan Appiah (madana) 15-May-1995
  10. Environment:
  11. User Mode - Win32
  12. Revision History:
  13. --*/
  14. #ifndef _SVCLOC_
  15. #define _SVCLOC_
  16. #include <inetcom.h> // for internet service identifier
  17. #ifdef __cplusplus
  18. extern "C" {
  19. #endif
  20. //
  21. // constant definitions.
  22. //
  23. //
  24. // internet service identifier mask.
  25. // each service is assigned a bit, so that we can
  26. // accomodate up to 64 service in ULONGLONG type.
  27. //
  28. #if 0
  29. #define INET_FTP_SERVICE (ULONGLONG)(INET_FTP)
  30. #define INET_GOPHER_SERVICE (ULONGLONG)(INET_GOPHER)
  31. #define INET_W3_SERVICE (ULONGLONG)(INET_HTTP)
  32. #define INET_W3_PROXY_SERVICE (ULONGLONG)(INET_HTTP_PROXY)
  33. #define INET_MSN_SERVICE (ULONGLONG)(INET_MSN)
  34. #define INET_NNTP_SERVICE (ULONGLONG)(INET_NNTP)
  35. #define INET_SMTP_SERVICE (ULONGLONG)(INET_SMTP)
  36. #define INET_POP3_SERVICE (ULONGLONG)(INET_POP3)
  37. #define INET_GATEWAY_SERVICE (ULONGLONG)(INET_GATEWAY)
  38. #define INET_CHAT_SERVICE (ULONGLONG)(INET_CHAT)
  39. #define INET_LDAP_SERVICE (ULONGLONG)(INET_LDAP)
  40. #define INET_IMAP_SERVICE (ULONGLONG)(INET_IMAP)
  41. #endif
  42. //
  43. // IIS 3.0 Service location id
  44. //
  45. // When adding a new service ID, add it the INET_ALL_SERVICES_ID
  46. #define INET_FTP_SVCLOC_ID (ULONGLONG)(0x0000000000000001)
  47. #define INET_GOPHER_SVCLOC_ID (ULONGLONG)(0x0000000000000002)
  48. #define INET_W3_SVCLOC_ID (ULONGLONG)(0x0000000000000004)
  49. #define INET_MW3_SVCLOC_ID (ULONGLONG)(0x8000000000000000)
  50. #define INET_MFTP_SVCLOC_ID (ULONGLONG)(0x4000000000000000)
  51. #define INET_ALL_SERVICES_ID ( INET_FTP_SVCLOC_ID | \
  52. INET_W3_SVCLOC_ID )
  53. //
  54. // default wait time for server discovery.
  55. //
  56. #define SVC_DEFAULT_WAIT_TIME 0x5 // 5 secs.
  57. //
  58. // Datatype definitions.
  59. //
  60. typedef __int64 LONGLONG;
  61. typedef unsigned __int64 ULONGLONG;
  62. typedef enum _INET_SERVICE_STATE {
  63. INetServiceStopped,
  64. // the service has invoked de-registration or
  65. // the service has never called registration.
  66. INetServiceRunning,
  67. // the service is running.
  68. INetServicePaused
  69. // the service is paused.
  70. } INET_SERVICE_STATE, *LPINET_SERVICE_STATE;
  71. typedef struct _INET_BIND_INFO {
  72. DWORD Length; // length of bind data.
  73. PVOID BindData; // bind data, such as binding string or sock addr.
  74. } INET_BIND_INFO, *LPINET_BIND_INFO;
  75. typedef INET_BIND_INFO INET_SERVER_ADDRESS;
  76. typedef LPINET_BIND_INFO LPINET_SERVER_ADDRESS;
  77. typedef struct _INET_BINDINGS {
  78. DWORD NumBindings;
  79. LPINET_BIND_INFO BindingsInfo; // array of bind info structures.
  80. } INET_BINDINGS, *LPINET_BINDINGS;
  81. typedef struct _INET_SERVICE_INFO {
  82. ULONGLONG ServiceMask;
  83. INET_SERVICE_STATE ServiceState;
  84. LPSTR ServiceComment;
  85. INET_BINDINGS Bindings;
  86. } INET_SERVICE_INFO, *LPINET_SERVICE_INFO;
  87. typedef struct _INET_SERVICES_LIST {
  88. DWORD NumServices;
  89. LPINET_SERVICE_INFO *Services; // array of service struct. pointers
  90. } INET_SERVICES_LIST, *LPINET_SERVICES_LIST;
  91. typedef union _INET_VERSION_NUM {
  92. DWORD VersionNumber;
  93. struct {
  94. WORD Major;
  95. WORD Minor;
  96. } Version;
  97. } INET_VERSION_NUM, *LPINET_VERSION_NUM;
  98. typedef struct _INET_SERVER_INFO {
  99. INET_SERVER_ADDRESS ServerAddress; // pointer to a sock addr.
  100. INET_VERSION_NUM VersionNum;
  101. LPSTR ServerName;
  102. DWORD LoadFactor; // in percentage, 0 - idle and 100 - fully loaded
  103. ULONGLONG ServicesMask;
  104. INET_SERVICES_LIST Services;
  105. } INET_SERVER_INFO, *LPINET_SERVER_INFO;
  106. typedef struct _INET_SERVERS_LIST {
  107. DWORD NumServers;
  108. LPINET_SERVER_INFO *Servers;
  109. } INET_SERVERS_LIST, *LPINET_SERVERS_LIST;
  110. //
  111. // APIs
  112. //
  113. DWORD
  114. WINAPI
  115. INetDiscoverServers(
  116. IN ULONGLONG ServicesMask,
  117. IN DWORD WaitTime,
  118. OUT LPINET_SERVERS_LIST *ServersList
  119. )
  120. /*++
  121. Routine Description:
  122. This API discovers all servers on the network that support and run the
  123. internet services specified.
  124. This API is called by the client side code, such as the internet admin
  125. tool or wininet.dll.
  126. Arguments:
  127. SevicesMask : A bit mask that specifies to discover servers with the
  128. these services running.
  129. ex: 0x0000000E, will discovers all servers running any of the
  130. following services :
  131. 1. FTP_SERVICE
  132. 2. GOPHER_SERVICE
  133. 3. WEB_SERVICE
  134. DiscoverBindings : if this flag is set, this API talks to each of the
  135. discovered server and queries the services and bindings
  136. supported. If the flag is set to FALSE, it quickly returns with
  137. the list of servers only.
  138. WaitTime : Response wait time in secs. If this value is zero, it
  139. returns what ever discovered so far by the previous invocation of
  140. this APIs, otherwise it waits for the specified secs to collect
  141. responses from the servers.
  142. ServersList : Pointer to a location where the pointer to list of
  143. servers info is returned. The API allocates dynamic memory for
  144. this return data, the caller should free it by calling
  145. INetFreeDiscoverServerList after it has been used.
  146. Return Value:
  147. Windows Error Code.
  148. --*/
  149. ;
  150. DWORD
  151. WINAPI
  152. INetGetServerInfo(
  153. IN LPSTR ServerName,
  154. IN ULONGLONG ServicesMask,
  155. IN DWORD WaitTime,
  156. OUT LPINET_SERVER_INFO *ServerInfo
  157. )
  158. /*++
  159. Routine Description:
  160. This API returns the server info and a list of services supported by
  161. the server and lists of bindings supported by each of the services.
  162. Arguments:
  163. ServerName : name of the server whose info to be queried.
  164. ServicesMask : services to be queried
  165. WaitTime : Time in secs to wait.
  166. ServerInfo : pointer to a location where the pointer to the server
  167. info structure will be returned. The caller should call
  168. INetFreeServerInfo to free up the list after use.
  169. Return Value:
  170. Windows Error Code.
  171. --*/
  172. ;
  173. VOID
  174. WINAPI
  175. INetFreeDiscoverServersList(
  176. IN OUT LPINET_SERVERS_LIST *ServersList
  177. )
  178. /*++
  179. Routine Description:
  180. This API frees the memory chunks that were allotted for the servers
  181. list by the INetDiscoverServers call.
  182. Arguments:
  183. ServersList : pointer to a location where the pointer to the server
  184. list to be freed is stored.
  185. Return Value:
  186. NONE.
  187. --*/
  188. ;
  189. VOID
  190. WINAPI
  191. INetFreeServerInfo(
  192. IN OUT LPINET_SERVER_INFO *ServerInfo
  193. )
  194. /*++
  195. Routine Description:
  196. This API frees the memory chunks that were allotted for the server
  197. info structure by the INetGetServerInfo call.
  198. Arguments:
  199. ServerInfo : pointer to a location where the pointer to the server
  200. info structure to be freed is stored.
  201. Return Value:
  202. NONE.
  203. --*/
  204. ;
  205. DWORD
  206. WINAPI
  207. INetRegisterService(
  208. IN ULONGLONG ServiceMask,
  209. IN INET_SERVICE_STATE ServiceState,
  210. IN LPSTR ServiceComment,
  211. IN LPINET_BINDINGS Bindings
  212. )
  213. /*++
  214. Routine Description:
  215. This API registers an internet service. The service writers should
  216. call this API just after successfully started the service and the
  217. service is ready to accept incoming RPC calls. This API accepts an
  218. array of RPC binding strings that the service is listening on for the
  219. incoming RPC connections. This list will be distributed to the
  220. clients that are discovering this service.
  221. Arguments:
  222. ServiceMask : service mask, such as 0x00000001 (GATEWAY_SERVICE)
  223. ServiceState : State of the service, INetServiceRunning and
  224. INetServicePaused are valid states to pass.
  225. ServiceComment : Service comment specified by the admin.
  226. Bindings : list of bindings that are supported by the service. The
  227. bindings can be binding strings are those returned by the
  228. RpcBindingToStringBinding call or the sockaddrs.
  229. Return Value:
  230. Windows Error Code.
  231. --*/
  232. ;
  233. typedef
  234. DWORD
  235. (WINAPI *INET_REGISTER_SVC_FN)(
  236. ULONGLONG,
  237. INET_SERVICE_STATE,
  238. LPSTR,
  239. LPINET_BINDINGS
  240. );
  241. DWORD
  242. WINAPI
  243. INetDeregisterService(
  244. IN ULONGLONG ServiceMask
  245. )
  246. /*++
  247. Routine Description:
  248. This API de-registers an internet service from being announced to the
  249. discovering clients. The service writers should call this API just
  250. before shutting down the service.
  251. Arguments:
  252. ServiceMask : service mask, such as 0x00000001 (GATEWAY_SERVICE)
  253. Return Value:
  254. Windows Error Code.
  255. --*/
  256. ;
  257. typedef
  258. DWORD (WINAPI *INET_DEREGISTER_SVC_FN)(
  259. ULONGLONG
  260. );
  261. typedef
  262. BOOL (WINAPI * INET_INIT_CONTROL_SVC_FN)(
  263. VOID
  264. );
  265. DWORD
  266. DllProcessAttachSvcloc(
  267. VOID
  268. );
  269. DWORD
  270. DllProcessDetachSvcloc(
  271. VOID
  272. );
  273. //
  274. // Initializes and terminates the service locator - must call these
  275. // before using the other APIs
  276. //
  277. BOOL
  278. WINAPI
  279. InitSvcLocator(
  280. VOID
  281. );
  282. BOOL
  283. WINAPI
  284. TerminateSvcLocator(
  285. VOID
  286. );
  287. extern INET_INIT_CONTROL_SVC_FN pfnInitSvcLoc;
  288. extern INET_INIT_CONTROL_SVC_FN pfnTerminateSvcLoc;
  289. #ifdef __cplusplus
  290. }
  291. #endif
  292. #endif // _SVCLOC_
  293.