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.

2729 lines
64 KiB

  1. //***************************************************************************
  2. //
  3. // File:
  4. //
  5. // Module: MS SNMP Provider
  6. //
  7. // Purpose:
  8. //
  9. // Copyright (c) 1997-2001 Microsoft Corporation, All Rights Reserved
  10. //
  11. //***************************************************************************
  12. #include "precomp.h"
  13. #include <provexpt.h>
  14. #include <snmpstd.h>
  15. #include <snmpmt.h>
  16. #include <snmptempl.h>
  17. #include <objbase.h>
  18. #include <wbemidl.h>
  19. #include <snmpcont.h>
  20. #include <snmpevt.h>
  21. #include <snmpthrd.h>
  22. #include <snmplog.h>
  23. #include <instpath.h>
  24. #include <snmpcl.h>
  25. #include <snmptype.h>
  26. #include <snmpobj.h>
  27. #include <smir.h>
  28. #include <correlat.h>
  29. #include "classfac.h"
  30. #include "clasprov.h"
  31. #include "creclass.h"
  32. #include "guids.h"
  33. #ifdef CORRELATOR_INIT
  34. SnmpCorrelation :: SnmpCorrelation (
  35. SnmpSession &session ,
  36. SnmpClassEventObject *eventObject
  37. ) : CCorrelator ( session ) ,
  38. m_session ( &session ) ,
  39. m_eventObject ( eventObject )
  40. #else //CORRELATOR_INIT
  41. SnmpCorrelation :: SnmpCorrelation (
  42. SnmpSession &session ,
  43. SnmpClassEventObject *eventObject,
  44. ISmirInterrogator *a_ISmirInterrogator
  45. ) : CCorrelator ( session, a_ISmirInterrogator ) ,
  46. m_session ( &session ) ,
  47. m_eventObject ( eventObject )
  48. #endif //CORRELATOR_INIT
  49. {
  50. }
  51. SnmpCorrelation :: ~SnmpCorrelation ()
  52. {
  53. m_session->DestroySession () ;
  54. }
  55. void SnmpCorrelation :: Correlated ( IN const CCorrelator_Info &info , IN ISmirGroupHandle *phGroup , IN const char* objectId )
  56. {
  57. DebugMacro1(
  58. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  59. __FILE__,__LINE__,
  60. L" SnmpCorrelation :: Correlated ( IN const CCorrelator_Info &info , IN ISmirGroupHandle *phGroup , IN const char* objectId )"
  61. ) ;
  62. )
  63. switch ( info.GetInfo () )
  64. {
  65. case CCorrelator_Info :: ECorrSuccess:
  66. {
  67. DebugMacro1(
  68. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  69. __FILE__,__LINE__,
  70. L" Successful correlation"
  71. ) ;
  72. )
  73. if ( phGroup )
  74. {
  75. phGroup->AddRef () ;
  76. m_eventObject->ReceiveGroup ( phGroup ) ;
  77. }
  78. else
  79. {
  80. }
  81. }
  82. break ;
  83. case CCorrelator_Info :: ECorrSnmpError:
  84. {
  85. DebugMacro1(
  86. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  87. __FILE__,__LINE__,
  88. L" Unsuccessful correlation"
  89. ) ;
  90. )
  91. m_eventObject->ReceiveError ( info ) ;
  92. }
  93. break ;
  94. default:
  95. {
  96. DebugMacro1(
  97. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  98. __FILE__,__LINE__,
  99. L" Unknown Correlation Status"
  100. ) ;
  101. )
  102. }
  103. break ;
  104. }
  105. if ( phGroup )
  106. phGroup->Release () ;
  107. DebugMacro1(
  108. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  109. __FILE__,__LINE__,
  110. L" Returning from SnmpCorrelation :: Correlated ( IN const CCorrelator_Info &info , IN ISmirGroupHandle *phGroup , IN const char* objectId )"
  111. ) ;
  112. )
  113. }
  114. void SnmpCorrelation :: Finished ( IN const BOOL Complete )
  115. {
  116. DebugMacro1(
  117. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  118. __FILE__,__LINE__,
  119. L" SnmpCorrelation :: Finished ( IN const BOOL Complete )"
  120. ) ;
  121. )
  122. m_eventObject->ReceiveComplete () ;
  123. DestroyCorrelator () ;
  124. DebugMacro1(
  125. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  126. __FILE__,__LINE__,
  127. L" Returning from SnmpCorrelation :: Finished ( IN const BOOL Complete )"
  128. ) ;
  129. )
  130. }
  131. SnmpClassEventObject :: SnmpClassEventObject (
  132. CImpClasProv *provider ,
  133. IWbemContext *a_Context
  134. ) : m_provider ( provider ) ,
  135. m_correlate ( TRUE ) ,
  136. m_synchronousComplete ( FALSE ) ,
  137. m_correlator ( NULL ) ,
  138. m_namespaceObject ( NULL ) ,
  139. m_inCallstack ( FALSE ) ,
  140. m_Context ( a_Context ) ,
  141. m_GroupsReceived ( 0 ),
  142. m_Interrogator ( NULL )
  143. {
  144. if ( m_provider )
  145. m_provider->AddRef () ;
  146. if ( m_Context )
  147. {
  148. m_Context->AddRef () ;
  149. /*
  150. * Look for correlation flag in Context
  151. */
  152. VARIANT t_Variant ;
  153. VariantInit ( & t_Variant ) ;
  154. HRESULT result = m_Context->GetValue ( WBEM_CLASS_CORRELATE_CONTEXT_PROP , 0 , & t_Variant ) ;
  155. if ( SUCCEEDED ( result ) & ( t_Variant.vt != VT_EMPTY ) )
  156. {
  157. if ( t_Variant.vt == VT_BOOL )
  158. m_correlate = t_Variant.boolVal ;
  159. VariantClear ( & t_Variant ) ;
  160. }
  161. }
  162. HRESULT result = CoCreateInstance (
  163. CLSID_SMIR_Database ,
  164. NULL ,
  165. CLSCTX_INPROC_SERVER | CLSCTX_LOCAL_SERVER ,
  166. IID_ISMIR_Interrogative ,
  167. ( void ** ) &m_Interrogator
  168. );
  169. if ( SUCCEEDED ( result ) )
  170. {
  171. ISMIRWbemConfiguration *smirConfiguration = NULL ;
  172. result = m_Interrogator->QueryInterface ( IID_ISMIRWbemConfiguration , ( void ** ) & smirConfiguration ) ;
  173. if ( SUCCEEDED ( result ) )
  174. {
  175. result = smirConfiguration->Authenticate (
  176. NULL,
  177. NULL,
  178. NULL,
  179. NULL,
  180. 0 ,
  181. NULL,
  182. FALSE
  183. ) ;
  184. if ( SUCCEEDED ( result ) )
  185. {
  186. smirConfiguration->SetContext ( m_Context ) ;
  187. smirConfiguration->Release () ;
  188. }
  189. }
  190. else
  191. {
  192. m_Interrogator->Release () ;
  193. m_synchronousComplete = TRUE ;
  194. m_errorObject.SetStatus ( WBEM_SNMP_E_PROVIDER_FAILURE ) ;
  195. m_errorObject.SetWbemStatus ( WBEM_E_PROVIDER_FAILURE ) ;
  196. m_errorObject.SetMessage ( L"QueryInterface on ISmirInterrogator Failed" ) ;
  197. }
  198. }
  199. else
  200. {
  201. m_synchronousComplete = TRUE ;
  202. m_errorObject.SetStatus ( WBEM_SNMP_E_PROVIDER_FAILURE ) ;
  203. m_errorObject.SetWbemStatus ( WBEM_E_PROVIDER_FAILURE ) ;
  204. m_errorObject.SetMessage ( L"CoCreateInstance on ISmirInterrogator Failed" ) ;
  205. }
  206. }
  207. SnmpClassEventObject :: ~SnmpClassEventObject ()
  208. {
  209. if ( m_provider )
  210. m_provider->Release () ;
  211. if ( m_namespaceObject )
  212. m_namespaceObject->Release () ;
  213. if ( m_Context )
  214. m_Context->Release () ;
  215. if ( m_Interrogator )
  216. m_Interrogator->Release () ;
  217. }
  218. BOOL SnmpClassEventObject :: GetClass ( WbemSnmpErrorObject &a_errorObject , IWbemClassObject **classObject , BSTR a_Class )
  219. {
  220. HRESULT result = m_Interrogator->GetWBEMClass ( classObject , a_Class ) ;
  221. if ( SUCCEEDED ( result ) )
  222. {
  223. }
  224. else
  225. {
  226. a_errorObject.SetStatus ( WBEM_SNMP_E_NOT_FOUND ) ;
  227. a_errorObject.SetWbemStatus ( WBEM_E_NOT_FOUND ) ;
  228. a_errorObject.SetMessage ( L"Failed to get class definition from SMIR" ) ;
  229. }
  230. return result ;
  231. }
  232. BOOL SnmpClassEventObject :: GetSnmpNotifyStatusObject ( IWbemClassObject **notifyObject )
  233. {
  234. IWbemClassObject *notificationClassObject = NULL ;
  235. IWbemClassObject *errorObject = NULL ;
  236. BOOL status = TRUE ;
  237. WbemSnmpErrorObject errorStatusObject ;
  238. if ( notificationClassObject = m_provider->GetSnmpNotificationObject ( errorStatusObject ) )
  239. {
  240. HRESULT result = notificationClassObject->SpawnInstance ( 0 , notifyObject ) ;
  241. if ( SUCCEEDED ( result ) )
  242. {
  243. VARIANT variant ;
  244. VariantInit ( &variant ) ;
  245. variant.vt = VT_I4 ;
  246. variant.lVal = m_errorObject.GetWbemStatus () ;
  247. result = (*notifyObject)->Put ( WBEM_PROPERTY_STATUSCODE , 0 , & variant , 0 ) ;
  248. VariantClear ( &variant ) ;
  249. if ( SUCCEEDED ( result ) )
  250. {
  251. variant.vt = VT_I4 ;
  252. variant.lVal = m_errorObject.GetStatus () ;
  253. result = (*notifyObject)->Put ( WBEM_PROPERTY_SNMPSTATUSCODE , 0 , & variant , 0 ) ;
  254. VariantClear ( &variant ) ;
  255. if ( SUCCEEDED ( result ) )
  256. {
  257. if ( m_errorObject.GetMessage () )
  258. {
  259. variant.vt = VT_BSTR ;
  260. variant.bstrVal = SysAllocString ( m_errorObject.GetMessage () ) ;
  261. result = (*notifyObject)->Put ( WBEM_PROPERTY_SNMPSTATUSMESSAGE , 0 , & variant , 0 ) ;
  262. VariantClear ( &variant ) ;
  263. if ( ! SUCCEEDED ( result ) )
  264. {
  265. (*notifyObject)->Release () ;
  266. status = GetNotifyStatusObject ( notifyObject ) ;
  267. }
  268. }
  269. }
  270. else
  271. {
  272. (*notifyObject)->Release () ;
  273. status = GetNotifyStatusObject ( notifyObject ) ;
  274. }
  275. }
  276. else
  277. {
  278. (*notifyObject)->Release () ;
  279. status = GetNotifyStatusObject ( notifyObject ) ;
  280. }
  281. notificationClassObject->Release () ;
  282. }
  283. else
  284. {
  285. status = GetNotifyStatusObject ( notifyObject ) ;
  286. }
  287. }
  288. else
  289. {
  290. status = GetNotifyStatusObject ( notifyObject ) ;
  291. }
  292. return status ;
  293. }
  294. BOOL SnmpClassEventObject :: GetNotifyStatusObject ( IWbemClassObject **notifyObject )
  295. {
  296. IWbemClassObject *notificationClassObject = NULL ;
  297. IWbemClassObject *errorObject = NULL ;
  298. BOOL status = TRUE ;
  299. WbemSnmpErrorObject errorStatusObject ;
  300. if ( notificationClassObject = m_provider->GetNotificationObject ( errorStatusObject ) )
  301. {
  302. HRESULT result = notificationClassObject->SpawnInstance ( 0 , notifyObject ) ;
  303. if ( SUCCEEDED ( result ) )
  304. {
  305. VARIANT variant ;
  306. VariantInit ( &variant ) ;
  307. variant.vt = VT_I4 ;
  308. variant.lVal = m_errorObject.GetWbemStatus () ;
  309. result = (*notifyObject)->Put ( WBEM_PROPERTY_STATUSCODE , 0 , & variant , 0 ) ;
  310. if ( SUCCEEDED ( result ) )
  311. {
  312. if ( m_errorObject.GetMessage () )
  313. {
  314. variant.vt = VT_BSTR ;
  315. variant.bstrVal = SysAllocString ( m_errorObject.GetMessage () ) ;
  316. result = (*notifyObject)->Put ( WBEM_PROPERTY_SNMPSTATUSMESSAGE , 0 , & variant , 0 ) ;
  317. VariantClear ( &variant ) ;
  318. if ( ! SUCCEEDED ( result ) )
  319. {
  320. status = FALSE ;
  321. (*notifyObject)->Release () ;
  322. (*notifyObject)=NULL ;
  323. }
  324. }
  325. }
  326. else
  327. {
  328. status = FALSE ;
  329. (*notifyObject)->Release () ;
  330. (*notifyObject)=NULL ;
  331. }
  332. VariantClear ( &variant ) ;
  333. notificationClassObject->Release () ;
  334. }
  335. else
  336. {
  337. status = FALSE ;
  338. }
  339. }
  340. else
  341. {
  342. status = FALSE ;
  343. }
  344. return status ;
  345. }
  346. BOOL SnmpClassEventObject :: GetAgentTransport (
  347. WbemSnmpErrorObject &a_errorObject ,
  348. IWbemQualifierSet *namespaceQualifierObject ,
  349. wchar_t *&agentTransport
  350. )
  351. {
  352. BOOL status = TRUE ;
  353. agentTransport = NULL ;
  354. BSTR t_Transport = NULL ;
  355. VARIANT t_Variant ;
  356. VariantInit ( & t_Variant ) ;
  357. if ( m_Context )
  358. {
  359. HRESULT result = m_Context->GetValue ( WBEM_QUALIFIER_AGENTTRANSPORT , 0 , & t_Variant ) ;
  360. if ( SUCCEEDED ( result ) & ( t_Variant.vt != VT_EMPTY ) )
  361. {
  362. if ( t_Variant.vt == VT_BSTR )
  363. {
  364. t_Transport = t_Variant.bstrVal ;
  365. }
  366. else
  367. {
  368. status = FALSE ;
  369. a_errorObject.SetStatus ( WBEM_SNMP_E_TYPE_MISMATCH ) ;
  370. a_errorObject.SetWbemStatus ( WBEM_E_FAILED ) ;
  371. a_errorObject.SetMessage ( L"Type mismatch for qualifier: AgentTransport" ) ;
  372. }
  373. }
  374. }
  375. if ( status & ! t_Transport )
  376. {
  377. LONG attributeType ;
  378. HRESULT result = namespaceQualifierObject->Get (
  379. WBEM_QUALIFIER_AGENTTRANSPORT ,
  380. 0,
  381. &t_Variant ,
  382. & attributeType
  383. ) ;
  384. if ( SUCCEEDED ( result ) )
  385. {
  386. if ( t_Variant.vt == VT_BSTR )
  387. {
  388. t_Transport = t_Variant.bstrVal ;
  389. }
  390. else
  391. {
  392. status = FALSE ;
  393. a_errorObject.SetStatus ( WBEM_SNMP_E_TYPE_MISMATCH ) ;
  394. a_errorObject.SetWbemStatus ( WBEM_E_FAILED ) ;
  395. a_errorObject.SetMessage ( L"Type mismatch for qualifier: AgentTransport" ) ;
  396. }
  397. }
  398. else
  399. {
  400. t_Transport = WBEM_AGENTIPTRANSPORT ;
  401. }
  402. }
  403. if ( status )
  404. {
  405. if ( ( _wcsicmp ( t_Transport , WBEM_AGENTIPTRANSPORT ) == 0 ) || ( _wcsicmp ( t_Transport , WBEM_AGENTIPXTRANSPORT ) == 0 ) )
  406. {
  407. agentTransport = UnicodeStringDuplicate ( t_Transport ) ;
  408. }
  409. else
  410. {
  411. /*
  412. * Transport type != IP || != IPX
  413. */
  414. status = FALSE ;
  415. a_errorObject.SetStatus ( WBEM_SNMP_E_INVALID_TRANSPORT ) ;
  416. a_errorObject.SetWbemStatus ( WBEM_E_FAILED ) ;
  417. a_errorObject.SetMessage ( L"Illegal value for qualifier: AgentTransport" ) ;
  418. }
  419. }
  420. VariantClear ( & t_Variant );
  421. return status ;
  422. }
  423. BOOL SnmpClassEventObject :: GetAgentVersion (
  424. WbemSnmpErrorObject &a_errorObject ,
  425. IWbemQualifierSet *namespaceQualifierObject ,
  426. wchar_t *&agentVersion
  427. )
  428. {
  429. BOOL status = TRUE ;
  430. agentVersion = NULL ;
  431. BSTR t_Version = NULL ;
  432. VARIANT t_Variant ;
  433. VariantInit ( & t_Variant ) ;
  434. if ( m_Context )
  435. {
  436. HRESULT result = m_Context->GetValue ( WBEM_QUALIFIER_AGENTSNMPVERSION , 0 , & t_Variant ) ;
  437. if ( SUCCEEDED ( result ) & ( t_Variant.vt != VT_EMPTY ) )
  438. {
  439. if ( t_Variant.vt == VT_BSTR )
  440. {
  441. t_Version = t_Variant.bstrVal ;
  442. }
  443. else
  444. {
  445. status = FALSE ;
  446. a_errorObject.SetStatus ( WBEM_SNMP_E_TYPE_MISMATCH ) ;
  447. a_errorObject.SetWbemStatus ( WBEM_E_FAILED ) ;
  448. a_errorObject.SetMessage ( L"Type mismatch for qualifier: AgentSNMPVersion" ) ;
  449. }
  450. }
  451. }
  452. if ( status & ! t_Version )
  453. {
  454. LONG attributeType ;
  455. HRESULT result = namespaceQualifierObject->Get (
  456. WBEM_QUALIFIER_AGENTSNMPVERSION ,
  457. 0,
  458. &t_Variant ,
  459. & attributeType
  460. ) ;
  461. if ( SUCCEEDED ( result ) )
  462. {
  463. if ( t_Variant.vt == VT_BSTR )
  464. {
  465. t_Version = t_Variant.bstrVal ;
  466. }
  467. else
  468. {
  469. status = FALSE ;
  470. a_errorObject.SetStatus ( WBEM_SNMP_E_TYPE_MISMATCH ) ;
  471. a_errorObject.SetWbemStatus ( WBEM_E_FAILED ) ;
  472. a_errorObject.SetMessage ( L"Type mismatch for qualifier: AgentSNMPVersion" ) ;
  473. }
  474. }
  475. else
  476. {
  477. t_Version = WBEM_AGENTSNMPVERSION_V1 ;
  478. }
  479. }
  480. if ( status )
  481. {
  482. if ( ( _wcsicmp ( t_Version , WBEM_AGENTSNMPVERSION_V1 ) == 0 ) || ( _wcsicmp ( t_Version , WBEM_AGENTSNMPVERSION_V2C ) == 0 ) )
  483. {
  484. agentVersion = UnicodeStringDuplicate ( t_Version ) ;
  485. }
  486. else
  487. {
  488. status = FALSE ;
  489. a_errorObject.SetStatus ( WBEM_SNMP_E_TYPE_MISMATCH ) ;
  490. a_errorObject.SetWbemStatus ( WBEM_E_FAILED ) ;
  491. a_errorObject.SetMessage ( L"Type mismatch for qualifier: AgentSNMPVersion" ) ;
  492. }
  493. }
  494. VariantClear ( & t_Variant );
  495. return status ;
  496. }
  497. BOOL SnmpClassEventObject :: GetAgentAddress (
  498. WbemSnmpErrorObject &a_errorObject ,
  499. IWbemQualifierSet *namespaceQualifierObject ,
  500. wchar_t *&agentAddress
  501. )
  502. {
  503. BOOL status = TRUE ;
  504. agentAddress = NULL ;
  505. BSTR t_Address = NULL ;
  506. VARIANT t_Variant ;
  507. VariantInit ( & t_Variant ) ;
  508. if ( m_Context )
  509. {
  510. HRESULT result = m_Context->GetValue ( WBEM_QUALIFIER_AGENTADDRESS , 0 , & t_Variant ) ;
  511. if ( SUCCEEDED ( result ) & ( t_Variant.vt != VT_EMPTY ) )
  512. {
  513. if ( t_Variant.vt == VT_BSTR )
  514. {
  515. t_Address = t_Variant.bstrVal ;
  516. if ( wcscmp ( t_Address , L"" ) == 0 )
  517. {
  518. status = FALSE ;
  519. a_errorObject.SetStatus ( WBEM_SNMP_E_TYPE_MISMATCH ) ;
  520. a_errorObject.SetWbemStatus ( WBEM_E_FAILED ) ;
  521. a_errorObject.SetMessage ( L"Type mismatch for qualifier: AgentAddress" ) ;
  522. }
  523. }
  524. else
  525. {
  526. status = FALSE ;
  527. a_errorObject.SetStatus ( WBEM_SNMP_E_TYPE_MISMATCH ) ;
  528. a_errorObject.SetWbemStatus ( WBEM_E_FAILED ) ;
  529. a_errorObject.SetMessage ( L"Type mismatch for qualifier: AgentAddress" ) ;
  530. }
  531. }
  532. }
  533. if ( status & ! t_Address )
  534. {
  535. LONG attributeType ;
  536. HRESULT result = namespaceQualifierObject->Get (
  537. WBEM_QUALIFIER_AGENTADDRESS ,
  538. 0,
  539. &t_Variant ,
  540. & attributeType
  541. ) ;
  542. if ( SUCCEEDED ( result ) )
  543. {
  544. if ( t_Variant.vt == VT_BSTR )
  545. {
  546. t_Address = t_Variant.bstrVal ;
  547. if ( wcscmp ( t_Address , L"" ) == 0 )
  548. {
  549. status = FALSE ;
  550. a_errorObject.SetStatus ( WBEM_SNMP_E_TYPE_MISMATCH ) ;
  551. a_errorObject.SetWbemStatus ( WBEM_E_FAILED ) ;
  552. a_errorObject.SetMessage ( L"Type mismatch for qualifier: AgentAddress" ) ;
  553. }
  554. }
  555. else
  556. {
  557. status = FALSE ;
  558. a_errorObject.SetStatus ( WBEM_SNMP_E_TYPE_MISMATCH ) ;
  559. a_errorObject.SetWbemStatus ( WBEM_E_FAILED ) ;
  560. a_errorObject.SetMessage ( L"Type mismatch for qualifier: AgentAddress" ) ;
  561. }
  562. }
  563. else
  564. {
  565. status = FALSE ;
  566. a_errorObject.SetStatus ( WBEM_SNMP_E_INVALID_TRANSPORTCONTEXT ) ;
  567. a_errorObject.SetWbemStatus ( WBEM_E_FAILED ) ;
  568. a_errorObject.SetMessage ( L"Namespace must specify valid qualifier for: AgentAddress" ) ;
  569. }
  570. }
  571. if ( status )
  572. {
  573. agentAddress = UnicodeStringDuplicate ( t_Address ) ;
  574. }
  575. VariantClear ( & t_Variant );
  576. return status ;
  577. }
  578. BOOL SnmpClassEventObject :: GetAgentReadCommunityName (
  579. WbemSnmpErrorObject &a_errorObject ,
  580. IWbemQualifierSet *namespaceQualifierObject ,
  581. wchar_t *&agentReadCommunityName
  582. )
  583. {
  584. BOOL status = TRUE ;
  585. agentReadCommunityName = NULL ;
  586. BSTR t_Community = NULL ;
  587. VARIANT t_Variant ;
  588. VariantInit ( & t_Variant ) ;
  589. if ( m_Context )
  590. {
  591. HRESULT result = m_Context->GetValue ( WBEM_QUALIFIER_AGENTREADCOMMUNITYNAME , 0 , & t_Variant ) ;
  592. if ( SUCCEEDED ( result ) & ( t_Variant.vt != VT_EMPTY ) )
  593. {
  594. if ( t_Variant.vt == VT_BSTR )
  595. {
  596. t_Community = t_Variant.bstrVal ;
  597. }
  598. else
  599. {
  600. status = FALSE ;
  601. a_errorObject.SetStatus ( WBEM_SNMP_E_TYPE_MISMATCH ) ;
  602. a_errorObject.SetWbemStatus ( WBEM_E_FAILED ) ;
  603. a_errorObject.SetMessage ( L"Type mismatch for qualifier: AgentReadCommunityName" ) ;
  604. }
  605. }
  606. }
  607. if ( status & ! t_Community )
  608. {
  609. LONG attributeType ;
  610. HRESULT result = namespaceQualifierObject->Get (
  611. WBEM_QUALIFIER_AGENTREADCOMMUNITYNAME ,
  612. 0,
  613. &t_Variant ,
  614. & attributeType
  615. ) ;
  616. if ( SUCCEEDED ( result ) )
  617. {
  618. if ( t_Variant.vt == VT_BSTR )
  619. {
  620. t_Community = t_Variant.bstrVal ;
  621. }
  622. else
  623. {
  624. status = FALSE ;
  625. a_errorObject.SetStatus ( WBEM_SNMP_E_TYPE_MISMATCH ) ;
  626. a_errorObject.SetWbemStatus ( WBEM_E_FAILED ) ;
  627. a_errorObject.SetMessage ( L"Type mismatch for qualifier: AgentReadCommunityName" ) ;
  628. }
  629. }
  630. else
  631. {
  632. t_Community = WBEM_AGENTCOMMUNITYNAME ;
  633. }
  634. }
  635. if ( status )
  636. {
  637. agentReadCommunityName = UnicodeStringDuplicate ( t_Community ) ;
  638. }
  639. VariantClear ( & t_Variant );
  640. return status ;
  641. }
  642. BOOL SnmpClassEventObject :: GetAgentRetryCount (
  643. WbemSnmpErrorObject &a_errorObject ,
  644. IWbemQualifierSet *namespaceQualifierObject ,
  645. ULONG &agentRetryCount
  646. )
  647. {
  648. BOOL status = TRUE ;
  649. agentRetryCount = 1 ;
  650. BOOL t_RetryCount = FALSE ;
  651. VARIANT t_Variant ;
  652. VariantInit ( & t_Variant ) ;
  653. if ( m_Context )
  654. {
  655. HRESULT result = m_Context->GetValue ( WBEM_QUALIFIER_AGENTRETRYCOUNT , 0 , & t_Variant ) ;
  656. if ( SUCCEEDED ( result ) & ( t_Variant.vt != VT_EMPTY ) )
  657. {
  658. if ( t_Variant.vt == VT_I4 )
  659. {
  660. t_RetryCount = TRUE ;
  661. agentRetryCount = t_Variant.lVal ;
  662. }
  663. else
  664. {
  665. status = FALSE ;
  666. a_errorObject.SetStatus ( WBEM_SNMP_E_TYPE_MISMATCH ) ;
  667. a_errorObject.SetWbemStatus ( WBEM_E_FAILED ) ;
  668. a_errorObject.SetMessage ( L"Type mismatch for qualifier: AgentRetryCount" ) ;
  669. }
  670. }
  671. }
  672. if ( status & ! t_RetryCount )
  673. {
  674. LONG attributeType ;
  675. HRESULT result = namespaceQualifierObject->Get (
  676. WBEM_QUALIFIER_AGENTRETRYCOUNT ,
  677. 0,
  678. &t_Variant ,
  679. & attributeType
  680. ) ;
  681. if ( SUCCEEDED ( result ) )
  682. {
  683. if ( t_Variant.vt == VT_I4 )
  684. {
  685. agentRetryCount = t_Variant.lVal ;
  686. }
  687. else
  688. {
  689. status = FALSE ;
  690. a_errorObject.SetStatus ( WBEM_SNMP_E_TYPE_MISMATCH ) ;
  691. a_errorObject.SetWbemStatus ( WBEM_E_FAILED ) ;
  692. a_errorObject.SetMessage ( L"Type mismatch for qualifier: AgentRetryCount" ) ;
  693. }
  694. }
  695. }
  696. VariantClear ( & t_Variant );
  697. return status ;
  698. }
  699. BOOL SnmpClassEventObject :: GetAgentRetryTimeout(
  700. WbemSnmpErrorObject &a_errorObject ,
  701. IWbemQualifierSet *namespaceQualifierObject ,
  702. ULONG &agentRetryTimeout
  703. )
  704. {
  705. BOOL status = TRUE ;
  706. agentRetryTimeout = 0 ;
  707. BOOL t_RetryTimeout = FALSE ;
  708. VARIANT t_Variant ;
  709. VariantInit ( & t_Variant ) ;
  710. if ( m_Context )
  711. {
  712. HRESULT result = m_Context->GetValue ( WBEM_QUALIFIER_AGENTRETRYTIMEOUT , 0 , & t_Variant ) ;
  713. if ( SUCCEEDED ( result ) & ( t_Variant.vt != VT_EMPTY ) )
  714. {
  715. if ( t_Variant.vt == VT_I4 )
  716. {
  717. t_RetryTimeout = TRUE ;
  718. agentRetryTimeout = t_Variant.lVal ;
  719. }
  720. else
  721. {
  722. status = FALSE ;
  723. a_errorObject.SetStatus ( WBEM_SNMP_E_TYPE_MISMATCH ) ;
  724. a_errorObject.SetWbemStatus ( WBEM_E_FAILED ) ;
  725. a_errorObject.SetMessage ( L"Type mismatch for qualifier: AgentRetryTimeout" ) ;
  726. }
  727. }
  728. }
  729. if ( status & ! t_RetryTimeout )
  730. {
  731. LONG attributeType ;
  732. HRESULT result = namespaceQualifierObject->Get (
  733. WBEM_QUALIFIER_AGENTRETRYTIMEOUT ,
  734. 0,
  735. &t_Variant ,
  736. & attributeType
  737. ) ;
  738. if ( SUCCEEDED ( result ) )
  739. {
  740. if ( t_Variant.vt == VT_I4 )
  741. {
  742. agentRetryTimeout = t_Variant.lVal ;
  743. }
  744. else
  745. {
  746. status = FALSE ;
  747. a_errorObject.SetStatus ( WBEM_SNMP_E_TYPE_MISMATCH ) ;
  748. a_errorObject.SetWbemStatus ( WBEM_E_FAILED ) ;
  749. a_errorObject.SetMessage ( L"Type mismatch for qualifier: AgentRetryTimeout" ) ;
  750. }
  751. }
  752. }
  753. VariantClear ( & t_Variant );
  754. return status ;
  755. }
  756. BOOL SnmpClassEventObject :: GetAgentMaxVarBindsPerPdu (
  757. WbemSnmpErrorObject &a_errorObject ,
  758. IWbemQualifierSet *namespaceQualifierObject ,
  759. ULONG &agentVarBindsPerPdu
  760. )
  761. {
  762. BOOL status = TRUE ;
  763. agentVarBindsPerPdu = 0 ;
  764. BOOL t_VarBinds = FALSE ;
  765. VARIANT t_Variant ;
  766. VariantInit ( & t_Variant ) ;
  767. if ( m_Context )
  768. {
  769. HRESULT result = m_Context->GetValue ( WBEM_QUALIFIER_AGENTVARBINDSPERPDU , 0 , & t_Variant ) ;
  770. if ( SUCCEEDED ( result ) & ( t_Variant.vt != VT_EMPTY ) )
  771. {
  772. if ( t_Variant.vt == VT_I4 )
  773. {
  774. t_VarBinds = TRUE ;
  775. agentVarBindsPerPdu = t_Variant.lVal ;
  776. }
  777. else
  778. {
  779. status = FALSE ;
  780. a_errorObject.SetStatus ( WBEM_SNMP_E_TYPE_MISMATCH ) ;
  781. a_errorObject.SetWbemStatus ( WBEM_E_FAILED ) ;
  782. a_errorObject.SetMessage ( L"Type mismatch for qualifier: AgentVarBindPerPdu" ) ;
  783. }
  784. }
  785. }
  786. if ( status & ! t_VarBinds )
  787. {
  788. LONG attributeType ;
  789. HRESULT result = namespaceQualifierObject->Get (
  790. WBEM_QUALIFIER_AGENTVARBINDSPERPDU ,
  791. 0,
  792. &t_Variant ,
  793. & attributeType
  794. ) ;
  795. if ( SUCCEEDED ( result ) )
  796. {
  797. if ( t_Variant.vt == VT_I4 )
  798. {
  799. agentVarBindsPerPdu = t_Variant.lVal ;
  800. }
  801. else
  802. {
  803. status = FALSE ;
  804. a_errorObject.SetStatus ( WBEM_SNMP_E_TYPE_MISMATCH ) ;
  805. a_errorObject.SetWbemStatus ( WBEM_E_FAILED ) ;
  806. a_errorObject.SetMessage ( L"Type mismatch for qualifier: AgentVarBindPerPdu" ) ;
  807. }
  808. }
  809. }
  810. VariantClear ( & t_Variant );
  811. return status ;
  812. }
  813. BOOL SnmpClassEventObject :: GetAgentFlowControlWindowSize (
  814. WbemSnmpErrorObject &a_errorObject ,
  815. IWbemQualifierSet *namespaceQualifierObject ,
  816. ULONG &agentFlowControlWindowSize
  817. )
  818. {
  819. BOOL status = TRUE ;
  820. agentFlowControlWindowSize = 0 ;
  821. BOOL t_WindowSize = FALSE ;
  822. VARIANT t_Variant ;
  823. VariantInit ( & t_Variant ) ;
  824. if ( m_Context )
  825. {
  826. HRESULT result = m_Context->GetValue ( WBEM_QUALIFIER_AGENTFLOWCONTROLWINDOWSIZE , 0 , & t_Variant ) ;
  827. if ( SUCCEEDED ( result ) & ( t_Variant.vt != VT_EMPTY ) )
  828. {
  829. if ( t_Variant.vt == VT_I4 )
  830. {
  831. t_WindowSize = TRUE ;
  832. agentFlowControlWindowSize = t_Variant.lVal ;
  833. }
  834. else
  835. {
  836. status = FALSE ;
  837. a_errorObject.SetStatus ( WBEM_SNMP_E_TYPE_MISMATCH ) ;
  838. a_errorObject.SetWbemStatus ( WBEM_E_FAILED ) ;
  839. a_errorObject.SetMessage ( L"Type mismatch for qualifier: AgentFlowControlWindowSize" ) ;
  840. }
  841. }
  842. }
  843. if ( status & ! t_WindowSize )
  844. {
  845. LONG attributeType ;
  846. HRESULT result = namespaceQualifierObject->Get (
  847. WBEM_QUALIFIER_AGENTFLOWCONTROLWINDOWSIZE ,
  848. 0,
  849. &t_Variant ,
  850. & attributeType
  851. ) ;
  852. if ( SUCCEEDED ( result ) )
  853. {
  854. if ( t_Variant.vt == VT_I4 )
  855. {
  856. agentFlowControlWindowSize = t_Variant.lVal ;
  857. }
  858. else
  859. {
  860. status = FALSE ;
  861. a_errorObject.SetStatus ( WBEM_SNMP_E_TYPE_MISMATCH ) ;
  862. a_errorObject.SetWbemStatus ( WBEM_E_FAILED ) ;
  863. a_errorObject.SetMessage ( L"Type mismatch for qualifier: AgentFlowControlWindowSize" ) ;
  864. }
  865. }
  866. }
  867. VariantClear ( & t_Variant );
  868. return status ;
  869. }
  870. BOOL SnmpClassEventObject :: GetNamespaceObject ( WbemSnmpErrorObject &a_errorObject )
  871. {
  872. BOOL status = TRUE ;
  873. if ( ! m_namespaceObject )
  874. {
  875. IWbemServices *parentServer = m_provider->GetParentServer () ;
  876. wchar_t *objectPathPrefix = UnicodeStringAppend ( WBEM_NAMESPACE_EQUALS , m_provider->GetThisNamespace () ) ;
  877. wchar_t *objectPath = UnicodeStringAppend ( objectPathPrefix , WBEM_NAMESPACE_QUOTE ) ;
  878. delete [] objectPathPrefix ;
  879. BSTR t_PathStr = SysAllocString ( objectPath ) ;
  880. HRESULT result = parentServer->GetObject (
  881. t_PathStr ,
  882. 0 ,
  883. m_Context ,
  884. &m_namespaceObject ,
  885. NULL
  886. ) ;
  887. SysFreeString ( t_PathStr ) ;
  888. if ( SUCCEEDED ( result ) )
  889. {
  890. }
  891. else
  892. {
  893. status = FALSE ;
  894. a_errorObject.SetStatus ( WBEM_SNMP_E_PROVIDER_FAILURE ) ;
  895. a_errorObject.SetWbemStatus ( WBEM_E_PROVIDER_FAILURE ) ;
  896. a_errorObject.SetMessage ( L"Failed to obtain namespace object" ) ;
  897. }
  898. delete [] objectPath ;
  899. }
  900. return status ;
  901. }
  902. BOOL SnmpClassEventObject :: GetTransportInformation (
  903. WbemSnmpErrorObject &a_errorObject ,
  904. SnmpSession *&session
  905. )
  906. {
  907. DebugMacro1(
  908. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  909. __FILE__,__LINE__,
  910. L" SnmpClassEventObject :: GetTransportInformation ()"
  911. ) ;
  912. )
  913. BOOL status = TRUE ;
  914. IWbemQualifierSet *namespaceQualifierObject ;
  915. HRESULT result = m_namespaceObject->GetQualifierSet ( &namespaceQualifierObject ) ;
  916. if ( SUCCEEDED ( result ) )
  917. {
  918. wchar_t *agentVersion = NULL ;
  919. wchar_t *agentAddress = NULL ;
  920. wchar_t *agentTransport = NULL ;
  921. wchar_t *agentReadCommunityName = NULL ;
  922. ULONG agentRetryCount ;
  923. ULONG agentRetryTimeout ;
  924. ULONG agentMaxVarBindsPerPdu ;
  925. ULONG agentFlowControlWindowSize ;
  926. status = GetAgentVersion ( m_errorObject , namespaceQualifierObject , agentVersion ) ;
  927. if ( status ) status = GetAgentAddress ( m_errorObject , namespaceQualifierObject , agentAddress ) ;
  928. if ( status ) status = GetAgentTransport ( m_errorObject , namespaceQualifierObject , agentTransport ) ;
  929. if ( status ) status = GetAgentReadCommunityName ( m_errorObject , namespaceQualifierObject , agentReadCommunityName ) ;
  930. if ( status ) status = GetAgentRetryCount ( m_errorObject , namespaceQualifierObject , agentRetryCount ) ;
  931. if ( status ) status = GetAgentRetryTimeout ( m_errorObject , namespaceQualifierObject , agentRetryTimeout ) ;
  932. if ( status ) status = GetAgentMaxVarBindsPerPdu ( m_errorObject , namespaceQualifierObject , agentMaxVarBindsPerPdu ) ;
  933. if ( status ) status = GetAgentFlowControlWindowSize ( m_errorObject , namespaceQualifierObject , agentFlowControlWindowSize ) ;
  934. if ( status )
  935. {
  936. char *dbcsAgentAddress = UnicodeToDbcsString ( agentAddress ) ;
  937. if ( dbcsAgentAddress )
  938. {
  939. char *dbcsAgentReadCommunityName = UnicodeToDbcsString ( agentReadCommunityName ) ;
  940. if ( dbcsAgentReadCommunityName )
  941. {
  942. if ( _wcsicmp ( agentTransport , WBEM_AGENTIPTRANSPORT ) == 0 )
  943. {
  944. char *t_Address ;
  945. if ( m_provider->GetIpAddressString () && m_provider->GetIpAddressValue () && _stricmp ( m_provider->GetIpAddressString () , dbcsAgentAddress ) == 0 )
  946. {
  947. t_Address = m_provider->GetIpAddressValue () ;
  948. }
  949. else
  950. {
  951. if ( SnmpTransportIpAddress :: ValidateAddress ( dbcsAgentAddress , SNMP_ADDRESS_RESOLVE_VALUE ) )
  952. {
  953. t_Address = dbcsAgentAddress ;
  954. }
  955. else
  956. {
  957. if ( SnmpTransportIpAddress :: ValidateAddress ( dbcsAgentAddress , SNMP_ADDRESS_RESOLVE_NAME ) )
  958. {
  959. t_Address = dbcsAgentAddress ;
  960. }
  961. else
  962. {
  963. status = FALSE ;
  964. a_errorObject.SetStatus ( WBEM_SNMP_E_INVALID_TRANSPORTCONTEXT ) ;
  965. a_errorObject.SetWbemStatus ( WBEM_E_FAILED ) ;
  966. a_errorObject.SetMessage ( L"Illegal IP address value or unresolvable name for AgentAddress" ) ;
  967. }
  968. }
  969. }
  970. if ( status )
  971. {
  972. if ( _wcsicmp ( agentVersion , WBEM_AGENTSNMPVERSION_V1 ) == 0 )
  973. {
  974. session = new SnmpV1OverIp (
  975. t_Address ,
  976. SNMP_ADDRESS_RESOLVE_NAME | SNMP_ADDRESS_RESOLVE_VALUE ,
  977. dbcsAgentReadCommunityName ,
  978. agentRetryCount ,
  979. agentRetryTimeout ,
  980. agentMaxVarBindsPerPdu ,
  981. agentFlowControlWindowSize
  982. );
  983. if ( ! ( *session ) () )
  984. {
  985. delete session ;
  986. session = NULL ;
  987. status = FALSE ;
  988. a_errorObject.SetStatus ( WBEM_SNMP_E_TRANSPORT_ERROR ) ;
  989. a_errorObject.SetWbemStatus ( WBEM_E_FAILED ) ;
  990. a_errorObject.SetMessage ( L"Failed to get transport resources" ) ;
  991. }
  992. }
  993. else if ( _wcsicmp ( agentVersion , WBEM_AGENTSNMPVERSION_V2C ) == 0 )
  994. {
  995. session = new SnmpV2COverIp (
  996. t_Address ,
  997. SNMP_ADDRESS_RESOLVE_NAME | SNMP_ADDRESS_RESOLVE_VALUE ,
  998. dbcsAgentReadCommunityName ,
  999. agentRetryCount ,
  1000. agentRetryTimeout ,
  1001. agentMaxVarBindsPerPdu ,
  1002. agentFlowControlWindowSize
  1003. );
  1004. if ( ! ( *session ) () )
  1005. {
  1006. delete session ;
  1007. session = NULL ;
  1008. status = FALSE ;
  1009. a_errorObject.SetStatus ( WBEM_SNMP_E_TRANSPORT_ERROR ) ;
  1010. a_errorObject.SetWbemStatus ( WBEM_E_FAILED ) ;
  1011. a_errorObject.SetMessage ( L"Failed to get transport resources" ) ;
  1012. }
  1013. }
  1014. else
  1015. {
  1016. status = FALSE ;
  1017. a_errorObject.SetStatus ( WBEM_SNMP_E_INVALID_TRANSPORTCONTEXT ) ;
  1018. a_errorObject.SetWbemStatus ( WBEM_E_FAILED ) ;
  1019. a_errorObject.SetMessage ( L"Illegal value for qualifier: AgentSnmpVersion" ) ;
  1020. }
  1021. }
  1022. }
  1023. else if ( _wcsicmp ( agentTransport , WBEM_AGENTIPXTRANSPORT ) == 0 )
  1024. {
  1025. if ( ! SnmpTransportIpxAddress :: ValidateAddress ( dbcsAgentAddress ) )
  1026. {
  1027. status = FALSE ;
  1028. a_errorObject.SetStatus ( WBEM_SNMP_E_INVALID_TRANSPORTCONTEXT ) ;
  1029. a_errorObject.SetWbemStatus ( WBEM_E_FAILED ) ;
  1030. a_errorObject.SetMessage ( L"Illegal value for qualifier: AgentAddress" ) ;
  1031. }
  1032. if ( status )
  1033. {
  1034. if ( _wcsicmp ( agentVersion , WBEM_AGENTSNMPVERSION_V1 ) == 0 )
  1035. {
  1036. session = new SnmpV1OverIpx (
  1037. dbcsAgentAddress ,
  1038. dbcsAgentReadCommunityName ,
  1039. agentRetryCount ,
  1040. agentRetryTimeout ,
  1041. agentMaxVarBindsPerPdu ,
  1042. agentFlowControlWindowSize
  1043. );
  1044. if ( ! ( *session ) () )
  1045. {
  1046. delete session ;
  1047. session = NULL ;
  1048. status = FALSE ;
  1049. a_errorObject.SetStatus ( WBEM_SNMP_E_TRANSPORT_ERROR ) ;
  1050. a_errorObject.SetWbemStatus ( WBEM_E_FAILED ) ;
  1051. a_errorObject.SetMessage ( L"Failed to get transport resources" ) ;
  1052. }
  1053. }
  1054. else if ( _wcsicmp ( agentVersion , WBEM_AGENTSNMPVERSION_V2C ) == 0 )
  1055. {
  1056. session = new SnmpV2COverIpx (
  1057. dbcsAgentAddress ,
  1058. dbcsAgentReadCommunityName ,
  1059. agentRetryCount ,
  1060. agentRetryTimeout ,
  1061. agentMaxVarBindsPerPdu ,
  1062. agentFlowControlWindowSize
  1063. );
  1064. if ( ! ( *session ) () )
  1065. {
  1066. delete session ;
  1067. session = NULL ;
  1068. status = FALSE ;
  1069. a_errorObject.SetStatus ( WBEM_SNMP_E_TRANSPORT_ERROR ) ;
  1070. a_errorObject.SetWbemStatus ( WBEM_E_FAILED ) ;
  1071. a_errorObject.SetMessage ( L"Failed to get transport resources" ) ;
  1072. }
  1073. }
  1074. else
  1075. {
  1076. status = FALSE ;
  1077. a_errorObject.SetStatus ( WBEM_SNMP_E_INVALID_TRANSPORTCONTEXT ) ;
  1078. a_errorObject.SetWbemStatus ( WBEM_E_FAILED ) ;
  1079. a_errorObject.SetMessage ( L"Illegal value for qualifier: AgentSnmpVersion" ) ;
  1080. }
  1081. }
  1082. }
  1083. else
  1084. {
  1085. status = FALSE ;
  1086. a_errorObject.SetStatus ( WBEM_SNMP_E_INVALID_TRANSPORTCONTEXT ) ;
  1087. a_errorObject.SetWbemStatus ( WBEM_E_FAILED ) ;
  1088. a_errorObject.SetMessage ( L"Illegal value for qualifier: AgentTransport" ) ;
  1089. }
  1090. delete [] dbcsAgentReadCommunityName ;
  1091. }
  1092. else
  1093. {
  1094. status = FALSE ;
  1095. a_errorObject.SetStatus ( WBEM_SNMP_E_INVALID_TRANSPORTCONTEXT ) ;
  1096. a_errorObject.SetWbemStatus ( WBEM_E_FAILED ) ;
  1097. a_errorObject.SetMessage ( L"Illegal value for qualifier: AgentReadCommunityName" ) ;
  1098. }
  1099. delete [] dbcsAgentAddress ;
  1100. }
  1101. else
  1102. {
  1103. status = FALSE ;
  1104. a_errorObject.SetStatus ( WBEM_SNMP_E_INVALID_TRANSPORTCONTEXT ) ;
  1105. a_errorObject.SetWbemStatus ( WBEM_E_FAILED ) ;
  1106. a_errorObject.SetMessage ( L"Illegal value for qualifier: AgentAddress" ) ;
  1107. }
  1108. }
  1109. else
  1110. {
  1111. DebugMacro1(
  1112. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  1113. __FILE__,__LINE__,
  1114. L" TransportInformation settings invalid"
  1115. ) ;
  1116. )
  1117. }
  1118. delete [] agentTransport ;
  1119. delete [] agentAddress ;
  1120. delete [] agentVersion ;
  1121. delete [] agentReadCommunityName ;
  1122. namespaceQualifierObject->Release () ;
  1123. }
  1124. else
  1125. {
  1126. status = FALSE ;
  1127. a_errorObject.SetStatus ( WBEM_SNMP_E_PROVIDER_FAILURE ) ;
  1128. a_errorObject.SetWbemStatus ( WBEM_E_PROVIDER_FAILURE ) ;
  1129. a_errorObject.SetMessage ( L"Failed to get class qualifier set" ) ;
  1130. }
  1131. DebugMacro1(
  1132. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  1133. __FILE__,__LINE__,
  1134. L" SnmpClassEventObject :: GetTransportInformation () with Result (%lx)" ,
  1135. a_errorObject.GetWbemStatus ()
  1136. ) ;
  1137. )
  1138. return status ;
  1139. }
  1140. SnmpClassGetEventObject :: SnmpClassGetEventObject (
  1141. CImpClasProv *provider ,
  1142. BSTR Class ,
  1143. IWbemContext *a_Context
  1144. ) : SnmpClassEventObject ( provider , a_Context ) , m_classObject ( NULL ) , m_Received ( FALSE ) , m_Class ( NULL )
  1145. {
  1146. m_Class = UnicodeStringDuplicate ( Class ) ;
  1147. }
  1148. SnmpClassGetEventObject :: ~SnmpClassGetEventObject ()
  1149. {
  1150. if ( m_classObject )
  1151. m_classObject->Release () ;
  1152. delete [] m_Class ;
  1153. }
  1154. BOOL SnmpClassGetEventObject :: GetSnmpNotifyStatusObject ( IWbemClassObject **notifyObject )
  1155. {
  1156. WbemSnmpErrorObject errorStatusObject ;
  1157. /*
  1158. * Don't ask for SnmpNotifyStatus if HMOM specifically asked for SnmpNotifyStatus, otherwise
  1159. * we'll end up in a deadlock situation.
  1160. */
  1161. BOOL status = TRUE ;
  1162. if ( _wcsicmp ( m_Class , WBEM_CLASS_SNMPNOTIFYSTATUS ) == 0 )
  1163. {
  1164. status = GetNotifyStatusObject ( notifyObject ) ;
  1165. }
  1166. else
  1167. {
  1168. IWbemClassObject *notificationClassObject = NULL ;
  1169. IWbemClassObject *errorObject = NULL ;
  1170. if ( notificationClassObject = m_provider->GetSnmpNotificationObject ( errorStatusObject ) )
  1171. {
  1172. HRESULT result = notificationClassObject->SpawnInstance ( 0 , notifyObject ) ;
  1173. if ( SUCCEEDED ( result ) )
  1174. {
  1175. VARIANT variant ;
  1176. VariantInit ( &variant ) ;
  1177. variant.vt = VT_I4 ;
  1178. variant.lVal = m_errorObject.GetWbemStatus () ;
  1179. result = (*notifyObject)->Put ( WBEM_PROPERTY_STATUSCODE , 0 , & variant , 0 ) ;
  1180. VariantClear ( &variant ) ;
  1181. if ( SUCCEEDED ( result ) )
  1182. {
  1183. variant.vt = VT_I4 ;
  1184. variant.lVal = m_errorObject.GetStatus () ;
  1185. result = (*notifyObject)->Put ( WBEM_PROPERTY_SNMPSTATUSCODE , 0 , & variant , 0 ) ;
  1186. VariantClear ( &variant ) ;
  1187. if ( SUCCEEDED ( result ) )
  1188. {
  1189. if ( m_errorObject.GetMessage () )
  1190. {
  1191. variant.vt = VT_BSTR ;
  1192. variant.bstrVal = SysAllocString ( m_errorObject.GetMessage () ) ;
  1193. result = (*notifyObject)->Put ( WBEM_PROPERTY_SNMPSTATUSMESSAGE , 0 , & variant , 0 ) ;
  1194. VariantClear ( &variant ) ;
  1195. if ( ! SUCCEEDED ( result ) )
  1196. {
  1197. (*notifyObject)->Release () ;
  1198. status = GetNotifyStatusObject ( notifyObject ) ;
  1199. }
  1200. }
  1201. }
  1202. else
  1203. {
  1204. (*notifyObject)->Release () ;
  1205. status = GetNotifyStatusObject ( notifyObject ) ;
  1206. }
  1207. }
  1208. else
  1209. {
  1210. (*notifyObject)->Release () ;
  1211. status = GetNotifyStatusObject ( notifyObject ) ;
  1212. }
  1213. notificationClassObject->Release () ;
  1214. }
  1215. else
  1216. {
  1217. status = GetNotifyStatusObject ( notifyObject ) ;
  1218. }
  1219. }
  1220. else
  1221. {
  1222. status = GetNotifyStatusObject ( notifyObject ) ;
  1223. }
  1224. }
  1225. return status ;
  1226. }
  1227. BOOL SnmpClassGetEventObject :: ProcessCorrelatedClass ( WbemSnmpErrorObject &a_errorObject )
  1228. {
  1229. BOOL status = TRUE ;
  1230. IWbemQualifierSet *namespaceQualifierObject = NULL ;
  1231. HRESULT result = m_classObject->GetQualifierSet ( &namespaceQualifierObject ) ;
  1232. if ( SUCCEEDED ( result ) )
  1233. {
  1234. LONG attributeType ;
  1235. VARIANT variant ;
  1236. VariantInit ( & variant ) ;
  1237. result = namespaceQualifierObject->Get (
  1238. WBEM_QUALIFIER_GROUP_OBJECTID ,
  1239. 0,
  1240. &variant ,
  1241. & attributeType
  1242. ) ;
  1243. if ( SUCCEEDED ( result ) )
  1244. {
  1245. if ( variant.vt == VT_BSTR )
  1246. {
  1247. // Get Device Transport information
  1248. SnmpObjectIdentifierType objectIdentifier ( variant.bstrVal ) ;
  1249. if ( objectIdentifier.IsValid () )
  1250. {
  1251. SnmpSession *session ;
  1252. status = GetTransportInformation ( m_errorObject , session ) ;
  1253. if ( status )
  1254. {
  1255. #ifdef CORRELATOR_INIT
  1256. m_correlator = new SnmpCorrelation ( *session , this ) ;
  1257. #else //CORRELATOR_INIT
  1258. m_correlator = new SnmpCorrelation ( *session , this, m_Interrogator ) ;
  1259. #endif //CORRELATOR_INIT
  1260. char *groupObjectId = UnicodeToDbcsString ( variant.bstrVal ) ;
  1261. if ( groupObjectId )
  1262. {
  1263. m_inCallstack = TRUE ;
  1264. m_correlator->Start ( groupObjectId ) ;
  1265. if ( m_inCallstack == FALSE )
  1266. m_synchronousComplete = TRUE ;
  1267. m_inCallstack = FALSE ;
  1268. delete [] groupObjectId ;
  1269. }
  1270. else
  1271. {
  1272. status = FALSE ;
  1273. a_errorObject.SetStatus ( WBEM_SNMP_E_INVALID_QUALIFIER ) ;
  1274. a_errorObject.SetWbemStatus ( WBEM_E_FAILED ) ;
  1275. a_errorObject.SetMessage ( L"Illegal value for qualifier: group_objectid" ) ;
  1276. }
  1277. }
  1278. }
  1279. else
  1280. {
  1281. status = FALSE ;
  1282. a_errorObject.SetStatus ( WBEM_SNMP_E_TYPE_MISMATCH ) ;
  1283. a_errorObject.SetWbemStatus ( WBEM_E_FAILED ) ;
  1284. a_errorObject.SetMessage ( L"Type mismatch for qualifier: group_objectid" ) ;
  1285. }
  1286. }
  1287. else
  1288. {
  1289. status = FALSE ;
  1290. a_errorObject.SetStatus ( WBEM_SNMP_E_TYPE_MISMATCH ) ;
  1291. a_errorObject.SetWbemStatus ( WBEM_E_FAILED ) ;
  1292. a_errorObject.SetMessage ( L"Type mismatch for qualifier: group_objectid" ) ;
  1293. }
  1294. VariantClear ( & variant ) ;
  1295. }
  1296. else
  1297. {
  1298. status = FALSE ;
  1299. a_errorObject.SetStatus ( WBEM_SNMP_E_INVALID_OBJECT ) ;
  1300. a_errorObject.SetWbemStatus ( WBEM_E_NOT_FOUND ) ;
  1301. a_errorObject.SetMessage ( L"Class must specify valid qualifier for: group_objectid" ) ;
  1302. }
  1303. namespaceQualifierObject->Release () ;
  1304. }
  1305. else
  1306. {
  1307. status = FALSE ;
  1308. a_errorObject.SetStatus ( WBEM_SNMP_E_INVALID_OBJECT ) ;
  1309. a_errorObject.SetWbemStatus ( WBEM_E_FAILED ) ;
  1310. a_errorObject.SetMessage ( L"Failed to get Class qualifier set, must specify valid qualifier for: group_objectid" ) ;
  1311. }
  1312. return status ;
  1313. }
  1314. BOOL SnmpClassGetEventObject :: ProcessClass ( WbemSnmpErrorObject &a_errorObject )
  1315. {
  1316. DebugMacro1(
  1317. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  1318. __FILE__,__LINE__,
  1319. L"SnmpClassGetEventObject :: ProcessClass ( WbemSnmpErrorObject &a_errorObject )"
  1320. ) ;
  1321. )
  1322. BOOL status = TRUE ;
  1323. // Get Class definition from SMIR
  1324. IWbemClassObject *classObject = NULL ;
  1325. HRESULT result = GetClass ( m_errorObject , &m_classObject , m_Class ) ;
  1326. if ( SUCCEEDED ( result ) )
  1327. {
  1328. // Get Namespace object which contains Device Transport information/Also used for merge of class
  1329. status = GetNamespaceObject ( a_errorObject ) ;
  1330. if ( status )
  1331. {
  1332. if ( _wcsicmp ( m_Class , WBEM_CLASS_SNMPMACRO ) == 0 )
  1333. {
  1334. ReceiveClass ( m_classObject ) ;
  1335. m_synchronousComplete = TRUE ;
  1336. }
  1337. else if ( _wcsicmp ( m_Class , WBEM_CLASS_SNMPOBJECTTYPE ) == 0 )
  1338. {
  1339. ReceiveClass ( m_classObject ) ;
  1340. m_synchronousComplete = TRUE ;
  1341. }
  1342. else if ( _wcsicmp ( m_Class , WBEM_CLASS_SNMPNOTIFYSTATUS ) == 0 )
  1343. {
  1344. ReceiveClass ( m_classObject ) ;
  1345. m_synchronousComplete = TRUE ;
  1346. }
  1347. else if ( _wcsicmp ( m_Class , WBEM_CLASS_SNMPNOTIFICATION ) == 0 )
  1348. {
  1349. ReceiveClass ( m_classObject ) ;
  1350. m_synchronousComplete = TRUE ;
  1351. }
  1352. else if ( _wcsicmp ( m_Class , WBEM_CLASS_SNMPEXTENDEDNOTIFICATION ) == 0 )
  1353. {
  1354. ReceiveClass ( m_classObject ) ;
  1355. m_synchronousComplete = TRUE ;
  1356. }
  1357. else if ( _wcsicmp ( m_Class , WBEM_CLASS_SNMPVARBIND ) == 0 )
  1358. {
  1359. ReceiveClass ( m_classObject ) ;
  1360. m_synchronousComplete = TRUE ;
  1361. }
  1362. else
  1363. {
  1364. // Determine if I need to correlate
  1365. VARIANT t_Variant ;
  1366. VariantInit ( & t_Variant ) ;
  1367. result = m_classObject->Get ( L"__SUPERCLASS" , 0 , & t_Variant , NULL , NULL ) ;
  1368. BSTR t_Parent = t_Variant.bstrVal ;
  1369. if ( SUCCEEDED ( result ) && (t_Variant.vt == VT_BSTR) && (t_Parent != NULL) && (*t_Parent != L'\0'))
  1370. {
  1371. if ( _wcsicmp ( t_Parent , WBEM_CLASS_SNMPNOTIFICATION ) == 0 || _wcsicmp ( t_Parent , WBEM_CLASS_SNMPEXTENDEDNOTIFICATION ) == 0 )
  1372. {
  1373. ReceiveClass ( m_classObject ) ;
  1374. m_synchronousComplete = TRUE ;
  1375. }
  1376. else if (_wcsicmp ( t_Parent , WBEM_CLASS_SNMPOBJECTTYPE ) == 0)
  1377. {
  1378. if ( m_correlate )
  1379. {
  1380. status = ProcessCorrelatedClass ( a_errorObject ) ;
  1381. if ( !status )
  1382. {
  1383. m_synchronousComplete = TRUE ;
  1384. }
  1385. }
  1386. else
  1387. {
  1388. ReceiveClass ( m_classObject ) ;
  1389. m_synchronousComplete = TRUE ;
  1390. }
  1391. }
  1392. else
  1393. {
  1394. status = FALSE ;
  1395. a_errorObject.SetStatus ( WBEM_SNMP_E_NOT_FOUND ) ;
  1396. a_errorObject.SetWbemStatus ( WBEM_E_NOT_FOUND ) ;
  1397. a_errorObject.SetMessage ( L"This is not a supported SNMP class." ) ;
  1398. }
  1399. }
  1400. else
  1401. {
  1402. status = FALSE ;
  1403. a_errorObject.SetStatus ( WBEM_SNMP_E_NOT_FOUND ) ;
  1404. a_errorObject.SetWbemStatus ( WBEM_E_NOT_FOUND ) ;
  1405. a_errorObject.SetMessage ( L"Failed to get __SUPERCLASS property. This is not an SNMP base class." ) ;
  1406. }
  1407. VariantClear ( & t_Variant ) ;
  1408. }
  1409. }
  1410. }
  1411. else
  1412. {
  1413. //no need to set an error msg etc 'cos GetClass does it.
  1414. status = FALSE;
  1415. }
  1416. DebugMacro1(
  1417. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  1418. __FILE__,__LINE__,
  1419. L"Returning from SnmpClassGetEventObject :: ProcessClass ( WbemSnmpErrorObject &a_errorObject (%lx))" ,
  1420. a_errorObject.GetWbemStatus ()
  1421. ) ;
  1422. )
  1423. return status ;
  1424. }
  1425. void SnmpClassGetEventObject :: ReceiveGroup ( IN ISmirGroupHandle *phGroup )
  1426. {
  1427. DebugMacro1(
  1428. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  1429. __FILE__,__LINE__,
  1430. L"SnmpClassGetEventObject :: ReceiveGroup ( IN ISmirGroupHandle *phGroup )"
  1431. ) ;
  1432. )
  1433. ReceiveClass ( m_classObject ) ;
  1434. phGroup->Release () ;
  1435. DebugMacro1(
  1436. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  1437. __FILE__,__LINE__,
  1438. L"Returning from SnmpClassGetEventObject :: ReceiveGroup ( IN ISmirGroupHandle *phGroup )"
  1439. ) ;
  1440. )
  1441. }
  1442. SnmpClassGetAsyncEventObject :: SnmpClassGetAsyncEventObject (
  1443. CImpClasProv *provider ,
  1444. BSTR Class ,
  1445. IWbemObjectSink *notify ,
  1446. IWbemContext *a_Context
  1447. ) : SnmpClassGetEventObject ( provider , Class , a_Context ) ,
  1448. m_notificationHandler ( notify )
  1449. {
  1450. DebugMacro1(
  1451. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  1452. __FILE__,__LINE__,
  1453. L"SnmpClassGetAsyncEventObject :: SnmpClassGetAsyncEventObject ()"
  1454. ) ;
  1455. )
  1456. m_notificationHandler->AddRef () ;
  1457. }
  1458. SnmpClassGetAsyncEventObject :: ~SnmpClassGetAsyncEventObject ()
  1459. {
  1460. DebugMacro1(
  1461. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  1462. __FILE__,__LINE__,
  1463. L"SnmpClassGetAsyncEventObject :: ~SnmpClassGetAsyncEventObject ()"
  1464. ) ;
  1465. )
  1466. IWbemClassObject *notifyStatus = NULL;
  1467. if ( FAILED ( m_errorObject.GetWbemStatus () ) )
  1468. {
  1469. // Get Status object
  1470. BOOL status = GetSnmpNotifyStatusObject ( &notifyStatus ) ;
  1471. }
  1472. DebugMacro1(
  1473. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  1474. __FILE__,__LINE__,
  1475. L"Sending Status"
  1476. ) ;
  1477. )
  1478. HRESULT result = m_notificationHandler->SetStatus ( 0 , m_errorObject.GetWbemStatus () , NULL , notifyStatus ) ;
  1479. if ( notifyStatus )
  1480. {
  1481. notifyStatus->Release () ;
  1482. }
  1483. m_notificationHandler->Release () ;
  1484. DebugMacro1(
  1485. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  1486. __FILE__,__LINE__,
  1487. L"Returning from SnmpClassGetAsyncEventObject :: ~SnmpClassGetAsyncEventObject ()"
  1488. ) ;
  1489. )
  1490. }
  1491. void SnmpClassGetAsyncEventObject :: Process ()
  1492. {
  1493. DebugMacro1(
  1494. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  1495. __FILE__,__LINE__,
  1496. L"SnmpClassGetAsyncEventObject :: Process ()"
  1497. ) ;
  1498. )
  1499. if ( ! m_synchronousComplete )
  1500. {
  1501. BOOL status = ProcessClass ( m_errorObject ) ;
  1502. if ( status )
  1503. {
  1504. if ( m_synchronousComplete )
  1505. ReceiveComplete () ;
  1506. }
  1507. else
  1508. {
  1509. ReceiveComplete () ;
  1510. }
  1511. }
  1512. else
  1513. {
  1514. ReceiveComplete () ;
  1515. }
  1516. DebugMacro1(
  1517. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  1518. __FILE__,__LINE__,
  1519. L"Returning from SnmpClassGetAsyncEventObject :: Process ()"
  1520. ) ;
  1521. )
  1522. }
  1523. void SnmpClassGetAsyncEventObject :: ReceiveClass ( IWbemClassObject *classObject )
  1524. {
  1525. DebugMacro1(
  1526. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  1527. __FILE__,__LINE__,
  1528. L"SnmpClassGetAsyncEventObject :: ReceiveClass ( IWbemClassObject *classObject )"
  1529. ) ;
  1530. )
  1531. if ( ! m_Received )
  1532. {
  1533. m_Received = TRUE ;
  1534. m_notificationHandler->Indicate ( 1 , & m_classObject ) ;
  1535. }
  1536. }
  1537. void SnmpClassGetAsyncEventObject :: ReceiveComplete ()
  1538. {
  1539. DebugMacro1(
  1540. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  1541. __FILE__,__LINE__,
  1542. L"SnmpClassGetAsyncEventObject :: ReceiveComplete ()"
  1543. ) ;
  1544. )
  1545. if ( SUCCEEDED ( m_errorObject.GetWbemStatus () ) )
  1546. {
  1547. /*
  1548. * If no error specified yet then check for NOT_FOUND
  1549. */
  1550. if ( ! m_Received )
  1551. {
  1552. m_errorObject.SetStatus ( WBEM_SNMP_E_NOT_FOUND ) ;
  1553. m_errorObject.SetWbemStatus ( WBEM_E_NOT_FOUND ) ;
  1554. m_errorObject.SetMessage ( L"Class not defined" ) ;
  1555. }
  1556. }
  1557. /*
  1558. * Remove worker object from worker thread container
  1559. */
  1560. DebugMacro1(
  1561. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  1562. __FILE__,__LINE__,
  1563. L"Reaping Task"
  1564. ) ;
  1565. )
  1566. if ( ! m_inCallstack )
  1567. {
  1568. DebugMacro1(
  1569. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  1570. __FILE__,__LINE__,
  1571. L"Deleting (this)"
  1572. ) ;
  1573. )
  1574. Complete () ;
  1575. }
  1576. else
  1577. m_inCallstack = FALSE ;
  1578. DebugMacro1(
  1579. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  1580. __FILE__,__LINE__,
  1581. L"Returning from SnmpClassGetAsyncEventObject :: Receive4 ()"
  1582. ) ;
  1583. )
  1584. }
  1585. void SnmpClassGetAsyncEventObject :: ReceiveError ( IN const SnmpErrorReport &a_errorReport )
  1586. {
  1587. DebugMacro1(
  1588. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  1589. __FILE__,__LINE__,
  1590. L"SnmpClassEnumEventObject :: ReceiveError ( IN const SnmpErrorReport &a_errorReport )"
  1591. ) ;
  1592. )
  1593. switch ( a_errorReport.GetError () )
  1594. {
  1595. case Snmp_Error:
  1596. {
  1597. switch ( a_errorReport.GetStatus () )
  1598. {
  1599. case Snmp_No_Response:
  1600. {
  1601. m_errorObject.SetStatus ( WBEM_SNMP_E_TRANSPORT_NO_RESPONSE ) ;
  1602. m_errorObject.SetWbemStatus ( WBEM_E_FAILED ) ;
  1603. m_errorObject.SetMessage ( L"No Response from device" ) ;
  1604. }
  1605. break;
  1606. default:
  1607. {
  1608. m_errorObject.SetStatus ( WBEM_SNMP_E_TRANSPORT_ERROR ) ;
  1609. m_errorObject.SetWbemStatus ( WBEM_E_FAILED ) ;
  1610. m_errorObject.SetMessage ( L"Unknown transport failure" ) ;
  1611. }
  1612. break ;
  1613. }
  1614. }
  1615. break ;
  1616. default:
  1617. {
  1618. m_errorObject.SetStatus ( WBEM_SNMP_E_TRANSPORT_ERROR ) ;
  1619. m_errorObject.SetWbemStatus ( WBEM_E_FAILED ) ;
  1620. m_errorObject.SetMessage ( L"Unknown transport failure" ) ;
  1621. }
  1622. break ;
  1623. }
  1624. }
  1625. SnmpClassEnumEventObject :: SnmpClassEnumEventObject (
  1626. CImpClasProv *provider ,
  1627. BSTR Parent ,
  1628. ULONG flags ,
  1629. IWbemContext *a_Context
  1630. ) : SnmpClassEventObject ( provider , a_Context ) , m_Flags ( flags )
  1631. {
  1632. m_Parent = UnicodeStringDuplicate ( Parent ) ;
  1633. }
  1634. BOOL SnmpClassEnumEventObject :: ProcessClass ( WbemSnmpErrorObject &a_errorObject , BSTR a_Class )
  1635. {
  1636. DebugMacro1(
  1637. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  1638. __FILE__,__LINE__,
  1639. L"SnmpClassEnumEventObject :: ProcessClass ( WbemSnmpErrorObject &a_errorObject , BSTR a_Class = (%s) )" ,
  1640. a_Class
  1641. ) ;
  1642. )
  1643. BOOL status = TRUE ;
  1644. // Get Class definition from SMIR
  1645. IWbemClassObject *classObject = NULL ;
  1646. HRESULT result = GetClass ( a_errorObject , &classObject , a_Class ) ;
  1647. if ( SUCCEEDED ( result ) )
  1648. {
  1649. // Get Namespace object which contains Device Transport information/Also used for merge of class
  1650. status = GetNamespaceObject ( a_errorObject ) ;
  1651. if ( status )
  1652. {
  1653. ReceiveClass ( classObject ) ;
  1654. }
  1655. classObject->Release () ;
  1656. }
  1657. else
  1658. {
  1659. status = FALSE ;
  1660. a_errorObject.SetStatus ( WBEM_SNMP_E_NOT_FOUND ) ;
  1661. a_errorObject.SetWbemStatus ( WBEM_E_NOT_FOUND ) ;
  1662. a_errorObject.SetMessage ( L"Class not defined" ) ;
  1663. }
  1664. DebugMacro1(
  1665. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  1666. __FILE__,__LINE__,
  1667. L"Returning from SnmpClassEnumEventObject :: ProcessClass ( WbemSnmpErrorObject &a_errorObject , BSTR a_Class = (%s) )" ,
  1668. a_Class
  1669. ) ;
  1670. )
  1671. return status ;
  1672. }
  1673. SnmpClassEnumEventObject :: ~SnmpClassEnumEventObject ()
  1674. {
  1675. delete [] m_Parent ;
  1676. }
  1677. BOOL SnmpClassEnumEventObject :: GetEnumeration ( WbemSnmpErrorObject &a_errorObject )
  1678. {
  1679. DebugMacro1(
  1680. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  1681. __FILE__,__LINE__,
  1682. L"SnmpClassEnumEventObject :: GetEnumeration ( WbemSnmpErrorObject &a_errorObject )"
  1683. ) ;
  1684. )
  1685. BOOL status = GetNamespaceObject ( m_errorObject ) ;
  1686. if ( status )
  1687. {
  1688. // Determine if I need to correlate
  1689. if ( m_correlate )
  1690. {
  1691. DebugMacro1(
  1692. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  1693. __FILE__,__LINE__,
  1694. L"Performing Class Correlation"
  1695. ) ;
  1696. )
  1697. // Get Device Transport information
  1698. SnmpSession *session ;
  1699. status = GetTransportInformation ( m_errorObject , session ) ;
  1700. if ( status )
  1701. {
  1702. m_inCallstack = TRUE ;
  1703. #ifdef CORRELATOR_INIT
  1704. m_correlator = new SnmpCorrelation ( *session , this ) ;
  1705. #else //CORRELATOR_INIT
  1706. m_correlator = new SnmpCorrelation ( *session , this, m_Interrogator ) ;
  1707. #endif //CORRELATOR_INIT
  1708. m_correlator->Start ( NULL ) ;
  1709. if ( m_inCallstack == FALSE )
  1710. m_synchronousComplete = TRUE ;
  1711. m_inCallstack = FALSE ;
  1712. }
  1713. else
  1714. {
  1715. }
  1716. }
  1717. else
  1718. {
  1719. DebugMacro1(
  1720. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  1721. __FILE__,__LINE__,
  1722. L"Not Performing Class Correlation"
  1723. ) ;
  1724. )
  1725. ReceiveGroup ( NULL ) ;
  1726. m_synchronousComplete = TRUE ;
  1727. }
  1728. }
  1729. DebugMacro1(
  1730. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  1731. __FILE__,__LINE__,
  1732. L"Returning from SnmpClassEnumEventObject :: GetEnumeration ( WbemSnmpErrorObject &a_errorObject )"
  1733. ) ;
  1734. )
  1735. return status ;
  1736. }
  1737. BOOL SnmpClassEnumEventObject :: GetNotificationEnumeration ( WbemSnmpErrorObject &a_errorObject )
  1738. {
  1739. DebugMacro1(
  1740. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  1741. __FILE__,__LINE__,
  1742. L"SnmpClassEnumEventObject :: GetNotificationEnumeration ( WbemSnmpErrorObject &a_errorObject )"
  1743. ) ;
  1744. )
  1745. HRESULT result = S_OK ;
  1746. BOOL status = GetNamespaceObject ( m_errorObject ) ;
  1747. if ( status )
  1748. {
  1749. IWbemClassObject *classObject = NULL ;
  1750. IEnumNotificationClass *enumClass = NULL ;
  1751. ISmirNotificationClassHandle *classHandle = NULL ;
  1752. result = m_Interrogator->EnumAllNotificationClasses (
  1753. &enumClass
  1754. ) ;
  1755. if ( SUCCEEDED ( result ) )
  1756. {
  1757. ULONG fetched = 0 ;
  1758. enumClass->Reset () ;
  1759. while ( enumClass->Next ( 1 , & classHandle , &fetched ) == WBEM_NO_ERROR )
  1760. {
  1761. result = classHandle->GetWBEMNotificationClass ( & classObject ) ;
  1762. if ( SUCCEEDED ( result ) )
  1763. {
  1764. ReceiveClass ( classObject ) ;
  1765. classObject->Release () ;
  1766. }
  1767. classHandle->Release () ;
  1768. }
  1769. enumClass->Release () ;
  1770. }
  1771. else
  1772. {
  1773. }
  1774. }
  1775. DebugMacro1(
  1776. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  1777. __FILE__,__LINE__,
  1778. L"Returning from SnmpClassEnumEventObject :: GetNotificationEnumeration ( WbemSnmpErrorObject &a_errorObject )"
  1779. ) ;
  1780. )
  1781. return SUCCEEDED ( result ) ;
  1782. }
  1783. BOOL SnmpClassEnumEventObject :: GetExtendedNotificationEnumeration ( WbemSnmpErrorObject &a_errorObject )
  1784. {
  1785. DebugMacro1(
  1786. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  1787. __FILE__,__LINE__,
  1788. L"SnmpClassEnumEventObject :: GetExtendedNotificationEnumeration ( WbemSnmpErrorObject &a_errorObject )"
  1789. ) ;
  1790. )
  1791. HRESULT result = S_OK ;
  1792. BOOL status = GetNamespaceObject ( m_errorObject ) ;
  1793. if ( status )
  1794. {
  1795. IWbemClassObject *classObject = NULL ;
  1796. IEnumExtNotificationClass *enumClass = NULL ;
  1797. ISmirExtNotificationClassHandle *classHandle = NULL ;
  1798. result = m_Interrogator->EnumAllExtNotificationClasses (
  1799. &enumClass
  1800. ) ;
  1801. if ( SUCCEEDED ( result ) )
  1802. {
  1803. ULONG fetched = 0 ;
  1804. enumClass->Reset () ;
  1805. while ( enumClass->Next ( 1 , & classHandle , &fetched ) == WBEM_NO_ERROR )
  1806. {
  1807. result = classHandle->GetWBEMExtNotificationClass ( & classObject ) ;
  1808. if ( SUCCEEDED ( result ) )
  1809. {
  1810. ReceiveClass ( classObject ) ;
  1811. classObject->Release () ;
  1812. }
  1813. classHandle->Release () ;
  1814. }
  1815. enumClass->Release () ;
  1816. }
  1817. else
  1818. {
  1819. }
  1820. }
  1821. DebugMacro1(
  1822. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  1823. __FILE__,__LINE__,
  1824. L"Returning from SnmpClassEnumEventObject :: GetExtendedNotificationEnumeration ( WbemSnmpErrorObject &a_errorObject )"
  1825. ) ;
  1826. )
  1827. return SUCCEEDED ( result ) ;
  1828. }
  1829. BOOL SnmpClassEnumEventObject :: ProcessEnumeration ( WbemSnmpErrorObject &a_errorObject )
  1830. {
  1831. DebugMacro1(
  1832. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  1833. __FILE__,__LINE__,
  1834. L"SnmpClassEnumEventObject :: ProcessEnumeration ( WbemSnmpErrorObject &a_errorObject (%s) )" ,
  1835. m_Parent
  1836. ) ;
  1837. )
  1838. BOOL status = TRUE ;
  1839. // Get Namespace object which contains Device Transport information/Also used for merge of class
  1840. if ( m_Flags & WBEM_FLAG_SHALLOW )
  1841. {
  1842. if ( ( ! m_Parent ) || _wcsicmp ( m_Parent , WBEM_CLASS_NULL ) == 0 )
  1843. {
  1844. status = ProcessClass ( a_errorObject , WBEM_CLASS_SNMPMACRO ) ;
  1845. status = status && ProcessClass ( a_errorObject , WBEM_CLASS_SNMPVARBIND ) ;
  1846. m_synchronousComplete = TRUE ;
  1847. }
  1848. else if ( _wcsicmp ( m_Parent , WBEM_CLASS_SNMPMACRO ) == 0 )
  1849. {
  1850. status = ProcessClass ( a_errorObject , WBEM_CLASS_SNMPOBJECTTYPE ) ;
  1851. m_synchronousComplete = TRUE ;
  1852. }
  1853. else if ( _wcsicmp ( m_Parent , WBEM_CLASS_SNMPOBJECTTYPE ) == 0 )
  1854. {
  1855. status = GetEnumeration ( a_errorObject ) ;
  1856. }
  1857. else if ( _wcsicmp ( m_Parent , WBEM_CLASS_NOTIFYSTATUS ) == 0 )
  1858. {
  1859. status = ProcessClass ( a_errorObject , WBEM_CLASS_SNMPNOTIFYSTATUS ) ;
  1860. m_synchronousComplete = TRUE ;
  1861. }
  1862. else if ( _wcsicmp ( m_Parent , WBEM_CLASS_EXTRINSICEVENT ) == 0 )
  1863. {
  1864. status = ProcessClass ( a_errorObject , WBEM_CLASS_SNMPNOTIFICATION ) ;
  1865. status = status & ProcessClass ( a_errorObject , WBEM_CLASS_SNMPEXTENDEDNOTIFICATION ) ;
  1866. m_synchronousComplete = TRUE ;
  1867. }
  1868. else if ( _wcsicmp ( m_Parent , WBEM_CLASS_SNMPNOTIFICATION ) == 0 )
  1869. {
  1870. status = GetNotificationEnumeration ( a_errorObject ) ;
  1871. m_synchronousComplete = TRUE ;
  1872. }
  1873. else if ( _wcsicmp ( m_Parent , WBEM_CLASS_SNMPEXTENDEDNOTIFICATION ) == 0 )
  1874. {
  1875. status = GetExtendedNotificationEnumeration ( a_errorObject ) ;
  1876. m_synchronousComplete = TRUE ;
  1877. }
  1878. else
  1879. {
  1880. // Get Class definition from SMIR
  1881. IWbemClassObject *classObject = NULL ;
  1882. HRESULT result = GetClass ( a_errorObject , &classObject , m_Parent ) ;
  1883. if ( SUCCEEDED ( result ) )
  1884. {
  1885. classObject->Release () ;
  1886. m_synchronousComplete = TRUE ;
  1887. status = TRUE ;
  1888. }
  1889. else
  1890. {
  1891. status = FALSE ;
  1892. a_errorObject.SetStatus ( WBEM_SNMP_E_NOT_FOUND ) ;
  1893. a_errorObject.SetWbemStatus ( WBEM_E_NOT_FOUND ) ;
  1894. a_errorObject.SetMessage ( L"Parent class not known" ) ;
  1895. m_synchronousComplete = TRUE ;
  1896. }
  1897. }
  1898. }
  1899. else
  1900. {
  1901. if ( ( ! m_Parent ) || _wcsicmp ( m_Parent , WBEM_CLASS_NULL ) == 0 )
  1902. {
  1903. status = ProcessClass ( a_errorObject , WBEM_CLASS_SNMPMACRO ) ;
  1904. if ( status )
  1905. {
  1906. status = ProcessClass ( a_errorObject , WBEM_CLASS_SNMPOBJECTTYPE ) ;
  1907. if ( status )
  1908. {
  1909. status = ProcessClass ( a_errorObject , WBEM_CLASS_SNMPNOTIFYSTATUS ) ;
  1910. if ( status )
  1911. {
  1912. status = ProcessClass ( a_errorObject , WBEM_CLASS_SNMPVARBIND ) ;
  1913. if ( status )
  1914. {
  1915. status = ProcessClass ( a_errorObject , WBEM_CLASS_SNMPNOTIFICATION ) ;
  1916. if ( status )
  1917. {
  1918. status = ProcessClass ( a_errorObject , WBEM_CLASS_SNMPEXTENDEDNOTIFICATION ) ;
  1919. if ( status )
  1920. {
  1921. status = GetNotificationEnumeration ( a_errorObject ) ;
  1922. if ( status )
  1923. {
  1924. status = GetExtendedNotificationEnumeration ( a_errorObject ) ;
  1925. if ( status )
  1926. {
  1927. status = GetEnumeration ( a_errorObject ) ;
  1928. }
  1929. }
  1930. }
  1931. }
  1932. }
  1933. }
  1934. }
  1935. }
  1936. }
  1937. else if ( _wcsicmp ( m_Parent , WBEM_CLASS_SNMPMACRO ) == 0 )
  1938. {
  1939. status = ProcessClass ( a_errorObject , WBEM_CLASS_SNMPOBJECTTYPE ) ;
  1940. if ( status )
  1941. {
  1942. status = GetEnumeration ( a_errorObject ) ;
  1943. }
  1944. }
  1945. else if ( _wcsicmp ( m_Parent , WBEM_CLASS_SNMPOBJECTTYPE ) == 0 )
  1946. {
  1947. status = GetEnumeration ( a_errorObject ) ;
  1948. }
  1949. else if ( _wcsicmp ( m_Parent , WBEM_CLASS_EXTRINSICEVENT ) == 0 )
  1950. {
  1951. status = GetNotificationEnumeration ( a_errorObject ) ;
  1952. if ( status )
  1953. {
  1954. status = GetExtendedNotificationEnumeration ( a_errorObject ) ;
  1955. }
  1956. m_synchronousComplete = TRUE ;
  1957. }
  1958. else
  1959. {
  1960. // Get Class definition from SMIR
  1961. IWbemClassObject *classObject = NULL ;
  1962. HRESULT result = GetClass ( a_errorObject , &classObject , m_Parent ) ;
  1963. if ( SUCCEEDED ( result ) )
  1964. {
  1965. classObject->Release () ;
  1966. m_synchronousComplete = TRUE ;
  1967. status = TRUE ;
  1968. }
  1969. else
  1970. {
  1971. status = FALSE ;
  1972. a_errorObject.SetStatus ( WBEM_SNMP_E_NOT_FOUND ) ;
  1973. a_errorObject.SetWbemStatus ( WBEM_E_NOT_FOUND ) ;
  1974. a_errorObject.SetMessage ( L"Parent class not known" ) ;
  1975. m_synchronousComplete = TRUE ;
  1976. }
  1977. }
  1978. }
  1979. DebugMacro1(
  1980. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  1981. __FILE__,__LINE__,
  1982. L"Returning from SnmpClassEnumEventObject :: ProcessEnumeration ( WbemSnmpErrorObject &a_errorObject (%s))" ,
  1983. m_Parent
  1984. ) ;
  1985. )
  1986. return status ;
  1987. }
  1988. void SnmpClassEnumEventObject :: ReceiveGroup ( IN ISmirGroupHandle *phGroup )
  1989. {
  1990. DebugMacro1(
  1991. if ( phGroup )
  1992. {
  1993. BSTR t_ModuleName = NULL ;
  1994. BSTR t_GroupOID = NULL ;
  1995. phGroup->GetModuleName ( &t_ModuleName ) ;
  1996. phGroup->GetGroupOID ( &t_GroupOID ) ;
  1997. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  1998. __FILE__,__LINE__,
  1999. L"SnmpClassEnumEventObject :: ReceiveGroup ( IN ISmirGroupHandle *phGroup = ((%s),(%s)) )" ,
  2000. t_ModuleName ,
  2001. t_GroupOID
  2002. ) ;
  2003. SysFreeString ( t_ModuleName ) ;
  2004. SysFreeString ( t_GroupOID ) ;
  2005. }
  2006. else
  2007. {
  2008. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  2009. __FILE__,__LINE__,
  2010. L"SnmpClassEnumEventObject :: ReceiveGroup ( IN ISmirGroupHandle *phGroup = NULL )"
  2011. ) ;
  2012. }
  2013. )
  2014. HRESULT result = S_OK ;
  2015. m_GroupsReceived ++ ;
  2016. IWbemClassObject *classObject = NULL ;
  2017. IEnumClass *enumClass = NULL ;
  2018. ISmirClassHandle *classHandle = NULL ;
  2019. if ( phGroup )
  2020. {
  2021. result = m_Interrogator->EnumClassesInGroup (
  2022. &enumClass ,
  2023. phGroup
  2024. ) ;
  2025. }
  2026. else
  2027. {
  2028. result = m_Interrogator->EnumAllClasses (
  2029. &enumClass
  2030. ) ;
  2031. }
  2032. if ( SUCCEEDED ( result ) )
  2033. {
  2034. ULONG fetched = 0 ;
  2035. enumClass->Reset () ;
  2036. while ( enumClass->Next ( 1 , & classHandle , &fetched ) == WBEM_NO_ERROR )
  2037. {
  2038. result = classHandle->GetWBEMClass ( & classObject ) ;
  2039. if ( SUCCEEDED ( result ) )
  2040. {
  2041. ReceiveClass ( classObject ) ;
  2042. classObject->Release () ;
  2043. }
  2044. classHandle->Release () ;
  2045. }
  2046. enumClass->Release () ;
  2047. }
  2048. else
  2049. {
  2050. }
  2051. if ( phGroup )
  2052. {
  2053. phGroup->Release () ;
  2054. }
  2055. DebugMacro1(
  2056. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  2057. __FILE__,__LINE__,
  2058. L"Returning from SnmpClassEnumEventObject :: ReceiveGroup ( IN ISmirGroupHandle *phGroup )"
  2059. ) ;
  2060. )
  2061. }
  2062. SnmpClassEnumAsyncEventObject :: SnmpClassEnumAsyncEventObject (
  2063. CImpClasProv *provider ,
  2064. BSTR Parent ,
  2065. ULONG flags ,
  2066. IWbemObjectSink *notify ,
  2067. IWbemContext *a_Context
  2068. ) : SnmpClassEnumEventObject ( provider , Parent , flags , a_Context ) ,
  2069. m_notificationHandler ( notify )
  2070. {
  2071. DebugMacro1(
  2072. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  2073. __FILE__,__LINE__,
  2074. L"SnmpClassEnumAsyncEventObject :: SnmpClassEnumAsyncEventObject ()"
  2075. ) ;
  2076. )
  2077. m_notificationHandler->AddRef () ;
  2078. }
  2079. SnmpClassEnumAsyncEventObject :: ~SnmpClassEnumAsyncEventObject ()
  2080. {
  2081. DebugMacro1(
  2082. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  2083. __FILE__,__LINE__,
  2084. L"SnmpClassEnumAsyncEventObject :: ~SnmpClassEnumAsyncEventObject ()"
  2085. ) ;
  2086. )
  2087. // Get Status object
  2088. IWbemClassObject *notifyStatus = NULL;
  2089. if ( FAILED ( m_errorObject.GetWbemStatus () ) )
  2090. {
  2091. BOOL status = GetSnmpNotifyStatusObject ( &notifyStatus ) ;
  2092. }
  2093. DebugMacro1(
  2094. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  2095. __FILE__,__LINE__,
  2096. L"Sending Status"
  2097. ) ;
  2098. )
  2099. HRESULT result = m_notificationHandler->SetStatus ( 0 , m_errorObject.GetWbemStatus () , NULL , notifyStatus ) ;
  2100. if ( notifyStatus )
  2101. {
  2102. notifyStatus->Release () ;
  2103. }
  2104. m_notificationHandler->Release () ;
  2105. DebugMacro1(
  2106. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  2107. __FILE__,__LINE__,
  2108. L"Returning from SnmpClassEnumAsyncEventObject :: ~SnmpClassEnumAsyncEventObject ()"
  2109. ) ;
  2110. )
  2111. }
  2112. void SnmpClassEnumAsyncEventObject :: Process ()
  2113. {
  2114. DebugMacro1(
  2115. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  2116. __FILE__,__LINE__,
  2117. L"SnmpClassEnumAsyncEventObject :: Process ()"
  2118. ) ;
  2119. )
  2120. if ( ! m_synchronousComplete )
  2121. {
  2122. BOOL status = ProcessEnumeration ( m_errorObject ) ;
  2123. if ( status )
  2124. {
  2125. if ( m_synchronousComplete )
  2126. ReceiveComplete () ;
  2127. }
  2128. else
  2129. {
  2130. ReceiveComplete () ;
  2131. }
  2132. }
  2133. else
  2134. {
  2135. ReceiveComplete () ;
  2136. }
  2137. DebugMacro1(
  2138. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  2139. __FILE__,__LINE__,
  2140. L"Returning from SnmpClassEnumAsyncEventObject :: Process ()"
  2141. ) ;
  2142. )
  2143. }
  2144. void SnmpClassEnumAsyncEventObject :: ReceiveClass ( IWbemClassObject *classObject )
  2145. {
  2146. DebugMacro1(
  2147. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  2148. __FILE__,__LINE__,
  2149. L"SnmpClassEnumAsyncEventObject :: ReceiveClass ()"
  2150. ) ;
  2151. )
  2152. m_notificationHandler->Indicate ( 1, & classObject ) ;
  2153. }
  2154. void SnmpClassEnumAsyncEventObject :: ReceiveError ( IN const SnmpErrorReport &errorReport )
  2155. {
  2156. DebugMacro1(
  2157. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  2158. __FILE__,__LINE__,
  2159. L"SnmpClassEnumAsyncEventObject :: ReceiveError ()"
  2160. ) ;
  2161. )
  2162. switch ( errorReport.GetError () )
  2163. {
  2164. case Snmp_Error:
  2165. {
  2166. switch ( errorReport.GetStatus () )
  2167. {
  2168. case Snmp_No_Response:
  2169. {
  2170. m_errorObject.SetStatus ( WBEM_SNMP_E_TRANSPORT_NO_RESPONSE ) ;
  2171. m_errorObject.SetWbemStatus ( WBEM_E_FAILED ) ;
  2172. m_errorObject.SetMessage ( L"No Response from device" ) ;
  2173. }
  2174. break;
  2175. default:
  2176. {
  2177. m_errorObject.SetStatus ( WBEM_SNMP_E_TRANSPORT_ERROR ) ;
  2178. m_errorObject.SetWbemStatus ( WBEM_E_FAILED ) ;
  2179. m_errorObject.SetMessage ( L"Unknown transport failure" ) ;
  2180. }
  2181. break ;
  2182. }
  2183. }
  2184. break ;
  2185. default:
  2186. {
  2187. m_errorObject.SetStatus ( WBEM_SNMP_E_TRANSPORT_ERROR ) ;
  2188. m_errorObject.SetWbemStatus ( WBEM_E_FAILED ) ;
  2189. m_errorObject.SetMessage ( L"Unknown transport failure" ) ;
  2190. }
  2191. break ;
  2192. }
  2193. }
  2194. void SnmpClassEnumAsyncEventObject :: ReceiveComplete ()
  2195. {
  2196. DebugMacro1(
  2197. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  2198. __FILE__,__LINE__,
  2199. L"SnmpClassEnumAsyncEventObject :: ReceiveComplete ()"
  2200. ) ;
  2201. )
  2202. if ( SUCCEEDED ( m_errorObject.GetWbemStatus () ) )
  2203. {
  2204. }
  2205. else
  2206. {
  2207. if ( m_GroupsReceived )
  2208. {
  2209. if ( FAILED ( m_errorObject.GetWbemStatus () ) )
  2210. {
  2211. if ( m_errorObject.GetStatus () == WBEM_SNMP_E_TRANSPORT_NO_RESPONSE )
  2212. {
  2213. m_errorObject.SetWbemStatus ( WBEM_S_TIMEDOUT ) ;
  2214. }
  2215. }
  2216. }
  2217. }
  2218. /*
  2219. * Remove worker object from worker thread container
  2220. */
  2221. DebugMacro1(
  2222. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  2223. __FILE__,__LINE__,
  2224. L"Reaping Task"
  2225. ) ;
  2226. )
  2227. if ( ! m_inCallstack )
  2228. {
  2229. DebugMacro1(
  2230. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  2231. __FILE__,__LINE__,
  2232. L"Deleting (this)"
  2233. ) ;
  2234. )
  2235. Complete () ;
  2236. }
  2237. else
  2238. m_inCallstack = FALSE ;
  2239. DebugMacro1(
  2240. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  2241. __FILE__,__LINE__,
  2242. L"Returning from SnmpClassEnumAsyncEventObject :: ReceiveComplete ()"
  2243. ) ;
  2244. )
  2245. }