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.

944 lines
22 KiB

  1. /*++
  2. Copyright (c) 1992-1997 Microsoft Corporation
  3. Module Name:
  4. regions.c
  5. Abstract:
  6. Contains routines for manipulating MIB region structures.
  7. Environment:
  8. User Mode - Win32
  9. Revision History:
  10. 10-Feb-1997 DonRyan
  11. Rewrote to implement SNMPv2 support.
  12. --*/
  13. ///////////////////////////////////////////////////////////////////////////////
  14. // //
  15. // Header files //
  16. // //
  17. ///////////////////////////////////////////////////////////////////////////////
  18. #include "globals.h"
  19. #include "subagnts.h"
  20. #include "regions.h"
  21. ///////////////////////////////////////////////////////////////////////////////
  22. // //
  23. // Private procedures //
  24. // //
  25. ///////////////////////////////////////////////////////////////////////////////
  26. #define WRAP_FOK(hResult) \
  27. do\
  28. {\
  29. fOk = (hResult);\
  30. if (!fOk)\
  31. {\
  32. goto Error;\
  33. }\
  34. }\
  35. while (FALSE)
  36. BOOL
  37. UpdateSupportedRegion(
  38. PMIB_REGION_LIST_ENTRY pExistingRLE,
  39. PMIB_REGION_LIST_ENTRY pRLE
  40. )
  41. /*++
  42. Routine Description:
  43. Updates MIB region properties based on supporting subagent.
  44. Arguments:
  45. pExisingRLE - pointer to existing MIB region to be updated.
  46. pRLE - pointer to subagent MIB region to be analyzed and saved.
  47. Return Values:
  48. Returns true if successful.
  49. --*/
  50. {
  51. INT nDiff;
  52. PMIB_REGION_LIST_ENTRY pSubagentRLE;
  53. // see if source is subagent
  54. if (pRLE->pSubagentRLE == NULL) {
  55. // save pointer
  56. pSubagentRLE = pRLE;
  57. } else {
  58. // save pointer
  59. pSubagentRLE = pRLE->pSubagentRLE;
  60. }
  61. // see if target uninitialized
  62. if (pExistingRLE->pSubagentRLE == NULL) {
  63. // save pointer to subagent region
  64. pExistingRLE->pSubagentRLE = pSubagentRLE;
  65. // save pointer to supporting subagent
  66. pExistingRLE->pSLE = pSubagentRLE->pSLE;
  67. } else {
  68. UINT nSubIds1;
  69. UINT nSubIds2;
  70. // determine length of existing subagent's original prefix
  71. nSubIds1 = pExistingRLE->pSubagentRLE->PrefixOid.idLength;
  72. // determine length of new subagent's prefix
  73. nSubIds2 = pSubagentRLE->PrefixOid.idLength;
  74. // update if more specific
  75. if (nSubIds1 <= nSubIds2) {
  76. // save pointer to subagent region
  77. pExistingRLE->pSubagentRLE = pSubagentRLE;
  78. // save pointer to supporting subagent
  79. pExistingRLE->pSLE = pSubagentRLE->pSLE;
  80. }
  81. }
  82. return TRUE;
  83. }
  84. BOOL
  85. SplitSupportedRegion(
  86. PMIB_REGION_LIST_ENTRY pRLE1,
  87. PMIB_REGION_LIST_ENTRY pRLE2,
  88. PMIB_REGION_LIST_ENTRY * ppLastSplitRLE
  89. )
  90. /*++
  91. Routine Description:
  92. Splits existing MIB region in order to insert new region.
  93. Arguments:
  94. pRLE1 - pointer to first MIB region to be split.
  95. pRLE2 - pointer to second MIB region to be split (not released).
  96. ppLastSplitRLE - pointer to receiver pointer to last split MIB region.
  97. Return Values:
  98. Returns true if successful.
  99. --*/
  100. {
  101. INT nLimitDiff;
  102. INT nPrefixDiff;
  103. PMIB_REGION_LIST_ENTRY pRLE3 = NULL;
  104. PMIB_REGION_LIST_ENTRY pRLE4 = NULL;
  105. PMIB_REGION_LIST_ENTRY pRLE5 = NULL;
  106. BOOL fOk = TRUE;
  107. // allocate regions
  108. if (!AllocRLE(&pRLE3) ||
  109. !AllocRLE(&pRLE4) ||
  110. !AllocRLE(&pRLE5)) {
  111. // release
  112. FreeRLE(pRLE3);
  113. FreeRLE(pRLE4);
  114. FreeRLE(pRLE5);
  115. // initialize OUT pointer to NULL for failure case
  116. *ppLastSplitRLE = NULL;
  117. // failure
  118. return FALSE;
  119. }
  120. // initialize pointer
  121. *ppLastSplitRLE = pRLE5;
  122. // calculate difference betweeen mib region limits
  123. nLimitDiff = SnmpUtilOidCmp(&pRLE1->LimitOid, &pRLE2->LimitOid);
  124. // calculate difference betweeen mib region prefixes
  125. nPrefixDiff = SnmpUtilOidCmp(&pRLE1->PrefixOid, &pRLE2->PrefixOid);
  126. // check for same prefix
  127. if (nPrefixDiff != 0) {
  128. // first prefix less
  129. if (nPrefixDiff < 0) {
  130. // r3.prefix equals min(rl.prefix,r2.prefix)
  131. WRAP_FOK(SnmpUtilOidCpy(&pRLE3->PrefixOid, &pRLE1->PrefixOid));
  132. // r3.limit equals max(rl.prefix,r2.prefix)
  133. WRAP_FOK(SnmpUtilOidCpy(&pRLE3->LimitOid, &pRLE2->PrefixOid));
  134. // r3 is supported by r1 subagent
  135. UpdateSupportedRegion(pRLE3, pRLE1);
  136. } else {
  137. // r3.prefix equals min(rl.prefix,r2.prefix)
  138. WRAP_FOK(SnmpUtilOidCpy(&pRLE3->PrefixOid, &pRLE2->PrefixOid));
  139. // r3.limit equals max(rl.prefix,r2.prefix)
  140. WRAP_FOK(SnmpUtilOidCpy(&pRLE3->LimitOid, &pRLE1->PrefixOid));
  141. // r3 is supported by r2 subagent
  142. UpdateSupportedRegion(pRLE3, pRLE2);
  143. }
  144. // r4.prefix equals r3.limit
  145. WRAP_FOK(SnmpUtilOidCpy(&pRLE4->PrefixOid, &pRLE3->LimitOid));
  146. // r4 is supported by both subagents
  147. UpdateSupportedRegion(pRLE4, pRLE1);
  148. UpdateSupportedRegion(pRLE4, pRLE2);
  149. // first limit less
  150. if (nLimitDiff < 0) {
  151. // r4.limit equals min(rl.limit,r2.limit)
  152. WRAP_FOK(SnmpUtilOidCpy(&pRLE4->LimitOid, &pRLE1->LimitOid));
  153. // r5.prefix equals r4.limit
  154. WRAP_FOK(SnmpUtilOidCpy(&pRLE5->PrefixOid, &pRLE4->LimitOid));
  155. // r5.limit equals max(rl.limit,r2.limit)
  156. WRAP_FOK(SnmpUtilOidCpy(&pRLE5->LimitOid, &pRLE2->LimitOid));
  157. // r5 is supported by r2 subagent
  158. UpdateSupportedRegion(pRLE5, pRLE2);
  159. // insert third mib region into list first
  160. InsertHeadList(&pRLE1->Link, &pRLE5->Link);
  161. } else if (nLimitDiff > 0) {
  162. // r4.limit equals min(rl.limit,r2.limit)
  163. WRAP_FOK(SnmpUtilOidCpy(&pRLE4->LimitOid, &pRLE2->LimitOid));
  164. // r5.prefix equals r4.limit
  165. WRAP_FOK(SnmpUtilOidCpy(&pRLE5->PrefixOid, &pRLE4->LimitOid));
  166. // r5.limit equals max(rl.limit,r2.limit)
  167. WRAP_FOK(SnmpUtilOidCpy(&pRLE5->LimitOid, &pRLE1->LimitOid));
  168. // r5 is supported by r1 subagent
  169. UpdateSupportedRegion(pRLE5, pRLE1);
  170. // insert third mib region into list first
  171. InsertHeadList(&pRLE1->Link, &pRLE5->Link);
  172. } else {
  173. // r4.limit equals min(rl.limit,r2.limit)
  174. WRAP_FOK(SnmpUtilOidCpy(&pRLE4->LimitOid, &pRLE2->LimitOid));
  175. // return r4 as last
  176. *ppLastSplitRLE = pRLE4;
  177. // release
  178. FreeRLE(pRLE5);
  179. }
  180. // insert remaining mib regions into list
  181. InsertHeadList(&pRLE1->Link, &pRLE4->Link);
  182. InsertHeadList(&pRLE1->Link, &pRLE3->Link);
  183. // remove existing
  184. RemoveEntryList(&pRLE1->Link);
  185. // release
  186. FreeRLE(pRLE1);
  187. } else if (nLimitDiff != 0) {
  188. // r3.prefix equals same prefix for r1 and r2
  189. WRAP_FOK(SnmpUtilOidCpy(&pRLE3->PrefixOid, &pRLE1->PrefixOid));
  190. // r3 is supported by both subagents
  191. UpdateSupportedRegion(pRLE3, pRLE1);
  192. UpdateSupportedRegion(pRLE3, pRLE2);
  193. // first limit less
  194. if (nLimitDiff < 0) {
  195. // r3.limit equals min(rl.limit,r2.limit)
  196. WRAP_FOK(SnmpUtilOidCpy(&pRLE3->LimitOid, &pRLE1->LimitOid));
  197. // r4.prefix equals r3.limit
  198. WRAP_FOK(SnmpUtilOidCpy(&pRLE4->PrefixOid, &pRLE3->LimitOid));
  199. // r4.limit equals max(rl.limit,r2.limit)
  200. WRAP_FOK(SnmpUtilOidCpy(&pRLE4->LimitOid, &pRLE2->LimitOid));
  201. // r4 is supported by r2 subagent
  202. UpdateSupportedRegion(pRLE4, pRLE2);
  203. } else {
  204. // r3.limit equals min(rl.limit,r2.limit)
  205. WRAP_FOK(SnmpUtilOidCpy(&pRLE3->LimitOid, &pRLE2->LimitOid));
  206. // r4.prefix equals r3.limit
  207. WRAP_FOK(SnmpUtilOidCpy(&pRLE4->PrefixOid, &pRLE3->LimitOid));
  208. // r4.limit equals max(rl.limit,r2.limit)
  209. WRAP_FOK(SnmpUtilOidCpy(&pRLE4->LimitOid, &pRLE1->LimitOid));
  210. // r4 is supported by r1 subagent
  211. UpdateSupportedRegion(pRLE4, pRLE1);
  212. }
  213. // return r4 as last
  214. *ppLastSplitRLE = pRLE4;
  215. // insert mib regions into list
  216. InsertHeadList(&pRLE1->Link, &pRLE4->Link);
  217. InsertHeadList(&pRLE1->Link, &pRLE3->Link);
  218. // remove existing
  219. RemoveEntryList(&pRLE1->Link);
  220. // release
  221. FreeRLE(pRLE1);
  222. FreeRLE(pRLE5);
  223. } else {
  224. // region supported existing subagent
  225. UpdateSupportedRegion(pRLE1, pRLE2);
  226. // return r1 as last
  227. *ppLastSplitRLE = pRLE1;
  228. // release
  229. FreeRLE(pRLE3);
  230. FreeRLE(pRLE4);
  231. FreeRLE(pRLE5);
  232. }
  233. // success
  234. return TRUE;
  235. Error:
  236. SNMPDBG((
  237. SNMP_LOG_ERROR,
  238. "SNMP: SVC: SnmpUtilOidCpy failed at %d.\n",
  239. __LINE__
  240. ));
  241. // release
  242. FreeRLE(pRLE3);
  243. FreeRLE(pRLE4);
  244. FreeRLE(pRLE5);
  245. *ppLastSplitRLE = NULL;
  246. return FALSE;
  247. }
  248. BOOL
  249. InsertSupportedRegion(
  250. PMIB_REGION_LIST_ENTRY pExistingRLE,
  251. PMIB_REGION_LIST_ENTRY pRLE
  252. )
  253. /*++
  254. Routine Description:
  255. Splits existing MIB region in order to insert new region.
  256. Arguments:
  257. pExisingRLE - pointer to existing MIB region to be split.
  258. pRLE - pointer to MIB region to be inserted.
  259. Return Values:
  260. Returns true if successful.
  261. --*/
  262. {
  263. BOOL fOk;
  264. PLIST_ENTRY pLE;
  265. PMIB_REGION_LIST_ENTRY pLastSplitRLE = NULL;
  266. INT nDiff;
  267. // attempt to split mib regions into pieces parts
  268. fOk = SplitSupportedRegion(pExistingRLE, pRLE, &pLastSplitRLE);
  269. // process remaining entries
  270. while (pLastSplitRLE != NULL) {
  271. // re-use stack pointer
  272. pExistingRLE = pLastSplitRLE;
  273. // re-initialize
  274. pLastSplitRLE = NULL;
  275. // obtain pointer to next entry
  276. pLE = pExistingRLE->Link.Flink;
  277. // make sure entries remaining
  278. if (pLE != &g_SupportedRegions) {
  279. // retrieve pointer to mib region that follows last split one
  280. pRLE = CONTAINING_RECORD(pLE, MIB_REGION_LIST_ENTRY, Link);
  281. // compare mib regions
  282. nDiff = SnmpUtilOidCmp(
  283. &pExistingRLE->LimitOid,
  284. &pRLE->PrefixOid
  285. );
  286. // overlapped?
  287. if (nDiff > 0) {
  288. // remove from list
  289. RemoveEntryList(&pRLE->Link);
  290. // split the two new overlapped mib regions
  291. fOk = SplitSupportedRegion(pExistingRLE, pRLE, &pLastSplitRLE);
  292. // release
  293. FreeRLE(pRLE);
  294. }
  295. }
  296. }
  297. return fOk;
  298. }
  299. /*---debug purpose only----
  300. void PrintSupportedRegion()
  301. {
  302. PLIST_ENTRY pLE;
  303. PMIB_REGION_LIST_ENTRY pRLE;
  304. // obtain pointer to list head
  305. pLE = g_SupportedRegions.Flink;
  306. // process all entries in list
  307. while (pLE != &g_SupportedRegions) {
  308. // retrieve pointer to mib region structure
  309. pRLE = CONTAINING_RECORD(pLE, MIB_REGION_LIST_ENTRY, Link);
  310. SNMPDBG((SNMP_LOG_VERBOSE,"\t[%s\n", SnmpUtilOidToA(&(pRLE->PrefixOid))));
  311. SNMPDBG((SNMP_LOG_VERBOSE,"\t\t%s]\n", SnmpUtilOidToA(&(pRLE->LimitOid))));
  312. // next entry
  313. pLE = pLE->Flink;
  314. }
  315. SNMPDBG((SNMP_LOG_VERBOSE,"----\n"));
  316. }
  317. */
  318. BOOL
  319. AddSupportedRegion(
  320. PMIB_REGION_LIST_ENTRY pRLE
  321. )
  322. /*++
  323. Routine Description:
  324. Add subagent's MIB region into master agent's list.
  325. Arguments:
  326. pRLE - pointer to MIB region to add to supported list.
  327. Return Values:
  328. Returns true if successful.
  329. --*/
  330. {
  331. PLIST_ENTRY pLE;
  332. PMIB_REGION_LIST_ENTRY pRLE2;
  333. PMIB_REGION_LIST_ENTRY pExistingRLE;
  334. BOOL fFoundOk = FALSE;
  335. BOOL fOk = FALSE;
  336. INT nDiff;
  337. // PrintSupportedRegion();
  338. // attempt to locate prefix in existing mib regions
  339. if (FindFirstOverlappingRegion(&pExistingRLE, pRLE)) {
  340. // split existing region into bits
  341. fOk = InsertSupportedRegion(pExistingRLE, pRLE);
  342. } else {
  343. // obtain pointer to list head
  344. pLE = g_SupportedRegions.Flink;
  345. // process all entries in list
  346. while (pLE != &g_SupportedRegions) {
  347. // retrieve pointer to mib region
  348. pExistingRLE = CONTAINING_RECORD(pLE, MIB_REGION_LIST_ENTRY, Link);
  349. // compare region prefix
  350. nDiff = SnmpUtilOidCmp(&pRLE->PrefixOid, &pExistingRLE->PrefixOid);
  351. // found match?
  352. if (nDiff < 0) {
  353. // success
  354. fFoundOk = TRUE;
  355. break; // bail...
  356. }
  357. // next entry
  358. pLE = pLE->Flink;
  359. }
  360. // validate pointer
  361. if (AllocRLE(&pRLE2)) {
  362. // transfer prefix oid from subagent region
  363. if (! SnmpUtilOidCpy(&pRLE2->PrefixOid, &pRLE->PrefixOid))
  364. {
  365. SNMPDBG((
  366. SNMP_LOG_ERROR,
  367. "SNMP: SVC: SnmpUtilOidCpy failed at %d.\n",
  368. __LINE__
  369. ));
  370. FreeRLE(pRLE2);
  371. goto Exit;
  372. }
  373. // transfer limit oid from subagent region
  374. if (! SnmpUtilOidCpy(&pRLE2->LimitOid, &pRLE->LimitOid))
  375. {
  376. SNMPDBG((
  377. SNMP_LOG_ERROR,
  378. "SNMP: SVC: SnmpUtilOidCpy failed at %d.\n",
  379. __LINE__
  380. ));
  381. FreeRLE(pRLE2);
  382. goto Exit;
  383. }
  384. // save region pointer
  385. pRLE2->pSubagentRLE = pRLE;
  386. // save subagent pointer
  387. pRLE2->pSLE = pRLE->pSLE;
  388. // validate
  389. if (fFoundOk) {
  390. // add new mib range into supported list
  391. InsertTailList(&pExistingRLE->Link, &pRLE2->Link);
  392. } else {
  393. // add new mib range into global supported list
  394. InsertTailList(&g_SupportedRegions, &pRLE2->Link);
  395. }
  396. // success
  397. fOk = TRUE;
  398. }
  399. }
  400. Exit:
  401. return fOk;
  402. }
  403. ///////////////////////////////////////////////////////////////////////////////
  404. // //
  405. // Public procedures //
  406. // //
  407. ///////////////////////////////////////////////////////////////////////////////
  408. BOOL
  409. AllocRLE(
  410. PMIB_REGION_LIST_ENTRY * ppRLE
  411. )
  412. /*++
  413. Routine Description:
  414. Allocates MIB region structure and initializes.
  415. Arguments:
  416. ppRLE - pointer to receive pointer to list entry.
  417. Return Values:
  418. Returns true if successful.
  419. --*/
  420. {
  421. BOOL fOk = FALSE;
  422. PMIB_REGION_LIST_ENTRY pRLE;
  423. // attempt to allocate structure
  424. pRLE = AgentMemAlloc(sizeof(MIB_REGION_LIST_ENTRY));
  425. // validate pointer
  426. if (pRLE != NULL) {
  427. // initialize links
  428. InitializeListHead(&pRLE->Link);
  429. // success
  430. fOk = TRUE;
  431. } else {
  432. SNMPDBG((
  433. SNMP_LOG_ERROR,
  434. "SNMP: SVC: could not allocate region entry.\n"
  435. ));
  436. }
  437. // transfer
  438. *ppRLE = pRLE;
  439. return fOk;
  440. }
  441. BOOL
  442. FreeRLE(
  443. PMIB_REGION_LIST_ENTRY pRLE
  444. )
  445. /*++
  446. Routine Description:
  447. Releases MIB region structure.
  448. Arguments:
  449. ppRLE - pointer to MIB region to be freed.
  450. Return Values:
  451. Returns true if successful.
  452. --*/
  453. {
  454. // validate pointer
  455. if (pRLE != NULL) {
  456. // release memory for prefix oid
  457. SnmpUtilOidFree(&pRLE->PrefixOid);
  458. // release memory for limit oid
  459. SnmpUtilOidFree(&pRLE->LimitOid);
  460. // release memory
  461. AgentMemFree(pRLE);
  462. }
  463. return TRUE;
  464. }
  465. BOOL
  466. UnloadRegions(
  467. PLIST_ENTRY pListHead
  468. )
  469. /*++
  470. Routine Description:
  471. Destroys list of MIB regions.
  472. Arguments:
  473. pListHead - pointer to list of regions.
  474. Return Values:
  475. Returns true if successful.
  476. --*/
  477. {
  478. PLIST_ENTRY pLE;
  479. PMIB_REGION_LIST_ENTRY pRLE;
  480. // process entries until empty
  481. while (!IsListEmpty(pListHead)) {
  482. // extract next entry from head
  483. pLE = RemoveHeadList(pListHead);
  484. // retrieve pointer to mib region structure
  485. pRLE = CONTAINING_RECORD(pLE, MIB_REGION_LIST_ENTRY, Link);
  486. // release
  487. FreeRLE(pRLE);
  488. }
  489. return TRUE;
  490. }
  491. BOOL
  492. FindFirstOverlappingRegion(
  493. PMIB_REGION_LIST_ENTRY * ppRLE,
  494. PMIB_REGION_LIST_ENTRY pNewRLE
  495. )
  496. /*++
  497. Routine Description:
  498. Detects if any existent region overlapps with the new one to be added.
  499. Arguments:
  500. ppRLE - pointer to receive pointer to list entry.
  501. pNewRLE - pointer to new region to be tested
  502. Return Values:
  503. Returns true if match found.
  504. --*/
  505. {
  506. PLIST_ENTRY pLE;
  507. PMIB_REGION_LIST_ENTRY pRLE;
  508. // initialize
  509. *ppRLE = NULL;
  510. // obtain pointer to list head
  511. pLE = g_SupportedRegions.Flink;
  512. // process all entries in list
  513. while (pLE != &g_SupportedRegions) {
  514. // retrieve pointer to mib region structure
  515. pRLE = CONTAINING_RECORD(pLE, MIB_REGION_LIST_ENTRY, Link);
  516. if (SnmpUtilOidCmp(&pNewRLE->PrefixOid, &pRLE->LimitOid) < 0 &&
  517. SnmpUtilOidCmp(&pNewRLE->LimitOid, &pRLE->PrefixOid) > 0)
  518. {
  519. *ppRLE = pRLE;
  520. return TRUE;
  521. }
  522. // next entry
  523. pLE = pLE->Flink;
  524. }
  525. // failure
  526. return FALSE;
  527. }
  528. BOOL
  529. FindSupportedRegion(
  530. PMIB_REGION_LIST_ENTRY * ppRLE,
  531. AsnObjectIdentifier * pPrefixOid,
  532. BOOL fAnyOk
  533. )
  534. /*++
  535. Routine Description:
  536. Locates MIB region in list.
  537. Arguments:
  538. ppRLE - pointer to receive pointer to list entry.
  539. pPrefixOid - pointer to OID to locate within MIB region.
  540. fAnyOk - true if exact match not necessary.
  541. Return Values:
  542. Returns true if match found.
  543. --*/
  544. {
  545. PLIST_ENTRY pLE;
  546. PMIB_REGION_LIST_ENTRY pRLE;
  547. INT nDiff;
  548. // initialize
  549. *ppRLE = NULL;
  550. // obtain pointer to list head
  551. pLE = g_SupportedRegions.Flink;
  552. // process all entries in list
  553. while (pLE != &g_SupportedRegions) {
  554. // retrieve pointer to mib region structure
  555. pRLE = CONTAINING_RECORD(pLE, MIB_REGION_LIST_ENTRY, Link);
  556. // region prefix should be also the prefix for the given OID
  557. nDiff = SnmpUtilOidNCmp(pPrefixOid, &pRLE->PrefixOid, pRLE->PrefixOid.idLength);
  558. // found match?
  559. if ((nDiff < 0 && fAnyOk) ||
  560. (nDiff == 0 && SnmpUtilOidCmp(pPrefixOid, &pRLE->LimitOid) < 0))
  561. {
  562. *ppRLE = pRLE;
  563. return TRUE;
  564. }
  565. // next entry
  566. pLE = pLE->Flink;
  567. }
  568. // failure
  569. return FALSE;
  570. }
  571. BOOL
  572. LoadSupportedRegions(
  573. )
  574. /*++
  575. Routine Description:
  576. Creates global list of supported MIB regions from subagent MIB regions.
  577. Arguments:
  578. None.
  579. Return Values:
  580. Returns true if successful.
  581. --*/
  582. {
  583. PLIST_ENTRY pLE1;
  584. PLIST_ENTRY pLE2;
  585. PSUBAGENT_LIST_ENTRY pSLE;
  586. PMIB_REGION_LIST_ENTRY pRLE;
  587. // get subagent list head
  588. pLE1 = g_Subagents.Flink;
  589. // process all entries in list
  590. while (pLE1 != &g_Subagents) {
  591. // retrieve pointer to subagent structure
  592. pSLE = CONTAINING_RECORD(pLE1, SUBAGENT_LIST_ENTRY, Link);
  593. SNMPDBG((
  594. SNMP_LOG_VERBOSE,
  595. "SNMP: SVC: Scan views supported by %s.\n",
  596. pSLE->pPathname
  597. ));
  598. // get supported regions list head
  599. pLE2 = pSLE->SupportedRegions.Flink;
  600. // process all entries in list
  601. while (pLE2 != &pSLE->SupportedRegions) {
  602. // retrieve pointer to mib region structure
  603. pRLE = CONTAINING_RECORD(pLE2, MIB_REGION_LIST_ENTRY, Link);
  604. SNMPDBG((
  605. SNMP_LOG_VERBOSE,
  606. "SNMP: SVC: view %s\n",
  607. SnmpUtilOidToA(&pRLE->PrefixOid)
  608. ));
  609. // attempt to add mib region
  610. if (!AddSupportedRegion(pRLE)) {
  611. // failure
  612. return FALSE;
  613. }
  614. // next mib region
  615. pLE2 = pLE2->Flink;
  616. }
  617. // next subagent
  618. pLE1 = pLE1->Flink;
  619. }
  620. // success
  621. return TRUE;
  622. }
  623. BOOL
  624. UnloadSupportedRegions(
  625. )
  626. /*++
  627. Routine Description:
  628. Destroys list of MIB regions.
  629. Arguments:
  630. None.
  631. Return Values:
  632. Returns true if successful.
  633. --*/
  634. {
  635. // unload global supported regions
  636. return UnloadRegions(&g_SupportedRegions);
  637. }