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.

146 lines
4.1 KiB

  1. //========================================================================
  2. // Copyright (C) 1997 Microsoft Corporation
  3. // Author: RameshV
  4. // Description: This file has been generated. Pl look at the .c file
  5. //========================================================================
  6. #ifndef _MM_ADDRESS_h_
  7. #define _MM_ADDRESS_H_
  8. #include <dhcpapi.h>
  9. DHCP_SUBNET_STATE __inline
  10. IS_SWITCHED(
  11. DHCP_SUBNET_STATE state
  12. )
  13. {
  14. return(( state == DhcpSubnetDisabledSwitched ) ||
  15. ( state == DhcpSubnetEnabledSwitched ));
  16. }
  17. DHCP_SUBNET_STATE __inline
  18. IS_DISABLED(
  19. DHCP_SUBNET_STATE state
  20. )
  21. {
  22. return (( state == DhcpSubnetDisabled) ||
  23. ( state == DhcpSubnetDisabledSwitched ));
  24. }
  25. DHCP_SUBNET_STATE __inline
  26. DISABLED(
  27. DHCP_SUBNET_STATE state
  28. )
  29. {
  30. if (( state == DhcpSubnetDisabledSwitched ) ||
  31. ( state == DhcpSubnetEnabledSwitched )) {
  32. return DhcpSubnetDisabledSwitched;
  33. }
  34. else {
  35. return DhcpSubnetDisabled;
  36. }
  37. }
  38. VOID __inline
  39. SWITCHED(
  40. DHCP_SUBNET_STATE *state
  41. )
  42. {
  43. if ( *state == DhcpSubnetDisabled ) {
  44. *state = DhcpSubnetDisabledSwitched;
  45. }
  46. else if ( *state == DhcpSubnetEnabled ) {
  47. *state = DhcpSubnetEnabledSwitched;
  48. }
  49. }
  50. BOOL
  51. MemSubnetRequestAddress(
  52. IN OUT PM_SUBNET Subnet, // the subnet to start the search in
  53. IN DWORD Address, // init. addr: 0 => search in SuperScope, SubnetAddr = try subnet first
  54. IN BOOL fAcquire, // also acquire the address? or just test for availability?
  55. IN BOOL fBootp, // acquire BOOTP address?
  56. OUT DWORD *RetAddress, // OPTIONAL if Address is not 0 or SubnetAddr -- address obtained
  57. OUT PM_SUBNET *RetSubnet // OPTIONAL if Address is not 0 - which subnet is the address from
  58. ) ;
  59. DWORD
  60. MemServerReleaseAddress(
  61. IN OUT PM_SERVER Server,
  62. IN DWORD Address,
  63. IN BOOL fBootp
  64. ) ;
  65. DWORD _inline
  66. MemSubnetReleaseAddress(
  67. IN OUT PM_SUBNET Subnet,
  68. IN DWORD Address,
  69. IN BOOL fBootp
  70. )
  71. {
  72. DWORD Error;
  73. DWORD OldState;
  74. PM_RANGE Range;
  75. PM_EXCL Excl;
  76. PM_RESERVATION Reservation;
  77. AssertRet(Subnet, ERROR_INVALID_PARAMETER);
  78. if( Subnet->fSubnet && Subnet->Address != (Address & Subnet->Mask ) )
  79. return MemServerReleaseAddress(
  80. Subnet->ServerPtr,
  81. Address,
  82. fBootp
  83. );
  84. Error = MemSubnetGetAddressInfo(
  85. Subnet,
  86. Address,
  87. &Range,
  88. NULL,
  89. &Reservation
  90. );
  91. if( ERROR_SUCCESS != Error ) return Error;
  92. Require(Range);
  93. if( NULL != Reservation ) {
  94. Require(FALSE);
  95. return ERROR_INVALID_PARAMETER;
  96. }
  97. if( 0 == (Range->State & (fBootp? MM_FLAG_ALLOW_BOOTP: MM_FLAG_ALLOW_DHCP))) {
  98. return ERROR_INVALID_PARAMETER;
  99. }
  100. Error = MemBitSetOrClear(
  101. Range->BitMask,
  102. Address - Range->Start,
  103. FALSE /* Release */,
  104. &OldState
  105. );
  106. if( ERROR_SUCCESS != Error ) return Error;
  107. if( OldState == FALSE ) return ERROR_FILE_NOT_FOUND;
  108. InterlockedIncrement(&Range->DirtyOps);
  109. if( fBootp && 0 != Range->BootpAllocated ) {
  110. InterlockedDecrement( &Range->BootpAllocated );
  111. }
  112. return ERROR_SUCCESS;
  113. }
  114. BOOL // TRUE ==> allowed, FALSE ==> not allowed
  115. MemSubnetCheckBootpDhcp(
  116. IN PM_SUBNET Subnet,
  117. IN BOOL fBootp,
  118. IN BOOL fCheckSuperScope
  119. ) ;
  120. #endif
  121. //========================================================================
  122. // end of file
  123. //========================================================================