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.

177 lines
4.0 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. //BeginExport(function)
  26. BOOL
  27. MemServerIsSwitchedSubnet(
  28. IN PM_SERVER Server,
  29. IN DWORD AnyIpAddress
  30. ) //EndExport(function)
  31. {
  32. DWORD Error;
  33. PM_SUBNET Subnet;
  34. Error = MemServerGetAddressInfo(
  35. Server,
  36. AnyIpAddress,
  37. &Subnet,
  38. NULL,
  39. NULL,
  40. NULL
  41. );
  42. if( ERROR_SUCCESS != Error ) return FALSE;
  43. return IS_SWITCHED(Subnet->State);
  44. }
  45. //BeginExport(function)
  46. BOOL
  47. MemServerIsSubnetDisabled(
  48. IN PM_SERVER Server,
  49. IN DWORD AnyIpAddress
  50. ) //EndExport(function)
  51. {
  52. DWORD Error;
  53. PM_SUBNET Subnet;
  54. Error = MemServerGetAddressInfo(
  55. Server,
  56. AnyIpAddress,
  57. &Subnet,
  58. NULL,
  59. NULL,
  60. NULL
  61. );
  62. if( ERROR_SUCCESS != Error ) return FALSE;
  63. return IS_DISABLED(Subnet->State);
  64. }
  65. //BeginExport(function)
  66. BOOL
  67. MemServerIsExcludedAddress(
  68. IN PM_SERVER Server,
  69. IN DWORD AnyIpAddress
  70. ) //EndExport(function)
  71. {
  72. DWORD Error;
  73. PM_EXCL Excl;
  74. Error = MemServerGetAddressInfo(
  75. Server,
  76. AnyIpAddress,
  77. NULL,
  78. NULL,
  79. &Excl,
  80. NULL
  81. );
  82. if( ERROR_SUCCESS != Error ) return FALSE;
  83. return (NULL != Excl);
  84. }
  85. //BeginExport(function)
  86. BOOL
  87. MemServerIsReservedAddress(
  88. IN PM_SERVER Server,
  89. IN DWORD AnyIpAddress
  90. ) //EndExport(function)
  91. {
  92. DWORD Error;
  93. PM_RESERVATION Reservation;
  94. Error = MemServerGetAddressInfo(
  95. Server,
  96. AnyIpAddress,
  97. NULL,
  98. NULL,
  99. NULL,
  100. &Reservation
  101. );
  102. if( ERROR_SUCCESS != Error ) return FALSE;
  103. return NULL != Reservation;
  104. }
  105. //BeginExport(function)
  106. BOOL
  107. MemServerIsOutOfRangeAddress(
  108. IN PM_SERVER Server,
  109. IN DWORD AnyIpAddress,
  110. IN BOOL fBootp
  111. ) //EndExport(function)
  112. {
  113. DWORD Error;
  114. PM_SUBNET Subnet;
  115. PM_RANGE Range;
  116. Error = MemServerGetAddressInfo(
  117. Server,
  118. AnyIpAddress,
  119. &Subnet,
  120. &Range,
  121. NULL,
  122. NULL
  123. );
  124. if( ERROR_SUCCESS != Error ) return TRUE;
  125. if( NULL == Range ) return TRUE;
  126. if( 0 == (Range->State & (fBootp? MM_FLAG_ALLOW_BOOTP : MM_FLAG_ALLOW_DHCP) ) ) {
  127. return TRUE;
  128. }
  129. return FALSE;
  130. }
  131. //BeginExport(function)
  132. DWORD
  133. MemServerGetSubnetMaskForAddress(
  134. IN PM_SERVER Server,
  135. IN DWORD AnyIpAddress
  136. ) //EndExport(function)
  137. {
  138. DWORD Error;
  139. PM_SUBNET Subnet;
  140. Error = MemServerGetAddressInfo(
  141. Server,
  142. AnyIpAddress,
  143. &Subnet,
  144. NULL,
  145. NULL,
  146. NULL
  147. );
  148. if( ERROR_SUCCESS != Error ) return 0;
  149. Require(Subnet);
  150. return Subnet->Mask;
  151. }
  152. //================================================================================
  153. // end of file
  154. //================================================================================