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.

1893 lines
43 KiB

  1. /*++
  2. Copyright (c) 1996 Microsoft Corporation
  3. Module Name:
  4. mibfuncs.c
  5. Abstract:
  6. Sample subagent instrumentation callbacks.
  7. --*/
  8. #include "precomp.h"
  9. #pragma hdrstop
  10. DWORD
  11. ConnectToRouter();
  12. DWORD
  13. UpdateGlobalInfo(
  14. IN AsnAny * objectArray
  15. );
  16. DWORD
  17. GetGlobalConfigInfo(
  18. OUT PIPBOOTP_MIB_GET_OUTPUT_DATA * ppimgod,
  19. OUT PDWORD pdwSize
  20. );
  21. DWORD
  22. UpdateBOOTPServerTable(
  23. IN sav_globalBOOTPServerEntry * psgbse
  24. );
  25. DWORD
  26. AddBOOTPServerEntry(
  27. IN DWORD dwServerAddr,
  28. IN PIPBOOTP_MIB_GET_OUTPUT_DATA pimgodOutData
  29. );
  30. DWORD
  31. DeleteBOOTPServerEntry(
  32. IN DWORD dwIndex,
  33. IN PIPBOOTP_MIB_GET_OUTPUT_DATA pimgodOutData
  34. );
  35. DWORD
  36. GetInterfaceInfo(
  37. IN UINT actionId,
  38. IN PIPBOOTP_MIB_GET_INPUT_DATA pimgidInData,
  39. OUT PIPBOOTP_MIB_GET_OUTPUT_DATA* ppimgod,
  40. OUT PDWORD pdwOutSize
  41. );
  42. DWORD
  43. ValidateInterfaceConfig(
  44. IN AsnAny * objectArray
  45. );
  46. DWORD
  47. SetInterfaceConfig(
  48. IN AsnAny * objectArray
  49. );
  50. ///////////////////////////////////////////////////////////////////////////////
  51. // //
  52. // global group (1.3.6.1.4.1.311.1.12.1) //
  53. // //
  54. ///////////////////////////////////////////////////////////////////////////////
  55. UINT
  56. get_global(
  57. UINT actionId,
  58. AsnAny * objectArray,
  59. UINT * errorIndex
  60. )
  61. {
  62. DWORD dwRes = (DWORD) -1,
  63. dwConfigSize = 0;
  64. buf_global* pbgBuffer = NULL;
  65. PIPBOOTP_GLOBAL_CONFIG pigcGlbConfig = NULL;
  66. PIPBOOTP_MIB_GET_OUTPUT_DATA pimgodConfigData = NULL;
  67. IPBOOTP_MIB_GET_INPUT_DATA imgidInData;
  68. TraceEnter( "get_global" );
  69. switch ( actionId )
  70. {
  71. case MIB_ACTION_GET:
  72. case MIB_ACTION_GETFIRST:
  73. //
  74. // Retrieve global config.
  75. //
  76. imgidInData.IMGID_TypeID = IPBOOTP_GLOBAL_CONFIG_ID;
  77. BOOTP_MIB_GET(
  78. &imgidInData,
  79. sizeof( IPBOOTP_MIB_GET_INPUT_DATA ),
  80. &pimgodConfigData,
  81. &dwConfigSize,
  82. dwRes
  83. );
  84. break;
  85. case MIB_ACTION_GETNEXT:
  86. default:
  87. TRACE1( "Wrong Action", actionId );
  88. return MIB_S_INVALID_PARAMETER;
  89. }
  90. //
  91. // if error print error message and free allocations
  92. //
  93. if ( dwRes != NO_ERROR )
  94. {
  95. TraceError( dwRes );
  96. if ( pimgodConfigData ) { MprAdminMIBBufferFree ( pimgodConfigData ); }
  97. return dwRes;
  98. }
  99. //
  100. // Set the return data.
  101. //
  102. pbgBuffer = (buf_global*) objectArray;
  103. //
  104. // Global config Data
  105. //
  106. pigcGlbConfig = (PIPBOOTP_GLOBAL_CONFIG) pimgodConfigData-> IMGOD_Buffer;
  107. SetAsnInteger(
  108. &( pbgBuffer-> globalMaxRecQueueSize ),
  109. pigcGlbConfig-> GC_MaxRecvQueueSize
  110. );
  111. SetAsnInteger(
  112. &( pbgBuffer-> globalServerCount ),
  113. pigcGlbConfig-> GC_ServerCount
  114. );
  115. //
  116. // +1 added to adjust value to enumeration values in asn.
  117. // Enumeration in asn cannot have a value of 0. Causes a warning
  118. // to be generated by the asn compiler.
  119. //
  120. SetAsnInteger(
  121. &(pbgBuffer-> globalLoggingLevel),
  122. pigcGlbConfig-> GC_LoggingLevel + 1
  123. );
  124. if ( pimgodConfigData ) { MprAdminMIBBufferFree ( pimgodConfigData ); }
  125. TraceLeave( "get_global" );
  126. return MIB_S_SUCCESS;
  127. }
  128. UINT
  129. set_global(
  130. UINT actionId,
  131. AsnAny * objectArray,
  132. UINT * errorIndex
  133. )
  134. {
  135. DWORD dwRes = MIB_S_SUCCESS,
  136. dwLogLevel = 0;
  137. sav_global* psgBuffer = NULL;
  138. TraceEnter( "set_global" );
  139. dwRes = MIB_S_SUCCESS;
  140. switch ( actionId )
  141. {
  142. case MIB_ACTION_VALIDATE :
  143. psgBuffer = (sav_global *) objectArray;
  144. //
  145. // verify log level setting
  146. //
  147. dwLogLevel = GetAsnInteger( &( psgBuffer-> globalLoggingLevel ), 0 );
  148. if ( dwLogLevel < d_globalLoggingLevel_none ||
  149. dwLogLevel > d_globalLoggingLevel_information )
  150. {
  151. dwRes = MIB_S_INVALID_PARAMETER;
  152. TRACE1( "Invalid logging level value : %d", dwLogLevel );
  153. }
  154. break;
  155. case MIB_ACTION_SET :
  156. dwRes = UpdateGlobalInfo( objectArray );
  157. break;
  158. case MIB_ACTION_CLEANUP :
  159. dwRes = MIB_S_SUCCESS;
  160. break;
  161. default :
  162. dwRes = MIB_S_INVALID_PARAMETER;
  163. TRACE1( "Invalid action specified : %d", actionId );
  164. break;
  165. }
  166. TraceEnter( "set_global" );
  167. return dwRes;
  168. }
  169. ///////////////////////////////////////////////////////////////////////////////
  170. // //
  171. // globalBOOTPServerEntry table (1.3.6.1.4.1.311.1.12.1.4.1) //
  172. // //
  173. ///////////////////////////////////////////////////////////////////////////////
  174. UINT
  175. get_globalBOOTPServerEntry(
  176. UINT actionId,
  177. AsnAny * objectArray,
  178. UINT * errorIndex
  179. )
  180. {
  181. DWORD dwRes = (DWORD) -1,
  182. dwCurrentAddr = INADDR_NONE,
  183. dwIndex = 0,
  184. dwGetSize = 0,
  185. dwSetSize = 0;
  186. PDWORD pdwAddrTable= NULL;
  187. buf_globalBOOTPServerEntry * pbgbse = NULL;
  188. PIPBOOTP_GLOBAL_CONFIG pigc = NULL;
  189. PIPBOOTP_MIB_SET_INPUT_DATA pimsidInData= NULL;
  190. PIPBOOTP_MIB_GET_OUTPUT_DATA pimgodOutData = NULL;
  191. IPBOOTP_MIB_GET_INPUT_DATA imgidInData;
  192. TraceEnter( "get_globalBOOTPServerEntry" );
  193. pbgbse = (buf_globalBOOTPServerEntry *) objectArray;
  194. //
  195. // retrive the BOOTP server table
  196. //
  197. imgidInData.IMGID_TypeID = IPBOOTP_GLOBAL_CONFIG_ID;
  198. BOOTP_MIB_GET(
  199. &imgidInData,
  200. sizeof( IPBOOTP_MIB_GET_INPUT_DATA ),
  201. &pimgodOutData,
  202. &dwGetSize,
  203. dwRes
  204. );
  205. if ( dwRes != NO_ERROR )
  206. {
  207. TraceError( dwRes );
  208. return dwRes;
  209. }
  210. pigc = (PIPBOOTP_GLOBAL_CONFIG) pimgodOutData-> IMGOD_Buffer;
  211. if ( !pigc-> GC_ServerCount )
  212. {
  213. TRACE0( "No BOOTP Server Entries" );
  214. return MIB_S_NO_MORE_ENTRIES;
  215. }
  216. pdwAddrTable = IPBOOTP_GLOBAL_SERVER_TABLE( pigc );
  217. //
  218. // Locate current entry in global server table
  219. //
  220. dwCurrentAddr = GetAsnIPAddress( &( pbgbse-> globalBOOTPServerAddr ), 0 );
  221. FIND_SERVER_ENTRY(
  222. dwCurrentAddr,
  223. pigc-> GC_ServerCount,
  224. pdwAddrTable,
  225. dwIndex
  226. );
  227. //
  228. // get requested entry
  229. //
  230. dwRes = MIB_S_SUCCESS;
  231. switch ( actionId )
  232. {
  233. case MIB_ACTION_GET :
  234. //
  235. // This is an idempotent case, since retieving a server address
  236. // requires the server address as index.
  237. // It is only useful to verify the presence of a particular server.
  238. //
  239. if ( dwIndex >= pigc-> GC_ServerCount )
  240. {
  241. dwRes = MIB_S_ENTRY_NOT_FOUND;
  242. TRACE0( "BOOTP Server Entry not found" );
  243. }
  244. break;
  245. case MIB_ACTION_GETFIRST :
  246. //
  247. // get entry at index 0 (if available )
  248. //
  249. dwIndex = 0;
  250. if ( !pigc-> GC_ServerCount )
  251. {
  252. dwRes = MIB_S_ENTRY_NOT_FOUND;
  253. TRACE0( "BOOTP Server Entry not found" );
  254. }
  255. break;
  256. case MIB_ACTION_GETNEXT :
  257. //
  258. // check if entry was found.
  259. // dwCurrentAddr == 0 is taken to mean that the next server entry
  260. // starting from the beginning of the table is requested.
  261. //
  262. if ( ( dwIndex >= pigc-> GC_ServerCount ) &&
  263. ( dwCurrentAddr != 0 ) )
  264. {
  265. dwRes = MIB_S_ENTRY_NOT_FOUND;
  266. TRACE0( "BOOTP Server Entry not found" );
  267. break;
  268. }
  269. //
  270. // try and get next
  271. //
  272. dwIndex = ( dwCurrentAddr ) ? dwIndex++ : 0;
  273. TRACE3( "GET_NEXT : Current addr : %x, server index : %d, Server count : %d", dwCurrentAddr, dwIndex, pigc-> GC_ServerCount );
  274. if ( dwIndex >= pigc-> GC_ServerCount )
  275. {
  276. dwRes = MIB_S_NO_MORE_ENTRIES;
  277. TRACE0( "No more BOOTP Server Entries" );
  278. break;
  279. }
  280. break;
  281. default :
  282. TRACE0( " get_globalServerEntry - Wrong Action " );
  283. dwRes = MIB_S_INVALID_PARAMETER;
  284. break;
  285. }
  286. //
  287. // set index for next retrieval
  288. //
  289. if ( dwRes == MIB_S_SUCCESS )
  290. {
  291. ForceSetAsnIPAddress(
  292. &( pbgbse-> globalBOOTPServerAddr ),
  293. &( pbgbse-> dwServerAddr ),
  294. pdwAddrTable[ dwIndex ]
  295. );
  296. }
  297. if ( pimgodOutData ) { MprAdminMIBBufferFree( pimgodOutData ); }
  298. TraceLeave( "get_globalBOOTPServerCount" );
  299. return dwRes;
  300. }
  301. UINT
  302. set_globalBOOTPServerEntry(
  303. UINT actionId,
  304. AsnAny * objectArray,
  305. UINT * errorIndex
  306. )
  307. {
  308. DWORD dwRes = (DWORD) -1,
  309. dwAddr = INADDR_NONE,
  310. dwOp = 0;
  311. sav_globalBOOTPServerEntry * psgbse = NULL;
  312. TraceEnter( "set_globalBOOTPServerEntry" );
  313. psgbse = (sav_globalBOOTPServerEntry *) objectArray;
  314. switch ( actionId )
  315. {
  316. case MIB_ACTION_VALIDATE :
  317. //
  318. // Verify if the specified IP address is valid.
  319. //
  320. dwAddr = GetAsnIPAddress(
  321. &( psgbse-> globalBOOTPServerAddr ),
  322. INADDR_NONE
  323. );
  324. if ( !dwAddr || dwAddr == INADDR_NONE )
  325. {
  326. dwRes = MIB_S_INVALID_PARAMETER;
  327. TRACE0( " Invalid Server address specified" );
  328. }
  329. //
  330. // Verify operation tag
  331. //
  332. dwRes = GetAsnInteger( &( psgbse-> globalBOOTPServerTag ), 0 );
  333. if ( dwRes != d_globalBOOTPServerTag_create &&
  334. dwRes != d_globalBOOTPServerTag_delete )
  335. {
  336. dwRes = MIB_S_INVALID_PARAMETER;
  337. TRACE0( " Invalid Operation specified" );
  338. break;
  339. }
  340. dwRes = MIB_S_SUCCESS;
  341. break;
  342. case MIB_ACTION_SET :
  343. dwRes = UpdateBOOTPServerTable( psgbse );
  344. break;
  345. case MIB_ACTION_CLEANUP :
  346. dwRes = MIB_S_SUCCESS;
  347. break;
  348. default :
  349. dwRes = MIB_S_INVALID_PARAMETER;
  350. TRACE0 ( " set_globalBOOTPServerEntry - Wrong Action " );
  351. break;
  352. }
  353. TraceLeave( " set_globalBOOTPServerEntry " );
  354. return dwRes;
  355. }
  356. ///////////////////////////////////////////////////////////////////////////////
  357. // //
  358. // interface group (1.3.6.1.4.1.311.1.12.2) //
  359. // //
  360. ///////////////////////////////////////////////////////////////////////////////
  361. ///////////////////////////////////////////////////////////////////////////////
  362. // //
  363. // ifStatsEntry table (1.3.6.1.4.1.311.1.12.2.1.1) //
  364. // //
  365. ///////////////////////////////////////////////////////////////////////////////
  366. UINT
  367. get_ifStatsEntry(
  368. UINT actionId,
  369. AsnAny * objectArray,
  370. UINT * errorIndex
  371. )
  372. {
  373. DWORD dwRes = (DWORD) -1,
  374. dwGetSize = 0,
  375. dwSetSize = 0;
  376. buf_ifStatsEntry * pbifse = NULL;
  377. PIPBOOTP_IF_STATS piis = NULL;
  378. PIPBOOTP_MIB_GET_OUTPUT_DATA pimgodOutData = NULL;
  379. IPBOOTP_MIB_GET_INPUT_DATA imgidInData;
  380. TraceEnter( "get_ifStatsEntry" );
  381. //
  382. // Retrieve Specified interface info.
  383. //
  384. pbifse = (buf_ifStatsEntry*) objectArray;
  385. imgidInData.IMGID_TypeID = IPBOOTP_IF_STATS_ID;
  386. imgidInData.IMGID_IfIndex = GetAsnInteger(
  387. &( pbifse-> ifSEIndex ),
  388. 0
  389. );
  390. //
  391. // When walking the mib using a sequence of getnext operations
  392. // the first getnext operation is translated into a getfirst
  393. // operation.
  394. //
  395. if ( actionId == MIB_ACTION_GETNEXT &&
  396. !imgidInData.IMGID_IfIndex )
  397. {
  398. actionId = MIB_ACTION_GETFIRST;
  399. }
  400. dwRes = GetInterfaceInfo(
  401. actionId,
  402. &imgidInData,
  403. &pimgodOutData,
  404. &dwGetSize
  405. );
  406. if ( dwRes != NO_ERROR )
  407. {
  408. TraceError( dwRes );
  409. return dwRes;
  410. }
  411. //
  412. // Set interface stats in return buffer
  413. //
  414. piis = (PIPBOOTP_IF_STATS) (pimgodOutData-> IMGOD_Buffer);
  415. SetAsnInteger( &( pbifse-> ifSEState ), piis-> IS_State );
  416. SetAsnCounter( &( pbifse-> ifSESendFailures ), piis-> IS_SendFailures );
  417. SetAsnCounter(
  418. &( pbifse-> ifSEReceiveFailures ),
  419. piis-> IS_ReceiveFailures
  420. );
  421. SetAsnCounter(
  422. &( pbifse-> ifSEArpUpdateFailures ),
  423. piis-> IS_ArpUpdateFailures
  424. );
  425. SetAsnCounter(
  426. &( pbifse-> ifSERequestReceiveds ),
  427. piis-> IS_RequestsReceived
  428. );
  429. SetAsnCounter(
  430. &( pbifse-> ifSERequestDiscards ),
  431. piis-> IS_RequestsDiscarded
  432. );
  433. SetAsnCounter(
  434. &( pbifse-> ifSEReplyReceiveds ),
  435. piis-> IS_RepliesReceived
  436. );
  437. SetAsnCounter(
  438. &( pbifse-> ifSEReplyDiscards ),
  439. piis-> IS_RepliesDiscarded
  440. );
  441. //
  442. // set index for following getnext operation, (if any)
  443. //
  444. ForceSetAsnInteger(
  445. &( pbifse-> ifSEIndex ),
  446. pimgodOutData-> IMGOD_IfIndex
  447. );
  448. if ( pimgodOutData ) { MprAdminMIBBufferFree( pimgodOutData ); }
  449. TraceLeave( "get_ifStatsEntry" );
  450. return MIB_S_SUCCESS ;
  451. }
  452. ///////////////////////////////////////////////////////////////////////////////
  453. // //
  454. // ifConfigEntry table (1.3.6.1.4.1.311.1.12.2.2.1) //
  455. // //
  456. ///////////////////////////////////////////////////////////////////////////////
  457. UINT
  458. get_ifConfigEntry(
  459. UINT actionId,
  460. AsnAny * objectArray,
  461. UINT * errorIndex
  462. )
  463. {
  464. DWORD dwRes = (DWORD) -1,
  465. dwGetSize = 0;
  466. buf_ifConfigEntry* pbifce = NULL;
  467. PIPBOOTP_IF_CONFIG piic = NULL;
  468. PIPBOOTP_MIB_GET_OUTPUT_DATA pimgodOutData = NULL;
  469. IPBOOTP_MIB_GET_INPUT_DATA imgidInData;
  470. TraceEnter( " get_ifConfigEntry " );
  471. //
  472. // retrieve interface config.
  473. //
  474. pbifce = (buf_ifConfigEntry*) objectArray;
  475. imgidInData.IMGID_TypeID = IPBOOTP_IF_CONFIG_ID;
  476. imgidInData.IMGID_IfIndex = GetAsnInteger( &( pbifce-> ifCEIndex ), 0 );
  477. //
  478. // When walking the mib using a sequence of getnext operations
  479. // the first getnext operation is translated into a getfirst
  480. // operation.
  481. //
  482. if ( actionId == MIB_ACTION_GETNEXT &&
  483. !imgidInData.IMGID_IfIndex )
  484. {
  485. actionId = MIB_ACTION_GETFIRST;
  486. }
  487. dwRes = GetInterfaceInfo(
  488. actionId,
  489. &imgidInData,
  490. &pimgodOutData,
  491. &dwGetSize
  492. );
  493. if ( dwRes != NO_ERROR || pimgodOutData == NULL )
  494. {
  495. TraceError( dwRes );
  496. return dwRes;
  497. }
  498. //
  499. // set requiste fields
  500. //
  501. piic = (PIPBOOTP_IF_CONFIG) (pimgodOutData-> IMGOD_Buffer);
  502. SetAsnInteger( &( pbifce-> ifCEState ), piic-> IC_State );
  503. SetAsnInteger( &( pbifce-> ifCERelayMode ), piic-> IC_RelayMode + 1 );
  504. SetAsnInteger( &( pbifce-> ifCEMaxHopCount ), piic-> IC_MaxHopCount );
  505. SetAsnInteger(
  506. &( pbifce-> ifCEMinSecondsSinceBoot ),
  507. piic-> IC_MinSecondsSinceBoot
  508. );
  509. //
  510. // set index for following getnext operation, (if any)
  511. //
  512. ForceSetAsnInteger(
  513. &( pbifce-> ifCEIndex ),
  514. pimgodOutData-> IMGOD_IfIndex
  515. );
  516. if ( pimgodOutData ) { MprAdminMIBBufferFree( pimgodOutData ); }
  517. TraceLeave( " get_ifConfigEntry " );
  518. return MIB_S_SUCCESS;
  519. }
  520. UINT
  521. set_ifConfigEntry(
  522. UINT actionId,
  523. AsnAny * objectArray,
  524. UINT * errorIndex
  525. )
  526. {
  527. DWORD dwRes = (DWORD) -1;
  528. TraceEnter( " set_ifConfigEntry " );
  529. switch ( actionId )
  530. {
  531. case MIB_ACTION_VALIDATE :
  532. dwRes = ValidateInterfaceConfig( objectArray );
  533. break;
  534. case MIB_ACTION_SET :
  535. dwRes = SetInterfaceConfig( objectArray );
  536. break;
  537. case MIB_ACTION_CLEANUP :
  538. dwRes = MIB_S_SUCCESS;
  539. break;
  540. default :
  541. TRACE0( " set_ifConfigEntry - wrong action " );
  542. dwRes = MIB_S_INVALID_PARAMETER;
  543. break;
  544. }
  545. TraceLeave( "set_ifConfigEntry" );
  546. return dwRes ;
  547. }
  548. ///////////////////////////////////////////////////////////////////////////////
  549. // //
  550. // ifBindingEntry table (1.3.6.1.4.1.311.1.12.2.3.1) //
  551. // //
  552. ///////////////////////////////////////////////////////////////////////////////
  553. UINT
  554. get_ifBindingEntry(
  555. UINT actionId,
  556. AsnAny * objectArray,
  557. UINT * errorIndex
  558. )
  559. {
  560. DWORD dwRes = (DWORD) -1,
  561. dwGetSize = 0;
  562. buf_ifBindingEntry * pbifb = NULL;
  563. PIPBOOTP_IF_BINDING piib = NULL;
  564. PIPBOOTP_MIB_GET_OUTPUT_DATA pimgodOutData = NULL;
  565. IPBOOTP_MIB_GET_INPUT_DATA imgidInData;
  566. TraceEnter( " get_ifBindingEntry " );
  567. //
  568. // retrieve interface binding info.
  569. //
  570. pbifb = (buf_ifBindingEntry*) objectArray;
  571. imgidInData.IMGID_TypeID = IPBOOTP_IF_BINDING_ID;
  572. imgidInData.IMGID_IfIndex = GetAsnInteger(
  573. &( pbifb-> ifBindingIndex ),
  574. 0
  575. );
  576. if ( actionId == MIB_ACTION_GETNEXT &&
  577. !imgidInData.IMGID_IfIndex )
  578. {
  579. actionId = MIB_ACTION_GETFIRST;
  580. }
  581. dwRes = GetInterfaceInfo(
  582. actionId,
  583. &imgidInData,
  584. &pimgodOutData,
  585. &dwGetSize
  586. );
  587. if ( dwRes != NO_ERROR || pimgodOutData == NULL )
  588. {
  589. TraceError( dwRes );
  590. return dwRes;
  591. }
  592. //
  593. // set requiste fields
  594. //
  595. piib = (PIPBOOTP_IF_BINDING) (pimgodOutData-> IMGOD_Buffer);
  596. SetAsnInteger( &( pbifb-> ifBindingState ), piib-> IB_State );
  597. SetAsnInteger( &( pbifb-> ifBindingAddrCount ), piib-> IB_AddrCount );
  598. ForceSetAsnInteger(
  599. &( pbifb-> ifBindingIndex ),
  600. pimgodOutData-> IMGOD_IfIndex
  601. );
  602. if ( pimgodOutData ) { MprAdminMIBBufferFree( pimgodOutData ); }
  603. TraceLeave( " get_ifBindingEntry " );
  604. return MIB_S_SUCCESS ;
  605. }
  606. ///////////////////////////////////////////////////////////////////////////////
  607. // //
  608. // ifAddressEntry table (1.3.6.1.4.1.311.1.12.2.4.1) //
  609. // //
  610. ///////////////////////////////////////////////////////////////////////////////
  611. UINT
  612. get_ifAddressEntry(
  613. UINT actionId,
  614. AsnAny * objectArray,
  615. UINT * errorIndex
  616. )
  617. {
  618. DWORD dwRes = (DWORD) -1,
  619. dwIndex = (DWORD) -1,
  620. dwGetSize = 0;
  621. buf_ifAddressEntry * pbifae = NULL;
  622. PIPBOOTP_IF_BINDING piib = NULL;
  623. PIPBOOTP_IP_ADDRESS pia = NULL;
  624. PIPBOOTP_MIB_GET_OUTPUT_DATA pimgodOutData = NULL;
  625. IPBOOTP_IP_ADDRESS ipa;
  626. IPBOOTP_MIB_GET_INPUT_DATA imgidInData;
  627. TraceEnter( " get_ifAddressEntry " );
  628. //
  629. // retrieve interface binding info.
  630. //
  631. pbifae = (buf_ifAddressEntry*) objectArray;
  632. imgidInData.IMGID_TypeID = IPBOOTP_IF_BINDING_ID;
  633. imgidInData.IMGID_IfIndex = GetAsnInteger(
  634. &( pbifae-> ifAEIfIndex ),
  635. 0
  636. );
  637. if ( actionId == MIB_ACTION_GETNEXT &&
  638. !imgidInData.IMGID_IfIndex )
  639. {
  640. actionId = MIB_ACTION_GETFIRST;
  641. }
  642. dwRes = GetInterfaceInfo(
  643. actionId,
  644. &imgidInData,
  645. &pimgodOutData,
  646. &dwGetSize
  647. );
  648. if ( dwRes != NO_ERROR )
  649. {
  650. TraceError( dwRes );
  651. return dwRes;
  652. }
  653. //
  654. // retrieve IPAddress from IP Address table
  655. //
  656. ipa.IA_Address = GetAsnIPAddress(
  657. &( pbifae-> ifAEAddress),
  658. INADDR_NONE
  659. );
  660. ipa.IA_Netmask = GetAsnIPAddress(
  661. &( pbifae-> ifAEMask),
  662. INADDR_NONE
  663. );
  664. piib = (PIPBOOTP_IF_BINDING) pimgodOutData-> IMGOD_Buffer;
  665. pia = (PIPBOOTP_IP_ADDRESS) IPBOOTP_IF_ADDRESS_TABLE( piib );
  666. FIND_IP_ADDRESS(
  667. ipa,
  668. piib-> IB_AddrCount,
  669. pia,
  670. dwIndex
  671. );
  672. //
  673. // set appr fields
  674. //
  675. dwRes = MIB_S_SUCCESS;
  676. switch ( actionId )
  677. {
  678. case MIB_ACTION_GET :
  679. //
  680. // idempotent case. Only possible use is to verify
  681. // specific peer present.
  682. //
  683. if ( dwIndex >= piib-> IB_AddrCount )
  684. {
  685. dwRes = MIB_S_ENTRY_NOT_FOUND;
  686. TRACE0( "IP address entry not found" );
  687. }
  688. break;
  689. case MIB_ACTION_GETFIRST :
  690. //
  691. // get entry at index 0 if available
  692. //
  693. dwIndex = 0;
  694. if ( !piib-> IB_AddrCount )
  695. {
  696. dwRes = MIB_S_NO_MORE_ENTRIES;
  697. TRACE1(
  698. "No more IP address Entries for interface : %d",
  699. imgidInData.IMGID_IfIndex
  700. );
  701. }
  702. break;
  703. case MIB_ACTION_GETNEXT :
  704. //
  705. // check if entry was found
  706. //
  707. if ( dwIndex >= piib-> IB_AddrCount )
  708. {
  709. dwRes = MIB_S_ENTRY_NOT_FOUND;
  710. TRACE0( "IP address Entry not found " );
  711. break;
  712. }
  713. //
  714. // try and get next
  715. //
  716. dwIndex++;
  717. if ( dwIndex >= piib-> IB_AddrCount )
  718. {
  719. dwRes = MIB_S_NO_MORE_ENTRIES;
  720. TRACE1(
  721. "No more IP address Entries for interface : %d",
  722. imgidInData.IMGID_IfIndex
  723. );
  724. break;
  725. }
  726. dwRes = MIB_S_SUCCESS;
  727. break;
  728. default :
  729. TRACE0( " get_globalPeerFilterEntry - Wrong Action " );
  730. dwRes = MIB_S_INVALID_PARAMETER;
  731. break;
  732. }
  733. //
  734. // set index for next retieval
  735. //
  736. if ( dwRes == MIB_S_SUCCESS )
  737. {
  738. ForceSetAsnInteger(
  739. &( pbifae-> ifAEIfIndex ),
  740. pimgodOutData-> IMGOD_IfIndex
  741. );
  742. ForceSetAsnIPAddress(
  743. &( pbifae-> ifAEAddress ),
  744. &( pbifae-> dwIfAEAddr ),
  745. pia[ dwIndex ].IA_Address
  746. );
  747. ForceSetAsnIPAddress(
  748. &( pbifae-> ifAEMask ),
  749. &( pbifae-> dwIfAEMask ),
  750. pia[ dwIndex ].IA_Netmask
  751. );
  752. }
  753. if ( pimgodOutData ) { MprAdminMIBBufferFree( pimgodOutData ); }
  754. TraceLeave( " get_ifAddressEntry " );
  755. return dwRes;
  756. }
  757. DWORD
  758. UpdateGlobalInfo(
  759. IN AsnAny * objectArray
  760. )
  761. {
  762. DWORD dwRes = (DWORD) -1,
  763. dwGetSize = 0,
  764. dwSetSize = 0;
  765. sav_global* psg = NULL;
  766. PIPBOOTP_GLOBAL_CONFIG pigc = NULL;
  767. PIPBOOTP_MIB_SET_INPUT_DATA pimsidInData= NULL;
  768. PIPBOOTP_MIB_GET_OUTPUT_DATA pimgodOutData = NULL;
  769. do
  770. {
  771. //
  772. // Retrieve the global config Data first
  773. //
  774. dwRes = GetGlobalConfigInfo(
  775. &pimgodOutData,
  776. &dwGetSize
  777. );
  778. if ( dwRes != NO_ERROR )
  779. {
  780. break;
  781. }
  782. pigc = (PIPBOOTP_GLOBAL_CONFIG) pimgodOutData-> IMGOD_Buffer;
  783. psg = (sav_global*) objectArray;
  784. //
  785. // Allocate set info buffer
  786. //
  787. dwSetSize = sizeof( IPBOOTP_MIB_SET_INPUT_DATA ) - 1 +
  788. IPBOOTP_GLOBAL_CONFIG_SIZE( pigc );
  789. pimsidInData =
  790. (PIPBOOTP_MIB_SET_INPUT_DATA) BOOTP_MIB_ALLOC( dwSetSize );
  791. if ( pimsidInData == NULL )
  792. {
  793. dwRes = ERROR_NOT_ENOUGH_MEMORY;
  794. TRACE0( "SetGlobalData - Mem. alloc failed" );
  795. break;
  796. }
  797. pimsidInData-> IMSID_TypeID = IPBOOTP_GLOBAL_CONFIG_ID;
  798. pimsidInData-> IMSID_IfIndex = (DWORD) -1;
  799. pimsidInData-> IMSID_BufferSize = IPBOOTP_GLOBAL_CONFIG_SIZE( pigc );
  800. //
  801. // Set config info fields.
  802. //
  803. //
  804. // if a variable is not specified, the corresp. value in the
  805. // config is left unchanged (by setting it to itself).
  806. //
  807. pigc-> GC_MaxRecvQueueSize = GetAsnInteger(
  808. &( psg-> globalMaxRecQueueSize ),
  809. pigc-> GC_MaxRecvQueueSize
  810. );
  811. //
  812. // -1 is subtracted from the enumerated fields to adjust
  813. // the ASN enumeration values to the actual log level values.
  814. // This is required since the enumeration cannot have
  815. // a zero value as per the ASN compiler.
  816. //
  817. // as a caveat, if the enumerated field is not specified in
  818. // this set operation, to preserve the value of the field
  819. // in the config, we first increment it. This way on the
  820. // -1 operation the value is restored.
  821. //
  822. pigc-> GC_LoggingLevel++;
  823. pigc-> GC_LoggingLevel = GetAsnInteger(
  824. &( psg-> globalLoggingLevel ),
  825. pigc-> GC_LoggingLevel
  826. ) - 1;
  827. CopyMemory(
  828. (PVOID) pimsidInData-> IMSID_Buffer,
  829. (PVOID*) pigc,
  830. IPBOOTP_GLOBAL_CONFIG_SIZE( pigc )
  831. );
  832. //
  833. // Save the info. in the MIB
  834. //
  835. BOOTP_MIB_SET(
  836. pimsidInData,
  837. dwSetSize,
  838. dwRes
  839. );
  840. if ( dwRes != NO_ERROR )
  841. {
  842. TraceError( dwRes );
  843. break;
  844. }
  845. dwRes = MIB_S_SUCCESS;
  846. } while ( FALSE );
  847. //
  848. // Free allocations
  849. //
  850. if ( pimgodOutData ) { MprAdminMIBBufferFree( pimgodOutData ); }
  851. if ( pimsidInData ) { BOOTP_MIB_FREE( pimsidInData ); }
  852. return dwRes;
  853. }
  854. DWORD
  855. GetGlobalConfigInfo(
  856. OUT PIPBOOTP_MIB_GET_OUTPUT_DATA * ppimgod,
  857. OUT PDWORD pdwSize
  858. )
  859. {
  860. DWORD dwRes = (DWORD) -1;
  861. PIPBOOTP_MIB_GET_OUTPUT_DATA pimgodOutData = NULL;
  862. IPBOOTP_MIB_GET_INPUT_DATA imgidInData;
  863. do
  864. {
  865. //
  866. // retrieve global config
  867. //
  868. *ppimgod = NULL;
  869. imgidInData.IMGID_TypeID = IPBOOTP_GLOBAL_CONFIG_ID;
  870. BOOTP_MIB_GET(
  871. &imgidInData,
  872. sizeof( IPBOOTP_MIB_GET_INPUT_DATA ),
  873. &pimgodOutData,
  874. pdwSize,
  875. dwRes
  876. );
  877. if (!pimgodOutData)
  878. return ERROR_NOT_ENOUGH_MEMORY;
  879. if ( dwRes != NO_ERROR )
  880. {
  881. TraceError( dwRes );
  882. break;
  883. }
  884. *ppimgod = pimgodOutData;
  885. } while ( FALSE );
  886. return dwRes;
  887. }
  888. DWORD
  889. UpdateBOOTPServerTable(
  890. IN sav_globalBOOTPServerEntry * psgbse
  891. )
  892. {
  893. DWORD dwRes = (DWORD) -1,
  894. dwInd = 0,
  895. dwOp = 0,
  896. dwServerAddr= INADDR_NONE,
  897. dwGetSize = 0,
  898. dwSetSize = 0;
  899. PDWORD pdwAddrTable= 0;
  900. PIPBOOTP_GLOBAL_CONFIG pigc = NULL;
  901. PIPBOOTP_MIB_SET_INPUT_DATA pimsid = NULL;
  902. PIPBOOTP_MIB_GET_OUTPUT_DATA pimgodOutData = NULL;
  903. do
  904. {
  905. //
  906. // Get global info
  907. //
  908. dwRes = GetGlobalConfigInfo(
  909. &pimgodOutData,
  910. &dwGetSize
  911. );
  912. if ( dwRes != NO_ERROR )
  913. {
  914. break;
  915. }
  916. //
  917. // Find server entry
  918. //
  919. dwServerAddr = GetAsnIPAddress(
  920. &( psgbse-> globalBOOTPServerAddr ),
  921. 0
  922. );
  923. pigc = (PIPBOOTP_GLOBAL_CONFIG) pimgodOutData-> IMGOD_Buffer;
  924. pdwAddrTable= IPBOOTP_GLOBAL_SERVER_TABLE( pigc );
  925. FIND_SERVER_ENTRY(
  926. dwServerAddr,
  927. pigc-> GC_ServerCount,
  928. pdwAddrTable,
  929. dwInd
  930. );
  931. //
  932. // if operation is server add
  933. //
  934. dwOp = GetAsnInteger( &( psgbse-> globalBOOTPServerTag ), 0 );
  935. switch( dwOp )
  936. {
  937. case d_globalBOOTPServerTag_create :
  938. //
  939. // if server already present, quit
  940. //
  941. if ( pigc-> GC_ServerCount &&
  942. dwInd < pigc-> GC_ServerCount )
  943. {
  944. dwRes = MIB_S_SUCCESS;
  945. break;
  946. }
  947. else
  948. {
  949. dwRes = AddBOOTPServerEntry(
  950. dwServerAddr,
  951. pimgodOutData
  952. );
  953. }
  954. break;
  955. case d_globalBOOTPServerTag_delete :
  956. //
  957. // operation is server delete
  958. //
  959. //
  960. // if server is not present quit.
  961. //
  962. if ( !pigc-> GC_ServerCount ||
  963. dwInd >= pigc-> GC_ServerCount )
  964. {
  965. dwRes = MIB_S_SUCCESS;
  966. break;
  967. }
  968. dwRes = DeleteBOOTPServerEntry(
  969. dwInd,
  970. pimgodOutData
  971. );
  972. break;
  973. default :
  974. dwRes = MIB_S_INVALID_PARAMETER;
  975. TRACE0( "Invalid action specified : logic error " );
  976. break;
  977. }
  978. } while ( FALSE );
  979. if ( pimgodOutData ) { MprAdminMIBBufferFree( pimgodOutData ); }
  980. return dwRes;
  981. }
  982. DWORD
  983. AddBOOTPServerEntry(
  984. IN DWORD dwServerAddr,
  985. IN PIPBOOTP_MIB_GET_OUTPUT_DATA pimgodOutData
  986. )
  987. {
  988. DWORD dwRes = (DWORD) -1,
  989. dwSetSize = 0;
  990. PDWORD pdwAddrTable= NULL;
  991. PIPBOOTP_GLOBAL_CONFIG pigc = NULL;
  992. PIPBOOTP_MIB_SET_INPUT_DATA pimsid = NULL;
  993. do
  994. {
  995. //
  996. // BOOTP Server needs to be added.
  997. //
  998. //
  999. // compute buffer size required
  1000. //
  1001. pigc = (PIPBOOTP_GLOBAL_CONFIG) pimgodOutData-> IMGOD_Buffer;
  1002. dwSetSize = sizeof( IPBOOTP_MIB_SET_INPUT_DATA ) - 1 +
  1003. IPBOOTP_GLOBAL_CONFIG_SIZE( pigc ) + sizeof( DWORD );
  1004. pimsid = (PIPBOOTP_MIB_SET_INPUT_DATA) BOOTP_MIB_ALLOC( dwSetSize );
  1005. if ( !pimsid )
  1006. {
  1007. dwRes = ERROR_NOT_ENOUGH_MEMORY;
  1008. TRACE0( "AddBOOTPServerEntry - out of memory" );
  1009. break;
  1010. }
  1011. //
  1012. // Add server
  1013. //
  1014. pimsid-> IMSID_TypeID = IPBOOTP_GLOBAL_CONFIG_ID;
  1015. pimsid-> IMSID_IfIndex = (DWORD) -1;
  1016. pimsid-> IMSID_BufferSize = IPBOOTP_GLOBAL_CONFIG_SIZE( pigc ) +
  1017. sizeof( DWORD );
  1018. CopyMemory(
  1019. (PVOID) &( pimsid-> IMSID_Buffer ),
  1020. (VOID *) pigc,
  1021. IPBOOTP_GLOBAL_CONFIG_SIZE( pigc )
  1022. );
  1023. pigc = (PIPBOOTP_GLOBAL_CONFIG) pimsid-> IMSID_Buffer;
  1024. pdwAddrTable = IPBOOTP_GLOBAL_SERVER_TABLE( pigc );
  1025. pdwAddrTable[ pigc-> GC_ServerCount ] = dwServerAddr;
  1026. pigc-> GC_ServerCount++;
  1027. //
  1028. // Update MIB
  1029. //
  1030. BOOTP_MIB_SET(
  1031. pimsid,
  1032. dwSetSize,
  1033. dwRes
  1034. );
  1035. } while ( FALSE );
  1036. if ( pimsid ) { BOOTP_MIB_FREE( pimsid ); }
  1037. return dwRes;
  1038. }
  1039. DWORD
  1040. DeleteBOOTPServerEntry(
  1041. IN DWORD dwIndex,
  1042. IN PIPBOOTP_MIB_GET_OUTPUT_DATA pimgodOutData
  1043. )
  1044. {
  1045. DWORD dwRes = (DWORD) -1,
  1046. dwSetSize = 0,
  1047. dwSrc = 0,
  1048. dwDst = 0;
  1049. PDWORD pdwSrcTable = NULL,
  1050. pdwDstTable = NULL;
  1051. PIPBOOTP_GLOBAL_CONFIG pigc = NULL;
  1052. PIPBOOTP_MIB_SET_INPUT_DATA pimsid = NULL;
  1053. do
  1054. {
  1055. //
  1056. // Server needs to be deleted.
  1057. //
  1058. //
  1059. // compute buffer size required
  1060. //
  1061. pigc = (PIPBOOTP_GLOBAL_CONFIG) pimgodOutData-> IMGOD_Buffer;
  1062. dwSetSize = sizeof( IPBOOTP_MIB_SET_INPUT_DATA ) - 1 +
  1063. IPBOOTP_GLOBAL_CONFIG_SIZE( pigc ) - sizeof( DWORD );
  1064. pimsid = (PIPBOOTP_MIB_SET_INPUT_DATA) BOOTP_MIB_ALLOC( dwSetSize );
  1065. if ( !pimsid )
  1066. {
  1067. dwRes = ERROR_NOT_ENOUGH_MEMORY;
  1068. TRACE0( "DeleteBOOTPServerEntry - out of memory" );
  1069. break;
  1070. }
  1071. //
  1072. // Delete server
  1073. //
  1074. //
  1075. // Copy base global config structure
  1076. //
  1077. pimsid-> IMSID_TypeID = IPBOOTP_GLOBAL_CONFIG_ID;
  1078. pimsid-> IMSID_IfIndex = (DWORD) -1;
  1079. pimsid-> IMSID_BufferSize = IPBOOTP_GLOBAL_CONFIG_SIZE( pigc ) -
  1080. sizeof( DWORD );
  1081. CopyMemory(
  1082. (PVOID) &( pimsid-> IMSID_Buffer ),
  1083. (VOID *) pigc,
  1084. sizeof( IPBOOTP_GLOBAL_CONFIG )
  1085. );
  1086. //
  1087. // Copy peer table. Skip entry to be deleted
  1088. //
  1089. pdwSrcTable = IPBOOTP_GLOBAL_SERVER_TABLE( pigc );
  1090. pigc = ( PIPBOOTP_GLOBAL_CONFIG ) pimsid-> IMSID_Buffer;
  1091. pdwDstTable = IPBOOTP_GLOBAL_SERVER_TABLE( pigc );
  1092. DELETE_SERVER_ENTRY(
  1093. dwIndex,
  1094. pigc-> GC_ServerCount,
  1095. pdwSrcTable,
  1096. pdwDstTable
  1097. );
  1098. pigc-> GC_ServerCount--;
  1099. //
  1100. // Update MIB
  1101. //
  1102. BOOTP_MIB_SET(
  1103. pimsid,
  1104. dwSetSize,
  1105. dwRes
  1106. );
  1107. } while ( FALSE );
  1108. if ( pimsid ) { BOOTP_MIB_FREE( pimsid ); }
  1109. return dwRes;
  1110. }
  1111. DWORD
  1112. GetInterfaceInfo(
  1113. IN UINT actionId,
  1114. IN PIPBOOTP_MIB_GET_INPUT_DATA pimgidInData,
  1115. OUT PIPBOOTP_MIB_GET_OUTPUT_DATA* ppimgod,
  1116. OUT PDWORD pdwOutSize
  1117. )
  1118. {
  1119. DWORD dwRes = (DWORD) -1;
  1120. PIPBOOTP_MIB_GET_OUTPUT_DATA pimgodOutData = NULL;
  1121. *ppimgod = NULL;
  1122. switch ( actionId )
  1123. {
  1124. case MIB_ACTION_GET :
  1125. BOOTP_MIB_GET(
  1126. pimgidInData,
  1127. sizeof( IPBOOTP_MIB_GET_INPUT_DATA ),
  1128. &pimgodOutData,
  1129. pdwOutSize,
  1130. dwRes
  1131. );
  1132. //
  1133. // ERROR_INVALID_PARAMETER is returned when there is
  1134. // no interface for the specified index.
  1135. //
  1136. if ( dwRes == ERROR_INVALID_PARAMETER )
  1137. {
  1138. dwRes = MIB_S_ENTRY_NOT_FOUND;
  1139. }
  1140. break;
  1141. case MIB_ACTION_GETFIRST :
  1142. BOOTP_MIB_GETFIRST(
  1143. pimgidInData,
  1144. sizeof( IPBOOTP_MIB_GET_INPUT_DATA ),
  1145. &pimgodOutData,
  1146. pdwOutSize,
  1147. dwRes
  1148. );
  1149. //
  1150. // ERROR_INVALID_PARAMETER is returned when there is
  1151. // no interface for the specified index.
  1152. //
  1153. if ( dwRes == ERROR_INVALID_PARAMETER )
  1154. {
  1155. dwRes = MIB_S_NO_MORE_ENTRIES;
  1156. }
  1157. break;
  1158. case MIB_ACTION_GETNEXT :
  1159. BOOTP_MIB_GETNEXT(
  1160. pimgidInData,
  1161. sizeof( IPBOOTP_MIB_GET_INPUT_DATA ),
  1162. &pimgodOutData,
  1163. pdwOutSize,
  1164. dwRes
  1165. );
  1166. //
  1167. // ERROR_INVALID_PARAMETER is returned when there is
  1168. // no interface for the specified index.
  1169. //
  1170. if ( dwRes == ERROR_INVALID_PARAMETER )
  1171. {
  1172. dwRes = MIB_S_NO_MORE_ENTRIES;
  1173. break;
  1174. }
  1175. //
  1176. // Get Next wraps to the next table at the end of the
  1177. // entries in the current table. To flag the end of a table,
  1178. // check the end of the table.
  1179. //
  1180. if ( pimgidInData-> IMGID_TypeID != pimgodOutData-> IMGOD_TypeID )
  1181. {
  1182. MprAdminMIBBufferFree( pimgodOutData );
  1183. dwRes = MIB_S_NO_MORE_ENTRIES;
  1184. }
  1185. break;
  1186. default :
  1187. dwRes = MIB_S_INVALID_PARAMETER;
  1188. break;
  1189. }
  1190. if ( dwRes == NO_ERROR )
  1191. {
  1192. *ppimgod = pimgodOutData;
  1193. }
  1194. return dwRes;
  1195. }
  1196. DWORD
  1197. ValidateInterfaceConfig(
  1198. IN AsnAny * objectArray
  1199. )
  1200. {
  1201. DWORD dwRes = MIB_S_INVALID_PARAMETER,
  1202. dwCount = (DWORD) -1,
  1203. dwMode = (DWORD) -1;
  1204. sav_ifConfigEntry* psifce = (sav_ifConfigEntry*) objectArray;
  1205. do
  1206. {
  1207. //
  1208. // verify relay mode
  1209. //
  1210. dwMode = GetAsnInteger( &( psifce-> ifCERelayMode ), (DWORD) -1 );
  1211. if ( dwMode != d_ifCERelayMode_disabled &&
  1212. dwMode != d_ifCERelayMode_enabled )
  1213. {
  1214. TRACE1( " Invalid update mode (%d) specified ", dwMode );
  1215. break;
  1216. }
  1217. dwRes = MIB_S_SUCCESS;
  1218. } while ( FALSE );
  1219. return dwRes;
  1220. }
  1221. DWORD
  1222. SetInterfaceConfig(
  1223. IN AsnAny * objectArray
  1224. )
  1225. {
  1226. DWORD dwRes = (DWORD) -1,
  1227. dwGetSize = 0,
  1228. dwSetSize = 0;
  1229. sav_ifConfigEntry* psifce = NULL;
  1230. PIPBOOTP_IF_CONFIG piic = NULL;
  1231. PIPBOOTP_MIB_SET_INPUT_DATA pimsidInData= NULL;
  1232. PIPBOOTP_MIB_GET_OUTPUT_DATA pimgodOutData = NULL;
  1233. IPBOOTP_MIB_GET_INPUT_DATA imgidInData;
  1234. do
  1235. {
  1236. //
  1237. // Retrieve existing interface config
  1238. //
  1239. psifce = (sav_ifConfigEntry*) objectArray;
  1240. imgidInData.IMGID_TypeID = IPBOOTP_IF_CONFIG_ID;
  1241. imgidInData.IMGID_IfIndex = GetAsnInteger(
  1242. &( psifce-> ifCEIndex ),
  1243. (DWORD) -1
  1244. );
  1245. dwRes = GetInterfaceInfo(
  1246. MIB_ACTION_GET,
  1247. &imgidInData,
  1248. &pimgodOutData,
  1249. &dwGetSize
  1250. );
  1251. if ( dwRes != NO_ERROR )
  1252. {
  1253. TraceError( dwRes );
  1254. break;
  1255. }
  1256. //
  1257. // Update fields
  1258. //
  1259. piic = (PIPBOOTP_IF_CONFIG) (pimgodOutData-> IMGOD_Buffer);
  1260. piic-> IC_RelayMode++;
  1261. piic-> IC_RelayMode = GetAsnInteger(
  1262. &( psifce-> ifCERelayMode ),
  1263. piic-> IC_RelayMode
  1264. ) - 1;
  1265. piic-> IC_MaxHopCount = GetAsnInteger(
  1266. &( psifce-> ifCEMaxHopCount ),
  1267. piic-> IC_MaxHopCount
  1268. );
  1269. piic-> IC_MinSecondsSinceBoot = GetAsnInteger(
  1270. &( psifce-> ifCEMinSecondsSinceBoot ),
  1271. piic-> IC_MinSecondsSinceBoot
  1272. );
  1273. BOOTP_MIB_SET(
  1274. pimsidInData,
  1275. dwSetSize,
  1276. dwRes
  1277. );
  1278. if ( dwRes != NO_ERROR )
  1279. {
  1280. TraceError( dwRes );
  1281. break;
  1282. }
  1283. dwRes = MIB_S_SUCCESS;
  1284. } while ( FALSE );
  1285. if ( pimgodOutData ) { MprAdminMIBBufferFree( pimgodOutData ); }
  1286. if ( pimsidInData ) { BOOTP_MIB_FREE( pimsidInData ); }
  1287. return dwRes;
  1288. }
  1289. DWORD
  1290. ConnectToRouter()
  1291. {
  1292. DWORD dwRes = (DWORD) -1;
  1293. EnterCriticalSection( &g_CS );
  1294. do
  1295. {
  1296. MPR_SERVER_HANDLE hTmp;
  1297. if ( g_hMIBServer )
  1298. {
  1299. dwRes = NO_ERROR;
  1300. break;
  1301. }
  1302. dwRes = MprAdminMIBServerConnect( NULL, &hTmp );
  1303. if ( dwRes == NO_ERROR )
  1304. {
  1305. InterlockedExchangePointer( &g_hMIBServer, hTmp );
  1306. }
  1307. else
  1308. {
  1309. TRACE1(
  1310. "Error %d setting up DIM connection to MIB Server\n",
  1311. dwRes
  1312. );
  1313. }
  1314. } while ( FALSE );
  1315. LeaveCriticalSection( &g_CS );
  1316. return dwRes;
  1317. }