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.

348 lines
5.6 KiB

  1. /*++
  2. Copyright (c) 1995 Microsoft Corporation
  3. Module Name:
  4. mib.c
  5. Abstract:
  6. Contains the MIB APIs
  7. Author:
  8. Stefan Solomon 07/06/1995
  9. Revision History:
  10. --*/
  11. #include "precomp.h"
  12. #pragma hdrstop
  13. DWORD
  14. WINAPI
  15. MibCreate(
  16. IN ULONG InputDataSize,
  17. IN PVOID InputData
  18. )
  19. {
  20. return ERROR_CAN_NOT_COMPLETE;
  21. }
  22. DWORD
  23. WINAPI
  24. MibDelete(
  25. IN ULONG InputDataSize,
  26. IN PVOID InputData
  27. )
  28. {
  29. return ERROR_CAN_NOT_COMPLETE;
  30. }
  31. DWORD
  32. WINAPI
  33. MibGet(
  34. IN ULONG InputDataSize,
  35. IN PVOID InputData,
  36. OUT PULONG OutputDataSize,
  37. OUT PVOID OutputData
  38. )
  39. {
  40. PRIP_MIB_GET_INPUT_DATA midp;
  41. PRIPMIB_BASE mbp;
  42. PRIP_INTERFACE mip;
  43. DWORD rc = NO_ERROR;
  44. PICB icbp;
  45. ULONG GlobalInfoSize;
  46. ACQUIRE_DATABASE_LOCK;
  47. if(RipOperState != OPER_STATE_UP) {
  48. RELEASE_DATABASE_LOCK;
  49. return ERROR_CAN_NOT_COMPLETE;
  50. }
  51. midp = (PRIP_MIB_GET_INPUT_DATA)InputData;
  52. switch(midp->TableId) {
  53. case RIP_BASE_ENTRY:
  54. if(*OutputDataSize < sizeof(RIPMIB_BASE)) {
  55. *OutputDataSize = sizeof(RIPMIB_BASE);
  56. rc = ERROR_INSUFFICIENT_BUFFER;
  57. break;
  58. }
  59. mbp = (PRIPMIB_BASE)OutputData;
  60. mbp->RIPOperState = RipOperState;
  61. *OutputDataSize = sizeof(RIPMIB_BASE);
  62. break;
  63. case RIP_INTERFACE_TABLE:
  64. if(*OutputDataSize < sizeof(RIPMIB_BASE)) {
  65. *OutputDataSize = sizeof(RIP_INTERFACE);
  66. rc = ERROR_INSUFFICIENT_BUFFER;
  67. break;
  68. }
  69. if((icbp = GetInterfaceByIndex(midp->InterfaceIndex)) == NULL) {
  70. *OutputDataSize = 0;
  71. rc = ERROR_NO_MORE_ITEMS;
  72. }
  73. else
  74. {
  75. ACQUIRE_IF_LOCK(icbp);
  76. mip = (PRIP_INTERFACE)OutputData;
  77. mip->InterfaceIndex = icbp->InterfaceIndex;
  78. mip->RipIfInfo = icbp->IfConfigInfo;
  79. mip->RipIfStats = icbp->IfStats;
  80. RELEASE_IF_LOCK(icbp);
  81. *OutputDataSize = sizeof(RIP_INTERFACE);
  82. rc = NO_ERROR;
  83. }
  84. break;
  85. default:
  86. rc = ERROR_CAN_NOT_COMPLETE;
  87. break;
  88. }
  89. RELEASE_DATABASE_LOCK;
  90. return rc;
  91. }
  92. DWORD
  93. WINAPI
  94. MibSet(
  95. IN ULONG InputDataSize,
  96. IN PVOID InputData
  97. )
  98. {
  99. PRIP_MIB_SET_INPUT_DATA midp;
  100. PICB icbp;
  101. DWORD rc;
  102. ACQUIRE_DATABASE_LOCK;
  103. if(RipOperState != OPER_STATE_UP) {
  104. RELEASE_DATABASE_LOCK;
  105. return ERROR_CAN_NOT_COMPLETE;
  106. }
  107. if(InputDataSize < sizeof(RIP_MIB_SET_INPUT_DATA)) {
  108. RELEASE_DATABASE_LOCK;
  109. return ERROR_INVALID_PARAMETER;
  110. }
  111. midp = (PRIP_MIB_SET_INPUT_DATA)InputData;
  112. switch(midp->TableId) {
  113. case RIP_INTERFACE_TABLE:
  114. if((icbp = GetInterfaceByIndex(midp->RipInterface.InterfaceIndex)) == NULL) {
  115. rc = ERROR_NO_MORE_ITEMS;
  116. }
  117. else
  118. {
  119. rc = SetRipInterface(midp->RipInterface.InterfaceIndex,
  120. &midp->RipInterface.RipIfInfo,
  121. icbp->RipIfFiltersIp,
  122. 0); // no ipx admin state change
  123. }
  124. break;
  125. default:
  126. rc = ERROR_INVALID_PARAMETER;
  127. break;
  128. }
  129. RELEASE_DATABASE_LOCK;
  130. return rc;
  131. }
  132. DWORD
  133. WINAPI
  134. MibGetFirst(
  135. IN ULONG InputDataSize,
  136. IN PVOID InputData,
  137. OUT PULONG OutputDataSize,
  138. OUT PVOID OutputData
  139. )
  140. {
  141. PRIP_MIB_GET_INPUT_DATA midp;
  142. PRIP_INTERFACE mip;
  143. DWORD rc = NO_ERROR;
  144. PICB icbp;
  145. ACQUIRE_DATABASE_LOCK;
  146. if(RipOperState != OPER_STATE_UP) {
  147. RELEASE_DATABASE_LOCK;
  148. return ERROR_CAN_NOT_COMPLETE;
  149. }
  150. if(InputDataSize < sizeof(RIP_MIB_GET_INPUT_DATA)) {
  151. RELEASE_DATABASE_LOCK;
  152. return ERROR_INVALID_PARAMETER;
  153. }
  154. midp = (PRIP_MIB_GET_INPUT_DATA)InputData;
  155. switch(midp->TableId) {
  156. case RIP_INTERFACE_TABLE:
  157. if(IsListEmpty(&IndexIfList)) {
  158. *OutputDataSize = 0;
  159. rc = ERROR_NO_MORE_ITEMS;
  160. }
  161. else
  162. {
  163. if(*OutputDataSize < sizeof(RIP_INTERFACE)) {
  164. *OutputDataSize = sizeof(RIP_INTERFACE);
  165. rc = ERROR_INSUFFICIENT_BUFFER;
  166. break;
  167. }
  168. icbp = CONTAINING_RECORD(IndexIfList.Flink, ICB, IfListLinkage);
  169. ACQUIRE_IF_LOCK(icbp);
  170. mip = (PRIP_INTERFACE)OutputData;
  171. mip->InterfaceIndex = icbp->InterfaceIndex;
  172. mip->RipIfInfo = icbp->IfConfigInfo;
  173. mip->RipIfStats = icbp->IfStats;
  174. RELEASE_IF_LOCK(icbp);
  175. *OutputDataSize = sizeof(RIP_INTERFACE);
  176. rc = NO_ERROR;
  177. }
  178. break;
  179. default:
  180. rc = ERROR_INVALID_PARAMETER;
  181. break;
  182. }
  183. RELEASE_DATABASE_LOCK;
  184. return rc;
  185. }
  186. DWORD
  187. WINAPI
  188. MibGetNext(
  189. IN ULONG InputDataSize,
  190. IN PVOID InputData,
  191. OUT PULONG OutputDataSize,
  192. OUT PVOID OutputData
  193. )
  194. {
  195. PRIP_MIB_GET_INPUT_DATA midp;
  196. PRIP_INTERFACE mip;
  197. DWORD rc = NO_ERROR;
  198. PICB icbp;
  199. PLIST_ENTRY lep;
  200. ACQUIRE_DATABASE_LOCK;
  201. if(RipOperState != OPER_STATE_UP) {
  202. RELEASE_DATABASE_LOCK;
  203. return ERROR_CAN_NOT_COMPLETE;
  204. }
  205. if(InputDataSize < sizeof(RIP_MIB_GET_INPUT_DATA)) {
  206. RELEASE_DATABASE_LOCK;
  207. return ERROR_INVALID_PARAMETER;
  208. }
  209. midp = (PRIP_MIB_GET_INPUT_DATA)InputData;
  210. switch(midp->TableId) {
  211. case RIP_INTERFACE_TABLE:
  212. lep = IndexIfList.Flink;
  213. rc = ERROR_NO_MORE_ITEMS;
  214. while(lep != &IndexIfList)
  215. {
  216. icbp = CONTAINING_RECORD(lep, ICB, IfListLinkage);
  217. if (icbp->InterfaceIndex > midp->InterfaceIndex) {
  218. // found the next
  219. if(*OutputDataSize < sizeof(RIP_INTERFACE)) {
  220. *OutputDataSize = sizeof(RIP_INTERFACE);
  221. rc = ERROR_INSUFFICIENT_BUFFER;
  222. break;
  223. }
  224. ACQUIRE_IF_LOCK(icbp);
  225. mip = (PRIP_INTERFACE)OutputData;
  226. mip->InterfaceIndex = icbp->InterfaceIndex;
  227. mip->RipIfInfo = icbp->IfConfigInfo;
  228. mip->RipIfStats = icbp->IfStats;
  229. RELEASE_IF_LOCK(icbp);
  230. *OutputDataSize = sizeof(RIP_INTERFACE);
  231. rc = NO_ERROR;
  232. break;
  233. }
  234. lep = lep->Flink;
  235. }
  236. break;
  237. default:
  238. rc = ERROR_INVALID_PARAMETER;
  239. break;
  240. }
  241. RELEASE_DATABASE_LOCK;
  242. return rc;
  243. }