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.

163 lines
4.9 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. //BeginExport(function)
  24. DWORD
  25. MemSubnetModify(
  26. IN PM_SUBNET Subnet,
  27. IN DWORD Address,
  28. IN DWORD Mask,
  29. IN DWORD State,
  30. IN DWORD SuperScopeId,
  31. IN LPWSTR Name,
  32. IN LPWSTR Description
  33. ) //EndExport(function)
  34. {
  35. DWORD Error;
  36. PM_SUBNET NewSubnet, ThisSubnet;
  37. PARRAY pArray;
  38. ARRAY_LOCATION Loc;
  39. AssertRet(Address == Subnet->Address, ERROR_INVALID_PARAMETER);
  40. Error = MemSubnetInit(
  41. &NewSubnet,
  42. Address,
  43. Mask,
  44. State,
  45. SuperScopeId,
  46. Name,
  47. Description
  48. );
  49. if( ERROR_SUCCESS != Error) return Error;
  50. Require(NULL != NewSubnet && Subnet->ServerPtr );
  51. if( Subnet->fSubnet ) {
  52. pArray = &(((PM_SERVER)(Subnet->ServerPtr))->Subnets);
  53. } else {
  54. pArray = &(((PM_SERVER)(Subnet->ServerPtr))->MScopes);
  55. }
  56. Error = MemArrayInitLoc(pArray, &Loc);
  57. while(ERROR_FILE_NOT_FOUND != Error) {
  58. Require(ERROR_SUCCESS == Error );
  59. Error = MemArrayGetElement(pArray, &Loc, &ThisSubnet);
  60. Require(ERROR_SUCCESS == Error && NULL != ThisSubnet );
  61. if( Subnet->Address != ThisSubnet->Address ) {
  62. Error = MemArrayNextLoc(pArray, &Loc);
  63. continue;
  64. }
  65. Require(Subnet == ThisSubnet);
  66. Error = MemArraySetElement(pArray, &Loc, NewSubnet);
  67. Require(ERROR_SUCCESS == Error);
  68. NewSubnet -> ServerPtr = Subnet->ServerPtr;
  69. NewSubnet -> Policy = Subnet->Policy;
  70. NewSubnet -> fSubnet = Subnet->fSubnet;
  71. NewSubnet -> Options = Subnet->Options;
  72. NewSubnet -> Ranges = Subnet->Ranges;
  73. NewSubnet -> Exclusions = Subnet->Exclusions;
  74. NewSubnet -> Reservations = Subnet->Reservations;
  75. NewSubnet -> Servers = Subnet->Servers;
  76. (void) MemFree(Subnet);
  77. return Error;
  78. }
  79. MemFree(NewSubnet);
  80. return ERROR_FILE_NOT_FOUND;
  81. }
  82. //BeginExport(function)
  83. DWORD
  84. MemMScopeModify(
  85. IN PM_SUBNET MScope,
  86. IN DWORD ScopeId,
  87. IN DWORD State,
  88. IN DWORD Policy,
  89. IN BYTE TTL,
  90. IN LPWSTR Name,
  91. IN LPWSTR Description,
  92. IN LPWSTR LangTag,
  93. IN DATE_TIME ExpiryTime
  94. ) //EndExport(function)
  95. {
  96. DWORD Error;
  97. PM_SUBNET NewMScope, ThisMScope;
  98. PARRAY pArray;
  99. ARRAY_LOCATION Loc;
  100. AssertRet(ScopeId == MScope->MScopeId, ERROR_INVALID_PARAMETER);
  101. Error = MemMScopeInit(
  102. &NewMScope,
  103. ScopeId,
  104. State,
  105. Policy,
  106. TTL,
  107. Name,
  108. Description,
  109. LangTag,
  110. ExpiryTime
  111. );
  112. if( ERROR_SUCCESS != Error) return Error;
  113. Require(NULL != NewMScope && MScope->ServerPtr );
  114. pArray = &(((PM_SERVER)(MScope->ServerPtr))->MScopes);
  115. Error = MemArrayInitLoc(pArray, &Loc);
  116. while(ERROR_FILE_NOT_FOUND != Error) {
  117. Require(ERROR_SUCCESS == Error );
  118. Error = MemArrayGetElement(pArray, &Loc, &ThisMScope);
  119. Require(ERROR_SUCCESS == Error && NULL != ThisMScope );
  120. if( MScope->MScopeId != ThisMScope->MScopeId ) {
  121. Error = MemArrayNextLoc(pArray, &Loc);
  122. continue;
  123. }
  124. Require(MScope == ThisMScope);
  125. Error = MemArraySetElement(pArray, &Loc, NewMScope);
  126. Require(ERROR_SUCCESS == Error);
  127. NewMScope -> ServerPtr = MScope->ServerPtr;
  128. NewMScope -> Options = MScope->Options;
  129. NewMScope -> Ranges = MScope->Ranges;
  130. NewMScope -> Exclusions = MScope->Exclusions;
  131. NewMScope -> Reservations = MScope->Reservations;
  132. NewMScope -> Servers = MScope->Servers;
  133. (void) MemFree(MScope);
  134. return Error;
  135. }
  136. MemFree(NewMScope);
  137. return ERROR_FILE_NOT_FOUND;
  138. }
  139. //================================================================================
  140. // end of file
  141. //================================================================================
  142.