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.

178 lines
4.2 KiB

  1. //================================================================================
  2. // Copyright (C) 1997 Microsoft Corporation
  3. // Author: RameshV
  4. // Description: implements the overall access api's (most of them)
  5. // ThreadSafe: no
  6. // Locks: none
  7. // Please read stdinfo.txt for programming style.
  8. //================================================================================
  9. #include <mm.h>
  10. #include <winbase.h>
  11. #include <array.h>
  12. #include <opt.h>
  13. #include <optl.h>
  14. #include <optclass.h>
  15. #include <bitmask.h>
  16. #include <range.h>
  17. #include <reserve.h>
  18. #include <subnet.h>
  19. #include <optdefl.h>
  20. #include <classdefl.h>
  21. #include <oclassdl.h>
  22. #include <sscope.h>
  23. #include <server.h>
  24. #include <address.h>
  25. #include <dhcpapi.h>
  26. #include "server2.h"
  27. //BeginExport(function)
  28. BOOL
  29. MemServerIsSwitchedSubnet(
  30. IN PM_SERVER Server,
  31. IN DWORD AnyIpAddress
  32. ) //EndExport(function)
  33. {
  34. DWORD Error;
  35. PM_SUBNET Subnet;
  36. Error = MemServerGetAddressInfo(
  37. Server,
  38. AnyIpAddress,
  39. &Subnet,
  40. NULL,
  41. NULL,
  42. NULL
  43. );
  44. if( ERROR_SUCCESS != Error ) return FALSE;
  45. return IS_SWITCHED(Subnet->State);
  46. }
  47. //BeginExport(function)
  48. BOOL
  49. MemServerIsSubnetDisabled(
  50. IN PM_SERVER Server,
  51. IN DWORD AnyIpAddress
  52. ) //EndExport(function)
  53. {
  54. DWORD Error;
  55. PM_SUBNET Subnet;
  56. Error = MemServerGetAddressInfo(
  57. Server,
  58. AnyIpAddress,
  59. &Subnet,
  60. NULL,
  61. NULL,
  62. NULL
  63. );
  64. if( ERROR_SUCCESS != Error ) return FALSE;
  65. return IS_DISABLED(Subnet->State);
  66. }
  67. //BeginExport(function)
  68. BOOL
  69. MemServerIsExcludedAddress(
  70. IN PM_SERVER Server,
  71. IN DWORD AnyIpAddress
  72. ) //EndExport(function)
  73. {
  74. DWORD Error;
  75. PM_EXCL Excl;
  76. Error = MemServerGetAddressInfo(
  77. Server,
  78. AnyIpAddress,
  79. NULL,
  80. NULL,
  81. &Excl,
  82. NULL
  83. );
  84. if( ERROR_SUCCESS != Error ) return FALSE;
  85. return (NULL != Excl);
  86. }
  87. //BeginExport(function)
  88. BOOL
  89. MemServerIsReservedAddress(
  90. IN PM_SERVER Server,
  91. IN DWORD AnyIpAddress
  92. ) //EndExport(function)
  93. {
  94. DWORD Error;
  95. PM_RESERVATION Reservation;
  96. Error = MemServerGetAddressInfo(
  97. Server,
  98. AnyIpAddress,
  99. NULL,
  100. NULL,
  101. NULL,
  102. &Reservation
  103. );
  104. if( ERROR_SUCCESS != Error ) return FALSE;
  105. return NULL != Reservation;
  106. }
  107. //BeginExport(function)
  108. BOOL
  109. MemServerIsOutOfRangeAddress(
  110. IN PM_SERVER Server,
  111. IN DWORD AnyIpAddress,
  112. IN BOOL fBootp
  113. ) //EndExport(function)
  114. {
  115. DWORD Error;
  116. PM_SUBNET Subnet;
  117. PM_RANGE Range;
  118. Error = MemServerGetAddressInfo(
  119. Server,
  120. AnyIpAddress,
  121. &Subnet,
  122. &Range,
  123. NULL,
  124. NULL
  125. );
  126. if( ERROR_SUCCESS != Error ) return TRUE;
  127. if( NULL == Range ) return TRUE;
  128. if( 0 == (Range->State & (fBootp? MM_FLAG_ALLOW_BOOTP : MM_FLAG_ALLOW_DHCP) ) ) {
  129. return TRUE;
  130. }
  131. return FALSE;
  132. }
  133. //BeginExport(function)
  134. DWORD
  135. MemServerGetSubnetMaskForAddress(
  136. IN PM_SERVER Server,
  137. IN DWORD AnyIpAddress
  138. ) //EndExport(function)
  139. {
  140. DWORD Error;
  141. PM_SUBNET Subnet;
  142. Error = MemServerGetAddressInfo(
  143. Server,
  144. AnyIpAddress,
  145. &Subnet,
  146. NULL,
  147. NULL,
  148. NULL
  149. );
  150. if( ERROR_SUCCESS != Error ) return 0;
  151. Require(Subnet);
  152. return Subnet->Mask;
  153. }
  154. //================================================================================
  155. // end of file
  156. //================================================================================