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.

180 lines
5.5 KiB

  1. //================================================================================
  2. // Copyright (C) 1997 Microsoft Corporation
  3. // Author: RameshV
  4. // Description: implements an additional subnet function that requires a server typedef..
  5. // ThreadSafe: no
  6. // Locks: none
  7. // Please read stdinfo.txt for programming style.
  8. //================================================================================
  9. #include <mm.h>
  10. #include <array.h>
  11. #include <opt.h>
  12. #include <optl.h>
  13. #include <optclass.h>
  14. #include <bitmask.h>
  15. #include <range.h>
  16. #include <reserve.h>
  17. #include <subnet.h>
  18. #include <optdefl.h>
  19. #include <classdefl.h>
  20. #include <oclassdl.h>
  21. #include <sscope.h>
  22. #include <server.h>
  23. #include "subnet2.h"
  24. #include "server\uniqid.h"
  25. //BeginExport(function)
  26. DWORD
  27. MemSubnetModify(
  28. IN PM_SUBNET Subnet,
  29. IN DWORD Address,
  30. IN DWORD Mask,
  31. IN DWORD State,
  32. IN DWORD SuperScopeId,
  33. IN LPWSTR Name,
  34. IN LPWSTR Description
  35. ) //EndExport(function)
  36. {
  37. DWORD Error;
  38. PM_SUBNET NewSubnet, ThisSubnet;
  39. PARRAY pArray;
  40. ARRAY_LOCATION Loc;
  41. AssertRet(Address == Subnet->Address, ERROR_INVALID_PARAMETER);
  42. Error = MemSubnetInit(
  43. &NewSubnet,
  44. Address,
  45. Mask,
  46. State,
  47. SuperScopeId,
  48. Name,
  49. Description
  50. );
  51. if( ERROR_SUCCESS != Error) return Error;
  52. Require(NULL != NewSubnet && Subnet->ServerPtr );
  53. if( Subnet->fSubnet ) {
  54. pArray = &(((PM_SERVER)(Subnet->ServerPtr))->Subnets);
  55. } else {
  56. pArray = &(((PM_SERVER)(Subnet->ServerPtr))->MScopes);
  57. }
  58. Error = MemArrayInitLoc(pArray, &Loc);
  59. while(ERROR_FILE_NOT_FOUND != Error) {
  60. Require(ERROR_SUCCESS == Error );
  61. Error = MemArrayGetElement(pArray, &Loc, &ThisSubnet);
  62. Require(ERROR_SUCCESS == Error && NULL != ThisSubnet );
  63. if( Subnet->Address != ThisSubnet->Address ) {
  64. Error = MemArrayNextLoc(pArray, &Loc);
  65. continue;
  66. }
  67. Require(Subnet == ThisSubnet);
  68. Error = DeleteRecord( ThisSubnet->UniqId );
  69. if ( ERROR_SUCCESS != Error ) {
  70. MemFree( NewSubnet );
  71. return Error;
  72. }
  73. Error = MemArraySetElement(pArray, &Loc, NewSubnet);
  74. Require(ERROR_SUCCESS == Error);
  75. NewSubnet -> ServerPtr = Subnet->ServerPtr;
  76. NewSubnet -> Policy = Subnet->Policy;
  77. NewSubnet -> fSubnet = Subnet->fSubnet;
  78. NewSubnet -> Options = Subnet->Options;
  79. NewSubnet -> Ranges = Subnet->Ranges;
  80. NewSubnet -> Exclusions = Subnet->Exclusions;
  81. NewSubnet -> Reservations = Subnet->Reservations;
  82. NewSubnet -> Servers = Subnet->Servers;
  83. (void) MemFree(Subnet);
  84. return Error;
  85. } // while
  86. MemFree(NewSubnet);
  87. return ERROR_FILE_NOT_FOUND;
  88. }
  89. //BeginExport(function)
  90. DWORD
  91. MemMScopeModify(
  92. IN PM_SUBNET MScope,
  93. IN DWORD ScopeId,
  94. IN DWORD State,
  95. IN DWORD Policy,
  96. IN BYTE TTL,
  97. IN LPWSTR Name,
  98. IN LPWSTR Description,
  99. IN LPWSTR LangTag,
  100. IN DATE_TIME ExpiryTime
  101. ) //EndExport(function)
  102. {
  103. DWORD Error;
  104. PM_SUBNET NewMScope, ThisMScope;
  105. PARRAY pArray;
  106. ARRAY_LOCATION Loc;
  107. AssertRet(ScopeId == MScope->MScopeId, ERROR_INVALID_PARAMETER);
  108. Error = MemMScopeInit(
  109. &NewMScope,
  110. ScopeId,
  111. State,
  112. Policy,
  113. TTL,
  114. Name,
  115. Description,
  116. LangTag,
  117. ExpiryTime
  118. );
  119. if( ERROR_SUCCESS != Error) return Error;
  120. Require(NULL != NewMScope && MScope->ServerPtr );
  121. pArray = &(((PM_SERVER)(MScope->ServerPtr))->MScopes);
  122. Error = MemArrayInitLoc(pArray, &Loc);
  123. while(ERROR_FILE_NOT_FOUND != Error) {
  124. Require(ERROR_SUCCESS == Error );
  125. Error = MemArrayGetElement(pArray, &Loc, &ThisMScope);
  126. Require(ERROR_SUCCESS == Error && NULL != ThisMScope );
  127. if( MScope->MScopeId != ThisMScope->MScopeId ) {
  128. Error = MemArrayNextLoc(pArray, &Loc);
  129. continue;
  130. }
  131. Require(MScope == ThisMScope);
  132. // Delete the old mscope
  133. Error = DeleteRecord( MScope->UniqId );
  134. if ( ERROR_SUCCESS != Error ) {
  135. return Error;
  136. }
  137. Error = MemArraySetElement(pArray, &Loc, NewMScope);
  138. Require(ERROR_SUCCESS == Error);
  139. NewMScope -> ServerPtr = MScope->ServerPtr;
  140. NewMScope -> Options = MScope->Options;
  141. NewMScope -> Ranges = MScope->Ranges;
  142. NewMScope -> Exclusions = MScope->Exclusions;
  143. NewMScope -> Reservations = MScope->Reservations;
  144. NewMScope -> Servers = MScope->Servers;
  145. NewMScope->UniqId = INVALID_UNIQ_ID;
  146. (void) MemFree(MScope);
  147. return Error;
  148. }
  149. MemFree(NewMScope);
  150. return ERROR_FILE_NOT_FOUND;
  151. } // MemMScopeModify()
  152. //================================================================================
  153. // end of file
  154. //================================================================================
  155.