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.

285 lines
5.0 KiB

  1. /*++
  2. Copyright (c) 1995 Microsoft Corporation
  3. Module Name:
  4. mibserv.c
  5. Abstract:
  6. The MIB services handling functions
  7. Author:
  8. Stefan Solomon 03/22/1995
  9. Revision History:
  10. --*/
  11. #include "precomp.h"
  12. #pragma hdrstop
  13. /*++
  14. Function: MibGetService
  15. Descr:
  16. --*/
  17. DWORD
  18. MibGetService(PIPX_MIB_INDEX mip,
  19. PIPX_SERVICE Svp,
  20. PULONG ServiceSize)
  21. {
  22. if((Svp == NULL) || (*ServiceSize < sizeof(IPX_SERVICE))) {
  23. *ServiceSize = sizeof(IPX_SERVICE);
  24. return ERROR_INSUFFICIENT_BUFFER;
  25. }
  26. if(IsService(mip->ServicesTableIndex.ServiceType,
  27. mip->ServicesTableIndex.ServiceName,
  28. Svp)) {
  29. return NO_ERROR;
  30. }
  31. else
  32. {
  33. return ERROR_INVALID_PARAMETER;
  34. }
  35. }
  36. /*++
  37. Function: MibGetFirstService
  38. Descr:
  39. --*/
  40. DWORD
  41. MibGetFirstService(PIPX_MIB_INDEX mip,
  42. PIPX_SERVICE Svp,
  43. PULONG ServiceSize)
  44. {
  45. if((Svp == NULL) || (*ServiceSize < sizeof(IPX_SERVICE))) {
  46. *ServiceSize = sizeof(IPX_SERVICE);
  47. return ERROR_INSUFFICIENT_BUFFER;
  48. }
  49. return(GetFirstService(STM_ORDER_BY_TYPE_AND_NAME, 0, Svp));
  50. }
  51. /*++
  52. Function: MibGetNextService
  53. Descr:
  54. --*/
  55. DWORD
  56. MibGetNextService(PIPX_MIB_INDEX mip,
  57. PIPX_SERVICE Svp,
  58. PULONG ServiceSize)
  59. {
  60. if((Svp == NULL) || (*ServiceSize < sizeof(IPX_SERVICE))) {
  61. *ServiceSize = sizeof(IPX_SERVICE);
  62. return ERROR_INSUFFICIENT_BUFFER;
  63. }
  64. Svp->Server.Type = mip->ServicesTableIndex.ServiceType;
  65. memcpy(Svp->Server.Name, mip->ServicesTableIndex.ServiceName, 48);
  66. return(GetNextService(STM_ORDER_BY_TYPE_AND_NAME, 0, Svp));
  67. }
  68. /*++
  69. Function: MibCreateStaticService
  70. Descr:
  71. --*/
  72. DWORD
  73. MibCreateStaticService(PIPX_MIB_ROW MibRowp)
  74. {
  75. PIPX_SERVICE StaticSvp;
  76. DWORD rc;
  77. PICB icbp;
  78. StaticSvp = &MibRowp->Service;
  79. ACQUIRE_DATABASE_LOCK;
  80. // check the interface exists
  81. if((icbp=GetInterfaceByIndex(StaticSvp->InterfaceIndex)) == NULL) {
  82. RELEASE_DATABASE_LOCK;
  83. return ERROR_INVALID_PARAMETER;
  84. }
  85. rc = CreateStaticService(icbp,
  86. &StaticSvp->Server);
  87. RELEASE_DATABASE_LOCK;
  88. return rc;
  89. }
  90. /*++
  91. Function: DeleteStaticService
  92. Descr:
  93. --*/
  94. DWORD
  95. MibDeleteStaticService(PIPX_MIB_ROW MibRowp)
  96. {
  97. PIPX_SERVICE StaticSvp;
  98. DWORD rc;
  99. StaticSvp = &MibRowp->Service;
  100. ACQUIRE_DATABASE_LOCK;
  101. // check the interface exists
  102. if(GetInterfaceByIndex(StaticSvp->InterfaceIndex) == NULL) {
  103. RELEASE_DATABASE_LOCK;
  104. return ERROR_INVALID_PARAMETER;
  105. }
  106. rc = DeleteStaticService(StaticSvp->InterfaceIndex,
  107. &StaticSvp->Server);
  108. RELEASE_DATABASE_LOCK;
  109. return rc;
  110. }
  111. /*++
  112. Function: MibGetStaticService
  113. Descr:
  114. --*/
  115. DWORD
  116. MibGetStaticService(PIPX_MIB_INDEX mip,
  117. PIPX_SERVICE Svp,
  118. PULONG ServiceSize)
  119. {
  120. if((Svp == NULL) || (*ServiceSize < sizeof(IPX_SERVICE))) {
  121. *ServiceSize = sizeof(IPX_SERVICE);
  122. return ERROR_INSUFFICIENT_BUFFER;
  123. }
  124. Svp->InterfaceIndex = mip->StaticServicesTableIndex.InterfaceIndex;
  125. Svp->Server.Type = mip->StaticServicesTableIndex.ServiceType;
  126. memcpy(Svp->Server.Name, mip->StaticServicesTableIndex.ServiceName, 48);
  127. Svp->Protocol = IPX_PROTOCOL_STATIC;
  128. return(GetFirstService(STM_ORDER_BY_INTERFACE_TYPE_NAME,
  129. STM_ONLY_THIS_INTERFACE | STM_ONLY_THIS_TYPE | STM_ONLY_THIS_NAME | STM_ONLY_THIS_PROTOCOL,
  130. Svp));
  131. }
  132. /*++
  133. Function: MibGetFirstStaticService
  134. Descr:
  135. --*/
  136. DWORD
  137. MibGetFirstStaticService(PIPX_MIB_INDEX mip,
  138. PIPX_SERVICE Svp,
  139. PULONG ServiceSize)
  140. {
  141. if((Svp == NULL) || (*ServiceSize < sizeof(IPX_SERVICE))) {
  142. *ServiceSize = sizeof(IPX_SERVICE);
  143. return ERROR_INSUFFICIENT_BUFFER;
  144. }
  145. // set the static protocol
  146. Svp->Protocol = IPX_PROTOCOL_STATIC;
  147. return(GetFirstService(STM_ORDER_BY_INTERFACE_TYPE_NAME,
  148. STM_ONLY_THIS_PROTOCOL,
  149. Svp));
  150. }
  151. /*++
  152. Function: MibGetNextStaticService
  153. Descr:
  154. --*/
  155. DWORD
  156. MibGetNextStaticService(PIPX_MIB_INDEX mip,
  157. PIPX_SERVICE Svp,
  158. PULONG ServiceSize)
  159. {
  160. if((Svp == NULL) || (*ServiceSize < sizeof(IPX_SERVICE))) {
  161. *ServiceSize = sizeof(IPX_SERVICE);
  162. return ERROR_INSUFFICIENT_BUFFER;
  163. }
  164. Svp->InterfaceIndex = mip->StaticServicesTableIndex.InterfaceIndex;
  165. Svp->Server.Type = mip->StaticServicesTableIndex.ServiceType;
  166. memcpy(Svp->Server.Name, mip->StaticServicesTableIndex.ServiceName, 48);
  167. Svp->Protocol = IPX_PROTOCOL_STATIC;
  168. return(GetNextService(STM_ORDER_BY_INTERFACE_TYPE_NAME,
  169. STM_ONLY_THIS_PROTOCOL,
  170. Svp));
  171. }
  172. /*++
  173. Function: MibSetStaticService
  174. Descr:
  175. --*/
  176. DWORD
  177. MibSetStaticService(PIPX_MIB_ROW MibRowp)
  178. {
  179. PIPX_SERVICE StaticSvp;
  180. DWORD rc;
  181. PICB icbp;
  182. StaticSvp = &MibRowp->Service;
  183. ACQUIRE_DATABASE_LOCK;
  184. // check the interface exists
  185. if((icbp=GetInterfaceByIndex(StaticSvp->InterfaceIndex)) == NULL) {
  186. RELEASE_DATABASE_LOCK;
  187. return ERROR_INVALID_PARAMETER;
  188. }
  189. DeleteStaticService(StaticSvp->InterfaceIndex,
  190. &StaticSvp->Server);
  191. rc = CreateStaticService(icbp,
  192. &StaticSvp->Server);
  193. RELEASE_DATABASE_LOCK;
  194. return rc;
  195. }