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.

495 lines
10 KiB

  1. /*++
  2. Copyright (c) 1994 Microsoft Corporation
  3. Module Name:
  4. proto.h
  5. Abstract:
  6. This module contains the function prototypes for the DHCP client.
  7. Author:
  8. Manny Weiser (mannyw) 21-Oct-1992
  9. Environment:
  10. User Mode - Win32
  11. Revision History:
  12. Madan Appiah (madana) 21-Oct-1993
  13. --*/
  14. #ifndef _PROTO_
  15. #define _PROTO_
  16. //
  17. // OS independant functions
  18. //
  19. DWORD
  20. DhcpInitialize(
  21. LPDWORD SleepTime
  22. );
  23. DWORD
  24. ObtainInitialParameters(
  25. PDHCP_CONTEXT DhcpContext,
  26. PDHCP_OPTIONS DhcpOptions,
  27. BOOL *fAutoConfigure
  28. );
  29. DWORD
  30. RenewLease(
  31. PDHCP_CONTEXT DhcpContext,
  32. PDHCP_OPTIONS DhcpOptions
  33. );
  34. DWORD
  35. CalculateTimeToSleep(
  36. PDHCP_CONTEXT DhcpContext
  37. );
  38. DWORD
  39. ReObtainInitialParameters(
  40. PDHCP_CONTEXT DhcpContext,
  41. LPDWORD Sleep
  42. );
  43. BOOL
  44. DhcpIsInitState(
  45. DHCP_CONTEXT *pContext
  46. );
  47. DWORD
  48. ReRenewParameters(
  49. PDHCP_CONTEXT DhcpContext,
  50. LPDWORD Sleep
  51. );
  52. DWORD
  53. ReleaseIpAddress(
  54. PDHCP_CONTEXT DhcpContext
  55. );
  56. DWORD // status
  57. SendInformAndGetReplies( // send an inform packet and collect replies
  58. IN PDHCP_CONTEXT DhcpContext, // the context to send out of
  59. IN DWORD nInformsToSend,// how many informs to send?
  60. IN DWORD MaxAcksToWait // how many acks to wait for
  61. );
  62. DWORD
  63. InitializeDhcpSocket(
  64. SOCKET *Socket,
  65. DHCP_IP_ADDRESS IpAddress,
  66. BOOL IsApiCall // is it related to an API generated context?
  67. );
  68. DWORD
  69. HandleIPAutoconfigurationAddressConflict(
  70. DHCP_CONTEXT *pContext
  71. );
  72. DHCP_IP_ADDRESS // Ip address o/p after hashing
  73. GrandHashing(
  74. IN LPBYTE HwAddress, // Hardware addres of the card
  75. IN DWORD HwLen, // Hardware length
  76. IN OUT LPDWORD Seed, // In: orig value, Out: final value
  77. IN DHCP_IP_ADDRESS Mask, // Subnet mask to generate ip addr in
  78. IN DHCP_IP_ADDRESS Subnet // Subnet address to generate ip addr in
  79. );
  80. DWORD
  81. DhcpPerformIPAutoconfiguration(
  82. DHCP_CONTEXT *pContext
  83. );
  84. ULONG
  85. DhcpDynDnsGetDynDNSOption(
  86. IN OUT BYTE *OptBuf,
  87. IN OUT ULONG *OptBufSize,
  88. IN HKEY hAdapterKey,
  89. IN LPCWSTR AdapterName,
  90. IN BOOL fEnabled,
  91. IN LPCSTR DhcpDomainOption,
  92. IN ULONG DhcpDomainOptionSize
  93. );
  94. ULONG
  95. DhcpDynDnsDeregisterAdapter(
  96. IN HKEY hAdapterKey,
  97. IN LPCWSTR AdapterName,
  98. IN BOOL fRAS,
  99. IN BOOL fDynDnsEnabled
  100. );
  101. ULONG
  102. DhcpDynDnsRegisterDhcpOrRasAdapter(
  103. IN HKEY hAdapterKey,
  104. IN LPCWSTR AdapterName,
  105. IN BOOL fDynDnsEnabled,
  106. IN BOOL fRAS,
  107. IN ULONG IpAddress,
  108. IN LPBYTE DomOpt OPTIONAL,
  109. IN ULONG DomOptSize,
  110. IN LPBYTE DnsListOpt OPTIONAL,
  111. IN ULONG DnsListOptSize,
  112. IN LPBYTE DnsFQDNOpt,
  113. IN ULONG DnsFQDNOptSize
  114. );
  115. ULONG *
  116. DhcpCreateListFromStringAndFree(
  117. IN LPWSTR Str,
  118. IN LPWSTR Separation,
  119. OUT LPDWORD nAddresses
  120. );
  121. ULONG
  122. DhcpDynDnsRegisterStaticAdapter(
  123. IN HKEY hAdapterKey,
  124. IN LPCWSTR AdapterName,
  125. IN BOOL fRAS,
  126. IN BOOL fDynDnsEnabled
  127. );
  128. DWORD
  129. NotifyDnsCache(
  130. VOID
  131. );
  132. DWORD
  133. CalculateExpDelay(
  134. DWORD dwDelay,
  135. DWORD dwFuzz
  136. );
  137. //
  138. // OS specific functions
  139. //
  140. DWORD
  141. SystemInitialize(
  142. VOID
  143. );
  144. VOID
  145. ScheduleWakeUp(
  146. PDHCP_CONTEXT DhcpContext,
  147. DWORD TimeToSleep
  148. );
  149. DWORD
  150. SetDhcpConfigurationForNIC(
  151. PDHCP_CONTEXT DhcpContext,
  152. PDHCP_OPTIONS DhcpOptions,
  153. DHCP_IP_ADDRESS IpAddress,
  154. DHCP_IP_ADDRESS ServerIpAddress,
  155. BOOL ObtainedNewAddress
  156. );
  157. DWORD
  158. SetAutoConfigurationForNIC(
  159. PDHCP_CONTEXT DhcpContext,
  160. DHCP_IP_ADDRESS Address,
  161. DHCP_IP_ADDRESS Mask
  162. );
  163. DWORD
  164. SendDhcpMessage(
  165. PDHCP_CONTEXT DhcpContext,
  166. DWORD MessageLength,
  167. LPDWORD TransactionId
  168. );
  169. DWORD
  170. SendDhcpDecline(
  171. PDHCP_CONTEXT DhcpContext,
  172. DWORD dwTransactionId,
  173. DWORD dwServerIPAddress,
  174. DWORD dwDeclinedIPAddress
  175. );
  176. DWORD
  177. GetSpecifiedDhcpMessage(
  178. PDHCP_CONTEXT DhcpContext,
  179. PDWORD BufferLength,
  180. DWORD TransactionId,
  181. DWORD TimeToWait
  182. );
  183. DWORD
  184. OpenDhcpSocket(
  185. PDHCP_CONTEXT DhcpContext
  186. );
  187. DWORD
  188. CloseDhcpSocket(
  189. PDHCP_CONTEXT DhcpContext
  190. );
  191. DWORD
  192. InitializeInterface(
  193. PDHCP_CONTEXT DhcpContext
  194. );
  195. DWORD
  196. UninitializeInterface(
  197. PDHCP_CONTEXT DhcpContext
  198. );
  199. VOID
  200. DhcpLogEvent(
  201. PDHCP_CONTEXT DhcpContext,
  202. DWORD EventNumber,
  203. DWORD ErrorCode
  204. );
  205. BOOL
  206. NdisWanAdapter(
  207. PDHCP_CONTEXT DhcpContext
  208. );
  209. POPTION
  210. AppendOptionParamsRequestList(
  211. #if defined(__DHCP_CLIENT_OPTIONS_API_ENABLED__)
  212. PDHCP_CONTEXT DhcpContext,
  213. #endif
  214. POPTION Option,
  215. LPBYTE OptionEnd
  216. );
  217. DWORD
  218. InitEnvSpecificDhcpOptions(
  219. PDHCP_CONTEXT DhcpContext
  220. );
  221. DWORD
  222. ExtractEnvSpecificDhcpOption(
  223. PDHCP_CONTEXT DhcpContext,
  224. DHCP_OPTION_ID OptionId,
  225. LPBYTE OptionData,
  226. DWORD OptionDataLength
  227. );
  228. DWORD
  229. SetEnvSpecificDhcpOptions(
  230. PDHCP_CONTEXT DhcpContext
  231. );
  232. DWORD
  233. DisplayUserMessage(
  234. PDHCP_CONTEXT DhcpContext,
  235. DWORD MessageId,
  236. DHCP_IP_ADDRESS IpAddress
  237. );
  238. DWORD
  239. UpdateStatus(
  240. VOID
  241. );
  242. #ifdef VXD
  243. VOID // declspec(import) hoses vxd so work
  244. DhcpSleep( DWORD dwMilliseconds ) ; // around it
  245. #else
  246. #define DhcpSleep Sleep
  247. #endif
  248. DWORD
  249. IPSetInterface(
  250. DWORD IpInterfaceContext
  251. );
  252. DWORD
  253. IPResetInterface(
  254. DWORD IpInterfaceContext
  255. );
  256. DWORD SetIPAddressAndArp(
  257. PVOID pvLocalInformation,
  258. DWORD dwAddress,
  259. DWORD dwSubnetMask
  260. );
  261. DWORD BringUpInterface(
  262. PVOID pvLocalInformation
  263. );
  264. DWORD
  265. OpenDriver(
  266. HANDLE *Handle,
  267. LPWSTR DriverName
  268. );
  269. DWORD
  270. DhcpRegReadMachineType(void);
  271. #ifdef NEWNT
  272. DWORD
  273. DhcpRegPingingEnabled(PDHCP_CONTEXT);
  274. LPSTR
  275. DhcpGetDomainName(
  276. LPWSTR AdapterName,
  277. LPSTR Buf, DWORD Size);
  278. #endif
  279. #ifdef VXD
  280. VOID
  281. CleanupDhcpOptions(
  282. PDHCP_CONTEXT DhcpContext
  283. );
  284. #endif
  285. DWORD
  286. DhcpRegOkToUseInform(
  287. LPWSTR AdapterName
  288. );
  289. DWORD
  290. DhcpRegAutonetRetries(
  291. IN PDHCP_CONTEXT DhcpContext
  292. );
  293. // Media sense related common functions
  294. DWORD
  295. ProcessMediaConnectEvent(
  296. PDHCP_CONTEXT dhcpContext,
  297. IP_STATUS mediaStatus
  298. );
  299. DWORD // win32 status
  300. DhcpDestroyContext( // destroy this context and free relevant stuff
  301. IN PDHCP_CONTEXT DhcpContext // the context to destroy and free
  302. );
  303. //
  304. // dhcp/vxd common function with different implementations
  305. //
  306. LPWSTR // Adapter name string
  307. DhcpAdapterName( // get the adapter name string stored in the context
  308. IN PDHCP_CONTEXT DhcpContext
  309. );
  310. //
  311. // registry
  312. //
  313. DWORD // win32
  314. DhcpRegRecurseDelete( // delete the key, recursing downwards
  315. IN HKEY Key, // root at this key and
  316. IN LPWSTR KeyName // delete the key given by this keyname (and all its children)
  317. );
  318. BOOL // obtained a static address?
  319. DhcpRegDomainName( // get the static domain name if any
  320. IN PDHCP_CONTEXT DhcpContext, // adapter to get static domain for..
  321. IN OUT LPBYTE DomainNameBuf, // buffer to fill with static domain name
  322. IN ULONG BufSize // size of above buffer in bytes..
  323. );
  324. // protocol.c
  325. DWORD // status
  326. SendDhcpDiscover( // send a discover packet
  327. IN PDHCP_CONTEXT DhcpContext, // on this context
  328. IN OUT DWORD *pdwXid // use this Xid (if zero, fill something and return it)
  329. );
  330. DWORD // Time in seconds
  331. DhcpCalculateWaitTime( // how much time to wait
  332. IN DWORD RoundNum, // which round is this
  333. OUT DWORD *WaitMilliSecs // if needed the # in milli seconds
  334. );
  335. VOID
  336. DhcpExtractFullOrLiteOptions( // Extract some important options alone or ALL
  337. IN PDHCP_CONTEXT DhcpContext, // input context
  338. IN LPBYTE OptStart, // start of the options stuff
  339. IN DWORD MessageSize, // # of bytes of options
  340. IN BOOL LiteOnly, // next struc is EXPECTED_OPTIONS and not FULL_OPTIONS
  341. OUT LPVOID DhcpOptions, // this is where the options would be stored
  342. IN OUT PLIST_ENTRY RecdOptions, // if !LiteOnly this gets filled with all incoming options
  343. IN OUT time_t *LeaseExpiry, // if !LiteOnly input expiry time, else output expiry time
  344. IN LPBYTE ClassName, // if !LiteOnly this is used to add to the option above
  345. IN DWORD ClassLen, // if !LiteOnly this gives the # of bytes of classname
  346. IN DWORD ServerId // if !LiteOnly this specifies the server which gave this
  347. );
  348. DWORD // status
  349. SendDhcpRequest( // send a dhcp request packet
  350. IN PDHCP_CONTEXT DhcpContext, // the context to send the packet on
  351. IN PDWORD pdwXid, // what is hte Xid to use?
  352. IN DWORD RequestedAddr, // what address do we want?
  353. IN DWORD SelectedServer,// is there a prefernce for a server?
  354. IN BOOL UseCiAddr // should CIADDR be set with desired address?
  355. );
  356. DWORD
  357. SendDhcpRelease(
  358. PDHCP_CONTEXT DhcpContext
  359. );
  360. typedef enum {
  361. DHCP_GATEWAY_UNREACHABLE = 0,
  362. DHCP_GATEWAY_REACHABLE,
  363. DHCP_GATEWAY_REQUEST_CANCELLED
  364. } DHCP_GATEWAY_STATUS;
  365. DHCP_GATEWAY_STATUS
  366. RefreshNotNeeded(
  367. IN PDHCP_CONTEXT DhcpContext
  368. );
  369. //
  370. // ioctl.c
  371. //
  372. DWORD
  373. IPDelNonPrimaryAddresses(
  374. LPWSTR AdapterName
  375. );
  376. DWORD
  377. GetIpInterfaceContext(
  378. LPWSTR AdapterName,
  379. DWORD IpIndex,
  380. LPDWORD IpInterfaceContext
  381. );
  382. //
  383. // dhcp.c
  384. //
  385. DWORD
  386. LockDhcpContext(
  387. PDHCP_CONTEXT DhcpContext,
  388. BOOL bCancelOngoingRequest
  389. );
  390. BOOL
  391. UnlockDhcpContext(
  392. PDHCP_CONTEXT DhcpContext
  393. );
  394. #endif // _PROTO_