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.

1244 lines
44 KiB

  1. /*++
  2. Copyright (c) 1996 Microsoft Corporation
  3. Module Name:
  4. mipxf.c
  5. Abstract:
  6. ms-ipx instrumentation callbacks.
  7. Author:
  8. Vadim Eydelman (vadime) 30-May-1996
  9. Revision History:
  10. --*/
  11. #include "precomp.h"
  12. ///////////////////////////////////////////////////////////////////////////////
  13. // //
  14. // mipxBase group (1.3.6.1.4.1.311.1.8.1) //
  15. // //
  16. ///////////////////////////////////////////////////////////////////////////////
  17. UINT
  18. get_mipxBase(
  19. UINT actionId,
  20. AsnAny * objectArray,
  21. UINT * errorIndex
  22. ) {
  23. #define Beb ((buf_mipxBase *)objectArray)
  24. IPX_MIB_GET_INPUT_DATA MibGetInputData;
  25. PIPXMIB_BASE Bep;
  26. DWORD rc;
  27. ULONG BeSize;
  28. if (!EnsureRouterConnection()) {
  29. *errorIndex = 0;
  30. return MIB_S_ENTRY_NOT_FOUND;
  31. }
  32. switch (actionId) {
  33. case MIB_ACTION_GET:
  34. MibGetInputData.TableId = IPX_BASE_ENTRY;
  35. rc = MprAdminMIBEntryGet(g_MibServerHandle,
  36. PID_IPX,
  37. IPX_PROTOCOL_BASE,
  38. &MibGetInputData,
  39. sizeof(IPX_MIB_GET_INPUT_DATA),
  40. &Bep,
  41. &BeSize);
  42. if (rc == NO_ERROR && Bep == NULL)
  43. {
  44. return MIB_S_ENTRY_NOT_FOUND;
  45. }
  46. if (rc==NO_ERROR) {
  47. SetAsnInteger (&Beb->mipxBaseOperState, Bep->OperState);
  48. SetAsnOctetString (&Beb->mipxBasePrimaryNetNumber, Beb->PrimaryNetVal,
  49. Bep->PrimaryNetNumber, sizeof (Beb->PrimaryNetVal));
  50. SetAsnOctetString (&Beb->mipxBaseNode, Beb->NodeVal,
  51. Bep->Node, sizeof (Beb->NodeVal));
  52. SetAsnDispString (&Beb->mipxBaseSysName, Beb->SysNameVal,
  53. Bep->SysName, sizeof (Beb->SysNameVal));
  54. SetAsnInteger (&Beb->mipxBaseMaxPathSplits, Bep->MaxPathSplits);
  55. SetAsnInteger (&Beb->mipxBaseIfCount, Bep->IfCount);
  56. SetAsnInteger (&Beb->mipxBaseDestCount, Bep->DestCount);
  57. SetAsnInteger (&Beb->mipxBaseServCount, Bep->ServCount);
  58. MprAdminMIBBufferFree (Bep);
  59. DbgTrace (DBG_IPXBASE, ("MIPX-Base: Get request succeded.\n"));
  60. return MIB_S_SUCCESS;
  61. }
  62. else {
  63. *errorIndex = 0;
  64. DbgTrace (DBG_IPXBASE,
  65. ("MIPX-Base: Get request failed with error %ld.\n", rc));
  66. return MIB_S_ENTRY_NOT_FOUND;
  67. }
  68. case MIB_ACTION_GETNEXT:
  69. DbgTrace (DBG_IPXBASE,
  70. ("MIPX-Base:Get called with GET_FIRST/GET_NEXT for scalar.\n"));
  71. return MIB_S_INVALID_PARAMETER;
  72. default:
  73. DbgTrace (DBG_IPXBASE,
  74. ("MIPX-Base:Get called with unsupported action code %d.\n",
  75. actionId));
  76. return MIB_S_INVALID_PARAMETER;
  77. }
  78. #undef Beb
  79. }
  80. ///////////////////////////////////////////////////////////////////////////////
  81. // //
  82. // mipxInterface group (1.3.6.1.4.1.311.1.8.2) //
  83. // //
  84. ///////////////////////////////////////////////////////////////////////////////
  85. ///////////////////////////////////////////////////////////////////////////////
  86. // //
  87. // mipxIfEntry table (1.3.6.1.4.1.311.1.8.2.1.1) //
  88. // //
  89. ///////////////////////////////////////////////////////////////////////////////
  90. UINT
  91. get_mipxIfEntry(
  92. UINT actionId,
  93. AsnAny * objectArray,
  94. UINT * errorIndex
  95. ) {
  96. #define Ifb ((buf_mipxIfEntry *)objectArray)
  97. PIPX_INTERFACE Ifp;
  98. IPX_MIB_GET_INPUT_DATA MibGetInputData;
  99. DWORD rc;
  100. ULONG IfSize;
  101. if (!EnsureRouterConnection()) {
  102. *errorIndex = 0;
  103. return MIB_S_ENTRY_NOT_FOUND;
  104. }
  105. MibGetInputData.TableId = IPX_INTERFACE_TABLE;
  106. MibGetInputData.MibIndex.InterfaceTableIndex.InterfaceIndex
  107. = (ULONG)GetAsnInteger (&Ifb->mipxIfIndex, ZERO_INTERFACE_INDEX);
  108. switch (actionId) {
  109. case MIB_ACTION_GET:
  110. ASSERTMSG ("No index in GET request for table ",
  111. Ifb->mipxIfIndex.asnType);
  112. rc = MprAdminMIBEntryGet(g_MibServerHandle,
  113. PID_IPX,
  114. IPX_PROTOCOL_BASE,
  115. &MibGetInputData,
  116. sizeof(IPX_MIB_GET_INPUT_DATA),
  117. &Ifp,
  118. &IfSize);
  119. break;
  120. case MIB_ACTION_GETNEXT:
  121. if (Ifb->mipxIfIndex.asnType)
  122. rc = MprAdminMIBEntryGetNext(g_MibServerHandle,
  123. PID_IPX,
  124. IPX_PROTOCOL_BASE,
  125. &MibGetInputData,
  126. sizeof(IPX_MIB_GET_INPUT_DATA),
  127. &Ifp,
  128. &IfSize);
  129. else
  130. rc = MprAdminMIBEntryGetFirst(g_MibServerHandle,
  131. PID_IPX,
  132. IPX_PROTOCOL_BASE,
  133. &MibGetInputData,
  134. sizeof(IPX_MIB_GET_INPUT_DATA),
  135. &Ifp,
  136. &IfSize);
  137. break;
  138. default:
  139. DbgTrace (DBG_IPXINTERFACES,
  140. ("MIPX-if:Get called with unsupported action code %d.\n",
  141. actionId));
  142. return MIB_S_INVALID_PARAMETER;
  143. }
  144. if (rc == NO_ERROR && Ifp == NULL)
  145. {
  146. rc = ERROR_CAN_NOT_COMPLETE;
  147. }
  148. switch (rc) {
  149. case NO_ERROR:
  150. DbgTrace (DBG_IPXINTERFACES, ("MIPX-if: Get(%d) request succeded for if %ld->%ld.\n",
  151. actionId,
  152. MibGetInputData.MibIndex.InterfaceTableIndex.InterfaceIndex,
  153. Ifp->InterfaceIndex));
  154. ForceAsnInteger (&Ifb->mipxIfIndex, Ifp->InterfaceIndex);
  155. SetAsnInteger (&Ifb->mipxIfAdminState, Ifp->AdminState);
  156. SetAsnInteger (&Ifb->mipxIfOperState, Ifp->IfStats.IfOperState);
  157. SetAsnInteger (&Ifb->mipxIfAdapterIndex, Ifp->AdapterIndex);
  158. SetAsnDispString (&Ifb->mipxIfName, Ifb->NameVal,
  159. Ifp->InterfaceName, sizeof (Ifb->NameVal));
  160. SetAsnInteger (&Ifb->mipxIfType, Ifp->InterfaceType);
  161. SetAsnInteger (&Ifb->mipxIfLocalMaxPacketSize, Ifp->IfStats.MaxPacketSize);
  162. SetAsnInteger (&Ifb->mipxIfMediaType, Ifp->MediaType);
  163. SetAsnOctetString (&Ifb->mipxIfNetNumber, Ifb->NetNumberVal,
  164. Ifp->NetNumber, sizeof (Ifb->NetNumberVal));
  165. SetAsnOctetString (&Ifb->mipxIfMacAddress, Ifb->MacAddressVal,
  166. Ifp->MacAddress, sizeof (Ifb->MacAddressVal));
  167. SetAsnInteger (&Ifb->mipxIfDelay, Ifp->Delay);
  168. SetAsnInteger (&Ifb->mipxIfThroughput, Ifp->Throughput);
  169. SetAsnInteger (&Ifb->mipxIfIpxWanEnable, Ifp->EnableIpxWanNegotiation);
  170. SetAsnInteger (&Ifb->mipxIfNetbiosAccept, Ifp->NetbiosAccept);
  171. SetAsnInteger (&Ifb->mipxIfNetbiosDeliver, Ifp->NetbiosDeliver);
  172. SetAsnCounter (&Ifb->mipxIfInHdrErrors, Ifp->IfStats.InHdrErrors);
  173. SetAsnCounter (&Ifb->mipxIfInFilterDrops, Ifp->IfStats.InFiltered);
  174. SetAsnCounter (&Ifb->mipxIfInNoRoutes, Ifp->IfStats.InNoRoutes);
  175. SetAsnCounter (&Ifb->mipxIfInDiscards, Ifp->IfStats.InDiscards);
  176. SetAsnCounter (&Ifb->mipxIfInDelivers, Ifp->IfStats.InDelivers);
  177. SetAsnCounter (&Ifb->mipxIfOutFilterDrops, Ifp->IfStats.OutFiltered);
  178. SetAsnCounter (&Ifb->mipxIfOutDiscards, Ifp->IfStats.OutDiscards);
  179. SetAsnCounter (&Ifb->mipxIfOutDelivers, Ifp->IfStats.OutDelivers);
  180. SetAsnCounter (&Ifb->mipxIfInNetbiosPackets, Ifp->IfStats.NetbiosReceived);
  181. SetAsnCounter (&Ifb->mipxIfOutNetbiosPackets, Ifp->IfStats.NetbiosSent);
  182. MprAdminMIBBufferFree (Ifp);
  183. return MIB_S_SUCCESS;
  184. case ERROR_NO_MORE_ITEMS:
  185. ASSERTMSG ("ERROR_NO_MORE_ITEMS returned, but request is not GETNEXT ",
  186. actionId==MIB_ACTION_GETNEXT);
  187. DbgTrace (DBG_IPXINTERFACES,
  188. ("MIPX-if: End of table reached on GETFIRST/GETNEXT request for if %ld.\n",
  189. MibGetInputData.MibIndex.InterfaceTableIndex.InterfaceIndex));
  190. return MIB_S_NO_MORE_ENTRIES;
  191. default:
  192. *errorIndex = 0;
  193. DbgTrace (DBG_IPXINTERFACES,
  194. ("MIPX-if: Get request for if %ld failed with error %ld.\n",
  195. MibGetInputData.MibIndex.InterfaceTableIndex.InterfaceIndex, rc));
  196. return MIB_S_ENTRY_NOT_FOUND;
  197. }
  198. #undef Ifb
  199. }
  200. UINT
  201. set_mipxIfEntry(
  202. UINT actionId,
  203. AsnAny * objectArray,
  204. UINT * errorIndex
  205. ) {
  206. #define Ifb ((sav_mipxIfEntry *)objectArray)
  207. PIPX_INTERFACE Ifp;
  208. IPX_MIB_GET_INPUT_DATA MibGetInputData;
  209. DWORD rc;
  210. ULONG IfSize;
  211. if (!EnsureRouterConnection()) {
  212. *errorIndex = 0;
  213. return MIB_S_ENTRY_NOT_FOUND;
  214. }
  215. switch (actionId) {
  216. case MIB_ACTION_VALIDATE:
  217. ASSERTMSG ("No index in VALIDATE request for table ",
  218. Ifb->mipxIfIndex.asnType);
  219. MibGetInputData.TableId = IPX_INTERFACE_TABLE;
  220. MibGetInputData.MibIndex.InterfaceTableIndex.InterfaceIndex
  221. = (ULONG)GetAsnInteger (&Ifb->mipxIfIndex, INVALID_INTERFACE_INDEX);
  222. rc = MprAdminMIBEntryGet(g_MibServerHandle,
  223. PID_IPX,
  224. IPX_PROTOCOL_BASE,
  225. &MibGetInputData,
  226. sizeof(IPX_MIB_GET_INPUT_DATA),
  227. &Ifp,
  228. &IfSize);
  229. if (rc == NO_ERROR && Ifp == NULL)
  230. {
  231. rc = ERROR_CAN_NOT_COMPLETE;
  232. }
  233. if (rc==NO_ERROR) {
  234. Ifb->MibSetInputData.MibRow.Interface = *Ifp;
  235. Ifb->MibSetInputData.MibRow.Interface.AdminState
  236. = (ULONG)GetAsnInteger(&Ifb->mipxIfAdminState,
  237. Ifb->MibSetInputData.MibRow.Interface.AdminState);
  238. GetAsnOctetString (
  239. Ifb->MibSetInputData.MibRow.Interface.NetNumber,
  240. &Ifb->mipxIfNetNumber,
  241. sizeof (Ifb->MibSetInputData.MibRow.Interface.NetNumber),
  242. NULL);
  243. GetAsnOctetString (
  244. Ifb->MibSetInputData.MibRow.Interface.MacAddress,
  245. &Ifb->mipxIfMacAddress,
  246. sizeof (Ifb->MibSetInputData.MibRow.Interface.MacAddress),
  247. NULL);
  248. Ifb->MibSetInputData.MibRow.Interface.EnableIpxWanNegotiation
  249. = (ULONG)GetAsnInteger (&Ifb->mipxIfIpxWanEnable,
  250. Ifb->MibSetInputData.MibRow.Interface.EnableIpxWanNegotiation);
  251. Ifb->MibSetInputData.MibRow.Interface.NetbiosAccept
  252. = (ULONG)GetAsnInteger (&Ifb->mipxIfNetbiosAccept,
  253. Ifb->MibSetInputData.MibRow.Interface.NetbiosAccept);
  254. Ifb->MibSetInputData.MibRow.Interface.NetbiosDeliver
  255. = (ULONG)GetAsnInteger (&Ifb->mipxIfNetbiosDeliver,
  256. Ifb->MibSetInputData.MibRow.Interface.NetbiosDeliver);
  257. MprAdminMIBBufferFree (Ifp);
  258. DbgTrace (DBG_IPXINTERFACES, ("MIPX-if: Validated if %ld\n",
  259. MibGetInputData.MibIndex.InterfaceTableIndex.InterfaceIndex));
  260. return MIB_S_SUCCESS;
  261. }
  262. else {
  263. DbgTrace (DBG_IPXINTERFACES,
  264. ("MIPX-if: Validate failed on if %ld with error %ld\n",
  265. MibGetInputData.MibIndex.InterfaceTableIndex.InterfaceIndex, rc));
  266. return MIB_S_ENTRY_NOT_FOUND;
  267. }
  268. case MIB_ACTION_SET:
  269. rc = MprAdminMIBEntrySet (g_MibServerHandle,
  270. PID_IPX,
  271. IPX_PROTOCOL_BASE,
  272. &Ifb->MibSetInputData,
  273. sizeof(IPX_MIB_SET_INPUT_DATA));
  274. if (rc==NO_ERROR) {
  275. DbgTrace (DBG_IPXINTERFACES, ("MIPX-if: Set succeded on if %ld\n",
  276. Ifb->MibSetInputData.MibRow.Interface.InterfaceIndex));
  277. return MIB_S_SUCCESS;
  278. }
  279. else {
  280. DbgTrace (DBG_IPXINTERFACES,
  281. ("MIPX-if: Set failed on if %ld with error %ld\n",
  282. Ifb->MibSetInputData.MibRow.Interface.InterfaceIndex, rc));
  283. return MIB_S_ENTRY_NOT_FOUND;
  284. }
  285. case MIB_ACTION_CLEANUP:
  286. return MIB_S_SUCCESS;
  287. default:
  288. DbgTrace (DBG_IPXINTERFACES,
  289. ("MIPX-if:Set called with unsupported action code %d.\n",
  290. actionId));
  291. return MIB_S_INVALID_PARAMETER;
  292. }
  293. #undef Ifb
  294. }
  295. ///////////////////////////////////////////////////////////////////////////////
  296. // //
  297. // mipxForwarding group (1.3.6.1.4.1.311.1.8.3) //
  298. // //
  299. ///////////////////////////////////////////////////////////////////////////////
  300. ///////////////////////////////////////////////////////////////////////////////
  301. // //
  302. // mipxDestEntry table (1.3.6.1.4.1.311.1.8.3.1.1) //
  303. // //
  304. ///////////////////////////////////////////////////////////////////////////////
  305. UINT
  306. get_mipxDestEntry(
  307. UINT actionId,
  308. AsnAny * objectArray,
  309. UINT * errorIndex
  310. ) {
  311. #define Rtb ((buf_mipxDestEntry *)objectArray)
  312. PIPX_ROUTE Rtp;
  313. IPX_MIB_GET_INPUT_DATA MibGetInputData;
  314. DWORD rc;
  315. ULONG RtSize;
  316. if (!EnsureRouterConnection()) {
  317. *errorIndex = 0;
  318. return MIB_S_ENTRY_NOT_FOUND;
  319. }
  320. MibGetInputData.TableId = IPX_DEST_TABLE;
  321. GetAsnOctetString (MibGetInputData.MibIndex.RoutingTableIndex.Network,
  322. &Rtb->mipxDestNetNum,
  323. sizeof (MibGetInputData.MibIndex.RoutingTableIndex.Network),
  324. ZERO_NET_NUM);
  325. switch (actionId) {
  326. case MIB_ACTION_GET:
  327. ASSERTMSG ("No index in GET request for table ",
  328. Rtb->mipxDestNetNum.asnType);
  329. rc = MprAdminMIBEntryGet(g_MibServerHandle,
  330. PID_IPX,
  331. IPX_PROTOCOL_BASE,
  332. &MibGetInputData,
  333. sizeof(IPX_MIB_GET_INPUT_DATA),
  334. &Rtp,
  335. &RtSize);
  336. break;
  337. case MIB_ACTION_GETNEXT:
  338. if (Rtb->mipxDestNetNum.asnType) {
  339. rc = MprAdminMIBEntryGetNext(g_MibServerHandle,
  340. PID_IPX,
  341. IPX_PROTOCOL_BASE,
  342. &MibGetInputData,
  343. sizeof(IPX_MIB_GET_INPUT_DATA),
  344. &Rtp,
  345. &RtSize);
  346. if (rc==NO_ERROR) {
  347. FreeAsnString (&Rtb->mipxDestNetNum);
  348. }
  349. }
  350. else
  351. rc = MprAdminMIBEntryGetFirst (g_MibServerHandle,
  352. PID_IPX,
  353. IPX_PROTOCOL_BASE,
  354. &MibGetInputData,
  355. sizeof(IPX_MIB_GET_INPUT_DATA),
  356. &Rtp,
  357. &RtSize);
  358. break;
  359. default:
  360. DbgTrace (DBG_DESTTABLE,
  361. ("MIPX-dest:Get called with unsupported action code %d.\n",
  362. actionId));
  363. return MIB_S_INVALID_PARAMETER;
  364. }
  365. switch (rc) {
  366. case NO_ERROR:
  367. DbgTrace (DBG_DESTTABLE,
  368. ("MIPX-dest: Get(%d) request succeded for net"
  369. " %.2x%.2x%.2x%.2x -> %.2x%.2x%.2x%.2x.\n", actionId,
  370. MibGetInputData.MibIndex.RoutingTableIndex.Network[0],
  371. MibGetInputData.MibIndex.RoutingTableIndex.Network[1],
  372. MibGetInputData.MibIndex.RoutingTableIndex.Network[2],
  373. MibGetInputData.MibIndex.RoutingTableIndex.Network[3],
  374. Rtp->Network[0],
  375. Rtp->Network[1],
  376. Rtp->Network[2],
  377. Rtp->Network[3]));
  378. ForceAsnOctetString (&Rtb->mipxDestNetNum, Rtb->NetNumVal,
  379. Rtp->Network, sizeof (Rtb->NetNumVal));
  380. switch (Rtp->Protocol) {
  381. case IPX_PROTOCOL_LOCAL:
  382. SetAsnInteger (&Rtb->mipxDestProtocol, 2);
  383. break;
  384. case IPX_PROTOCOL_STATIC:
  385. SetAsnInteger (&Rtb->mipxDestProtocol, 5);
  386. break;
  387. case IPX_PROTOCOL_RIP:
  388. SetAsnInteger (&Rtb->mipxDestProtocol, 3);
  389. break;
  390. case IPX_PROTOCOL_NLSP:
  391. SetAsnInteger (&Rtb->mipxDestProtocol, 4);
  392. break;
  393. default:
  394. SetAsnInteger (&Rtb->mipxDestProtocol, 1); // other
  395. break;
  396. }
  397. SetAsnInteger (&Rtb->mipxDestTicks, Rtp->TickCount);
  398. SetAsnInteger (&Rtb->mipxDestHopCount, Rtp->HopCount);
  399. SetAsnInteger (&Rtb->mipxDestNextHopIfIndex, Rtp->InterfaceIndex);
  400. SetAsnOctetString (&Rtb->mipxDestNextHopMacAddress, Rtb->NextHopMacAddressVal,
  401. Rtp->NextHopMacAddress, sizeof (Rtb->NextHopMacAddressVal));
  402. SetAsnInteger (&Rtb->mipxDestFlags, Rtp->Flags);
  403. MprAdminMIBBufferFree (Rtp);
  404. return MIB_S_SUCCESS;
  405. case ERROR_NO_MORE_ITEMS:
  406. ASSERTMSG ("ERROR_NO_MORE_ITEMS returned, but request is not GETNEXT ",
  407. actionId==MIB_ACTION_GETNEXT);
  408. DbgTrace (DBG_DESTTABLE,
  409. ("MIPX-dest: End of table reached on GETFIRST/GETNEXT request"
  410. " for network %.2x%.2x%.2x%.2x.\n",
  411. MibGetInputData.MibIndex.RoutingTableIndex.Network[0],
  412. MibGetInputData.MibIndex.RoutingTableIndex.Network[1],
  413. MibGetInputData.MibIndex.RoutingTableIndex.Network[2],
  414. MibGetInputData.MibIndex.RoutingTableIndex.Network[3]));
  415. return MIB_S_NO_MORE_ENTRIES;
  416. default:
  417. *errorIndex = 0;
  418. DbgTrace (DBG_DESTTABLE,
  419. ("MIPX-dest: Get request for network %.2x%.2x%.2x%.2x"
  420. " failed with error %ld.\n",
  421. MibGetInputData.MibIndex.RoutingTableIndex.Network[0],
  422. MibGetInputData.MibIndex.RoutingTableIndex.Network[1],
  423. MibGetInputData.MibIndex.RoutingTableIndex.Network[2],
  424. MibGetInputData.MibIndex.RoutingTableIndex.Network[3], rc));
  425. return MIB_S_ENTRY_NOT_FOUND;
  426. }
  427. #undef Rtb
  428. }
  429. ///////////////////////////////////////////////////////////////////////////////
  430. // //
  431. // mipxStaticRouteEntry table (1.3.6.1.4.1.311.1.8.3.2.1) //
  432. // //
  433. ///////////////////////////////////////////////////////////////////////////////
  434. UINT
  435. get_mipxStaticRouteEntry(
  436. UINT actionId,
  437. AsnAny * objectArray,
  438. UINT * errorIndex
  439. ) {
  440. #define Rtb ((buf_mipxStaticRouteEntry *)objectArray)
  441. PIPX_ROUTE Rtp;
  442. IPX_MIB_GET_INPUT_DATA MibGetInputData;
  443. DWORD rc;
  444. ULONG RtSize;
  445. if (!EnsureRouterConnection()) {
  446. *errorIndex = 0;
  447. return MIB_S_ENTRY_NOT_FOUND;
  448. }
  449. MibGetInputData.TableId = IPX_STATIC_ROUTE_TABLE;
  450. MibGetInputData.MibIndex.StaticRoutesTableIndex.InterfaceIndex
  451. = (ULONG)GetAsnInteger (&Rtb->mipxStaticRouteIfIndex, ZERO_INTERFACE_INDEX);
  452. GetAsnOctetString (
  453. MibGetInputData.MibIndex.StaticRoutesTableIndex.Network,
  454. &Rtb->mipxStaticRouteNetNum,
  455. sizeof (MibGetInputData.MibIndex.StaticRoutesTableIndex.Network),
  456. ZERO_NET_NUM);
  457. switch (actionId) {
  458. case MIB_ACTION_GET:
  459. ASSERTMSG ("No index in GET request for table ",
  460. Rtb->mipxStaticRouteIfIndex.asnType
  461. &&Rtb->mipxStaticRouteNetNum.asnType);
  462. rc = MprAdminMIBEntryGet(g_MibServerHandle,
  463. PID_IPX,
  464. IPX_PROTOCOL_BASE,
  465. &MibGetInputData,
  466. sizeof(IPX_MIB_GET_INPUT_DATA),
  467. &Rtp,
  468. &RtSize);
  469. break;
  470. case MIB_ACTION_GETNEXT:
  471. if (Rtb->mipxStaticRouteIfIndex.asnType) {
  472. if (!Rtb->mipxStaticRouteNetNum.asnType) {
  473. rc = MprAdminMIBEntryGet(g_MibServerHandle,
  474. PID_IPX,
  475. IPX_PROTOCOL_BASE,
  476. &MibGetInputData,
  477. sizeof(IPX_MIB_GET_INPUT_DATA),
  478. &Rtp,
  479. &RtSize);
  480. if (rc==NO_ERROR)
  481. break;
  482. }
  483. rc = MprAdminMIBEntryGetNext(g_MibServerHandle,
  484. PID_IPX,
  485. IPX_PROTOCOL_BASE,
  486. &MibGetInputData,
  487. sizeof(IPX_MIB_GET_INPUT_DATA),
  488. &Rtp,
  489. &RtSize);
  490. if (rc==NO_ERROR) {
  491. if (Rtb->mipxStaticRouteNetNum.asnType) {
  492. FreeAsnString (&Rtb->mipxStaticRouteNetNum);
  493. }
  494. }
  495. }
  496. else {
  497. ASSERTMSG ("Second index is present but first is not ",
  498. !Rtb->mipxStaticRouteNetNum.asnType);
  499. rc = MprAdminMIBEntryGetFirst (g_MibServerHandle,
  500. PID_IPX,
  501. IPX_PROTOCOL_BASE,
  502. &MibGetInputData,
  503. sizeof(IPX_MIB_GET_INPUT_DATA),
  504. &Rtp,
  505. &RtSize);
  506. }
  507. break;
  508. default:
  509. DbgTrace (DBG_STATICROUTES,
  510. ("MIPX-staticRoutes: Get called with unsupported action code %d.\n",
  511. actionId));
  512. return MIB_S_INVALID_PARAMETER;
  513. }
  514. if (rc == NO_ERROR && Rtp == NULL)
  515. {
  516. rc = ERROR_CAN_NOT_COMPLETE;
  517. }
  518. switch (rc) {
  519. case NO_ERROR:
  520. DbgTrace (DBG_STATICROUTES,
  521. ("MIPX-staticRoutes: Get(%d) request succeded for net"
  522. " %.2x%.2x%.2x%.2x -> %.2x%.2x%.2x%.2x on if %ld\n", actionId,
  523. MibGetInputData.MibIndex.StaticRoutesTableIndex.Network[0],
  524. MibGetInputData.MibIndex.StaticRoutesTableIndex.Network[1],
  525. MibGetInputData.MibIndex.StaticRoutesTableIndex.Network[2],
  526. MibGetInputData.MibIndex.StaticRoutesTableIndex.Network[3],
  527. Rtp->Network[0],
  528. Rtp->Network[1],
  529. Rtp->Network[2],
  530. Rtp->Network[3],
  531. MibGetInputData.MibIndex.StaticRoutesTableIndex.InterfaceIndex));
  532. ForceAsnInteger (&Rtb->mipxStaticRouteIfIndex, Rtp->InterfaceIndex);
  533. ForceAsnOctetString (&Rtb->mipxStaticRouteNetNum, Rtb->NetNumVal,
  534. Rtp->Network, sizeof (Rtb->NetNumVal));
  535. SetAsnInteger (&Rtb->mipxStaticRouteEntryStatus, MIPX_EXIST_STATE_CREATED);
  536. SetAsnInteger (&Rtb->mipxStaticRouteTicks, Rtp->TickCount);
  537. SetAsnInteger (&Rtb->mipxStaticRouteHopCount, Rtp->HopCount);
  538. SetAsnOctetString (&Rtb->mipxStaticRouteNextHopMacAddress, Rtb->NextHopMacAddressVal,
  539. Rtp->NextHopMacAddress, sizeof (Rtb->NextHopMacAddressVal));
  540. MprAdminMIBBufferFree (Rtp);
  541. return MIB_S_SUCCESS;
  542. case ERROR_NO_MORE_ITEMS:
  543. ASSERTMSG ("ERROR_NO_MORE_ITEMS returned, but request is not GETNEXT ",
  544. actionId==MIB_ACTION_GETNEXT);
  545. DbgTrace (DBG_STATICROUTES,
  546. ("MIPX-staticRoutes: End of table reached on GETFIRST/GETNEXT request for network"
  547. " %.2x%.2x%.2x%.2x on if %ld.\n",
  548. MibGetInputData.MibIndex.StaticRoutesTableIndex.Network[0],
  549. MibGetInputData.MibIndex.StaticRoutesTableIndex.Network[1],
  550. MibGetInputData.MibIndex.StaticRoutesTableIndex.Network[2],
  551. MibGetInputData.MibIndex.StaticRoutesTableIndex.Network[3],
  552. MibGetInputData.MibIndex.StaticRoutesTableIndex.InterfaceIndex));
  553. return MIB_S_NO_MORE_ENTRIES;
  554. default:
  555. *errorIndex = 0;
  556. DbgTrace (DBG_STATICROUTES,
  557. ("MIPX-staticRoutes: Get request for network %.2x%.2x%.2x%.2x."
  558. " on if %ld failed with error %ld.\n",
  559. MibGetInputData.MibIndex.StaticRoutesTableIndex.Network[0],
  560. MibGetInputData.MibIndex.StaticRoutesTableIndex.Network[1],
  561. MibGetInputData.MibIndex.StaticRoutesTableIndex.Network[2],
  562. MibGetInputData.MibIndex.StaticRoutesTableIndex.Network[3],
  563. MibGetInputData.MibIndex.StaticRoutesTableIndex.InterfaceIndex, rc));
  564. return MIB_S_ENTRY_NOT_FOUND;
  565. }
  566. #undef Rtb
  567. }
  568. UINT
  569. set_mipxStaticRouteEntry(
  570. UINT actionId,
  571. AsnAny * objectArray,
  572. UINT * errorIndex
  573. ) {
  574. #define Rtb ((sav_mipxStaticRouteEntry *)objectArray)
  575. PIPX_ROUTE Rtp;
  576. IPX_MIB_GET_INPUT_DATA MibGetInputData;
  577. DWORD rc;
  578. ULONG RtSize;
  579. if (!EnsureRouterConnection()) {
  580. *errorIndex = 0;
  581. return MIB_S_ENTRY_NOT_FOUND;
  582. }
  583. switch (actionId) {
  584. case MIB_ACTION_VALIDATE:
  585. ASSERTMSG ("No index in VALIDATE request for table ",
  586. Rtb->mipxStaticRouteIfIndex.asnType&&Rtb->mipxStaticRouteIfIndex.asnType);
  587. MibGetInputData.TableId = IPX_STATIC_ROUTE_TABLE;
  588. MibGetInputData.MibIndex.StaticRoutesTableIndex.InterfaceIndex
  589. = (ULONG)GetAsnInteger (&Rtb->mipxStaticRouteIfIndex,INVALID_INTERFACE_INDEX);
  590. GetAsnOctetString (
  591. MibGetInputData.MibIndex.StaticRoutesTableIndex.Network,
  592. &Rtb->mipxStaticRouteNetNum,
  593. sizeof (MibGetInputData.MibIndex.StaticRoutesTableIndex.Network),
  594. ZERO_NET_NUM);
  595. Rtb->ActionFlag
  596. = (BOOLEAN)GetAsnInteger (&Rtb->mipxStaticRouteEntryStatus,
  597. MIPX_EXIST_STATE_NOACTION);
  598. rc = MprAdminMIBEntryGet(g_MibServerHandle,
  599. PID_IPX,
  600. IPX_PROTOCOL_BASE,
  601. &MibGetInputData,
  602. sizeof(IPX_MIB_GET_INPUT_DATA),
  603. &Rtp,
  604. &RtSize);
  605. if (rc == NO_ERROR && Rtp == NULL)
  606. {
  607. rc = ERROR_CAN_NOT_COMPLETE;
  608. }
  609. if (rc==NO_ERROR) {
  610. Rtb->MibSetInputData.MibRow.Route = *Rtp;
  611. if (Rtb->ActionFlag == MIPX_EXIST_STATE_CREATED)
  612. Rtb->ActionFlag = MIPX_EXIST_STATE_NOACTION;
  613. MprAdminMIBBufferFree (Rtp);
  614. DbgTrace (DBG_STATICROUTES,
  615. ("MIPX-static routes: Validated"
  616. " network %.2x.2x.2x.2x on if %ld\n",
  617. MibGetInputData.MibIndex.StaticRoutesTableIndex.Network[0],
  618. MibGetInputData.MibIndex.StaticRoutesTableIndex.Network[1],
  619. MibGetInputData.MibIndex.StaticRoutesTableIndex.Network[2],
  620. MibGetInputData.MibIndex.StaticRoutesTableIndex.Network[3],
  621. MibGetInputData.MibIndex.StaticRoutesTableIndex.InterfaceIndex));
  622. }
  623. else if (Rtb->ActionFlag == MIPX_EXIST_STATE_CREATED) {
  624. DbgTrace (DBG_STATICROUTES,
  625. ("MIPX-static routes: Prepared to add"
  626. " network %.2x.2x.2x.2x on if %ld\n",
  627. MibGetInputData.MibIndex.StaticRoutesTableIndex.Network[0],
  628. MibGetInputData.MibIndex.StaticRoutesTableIndex.Network[1],
  629. MibGetInputData.MibIndex.StaticRoutesTableIndex.Network[2],
  630. MibGetInputData.MibIndex.StaticRoutesTableIndex.Network[3],
  631. MibGetInputData.MibIndex.StaticRoutesTableIndex.InterfaceIndex));
  632. Rtb->MibSetInputData.MibRow.Route.InterfaceIndex
  633. = (ULONG)GetAsnInteger (&Rtb->mipxStaticRouteIfIndex,
  634. INVALID_INTERFACE_INDEX);
  635. GetAsnOctetString (Rtb->MibSetInputData.MibRow.Route.Network,
  636. &Rtb->mipxStaticRouteNetNum,
  637. sizeof (Rtb->MibSetInputData.MibRow.Route.Network),
  638. ZERO_NET_NUM);
  639. Rtb->MibSetInputData.MibRow.Route.Protocol = IPX_PROTOCOL_STATIC;
  640. Rtb->MibSetInputData.MibRow.Route.Flags = 0;
  641. Rtb->MibSetInputData.MibRow.Route.TickCount = MAXSHORT;
  642. Rtb->MibSetInputData.MibRow.Route.HopCount = 15;
  643. memset (Rtb->MibSetInputData.MibRow.Route.NextHopMacAddress,
  644. 0xFF,
  645. sizeof (Rtb->MibSetInputData.MibRow.Route.NextHopMacAddress));
  646. }
  647. else {
  648. DbgTrace (DBG_STATICROUTES,
  649. ("MIPX-static routes: Validate failed"
  650. " for network %.2x.2x.2x.2x on if %ld with error %ld\n",
  651. MibGetInputData.MibIndex.StaticRoutesTableIndex.Network[0],
  652. MibGetInputData.MibIndex.StaticRoutesTableIndex.Network[1],
  653. MibGetInputData.MibIndex.StaticRoutesTableIndex.Network[2],
  654. MibGetInputData.MibIndex.StaticRoutesTableIndex.Network[3],
  655. MibGetInputData.MibIndex.StaticRoutesTableIndex.InterfaceIndex,rc));
  656. return MIB_S_ENTRY_NOT_FOUND;
  657. }
  658. Rtb->MibSetInputData.MibRow.Route.TickCount
  659. = (USHORT)GetAsnInteger (&Rtb->mipxStaticRouteTicks,
  660. Rtb->MibSetInputData.MibRow.Route.TickCount);
  661. Rtb->MibSetInputData.MibRow.Route.HopCount
  662. = (USHORT)GetAsnInteger (&Rtb->mipxStaticRouteHopCount,
  663. Rtb->MibSetInputData.MibRow.Route.HopCount);
  664. GetAsnOctetString (Rtb->MibSetInputData.MibRow.Route.NextHopMacAddress,
  665. &Rtb->mipxStaticRouteNextHopMacAddress,
  666. sizeof (Rtb->MibSetInputData.MibRow.Route.NextHopMacAddress),
  667. NULL);
  668. return MIB_S_SUCCESS;
  669. case MIB_ACTION_SET:
  670. switch (Rtb->ActionFlag) {
  671. case MIPX_EXIST_STATE_NOACTION:
  672. rc = MprAdminMIBEntrySet (g_MibServerHandle,
  673. PID_IPX,
  674. IPX_PROTOCOL_BASE,
  675. &Rtb->MibSetInputData,
  676. sizeof(IPX_MIB_SET_INPUT_DATA));
  677. break;
  678. case MIPX_EXIST_STATE_DELETED:
  679. rc = MprAdminMIBEntryDelete (g_MibServerHandle,
  680. PID_IPX,
  681. IPX_PROTOCOL_BASE,
  682. &Rtb->MibSetInputData,
  683. sizeof(IPX_MIB_SET_INPUT_DATA));
  684. break;
  685. case MIPX_EXIST_STATE_CREATED:
  686. rc = MprAdminMIBEntryCreate (g_MibServerHandle,
  687. PID_IPX,
  688. IPX_PROTOCOL_BASE,
  689. &Rtb->MibSetInputData,
  690. sizeof(IPX_MIB_SET_INPUT_DATA));
  691. break;
  692. }
  693. if (rc==NO_ERROR) {
  694. DbgTrace (DBG_STATICROUTES,
  695. ("MIPX-static routes: Set succeded for"
  696. " network %.2x.2x.2x.2x on if %ld\n",
  697. Rtb->MibSetInputData.MibRow.Route.Network[0],
  698. Rtb->MibSetInputData.MibRow.Route.Network[1],
  699. Rtb->MibSetInputData.MibRow.Route.Network[2],
  700. Rtb->MibSetInputData.MibRow.Route.Network[3],
  701. Rtb->MibSetInputData.MibRow.Route.InterfaceIndex));
  702. return MIB_S_SUCCESS;
  703. }
  704. else {
  705. DbgTrace (DBG_STATICROUTES,
  706. ("MIPX-static routes: Set failed for"
  707. " network %.2x.2x.2x.2x on if %ld with error %ld\n",
  708. Rtb->MibSetInputData.MibRow.Route.Network[0],
  709. Rtb->MibSetInputData.MibRow.Route.Network[1],
  710. Rtb->MibSetInputData.MibRow.Route.Network[2],
  711. Rtb->MibSetInputData.MibRow.Route.Network[3],
  712. Rtb->MibSetInputData.MibRow.Route.InterfaceIndex, rc));
  713. return MIB_S_ENTRY_NOT_FOUND;
  714. }
  715. case MIB_ACTION_CLEANUP:
  716. return MIB_S_SUCCESS;
  717. default:
  718. DbgTrace (DBG_STATICROUTES,
  719. ("MIPX-static routes: Set called with unsupported action code %d.\n",
  720. actionId));
  721. return MIB_S_INVALID_PARAMETER;
  722. }
  723. #undef Rtb
  724. }
  725. ///////////////////////////////////////////////////////////////////////////////
  726. // //
  727. // mipxServices group (1.3.6.1.4.1.311.1.8.4) //
  728. // //
  729. ///////////////////////////////////////////////////////////////////////////////
  730. ///////////////////////////////////////////////////////////////////////////////
  731. // //
  732. // mipxServEntry table (1.3.6.1.4.1.311.1.8.4.1.1) //
  733. // //
  734. ///////////////////////////////////////////////////////////////////////////////
  735. UINT
  736. get_mipxServEntry(
  737. UINT actionId,
  738. AsnAny * objectArray,
  739. UINT * errorIndex
  740. ) {
  741. #define Svb ((buf_mipxServEntry *)objectArray)
  742. PIPX_SERVICE Svp, SvpCur;
  743. IPX_MIB_GET_INPUT_DATA MibGetInputData;
  744. DWORD rc;
  745. ULONG SvSize;
  746. INT lenPrev, lenNext, lenCur;
  747. if (!EnsureRouterConnection()) {
  748. *errorIndex = 0;
  749. return MIB_S_ENTRY_NOT_FOUND;
  750. }
  751. MibGetInputData.TableId = IPX_SERV_TABLE;
  752. MibGetInputData.MibIndex.ServicesTableIndex.ServiceType
  753. = GetAsnServType (&Svb->mipxServType, ZERO_SERVER_TYPE);
  754. GetAsnDispString (MibGetInputData.MibIndex.ServicesTableIndex.ServiceName,
  755. &Svb->mipxServName, ZERO_SERVER_NAME);
  756. switch (actionId) {
  757. case MIB_ACTION_GET:
  758. ASSERTMSG ("No index in GET request for table ",
  759. Svb->mipxServType.asnType && Svb->mipxServName.asnType);
  760. rc = MprAdminMIBEntryGet(g_MibServerHandle,
  761. PID_IPX,
  762. IPX_PROTOCOL_BASE,
  763. &MibGetInputData,
  764. sizeof(IPX_MIB_GET_INPUT_DATA),
  765. &Svp,
  766. &SvSize);
  767. break;
  768. case MIB_ACTION_GETNEXT:
  769. if (Svb->mipxServType.asnType) {
  770. if (!Svb->mipxServName.asnType) {
  771. rc = MprAdminMIBEntryGet(g_MibServerHandle,
  772. PID_IPX,
  773. IPX_PROTOCOL_BASE,
  774. &MibGetInputData,
  775. sizeof(IPX_MIB_GET_INPUT_DATA),
  776. &Svp,
  777. &SvSize);
  778. if (rc==NO_ERROR) {
  779. FreeAsnString (&Svb->mipxServType);
  780. break;
  781. }
  782. }
  783. rc = MprAdminMIBEntryGetNext(g_MibServerHandle,
  784. PID_IPX,
  785. IPX_PROTOCOL_BASE,
  786. &MibGetInputData,
  787. sizeof(IPX_MIB_GET_INPUT_DATA),
  788. &Svp,
  789. &SvSize);
  790. if (rc==NO_ERROR) {
  791. FreeAsnString (&Svb->mipxServType);
  792. if (Svb->mipxServName.asnType) {
  793. FreeAsnString (&Svb->mipxServName);
  794. }
  795. }
  796. }
  797. else {
  798. ASSERTMSG ("Second index is present but first is not ",
  799. !Svb->mipxServName.asnType);
  800. rc = MprAdminMIBEntryGetFirst(g_MibServerHandle,
  801. PID_IPX,
  802. IPX_PROTOCOL_BASE,
  803. &MibGetInputData,
  804. sizeof(IPX_MIB_GET_INPUT_DATA),
  805. &Svp,
  806. &SvSize);
  807. }
  808. break;
  809. default:
  810. DbgTrace (DBG_SERVERTABLE,
  811. ("MIPX-servers: Get called with unsupported action code %d.\n",
  812. actionId));
  813. return MIB_S_INVALID_PARAMETER;
  814. }
  815. switch (rc) {
  816. case NO_ERROR:
  817. DbgTrace (DBG_SERVERTABLE,
  818. ("MIPX-servers: Get(%d) request succeded for service"
  819. " %.4x-%.48s -> %.4x-%.48s.\n", actionId,
  820. MibGetInputData.MibIndex.ServicesTableIndex.ServiceType,
  821. MibGetInputData.MibIndex.ServicesTableIndex.ServiceName,
  822. Svp->Server.Type, Svp->Server.Name));
  823. ForceAsnServType (&Svb->mipxServType, Svb->TypeVal, Svp->Server.Type);
  824. ForceAsnDispString (&Svb->mipxServName, Svb->NameVal,
  825. Svp->Server.Name, sizeof (Svb->NameVal));
  826. switch (Svp->Protocol) {
  827. case IPX_PROTOCOL_LOCAL:
  828. SetAsnInteger (&Svb->mipxServProtocol, 2);
  829. break;
  830. case IPX_PROTOCOL_STATIC:
  831. SetAsnInteger (&Svb->mipxServProtocol, 5);
  832. break;
  833. case IPX_PROTOCOL_SAP:
  834. SetAsnInteger (&Svb->mipxServProtocol, 6);
  835. break;
  836. case IPX_PROTOCOL_NLSP:
  837. SetAsnInteger (&Svb->mipxServProtocol, 4);
  838. break;
  839. default:
  840. SetAsnInteger (&Svb->mipxServProtocol, 1); // other
  841. break;
  842. }
  843. SetAsnInteger (&Svb->mipxServProtocol, Svp->Protocol);
  844. SetAsnOctetString (&Svb->mipxServNetNum, Svb->NetNumVal,
  845. Svp->Server.Network, sizeof (Svb->NetNumVal));
  846. SetAsnOctetString (&Svb->mipxServNode, Svb->NodeVal,
  847. Svp->Server.Node, sizeof (Svb->NodeVal));
  848. SetAsnOctetString (&Svb->mipxServSocket, Svb->SocketVal,
  849. Svp->Server.Socket, sizeof (Svb->SocketVal));
  850. SetAsnInteger (&Svb->mipxServHopCount, Svp->Server.HopCount);
  851. MprAdminMIBBufferFree (Svp);
  852. return MIB_S_SUCCESS;
  853. case ERROR_NO_MORE_ITEMS:
  854. ASSERTMSG ("ERROR_NO_MORE_ITEMS returned, but request is not GETNEXT ",
  855. actionId==MIB_ACTION_GETNEXT);
  856. DbgTrace (DBG_SERVERTABLE,
  857. ("MIPX-servers: End of table reached on GETFIRST/GETNEXT request"
  858. " for service %.4x-%.48s.\n",
  859. MibGetInputData.MibIndex.ServicesTableIndex.ServiceType,
  860. MibGetInputData.MibIndex.ServicesTableIndex.ServiceName));
  861. return MIB_S_NO_MORE_ENTRIES;
  862. default:
  863. *errorIndex = 0;
  864. DbgTrace (DBG_SERVERTABLE,
  865. ("MIPX-servers: Get request for service %.4x-%.48s"
  866. " failed with error %ld.\n",
  867. MibGetInputData.MibIndex.ServicesTableIndex.ServiceType,
  868. MibGetInputData.MibIndex.ServicesTableIndex.ServiceName, rc));
  869. return MIB_S_ENTRY_NOT_FOUND;
  870. }
  871. #undef Svb
  872. }
  873. ///////////////////////////////////////////////////////////////////////////////
  874. // //
  875. // mipxStaticServEntry table (1.3.6.1.4.1.311.1.8.4.2.1) //
  876. // //
  877. ///////////////////////////////////////////////////////////////////////////////
  878. UINT
  879. get_mipxStaticServEntry(
  880. UINT actionId,
  881. AsnAny * objectArray,
  882. UINT * errorIndex
  883. ) {
  884. #define Svb ((buf_mipxStaticServEntry *)objectArray)
  885. PIPX_SERVICE Svp;
  886. IPX_MIB_GET_INPUT_DATA MibGetInputData;
  887. DWORD rc;
  888. ULONG SvSize;
  889. if (!EnsureRouterConnection()) {
  890. *errorIndex = 0;
  891. return MIB_S_ENTRY_NOT_FOUND;
  892. }
  893. MibGetInputData.TableId = IPX_STATIC_SERV_TABLE;
  894. MibGetInputData.MibIndex.StaticServicesTableIndex.InterfaceIndex
  895. = (ULONG)GetAsnInteger (&Svb->mipxStaticServIfIndex,
  896. ZERO_INTERFACE_INDEX);
  897. MibGetInputData.MibIndex.StaticServicesTableIndex.ServiceType
  898. = GetAsnServType (&Svb->mipxStaticServType, ZERO_SERVER_TYPE);
  899. GetAsnDispString (
  900. MibGetInputData.MibIndex.StaticServicesTableIndex.ServiceName,
  901. &Svb->mipxStaticServName, ZERO_SERVER_NAME);
  902. switch (actionId) {
  903. case MIB_ACTION_GET:
  904. ASSERTMSG ("No index in GET request for table ",
  905. Svb->mipxStaticServIfIndex.asnType
  906. &&Svb->mipxStaticServType.asnType
  907. &&Svb->mipxStaticServName.asnType);
  908. rc = MprAdminMIBEntryGet(g_MibServerHandle,
  909. PID_IPX,
  910. IPX_PROTOCOL_BASE,
  911. &MibGetInputData,
  912. sizeof(IPX_MIB_GET_INPUT_DATA),
  913. &Svp,
  914. &SvSize);
  915. break;
  916. case MIB_ACTION_GETNEXT:
  917. if (Svb->mipxStaticServIfIndex.asnType) {
  918. if (!Svb->mipxStaticServType.asnType
  919. || !Svb->mipxStaticServName.asnType) {
  920. rc = MprAdminMIBEntryGet(g_MibServerHandle,
  921. PID_IPX,
  922. IPX_PROTOCOL_BASE,
  923. &MibGetInputData,
  924. sizeof(IPX_MIB_GET_INPUT_DATA),
  925. &Svp,
  926. &SvSize);
  927. if (rc==NO_ERROR) {
  928. if (Svb->mipxStaticServType.asnType) {
  929. FreeAsnString (&Svb->mipxStaticServType);
  930. }
  931. if (Svb->mipxStaticServName.asnType) {
  932. FreeAsnString (&Svb->mipxStaticServName);
  933. }
  934. break;
  935. }
  936. }
  937. rc = MprAdminMIBEntryGetNext(g_MibServerHandle,
  938. PID_IPX,
  939. IPX_PROTOCOL_BASE,
  940. &MibGetInputData,
  941. sizeof(IPX_MIB_GET_INPUT_DATA),
  942. &Svp,
  943. &SvSize);
  944. if (rc==NO_ERROR) {
  945. if (Svb->mipxStaticServType.asnType) {
  946. FreeAsnString (&Svb->mipxStaticServType);
  947. }
  948. if (Svb->mipxStaticServName.asnType) {
  949. FreeAsnString (&Svb->mipxStaticServName);
  950. }
  951. }
  952. }
  953. else {
  954. ASSERTMSG ("Second or third indeces present but first is not ",
  955. !Svb->mipxStaticServType.asnType
  956. &&!Svb->mipxStaticServName.asnType);
  957. rc = MprAdminMIBEntryGetFirst (g_MibServerHandle,
  958. PID_IPX,
  959. IPX_PROTOCOL_BASE,
  960. &MibGetInputData,
  961. sizeof(IPX_MIB_GET_INPUT_DATA),
  962. &Svp,
  963. &SvSize);
  964. }
  965. break;
  966. default:
  967. DbgTrace (DBG_STATICSERVERS,
  968. ("MIPX-static servers: Get called with unsupported action code %d.\n",
  969. actionId));
  970. return MIB_S_INVALID_PARAMETER;
  971. }
  972. if (rc == NO_ERROR && Svp == NULL)
  973. {
  974. rc = ERROR_CAN_NOT_COMPLETE;
  975. }
  976. switch (rc) {
  977. case NO_ERROR:
  978. DbgTrace (DBG_STATICSERVERS,
  979. ("MIPX-static servers: Get (%d) request succeded for service"
  980. " %.4x-%.48s -> %.4x-%.48s on if %ld.\n", actionId,
  981. MibGetInputData.MibIndex.StaticServicesTableIndex.ServiceType,
  982. MibGetInputData.MibIndex.StaticServicesTableIndex.ServiceName,
  983. Svp->Server.Type, Svp->Server.Name,
  984. MibGetInputData.MibIndex.StaticServicesTableIndex.InterfaceIndex));
  985. ForceAsnInteger (&Svb->mipxStaticServIfIndex, Svp->InterfaceIndex);
  986. ForceAsnServType (&Svb->mipxStaticServType, Svb->TypeVal, Svp->Server.Type);
  987. ForceAsnDispString (&Svb->mipxStaticServName, Svb->NameVal,
  988. Svp->Server.Name, sizeof (Svb->NameVal));
  989. SetAsnInteger (&Svb->mipxStaticServEntryStatus, MIPX_EXIST_STATE_CREATED);
  990. SetAsnOctetString (&Svb->mipxStaticServNetNum, Svb->NetNumVal,
  991. Svp->Server.Network, sizeof (Svb->NetNumVal));
  992. SetAsnOctetString (&Svb->mipxStaticServNode, Svb->NodeVal,
  993. Svp->Server.Node, sizeof (Svb->NodeVal));
  994. SetAsnOctetString (&Svb->mipxStaticServSocket, Svb->SocketVal,
  995. Svp->Server.Socket, sizeof (Svb->SocketVal));
  996. SetAsnInteger (&Svb->mipxStaticServHopCount, Svp->Server.HopCount);
  997. MprAdminMIBBufferFree (Svp);
  998. return MIB_S_SUCCESS;
  999. case ERROR_NO_MORE_ITEMS:
  1000. ASSERTMSG ("ERROR_NO_MORE_ITEMS returned, but request is not GETNEXT ",
  1001. actionId==MIB_ACTION_GETNEXT);
  1002. DbgTrace (DBG_STATICSERVERS,
  1003. ("MIPX-static servers: End of table reached on GETFIRST/GETNEXT request"
  1004. " for service %.4x-%.48s on if %ld.\n",
  1005. MibGetInputData.MibIndex.StaticServicesTableIndex.ServiceType,
  1006. MibGetInputData.MibIndex.StaticServicesTableIndex.ServiceName,
  1007. MibGetInputData.MibIndex.StaticServicesTableIndex.InterfaceIndex));
  1008. return MIB_S_NO_MORE_ENTRIES;
  1009. default:
  1010. *errorIndex = 0;
  1011. DbgTrace (DBG_STATICSERVERS,
  1012. ("MIPX-static servers: Get request for service %.4x-%.48s"
  1013. " on if %ld failed with error %ld.\n",
  1014. MibGetInputData.MibIndex.StaticServicesTableIndex.ServiceType,
  1015. MibGetInputData.MibIndex.StaticServicesTableIndex.ServiceName,
  1016. MibGetInputData.MibIndex.StaticServicesTableIndex.InterfaceIndex,
  1017. rc));
  1018. return MIB_S_ENTRY_NOT_FOUND;
  1019. }
  1020. #undef Svb
  1021. }
  1022. UINT
  1023. set_mipxStaticServEntry(
  1024. UINT actionId,
  1025. AsnAny * objectArray,
  1026. UINT * errorIndex
  1027. ) {
  1028. #define Svb ((sav_mipxStaticServEntry *)objectArray)
  1029. PIPX_SERVICE Svp;
  1030. IPX_MIB_GET_INPUT_DATA MibGetInputData;
  1031. DWORD rc;
  1032. ULONG SvSize;
  1033. if (!EnsureRouterConnection()) {
  1034. *errorIndex = 0;
  1035. return MIB_S_ENTRY_NOT_FOUND;
  1036. }
  1037. switch (actionId) {
  1038. case MIB_ACTION_VALIDATE:
  1039. ASSERTMSG ("No index in VALIDATE request for table ",
  1040. Svb->mipxStaticServIfIndex.asnType
  1041. &&Svb->mipxStaticServType.asnType
  1042. &&Svb->mipxStaticServName.asnType);
  1043. MibGetInputData.TableId = IPX_STATIC_SERV_TABLE;
  1044. MibGetInputData.MibIndex.StaticServicesTableIndex.InterfaceIndex
  1045. = (ULONG)GetAsnInteger (&Svb->mipxStaticServIfIndex,
  1046. INVALID_INTERFACE_INDEX);
  1047. MibGetInputData.MibIndex.StaticServicesTableIndex.ServiceType
  1048. = GetAsnServType (&Svb->mipxStaticServType, INVALID_SERVER_TYPE);
  1049. GetAsnDispString (
  1050. MibGetInputData.MibIndex.StaticServicesTableIndex.ServiceName,
  1051. &Svb->mipxStaticServName,
  1052. INVALID_SERVER_NAME);
  1053. Svb->ActionFlag
  1054. = (BOOLEAN)GetAsnInteger (&Svb->mipxStaticServEntryStatus,
  1055. MIPX_EXIST_STATE_NOACTION);
  1056. rc = MprAdminMIBEntryGet(g_MibServerHandle,
  1057. PID_IPX,
  1058. IPX_PROTOCOL_BASE,
  1059. &MibGetInputData,
  1060. sizeof(IPX_MIB_GET_INPUT_DATA),
  1061. &Svp,
  1062. &SvSize);
  1063. if (rc == NO_ERROR && Svp == NULL)
  1064. {
  1065. return MIB_S_ENTRY_NOT_FOUND;
  1066. }
  1067. if (rc==NO_ERROR) {
  1068. Svb->MibSetInputData.MibRow.Service = *Svp;
  1069. if (Svb->ActionFlag == MIPX_EXIST_STATE_CREATED)
  1070. Svb->ActionFlag = MIPX_EXIST_STATE_NOACTION;
  1071. MprAdminMIBBufferFree (Svp);
  1072. DbgTrace (DBG_STATICSERVERS,
  1073. ("MIPX-static servers: Validated"
  1074. " service %.4x-%.48s on if %ld.\n",
  1075. MibGetInputData.MibIndex.StaticServicesTableIndex.ServiceType,
  1076. MibGetInputData.MibIndex.StaticServicesTableIndex.ServiceName,
  1077. MibGetInputData.MibIndex.StaticServicesTableIndex.InterfaceIndex));
  1078. }
  1079. else if (Svb->ActionFlag == MIPX_EXIST_STATE_CREATED) {
  1080. DbgTrace (DBG_STATICSERVERS,
  1081. ("MIPX-static servers: Prepared to add"
  1082. " service %.4x-%.48s on if %ld.\n",
  1083. MibGetInputData.MibIndex.StaticServicesTableIndex.ServiceType,
  1084. MibGetInputData.MibIndex.StaticServicesTableIndex.ServiceName,
  1085. MibGetInputData.MibIndex.StaticServicesTableIndex.InterfaceIndex));
  1086. Svb->MibSetInputData.MibRow.Service.InterfaceIndex
  1087. = (ULONG) GetAsnInteger (&Svb->mipxStaticServIfIndex,
  1088. INVALID_INTERFACE_INDEX);
  1089. Svb->MibSetInputData.MibRow.Service.Protocol = IPX_PROTOCOL_STATIC;
  1090. Svb->MibSetInputData.MibRow.Service.Server.Type
  1091. = GetAsnServType (&Svb->mipxStaticServType,
  1092. INVALID_SERVER_TYPE);
  1093. GetAsnDispString (
  1094. Svb->MibSetInputData.MibRow.Service.Server.Name,
  1095. &Svb->mipxStaticServName,
  1096. INVALID_SERVER_NAME);
  1097. memset (Svb->MibSetInputData.MibRow.Service.Server.Network, 0,
  1098. sizeof (Svb->MibSetInputData.MibRow.Service.Server.Network));
  1099. memset (Svb->MibSetInputData.MibRow.Service.Server.Node, 0,
  1100. sizeof (Svb->MibSetInputData.MibRow.Service.Server.Node));
  1101. memset (Svb->MibSetInputData.MibRow.Service.Server.Socket, 0,
  1102. sizeof (Svb->MibSetInputData.MibRow.Service.Server.Socket));
  1103. Svb->MibSetInputData.MibRow.Service.Server.HopCount = 15;
  1104. }
  1105. else {
  1106. DbgTrace (DBG_STATICSERVERS,
  1107. ("MIPX-static servers: Validate failed"
  1108. " for service %.4x-%.48s on if %ld with error %ld.\n",
  1109. MibGetInputData.MibIndex.StaticServicesTableIndex.ServiceType,
  1110. MibGetInputData.MibIndex.StaticServicesTableIndex.ServiceName,
  1111. MibGetInputData.MibIndex.StaticServicesTableIndex.InterfaceIndex,
  1112. rc));
  1113. return MIB_S_ENTRY_NOT_FOUND;
  1114. }
  1115. GetAsnOctetString (Svb->MibSetInputData.MibRow.Service.Server.Network,
  1116. &Svb->mipxStaticServNetNum,
  1117. sizeof (Svb->MibSetInputData.MibRow.Service.Server.Network),
  1118. NULL);
  1119. GetAsnOctetString (Svb->MibSetInputData.MibRow.Service.Server.Node,
  1120. &Svb->mipxStaticServNode,
  1121. sizeof (Svb->MibSetInputData.MibRow.Service.Server.Node),
  1122. NULL);
  1123. GetAsnOctetString (Svb->MibSetInputData.MibRow.Service.Server.Socket,
  1124. &Svb->mipxStaticServSocket,
  1125. sizeof (Svb->MibSetInputData.MibRow.Service.Server.Socket),
  1126. NULL);
  1127. Svb->MibSetInputData.MibRow.Service.Server.HopCount =
  1128. (USHORT)GetAsnInteger (&Svb->mipxStaticServHopCount,
  1129. Svb->MibSetInputData.MibRow.Service.Server.HopCount);
  1130. return MIB_S_SUCCESS;
  1131. case MIB_ACTION_SET:
  1132. switch (Svb->ActionFlag) {
  1133. case MIPX_EXIST_STATE_NOACTION:
  1134. rc = MprAdminMIBEntrySet (g_MibServerHandle,
  1135. PID_IPX,
  1136. IPX_PROTOCOL_BASE,
  1137. &Svb->MibSetInputData,
  1138. sizeof(IPX_MIB_SET_INPUT_DATA));
  1139. break;
  1140. case MIPX_EXIST_STATE_DELETED:
  1141. rc = MprAdminMIBEntryDelete (g_MibServerHandle,
  1142. PID_IPX,
  1143. IPX_PROTOCOL_BASE,
  1144. &Svb->MibSetInputData,
  1145. sizeof(IPX_MIB_SET_INPUT_DATA));
  1146. break;
  1147. case MIPX_EXIST_STATE_CREATED:
  1148. rc = MprAdminMIBEntryCreate (g_MibServerHandle,
  1149. PID_IPX,
  1150. IPX_PROTOCOL_BASE,
  1151. &Svb->MibSetInputData,
  1152. sizeof(IPX_MIB_SET_INPUT_DATA));
  1153. break;
  1154. }
  1155. if (rc==NO_ERROR) {
  1156. DbgTrace (DBG_STATICSERVERS,
  1157. ("MIPX-static servers: Set succeded"
  1158. " for service %.4x-%.48s on if %ld.\n",
  1159. Svb->MibSetInputData.MibRow.Service.Server.Type,
  1160. Svb->MibSetInputData.MibRow.Service.Server.Name,
  1161. Svb->MibSetInputData.MibRow.Service.InterfaceIndex));
  1162. return MIB_S_SUCCESS;
  1163. }
  1164. else {
  1165. DbgTrace (DBG_STATICSERVERS,
  1166. ("MIPX-static servers: Set failed for"
  1167. " for service %.4x-%.48s on if %ld with error %ld.\n",
  1168. Svb->MibSetInputData.MibRow.Service.Server.Type,
  1169. Svb->MibSetInputData.MibRow.Service.Server.Name,
  1170. Svb->MibSetInputData.MibRow.Service.InterfaceIndex,
  1171. rc));
  1172. return MIB_S_ENTRY_NOT_FOUND;
  1173. }
  1174. case MIB_ACTION_CLEANUP:
  1175. return MIB_S_SUCCESS;
  1176. default:
  1177. DbgTrace (DBG_STATICSERVERS,
  1178. ("MIPX-static servers: Set called with unsupported action code %d.\n",
  1179. actionId));
  1180. return MIB_S_INVALID_PARAMETER;
  1181. }
  1182. #undef Svb
  1183. }