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.

417 lines
10 KiB

  1. /******************************************************************************
  2. **
  3. ** Copyright (c) 1998-1999 Microsoft Corporation
  4. **
  5. ** Module Name:
  6. **
  7. ** icsapi.h
  8. **
  9. ** Abstract:
  10. **
  11. ** External header for Internet Connection Sharing API module
  12. **
  13. ** Author:
  14. **
  15. ** Bruce Johnson (bjohnson)
  16. **
  17. **
  18. ** Environment:
  19. **
  20. ** Win32.
  21. **
  22. ** Revision History:
  23. **
  24. ** Date Author Comments
  25. ** -------- ---------- ----------------------------------------------------
  26. ** 03/08/99 bjohnson Created
  27. **
  28. ****************************************************************************/
  29. //****************************************************************************
  30. // Defines
  31. //****************************************************************************
  32. //
  33. // ICSAPI32 parameters
  34. //
  35. //****************************************************************************
  36. // ICS Return Codes
  37. //****************************************************************************
  38. #define ICS_ERROR_SUCCESS 0x00000000
  39. #define ICS_ERROR_FAILURE 0x80000001
  40. #define ICS_ERROR_NOT_IMPLEMENTED 0x80000002
  41. #define ICS_ERROR_NO_MEMORY 0x80000003
  42. #define ICS_ERROR_INVALID_OPTION 0x80000004
  43. #define ICS_ERROR_INVALID_PARAMETER 0x80000005
  44. //****************************************************************************
  45. // Options for IcsSetMapping
  46. //****************************************************************************
  47. #define ICS_PORTMAP_ENABLE 1
  48. #define ICS_PORTMAP_DISABLE 2
  49. #define ICS_PORTMAP_DISABLE_ALL 3
  50. #define ICS_PORTMAP_ENABLE_NON_PERSISTENT 4
  51. //****************************************************************************
  52. // Options for IcsDisconnect
  53. //****************************************************************************
  54. #define ICS_DISCONNECT_IMMEDIATELY 0
  55. #define ICS_DISCONNECT_IF_IDLE 1
  56. //****************************************************************************
  57. // Connect status
  58. //****************************************************************************
  59. #define ICS_CONN_STATUS_DISCONNECTED 0
  60. #define ICS_CONN_STATUS_DIALING 1
  61. #define ICS_CONN_STATUS_AUTHENTICATING 2
  62. #define ICS_CONN_STATUS_CONNECTED 3
  63. #define ICS_CONN_STATUS_LINE_IDLE 4
  64. //****************************************************************************
  65. // Autodial configuration
  66. //****************************************************************************
  67. #define ICS_AUTODIAL_OPT_NONE 0x00000000 // No options
  68. #define ICS_AUTODIAL_OPT_NEVER 0x00000001 // Never Autodial
  69. #define ICS_AUTODIAL_OPT_ALWAYS 0x00000002 // Autodial regardless
  70. #define ICS_AUTODIAL_OPT_DEMAND 0x00000004 // Autodial on demand
  71. //****************************************************************************
  72. // Ip Information options
  73. //****************************************************************************
  74. #define ICS_IP_OPT_NONE 0x00000000 // No options
  75. #define ICS_IP_OPT_ENABLE_DHCP 0x00000001 // Enable DHCP
  76. //****************************************************************************
  77. // Miscellaneous
  78. //****************************************************************************
  79. #define ICS_MAX_NAME 255
  80. #define ICS_MAX_PORTKEY 255
  81. #define ICS_MAX_INDEX 255
  82. #define ICS_MAX_STRING 1024
  83. #define ICS_DISABLED 0
  84. #define ICS_ENABLED 1
  85. //****************************************************************************
  86. // Typedefs
  87. //****************************************************************************
  88. //
  89. // ICS Machine Information
  90. //
  91. typedef struct _ICS_MACHINE_INFO {
  92. char szName[ICS_MAX_NAME+1];
  93. BYTE bMacAddress[6];
  94. DWORD IpAddress;
  95. DWORD dwLeaseTime;
  96. DWORD dwOptions;
  97. } ICS_MACHINE_INFO, *PICS_MACHINE_INFO, *LPICS_MACHINE_INFO;
  98. //
  99. // ICS Client Options
  100. //
  101. typedef struct _ICS_CLIENT_OPTIONS {
  102. char szName[ICS_MAX_NAME+1];
  103. DWORD dwOptions;
  104. } ICS_CLIENT_OPTIONS, *PICS_CLIENT_OPTIONS, *LPICS_CLIENT_OPTIONS;
  105. //
  106. // ICS Port Mapping
  107. //
  108. typedef struct _ICS_PORT_MAPPING {
  109. char szName[ICS_MAX_NAME+1];
  110. char szPortMapping[ICS_MAX_PORTKEY+1];
  111. DWORD dwOptions;
  112. } ICS_PORT_MAPPING, *PICS_PORT_MAPPING, *LPICS_PORT_MAPPING;
  113. //
  114. // ICS Active Port Mapping
  115. //
  116. typedef struct _ICS_ACTIVE_PORT_MAPPING {
  117. ICS_PORT_MAPPING PortMap;
  118. ICS_MACHINE_INFO Client;
  119. } ICS_ACTIVE_PORT_MAPPING, *PICS_ACTIVE_PORT_MAPPING, *LPICS_ACTIVE_PORT_MAPPING;
  120. //
  121. // ICS Adapter Information
  122. //
  123. typedef struct _ICS_ADAPTER {
  124. char szAdapterName[ICS_MAX_NAME+1];
  125. char szAdapterIndex[ICS_MAX_INDEX+1];
  126. } ICS_ADAPTER, *PICS_ADAPTER, *LPICS_ADAPTER;
  127. //
  128. // ICS IP Information
  129. //
  130. typedef struct _ICS_IP_INFORMATION {
  131. DWORD dwOptions;
  132. char szIPAddress[ICS_MAX_STRING];
  133. char szIPMask[ICS_MAX_STRING];
  134. char szDefaultGateway[ICS_MAX_STRING];
  135. char szDNSServerPrimary[ICS_MAX_STRING];
  136. char szDNSServerSecondary[ICS_MAX_STRING];
  137. char szHostName[ICS_MAX_STRING];
  138. char szDomainName[ICS_MAX_STRING];
  139. char szDomainSuffixSearchList[ICS_MAX_STRING];
  140. } ICS_IP_INFORMATION, *PICS_IP_INFORMATION, *LPICS_IP_INFORMATION;
  141. //
  142. // ICS General Statistics
  143. //
  144. typedef struct _ICS_GENERAL_STATISTICS {
  145. DWORD dwBytesSent;
  146. DWORD dwBytesReceived;
  147. DWORD dwActiveClients;
  148. DWORD dwActivePortMappings;
  149. DWORD dwUpTime;
  150. DWORD dwStatusFlags;
  151. char szAutodialMachine [ICS_MAX_NAME+1];
  152. } ICS_GENERAL_STATISTICS, *PICS_GENERAL_STATISTICS, *LPICS_GENERAL_STATISTICS;
  153. //
  154. // ICS General Configuration
  155. //
  156. typedef struct _ICS_GENERAL_CONFIGURATION {
  157. DWORD dwEnabled;
  158. DWORD dwShowTrayIcon;
  159. DWORD dwDHCPEnabled;
  160. DWORD dwDNSEnabled;
  161. DWORD dwLoggingEnabled;
  162. DWORD dwDHCPSubnet;
  163. DWORD dwDHCPServerAddress;
  164. DWORD dwOptions;
  165. DWORD dwAutodialEnabled;
  166. DWORD dwAutodialTimeout;
  167. char szAutodialConnection [ICS_MAX_NAME+1];
  168. char szInternetAdapter [ICS_MAX_INDEX+1];
  169. char szHomeNetworkAdapter [ICS_MAX_INDEX+1];
  170. } ICS_GENERAL_CONFIGURATION, *PICS_GENERAL_CONFIGURATION, *LPICS_GENERAL_CONFIGURATION;
  171. typedef struct _ICS_GENERAL_CONFIGURATION ICS_CONFIG, *PICS_CONFIG, *LPICS_CONFIG;
  172. typedef enum {
  173. ICS_MSG_CONNECT_STATUS_CHANGE,
  174. ICS_MSG_ICS_STATUS_CHANGE,
  175. } ICS_MESSAGE_TYPE;
  176. typedef struct
  177. {
  178. DWORD dwConnectStatus;
  179. DWORD dwLastError;
  180. } ICS_MSG_CONNECT_STATUS_CHANGE_INFO;
  181. typedef struct
  182. {
  183. DWORD dwIcsStatus;
  184. } ICS_MSG_ICS_STATUS_CHANGE_INFO;
  185. typedef struct _ICS_MESSAGE {
  186. ICS_MESSAGE_TYPE Type;
  187. union
  188. {
  189. ICS_MSG_CONNECT_STATUS_CHANGE_INFO IcsConnectStatusChangeInfo;
  190. ICS_MSG_ICS_STATUS_CHANGE_INFO IcsStatusChangeInfo;
  191. } MsgSpecific;
  192. } ICS_MESSAGE, *LPICS_MESSAGE;
  193. #define IM_dwConnectStatus MsgSpecific.IcsConnectStatusChangeInfo.dwConnectStatus
  194. #define IM_dwLastError MsgSpecific.IcsConnectStatusChangeInfo.dwLastError
  195. #define IM_dwIcsStatus MsgSpecific.IcsStatusChangeInfo.dwIcsStatus
  196. typedef VOID (WINAPI *ICS_MSG_NOTIFIER_FN)(LPICS_MESSAGE pIcsMsg);
  197. //****************************************************************************
  198. //
  199. // Prototypes
  200. //
  201. //****************************************************************************
  202. //****************************************************************************
  203. // Configuration API's
  204. //****************************************************************************
  205. DWORD APIENTRY
  206. IcsGetConfiguration(
  207. LPICS_CONFIG lpIcsConfig
  208. );
  209. DWORD APIENTRY
  210. IcsSetConfiguration(
  211. LPICS_CONFIG lpIcsConfig
  212. );
  213. DWORD APIENTRY
  214. IcsGetAdapterList(
  215. LPICS_ADAPTER lpIcsAdapterList,
  216. LPDWORD lpdwBufferSize
  217. );
  218. DWORD APIENTRY
  219. IcsGetIpInformation(
  220. LPICS_ADAPTER lpIcsAdapter,
  221. LPICS_IP_INFORMATION lpIcsIpInformation
  222. );
  223. DWORD APIENTRY
  224. IcsSetIpInformation(
  225. LPICS_ADAPTER lpIcsAdapter,
  226. LPICS_IP_INFORMATION lpIcsIpInformation
  227. );
  228. DWORD APIENTRY
  229. IcsSetInternetConnection(
  230. LPICS_ADAPTER lpIcsAdapter
  231. );
  232. DWORD APIENTRY
  233. IcsSetHomenetConnection(
  234. LPICS_ADAPTER lpIcsAdapter
  235. );
  236. DWORD APIENTRY
  237. IcsEnumerateInstalledMappings(
  238. LPICS_PORT_MAPPING lpIcsPortMappings,
  239. LPDWORD lpdwBufferSize
  240. );
  241. DWORD APIENTRY
  242. IcsGetAutodialEnable(
  243. LPDWORD lpdwOpt
  244. );
  245. //****************************************************************************
  246. // Management API's
  247. //****************************************************************************
  248. BOOLEAN APIENTRY
  249. IsIcsInstalled(
  250. VOID
  251. );
  252. BOOLEAN APIENTRY
  253. IsIcsAvailable(
  254. VOID
  255. );
  256. BOOLEAN APIENTRY
  257. IsIcsEnabled(
  258. VOID
  259. );
  260. DWORD APIENTRY
  261. IcsConnect(
  262. LPSTR lpszPhonebook,
  263. BOOL Synchronous
  264. );
  265. DWORD APIENTRY
  266. IcsDisconnect(
  267. DWORD dwOptions
  268. );
  269. DWORD APIENTRY
  270. IcsEnable(
  271. DWORD dwOptions
  272. );
  273. DWORD APIENTRY
  274. IcsDisable(
  275. DWORD dwOptions
  276. );
  277. DWORD APIENTRY
  278. IcsGetStatistics(
  279. LPICS_GENERAL_STATISTICS lpIcsGeneralStats
  280. );
  281. DWORD APIENTRY
  282. Remote_IcsGetStatistics(
  283. LPICS_GENERAL_STATISTICS lpIcsGeneralStats
  284. );
  285. DWORD APIENTRY
  286. IcsEnumerateClients(
  287. LPICS_MACHINE_INFO lpIcsClients,
  288. LPDWORD lpdwBufferSize
  289. );
  290. DWORD APIENTRY
  291. IcsEnumerateActiveMappings(
  292. LPICS_ACTIVE_PORT_MAPPING lpIcsActiveMappings,
  293. LPDWORD lpdwBufferSize
  294. );
  295. DWORD APIENTRY
  296. IcsSetMapping(
  297. LPICS_MACHINE_INFO lpIcsClient,
  298. LPICS_PORT_MAPPING lpIcsPortMap,
  299. DWORD dwOptions
  300. );
  301. DWORD APIENTRY
  302. IcsGetClientOptions(
  303. LPICS_MACHINE_INFO lpIcsClient,
  304. LPICS_CLIENT_OPTIONS lpIcsClientOptions
  305. );
  306. DWORD APIENTRY
  307. IcsSetClientOptions(
  308. LPICS_MACHINE_INFO lpIcsClient,
  309. LPICS_CLIENT_OPTIONS lpIcsClientOptions
  310. );
  311. DWORD APIENTRY
  312. IcsGetConnectStatus(
  313. LPDWORD lpdwConnectStatus,
  314. LPDWORD lpdwLastError
  315. );
  316. DWORD APIENTRY
  317. IcsRegisterNotifierCallback(
  318. LPVOID fnNotifier,
  319. DWORD Options
  320. );