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.

141 lines
3.2 KiB

  1. /*
  2. Copyright (c) 1998, Microsoft Corporation, all rights reserved
  3. Description:
  4. History:
  5. */
  6. #ifndef _RASDHCP__H_
  7. #define _RASDHCP__H_
  8. #include "rasiphlp_.h"
  9. #include <time.h>
  10. #include <dhcpcapi.h>
  11. #include <winsock2.h>
  12. #include <mprlog.h>
  13. #include <rasman.h>
  14. #include <rasppp.h>
  15. #include <raserror.h>
  16. #include "helper.h"
  17. #include "tcpreg.h"
  18. #include "timer.h"
  19. #include "rastcp.h"
  20. #include "rassrvr.h"
  21. #include "rasdhcp.h"
  22. // This is used in combination with MAC address and Index to generate a
  23. // unique clientUID.
  24. #define RAS_PREPEND "RAS "
  25. // The following should be a multiple of TIMER_PERIOD/1000
  26. #define RETRY_TIME 120 // Every 120 seconds
  27. // Values of the ADDR_INFO->ai_Flags field
  28. // Set after lease expires and after registry is read. Unset after a
  29. // successful renew.
  30. #define AI_FLAG_RENEW 0x00000001
  31. // Set if in use
  32. #define AI_FLAG_IN_USE 0x00000002
  33. typedef struct _Addr_Info
  34. {
  35. struct _Addr_Info* ai_Next;
  36. TIMERLIST ai_Timer;
  37. DHCP_LEASE_INFO ai_LeaseInfo;
  38. // AI_FLAG_*
  39. DWORD ai_Flags;
  40. // Valid only for allocated addresses. For diagnositc purposes.
  41. HPORT ai_hPort;
  42. // Client UID is a combo of RAS_PREPEND,
  43. // 8 byte base and a 4 byte index.
  44. union
  45. {
  46. BYTE ai_ClientUIDBuf[16];
  47. DWORD ai_ClientUIDWords[4];
  48. };
  49. } ADDR_INFO;
  50. typedef struct _Available_Index
  51. {
  52. struct _Available_Index* pNext;
  53. // This index is < RasDhcpNextIndex, but is available
  54. // because we couldn't renew its lease.
  55. DWORD dwIndex;
  56. } AVAIL_INDEX;
  57. NT_PRODUCT_TYPE RasDhcpNtProductType = NtProductWinNt;
  58. ADDR_INFO* RasDhcpFreePool = NULL;
  59. ADDR_INFO* RasDhcpAllocPool = NULL;
  60. AVAIL_INDEX* RasDhcpAvailIndexes = NULL;
  61. BOOL RasDhcpUsingEasyNet = TRUE;
  62. DWORD RasDhcpNumAddrsAlloced = 0;
  63. DWORD RasDhcpNumReqAddrs = 0;
  64. DWORD RasDhcpNextIndex = 0;
  65. TIMERLIST RasDhcpMonitorTimer = { 0 };
  66. // This critical section controls access to the above global variables
  67. extern CRITICAL_SECTION RasDhcpCriticalSection;
  68. DWORD
  69. rasDhcpAllocateAddress(
  70. VOID
  71. );
  72. VOID
  73. rasDhcpRenewLease(
  74. IN HANDLE rasDhcpTimerShutdown,
  75. IN TIMERLIST* pTimer
  76. );
  77. VOID
  78. rasDhcpFreeAddress(
  79. IN ADDR_INFO* pAddrInfo
  80. );
  81. VOID
  82. rasDhcpMonitorAddresses(
  83. IN HANDLE rasDhcpTimerShutdown,
  84. IN TIMERLIST* pTimer
  85. );
  86. VOID
  87. rasDhcpInitializeAddrInfo(
  88. IN OUT ADDR_INFO* pNewAddrInfo,
  89. IN BYTE* pbAddress,
  90. OUT BOOL* pfPutInAvailList
  91. );
  92. VOID
  93. rasDhcpDeleteLists(
  94. VOID
  95. );
  96. BOOL
  97. rasDhcpNeedToRenewLease(
  98. IN ADDR_INFO* pAddrInfo
  99. );
  100. DWORD
  101. rasDhcpMaxAddrsToAllocate(
  102. VOID
  103. );
  104. #endif // #ifndef _RASDHCP__H_