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.

2190 lines
52 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 <snmptempl.h>
  15. #include <snmpmt.h>
  16. #include <typeinfo.h>
  17. #include <process.h>
  18. #include <objbase.h>
  19. #include <stdio.h>
  20. #include <wbemidl.h>
  21. #include "classfac.h"
  22. #include "guids.h"
  23. #include <snmpcont.h>
  24. #include <snmpevt.h>
  25. #include <snmpthrd.h>
  26. #include <snmplog.h>
  27. #include <snmpcl.h>
  28. #include <instpath.h>
  29. #include <snmptype.h>
  30. #include <snmpauto.h>
  31. #include <snmpobj.h>
  32. #include <genlex.h>
  33. #include <sql_1.h>
  34. #include <objpath.h>
  35. #include <provtree.h>
  36. #include <provdnf.h>
  37. #include "propprov.h"
  38. #include "propsnmp.h"
  39. #include "propget.h"
  40. #include "propset.h"
  41. #include "propdel.h"
  42. #include "propinst.h"
  43. #include "propquery.h"
  44. #include "snmpget.h"
  45. #include "snmpnext.h"
  46. SnmpClassObject :: SnmpClassObject (
  47. const SnmpClassObject & snmpClassObject
  48. ) : WbemSnmpClassObject ( snmpClassObject ) ,
  49. snmpVersion ( snmpClassObject.snmpVersion ) ,
  50. m_accessible ( snmpClassObject.m_accessible ) ,
  51. m_parentOperation ( snmpClassObject.m_parentOperation )
  52. {
  53. }
  54. SnmpClassObject :: SnmpClassObject (
  55. SnmpResponseEventObject *parentOperation
  56. ) : snmpVersion ( 0 ) ,
  57. m_accessible ( FALSE ) ,
  58. m_parentOperation ( parentOperation )
  59. {
  60. }
  61. SnmpClassObject :: ~SnmpClassObject ()
  62. {
  63. }
  64. SnmpResponseEventObject :: SnmpResponseEventObject (
  65. CImpPropProv *providerArg ,
  66. IWbemContext *a_Context
  67. ) : provider ( providerArg ) , m_namespaceObject ( NULL ) , m_Context ( a_Context ) , m_agentVersion ( 0 )
  68. {
  69. if ( m_Context )
  70. {
  71. m_Context->AddRef () ;
  72. VARIANT t_Variant ;
  73. VariantInit ( & t_Variant ) ;
  74. t_Variant.vt = VT_BOOL ;
  75. t_Variant.boolVal = VARIANT_FALSE ;
  76. m_Context->SetValue ( WBEM_CLASS_CORRELATE_CONTEXT_PROP , 0 , &t_Variant ) ;
  77. VariantClear ( &t_Variant ) ;
  78. }
  79. if ( provider )
  80. provider->AddRef () ;
  81. }
  82. SnmpResponseEventObject :: ~SnmpResponseEventObject ()
  83. {
  84. if ( m_Context )
  85. m_Context->Release () ;
  86. if ( provider )
  87. provider->Release () ;
  88. if ( m_namespaceObject )
  89. m_namespaceObject->Release () ;
  90. }
  91. BOOL SnmpResponseEventObject :: HasNonNullKeys ( IWbemClassObject *a_Obj )
  92. {
  93. HRESULT hr = WBEM_E_INVALID_PARAMETER;
  94. if ( a_Obj )
  95. {
  96. hr = a_Obj->BeginEnumeration ( WBEM_FLAG_KEYS_ONLY ) ;
  97. if ( SUCCEEDED ( hr ) )
  98. {
  99. VARIANT t_vVal ;
  100. VariantInit ( &t_vVal ) ;
  101. //returns WBEM_S_NO_ERROR or WBEM_S_NO_MORE_DATA on success
  102. hr = a_Obj->Next( 0, NULL, &t_vVal, NULL, NULL ) ;
  103. while ( hr == WBEM_S_NO_ERROR )
  104. {
  105. if ( t_vVal.vt == VT_NULL )
  106. {
  107. hr = WBEM_E_FAILED ;
  108. }
  109. VariantClear ( &t_vVal ) ;
  110. VariantInit ( &t_vVal ) ;
  111. if ( hr != WBEM_E_FAILED )
  112. {
  113. hr = a_Obj->Next( 0, NULL, &t_vVal, NULL, NULL ) ;
  114. }
  115. }
  116. VariantClear ( &t_vVal ) ;
  117. a_Obj->EndEnumeration () ;
  118. }
  119. }
  120. return SUCCEEDED ( hr ) ;
  121. }
  122. BOOL SnmpResponseEventObject :: GetNamespaceObject ( WbemSnmpErrorObject &a_errorObject )
  123. {
  124. BOOL status = TRUE ;
  125. IWbemServices *parentServer = provider->GetParentServer () ;
  126. wchar_t *objectPathPrefix = UnicodeStringAppend ( WBEM_NAMESPACE_EQUALS , provider->GetThisNamespace () ) ;
  127. wchar_t *objectPath = UnicodeStringAppend ( objectPathPrefix , WBEM_NAMESPACE_QUOTE ) ;
  128. delete [] objectPathPrefix ;
  129. BSTR t_Path = SysAllocString ( objectPath ) ;
  130. HRESULT result = parentServer->GetObject (
  131. t_Path ,
  132. 0 ,
  133. m_Context ,
  134. &m_namespaceObject ,
  135. NULL
  136. ) ;
  137. SysFreeString ( t_Path ) ;
  138. if ( SUCCEEDED ( result ) )
  139. {
  140. }
  141. else
  142. {
  143. status = FALSE ;
  144. a_errorObject.SetStatus ( WBEM_SNMP_ERROR_CRITICAL_ERROR ) ;
  145. a_errorObject.SetWbemStatus ( WBEM_ERROR_CRITICAL_ERROR ) ;
  146. a_errorObject.SetMessage ( L"Failed to obtain namespace object" ) ;
  147. }
  148. parentServer->Release () ;
  149. delete [] objectPath ;
  150. return status ;
  151. }
  152. BOOL SnmpResponseEventObject :: GetSnmpNotifyStatusObject ( IWbemClassObject **notifyObject )
  153. {
  154. IWbemClassObject *notificationClassObject = NULL ;
  155. IWbemClassObject *errorObject = NULL ;
  156. BOOL status = TRUE ;
  157. WbemSnmpErrorObject errorStatusObject ;
  158. if ( notificationClassObject = provider->GetSnmpNotificationObject ( errorStatusObject ) )
  159. {
  160. HRESULT result = notificationClassObject->SpawnInstance ( 0 , notifyObject ) ;
  161. if ( SUCCEEDED ( result ) )
  162. {
  163. VARIANT variant ;
  164. VariantInit ( &variant ) ;
  165. variant.vt = VT_I4 ;
  166. variant.lVal = m_errorObject.GetWbemStatus () ;
  167. result = (*notifyObject)->Put ( WBEM_PROPERTY_STATUSCODE , 0 , & variant , 0 ) ;
  168. VariantClear ( &variant ) ;
  169. if ( SUCCEEDED ( result ) )
  170. {
  171. variant.vt = VT_I4 ;
  172. variant.lVal = m_errorObject.GetStatus () ;
  173. result = (*notifyObject)->Put ( WBEM_PROPERTY_SNMPSTATUSCODE , 0 , & variant , 0 ) ;
  174. VariantClear ( &variant ) ;
  175. if ( SUCCEEDED ( result ) )
  176. {
  177. if ( m_errorObject.GetMessage () )
  178. {
  179. variant.vt = VT_BSTR ;
  180. variant.bstrVal = SysAllocString ( m_errorObject.GetMessage () ) ;
  181. result = (*notifyObject)->Put ( WBEM_PROPERTY_SNMPSTATUSMESSAGE , 0 , & variant , 0 ) ;
  182. VariantClear ( &variant ) ;
  183. if ( ! SUCCEEDED ( result ) )
  184. {
  185. (*notifyObject)->Release () ;
  186. status = GetNotifyStatusObject ( notifyObject ) ;
  187. }
  188. }
  189. }
  190. else
  191. {
  192. (*notifyObject)->Release () ;
  193. status = GetNotifyStatusObject ( notifyObject ) ;
  194. }
  195. }
  196. else
  197. {
  198. (*notifyObject)->Release () ;
  199. status = GetNotifyStatusObject ( notifyObject ) ;
  200. }
  201. notificationClassObject->Release () ;
  202. }
  203. else
  204. {
  205. status = GetNotifyStatusObject ( notifyObject ) ;
  206. }
  207. }
  208. else
  209. {
  210. status = GetNotifyStatusObject ( notifyObject ) ;
  211. }
  212. return status ;
  213. }
  214. BOOL SnmpResponseEventObject :: GetNotifyStatusObject ( IWbemClassObject **notifyObject )
  215. {
  216. IWbemClassObject *notificationClassObject = NULL ;
  217. BOOL status = TRUE ;
  218. WbemSnmpErrorObject errorStatusObject ;
  219. if ( notificationClassObject = provider->GetNotificationObject ( errorStatusObject ) )
  220. {
  221. HRESULT result = notificationClassObject->SpawnInstance ( 0 , notifyObject ) ;
  222. if ( SUCCEEDED ( result ) )
  223. {
  224. VARIANT variant ;
  225. VariantInit ( &variant ) ;
  226. variant.vt = VT_I4 ;
  227. variant.lVal = m_errorObject.GetWbemStatus () ;
  228. result = (*notifyObject)->Put ( WBEM_PROPERTY_STATUSCODE , 0 , & variant , 0 ) ;
  229. if ( SUCCEEDED ( result ) )
  230. {
  231. if ( m_errorObject.GetMessage () )
  232. {
  233. variant.vt = VT_BSTR ;
  234. variant.bstrVal = SysAllocString ( m_errorObject.GetMessage () ) ;
  235. result = (*notifyObject)->Put ( WBEM_PROPERTY_SNMPSTATUSMESSAGE , 0 , & variant , 0 ) ;
  236. VariantClear ( &variant ) ;
  237. if ( ! SUCCEEDED ( result ) )
  238. {
  239. status = FALSE ;
  240. (*notifyObject)->Release () ;
  241. (*notifyObject)=NULL ;
  242. }
  243. }
  244. }
  245. else
  246. {
  247. (*notifyObject)->Release () ;
  248. (*notifyObject)=NULL ;
  249. status = FALSE ;
  250. }
  251. VariantClear ( &variant ) ;
  252. notificationClassObject->Release () ;
  253. }
  254. else
  255. {
  256. status = FALSE ;
  257. }
  258. }
  259. else
  260. {
  261. status = FALSE ;
  262. }
  263. return status ;
  264. }
  265. BOOL SnmpResponseEventObject :: GetAgentTransport (
  266. WbemSnmpErrorObject &a_errorObject ,
  267. IWbemQualifierSet *namespaceQualifierObject ,
  268. wchar_t *&agentTransport
  269. )
  270. {
  271. BOOL status = TRUE ;
  272. agentTransport = NULL ;
  273. BSTR t_Transport = NULL ;
  274. wchar_t *t_QualifierTransport = NULL ;
  275. VARIANT t_Variant ;
  276. VariantInit ( & t_Variant ) ;
  277. if ( m_Context )
  278. {
  279. HRESULT result = m_Context->GetValue ( WBEM_QUALIFIER_AGENTTRANSPORT , 0 , & t_Variant ) ;
  280. if ( SUCCEEDED ( result ) & ( t_Variant.vt != VT_EMPTY ) )
  281. {
  282. if ( t_Variant.vt == VT_BSTR )
  283. {
  284. t_Transport = t_Variant.bstrVal ;
  285. }
  286. else
  287. {
  288. status = FALSE ;
  289. a_errorObject.SetStatus ( WBEM_SNMP_E_TYPE_MISMATCH ) ;
  290. a_errorObject.SetWbemStatus ( WBEM_E_FAILED ) ;
  291. a_errorObject.SetMessage ( L"Type mismatch for qualifier: AgentTransport" ) ;
  292. }
  293. }
  294. }
  295. if ( status & ! t_Transport )
  296. {
  297. WbemSnmpQualifier *qualifier = GetSnmpClassObject ()->FindQualifier ( WBEM_QUALIFIER_AGENTTRANSPORT ) ;
  298. if ( qualifier )
  299. {
  300. SnmpInstanceType *value = qualifier->GetValue () ;
  301. if ( typeid ( *value ) == typeid ( SnmpDisplayStringType ) )
  302. {
  303. SnmpDisplayStringType *stringType = ( SnmpDisplayStringType * ) value ;
  304. t_Transport = t_QualifierTransport = stringType->GetValue () ;
  305. if ( t_QualifierTransport )
  306. {
  307. }
  308. else
  309. {
  310. status = FALSE ;
  311. a_errorObject.SetStatus ( WBEM_SNMP_E_INVALID_QUALIFIER ) ;
  312. a_errorObject.SetWbemStatus ( WBEM_E_FAILED ) ;
  313. a_errorObject.SetMessage ( L"Type mismatch for qualifier: AgentTransport" ) ;
  314. }
  315. }
  316. else
  317. {
  318. status = FALSE ;
  319. a_errorObject.SetStatus ( WBEM_SNMP_E_INVALID_QUALIFIER ) ;
  320. a_errorObject.SetWbemStatus ( WBEM_E_FAILED ) ;
  321. a_errorObject.SetMessage ( L"Type mismatch for qualifier: AgentTransport" ) ;
  322. }
  323. }
  324. }
  325. if ( status & ! t_Transport )
  326. {
  327. LONG attributeType ;
  328. HRESULT result = namespaceQualifierObject->Get (
  329. WBEM_QUALIFIER_AGENTTRANSPORT ,
  330. 0,
  331. &t_Variant ,
  332. & attributeType
  333. ) ;
  334. if ( SUCCEEDED ( result ) )
  335. {
  336. if ( t_Variant.vt == VT_BSTR )
  337. {
  338. t_Transport = t_Variant.bstrVal ;
  339. }
  340. else
  341. {
  342. status = FALSE ;
  343. a_errorObject.SetStatus ( WBEM_SNMP_E_TYPE_MISMATCH ) ;
  344. a_errorObject.SetWbemStatus ( WBEM_E_FAILED ) ;
  345. a_errorObject.SetMessage ( L"Type mismatch for qualifier: AgentTransport" ) ;
  346. }
  347. }
  348. else
  349. {
  350. t_Transport = WBEM_AGENTIPTRANSPORT ;
  351. }
  352. }
  353. if ( status )
  354. {
  355. if ( ( _wcsicmp ( t_Transport , WBEM_AGENTIPTRANSPORT ) == 0 ) || ( _wcsicmp ( t_Transport , WBEM_AGENTIPXTRANSPORT ) == 0 ) )
  356. {
  357. agentTransport = UnicodeStringDuplicate ( t_Transport ) ;
  358. }
  359. else
  360. {
  361. /*
  362. * Transport type != IP || != IPX
  363. */
  364. status = FALSE ;
  365. a_errorObject.SetStatus ( WBEM_SNMP_E_INVALID_TRANSPORT ) ;
  366. a_errorObject.SetWbemStatus ( WBEM_E_FAILED ) ;
  367. a_errorObject.SetMessage ( L"Illegal value for qualifier: AgentTransport" ) ;
  368. }
  369. }
  370. VariantClear ( & t_Variant );
  371. delete [] t_QualifierTransport ;
  372. if ( status )
  373. {
  374. DebugMacro3(
  375. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  376. __FILE__,__LINE__,
  377. L"Using AgentTransport ( %s ) " , agentTransport
  378. ) ;
  379. )
  380. }
  381. return status ;
  382. }
  383. ULONG SnmpResponseEventObject :: SetAgentVersion (
  384. WbemSnmpErrorObject &a_errorObject
  385. )
  386. {
  387. BOOL status = TRUE ;
  388. if (m_agentVersion == 0)
  389. {
  390. BSTR t_Version = NULL ;
  391. wchar_t *t_QualifierVersion = NULL ;
  392. VARIANT t_Variant ;
  393. VariantInit ( & t_Variant ) ;
  394. if ( m_Context )
  395. {
  396. HRESULT result = m_Context->GetValue ( WBEM_QUALIFIER_AGENTSNMPVERSION , 0 , & t_Variant ) ;
  397. if ( SUCCEEDED ( result ) & ( t_Variant.vt != VT_EMPTY ) )
  398. {
  399. if ( t_Variant.vt == VT_BSTR )
  400. {
  401. t_Version = t_Variant.bstrVal ;
  402. }
  403. else
  404. {
  405. status = FALSE ;
  406. a_errorObject.SetStatus ( WBEM_SNMP_E_TYPE_MISMATCH ) ;
  407. a_errorObject.SetWbemStatus ( WBEM_E_FAILED ) ;
  408. a_errorObject.SetMessage ( L"Type mismatch for qualifier: AgentSNMPVersion" ) ;
  409. }
  410. }
  411. }
  412. if ( status & ! t_Version )
  413. {
  414. WbemSnmpQualifier *qualifier = GetSnmpClassObject ()->FindQualifier ( WBEM_QUALIFIER_AGENTSNMPVERSION ) ;
  415. if ( qualifier )
  416. {
  417. SnmpInstanceType *value = qualifier->GetValue () ;
  418. if ( typeid ( *value ) == typeid ( SnmpDisplayStringType ) )
  419. {
  420. SnmpDisplayStringType *stringType = ( SnmpDisplayStringType * ) value ;
  421. t_Version = t_QualifierVersion = stringType->GetValue () ;
  422. if ( t_QualifierVersion )
  423. {
  424. }
  425. else
  426. {
  427. status = FALSE ;
  428. a_errorObject.SetStatus ( WBEM_SNMP_E_INVALID_QUALIFIER ) ;
  429. a_errorObject.SetWbemStatus ( WBEM_E_FAILED ) ;
  430. a_errorObject.SetMessage ( L"Type mismatch for qualifier: AgentSNMPVersion" ) ;
  431. }
  432. }
  433. else
  434. {
  435. status = FALSE ;
  436. a_errorObject.SetStatus ( WBEM_SNMP_E_INVALID_QUALIFIER ) ;
  437. a_errorObject.SetWbemStatus ( WBEM_E_FAILED ) ;
  438. a_errorObject.SetMessage ( L"Type mismatch for qualifier: AgentSNMPVersion" ) ;
  439. }
  440. }
  441. }
  442. if ( status & ! t_Version )
  443. {
  444. if ( ! m_namespaceObject )
  445. {
  446. status = GetNamespaceObject ( a_errorObject ) ;
  447. }
  448. if ( status )
  449. {
  450. IWbemQualifierSet *namespaceQualifierObject = NULL ;
  451. HRESULT result = m_namespaceObject->GetQualifierSet ( &namespaceQualifierObject ) ;
  452. if ( SUCCEEDED ( result ) )
  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. namespaceQualifierObject->Release();
  480. }
  481. }
  482. }
  483. if ( status )
  484. {
  485. if ( _wcsicmp ( t_Version , WBEM_AGENTSNMPVERSION_V1 ) == 0 )
  486. {
  487. m_agentVersion = 1 ;
  488. }
  489. else if ( _wcsicmp ( t_Version , WBEM_AGENTSNMPVERSION_V2C ) == 0 )
  490. {
  491. m_agentVersion = 2 ;
  492. }
  493. else
  494. {
  495. status = FALSE ;
  496. a_errorObject.SetStatus ( WBEM_SNMP_E_TYPE_MISMATCH ) ;
  497. a_errorObject.SetWbemStatus ( WBEM_E_FAILED ) ;
  498. a_errorObject.SetMessage ( L"Type/Value mismatch for qualifier: AgentSNMPVersion" ) ;
  499. }
  500. }
  501. VariantClear ( & t_Variant );
  502. delete [] t_QualifierVersion ;
  503. }
  504. if ( status )
  505. {
  506. DebugMacro3(
  507. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  508. __FILE__,__LINE__,
  509. L"Using AgentVersion ( %d ) " , m_agentVersion
  510. ) ;
  511. )
  512. }
  513. return m_agentVersion ;
  514. }
  515. BOOL SnmpResponseEventObject :: GetAgentAddress (
  516. WbemSnmpErrorObject &a_errorObject ,
  517. IWbemQualifierSet *namespaceQualifierObject ,
  518. wchar_t *&agentAddress
  519. )
  520. {
  521. BOOL status = TRUE ;
  522. agentAddress = NULL ;
  523. BSTR t_Address = NULL ;
  524. wchar_t *t_QualifierAddress = NULL ;
  525. VARIANT t_Variant ;
  526. VariantInit ( & t_Variant ) ;
  527. if ( m_Context )
  528. {
  529. HRESULT result = m_Context->GetValue ( WBEM_QUALIFIER_AGENTADDRESS , 0 , & t_Variant ) ;
  530. if ( SUCCEEDED ( result ) & ( t_Variant.vt != VT_EMPTY ) )
  531. {
  532. if ( t_Variant.vt == VT_BSTR )
  533. {
  534. t_Address = t_Variant.bstrVal ;
  535. if ( wcscmp ( t_Address , L"" ) == 0 )
  536. {
  537. status = FALSE ;
  538. a_errorObject.SetStatus ( WBEM_SNMP_E_TYPE_MISMATCH ) ;
  539. a_errorObject.SetWbemStatus ( WBEM_E_FAILED ) ;
  540. a_errorObject.SetMessage ( L"Type mismatch for qualifier: AgentAddress" ) ;
  541. }
  542. }
  543. else
  544. {
  545. status = FALSE ;
  546. a_errorObject.SetStatus ( WBEM_SNMP_E_TYPE_MISMATCH ) ;
  547. a_errorObject.SetWbemStatus ( WBEM_E_FAILED ) ;
  548. a_errorObject.SetMessage ( L"Type mismatch for qualifier: AgentAddress" ) ;
  549. }
  550. }
  551. }
  552. if ( status & ! t_Address )
  553. {
  554. WbemSnmpQualifier *qualifier = GetSnmpClassObject ()->FindQualifier ( WBEM_QUALIFIER_AGENTADDRESS ) ;
  555. if ( qualifier )
  556. {
  557. SnmpInstanceType *value = qualifier->GetValue () ;
  558. if ( typeid ( *value ) == typeid ( SnmpDisplayStringType ) )
  559. {
  560. SnmpDisplayStringType *stringType = ( SnmpDisplayStringType * ) value ;
  561. t_Address = t_QualifierAddress = stringType->GetValue () ;
  562. if ( t_QualifierAddress )
  563. {
  564. if ( wcscmp ( t_Address , L"" ) == 0 )
  565. {
  566. status = FALSE ;
  567. a_errorObject.SetStatus ( WBEM_SNMP_E_TYPE_MISMATCH ) ;
  568. a_errorObject.SetWbemStatus ( WBEM_E_FAILED ) ;
  569. a_errorObject.SetMessage ( L"Type mismatch for qualifier: AgentAddress" ) ;
  570. }
  571. }
  572. else
  573. {
  574. status = FALSE ;
  575. a_errorObject.SetStatus ( WBEM_SNMP_E_INVALID_QUALIFIER ) ;
  576. a_errorObject.SetWbemStatus ( WBEM_E_FAILED ) ;
  577. a_errorObject.SetMessage ( L"Type mismatch for qualifier: AgentAddress" ) ;
  578. }
  579. }
  580. else
  581. {
  582. status = FALSE ;
  583. a_errorObject.SetStatus ( WBEM_SNMP_E_INVALID_QUALIFIER ) ;
  584. a_errorObject.SetWbemStatus ( WBEM_E_FAILED ) ;
  585. a_errorObject.SetMessage ( L"Type mismatch for qualifier: AgentAddress" ) ;
  586. }
  587. }
  588. }
  589. if ( status & ! t_Address )
  590. {
  591. LONG attributeType ;
  592. HRESULT result = namespaceQualifierObject->Get (
  593. WBEM_QUALIFIER_AGENTADDRESS ,
  594. 0,
  595. &t_Variant ,
  596. & attributeType
  597. ) ;
  598. if ( SUCCEEDED ( result ) )
  599. {
  600. if ( t_Variant.vt == VT_BSTR )
  601. {
  602. t_Address = t_Variant.bstrVal ;
  603. if ( wcscmp ( t_Address , L"" ) == 0 )
  604. {
  605. status = FALSE ;
  606. a_errorObject.SetStatus ( WBEM_SNMP_E_TYPE_MISMATCH ) ;
  607. a_errorObject.SetWbemStatus ( WBEM_E_FAILED ) ;
  608. a_errorObject.SetMessage ( L"Type mismatch for qualifier: AgentAddress" ) ;
  609. }
  610. }
  611. else
  612. {
  613. status = FALSE ;
  614. a_errorObject.SetStatus ( WBEM_SNMP_E_TYPE_MISMATCH ) ;
  615. a_errorObject.SetWbemStatus ( WBEM_E_FAILED ) ;
  616. a_errorObject.SetMessage ( L"Type mismatch for qualifier: AgentAddress" ) ;
  617. }
  618. }
  619. else
  620. {
  621. status = FALSE ;
  622. a_errorObject.SetStatus ( WBEM_SNMP_E_INVALID_TRANSPORTCONTEXT ) ;
  623. a_errorObject.SetWbemStatus ( WBEM_E_FAILED ) ;
  624. a_errorObject.SetMessage ( L"Namespace must specify valid qualifier for: AgentAddress" ) ;
  625. }
  626. }
  627. if ( status )
  628. {
  629. agentAddress = UnicodeStringDuplicate ( t_Address ) ;
  630. }
  631. VariantClear ( & t_Variant );
  632. delete [] t_QualifierAddress ;
  633. if ( status )
  634. {
  635. DebugMacro3(
  636. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  637. __FILE__,__LINE__,
  638. L"Using AgentAddress ( %s ) " , agentAddress
  639. ) ;
  640. )
  641. }
  642. return status ;
  643. }
  644. BOOL SnmpResponseEventObject :: GetAgentReadCommunityName (
  645. WbemSnmpErrorObject &a_errorObject ,
  646. IWbemQualifierSet *namespaceQualifierObject ,
  647. wchar_t *&agentReadCommunityName
  648. )
  649. {
  650. BOOL status = TRUE ;
  651. agentReadCommunityName = NULL ;
  652. BSTR t_Community = NULL ;
  653. wchar_t *t_QualifierCommunity = NULL ;
  654. VARIANT t_Variant ;
  655. VariantInit ( & t_Variant ) ;
  656. if ( m_Context )
  657. {
  658. HRESULT result = m_Context->GetValue ( WBEM_QUALIFIER_AGENTREADCOMMUNITYNAME , 0 , & t_Variant ) ;
  659. if ( SUCCEEDED ( result ) & ( t_Variant.vt != VT_EMPTY ) )
  660. {
  661. if ( t_Variant.vt == VT_BSTR )
  662. {
  663. t_Community = t_Variant.bstrVal ;
  664. }
  665. else
  666. {
  667. status = FALSE ;
  668. a_errorObject.SetStatus ( WBEM_SNMP_E_TYPE_MISMATCH ) ;
  669. a_errorObject.SetWbemStatus ( WBEM_E_FAILED ) ;
  670. a_errorObject.SetMessage ( L"Type mismatch for qualifier: AgentReadCommunityName" ) ;
  671. }
  672. }
  673. }
  674. if ( status & ! t_Community )
  675. {
  676. WbemSnmpQualifier *qualifier = GetSnmpClassObject ()->FindQualifier ( WBEM_QUALIFIER_AGENTREADCOMMUNITYNAME ) ;
  677. if ( qualifier )
  678. {
  679. SnmpInstanceType *value = qualifier->GetValue () ;
  680. if ( typeid ( *value ) == typeid ( SnmpDisplayStringType ) )
  681. {
  682. SnmpDisplayStringType *stringType = ( SnmpDisplayStringType * ) value ;
  683. t_Community = t_QualifierCommunity = stringType->GetValue () ;
  684. if ( t_QualifierCommunity )
  685. {
  686. }
  687. else
  688. {
  689. status = FALSE ;
  690. a_errorObject.SetStatus ( WBEM_SNMP_E_INVALID_QUALIFIER ) ;
  691. a_errorObject.SetWbemStatus ( WBEM_E_FAILED ) ;
  692. a_errorObject.SetMessage ( L"Type mismatch for qualifier: AgentReadCommunityName" ) ;
  693. }
  694. }
  695. else
  696. {
  697. status = FALSE ;
  698. a_errorObject.SetStatus ( WBEM_SNMP_E_INVALID_QUALIFIER ) ;
  699. a_errorObject.SetWbemStatus ( WBEM_E_FAILED ) ;
  700. a_errorObject.SetMessage ( L"Type mismatch for qualifier: AgentReadCommunityName" ) ;
  701. }
  702. }
  703. }
  704. if ( status & ! t_Community )
  705. {
  706. LONG attributeType ;
  707. HRESULT result = namespaceQualifierObject->Get (
  708. WBEM_QUALIFIER_AGENTREADCOMMUNITYNAME ,
  709. 0,
  710. &t_Variant ,
  711. & attributeType
  712. ) ;
  713. if ( SUCCEEDED ( result ) )
  714. {
  715. if ( t_Variant.vt == VT_BSTR )
  716. {
  717. t_Community = t_Variant.bstrVal ;
  718. }
  719. else
  720. {
  721. status = FALSE ;
  722. a_errorObject.SetStatus ( WBEM_SNMP_E_TYPE_MISMATCH ) ;
  723. a_errorObject.SetWbemStatus ( WBEM_E_FAILED ) ;
  724. a_errorObject.SetMessage ( L"Type mismatch for qualifier: AgentReadCommunityName" ) ;
  725. }
  726. }
  727. else
  728. {
  729. t_Community = WBEM_AGENTCOMMUNITYNAME ;
  730. }
  731. }
  732. if ( status )
  733. {
  734. agentReadCommunityName = UnicodeStringDuplicate ( t_Community ) ;
  735. }
  736. VariantClear ( & t_Variant );
  737. delete [] t_QualifierCommunity ;
  738. if ( status )
  739. {
  740. DebugMacro3(
  741. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  742. __FILE__,__LINE__,
  743. L"Using AgentReadCommunityName ( %s ) " , agentReadCommunityName
  744. ) ;
  745. )
  746. }
  747. return status ;
  748. }
  749. BOOL SnmpResponseEventObject :: GetAgentWriteCommunityName (
  750. WbemSnmpErrorObject &a_errorObject ,
  751. IWbemQualifierSet *namespaceQualifierObject ,
  752. wchar_t *&agentWriteCommunityName
  753. )
  754. {
  755. BOOL status = TRUE ;
  756. agentWriteCommunityName = NULL ;
  757. BSTR t_Community = NULL ;
  758. wchar_t *t_QualifierCommunity = NULL ;
  759. VARIANT t_Variant ;
  760. VariantInit ( & t_Variant ) ;
  761. if ( m_Context )
  762. {
  763. HRESULT result = m_Context->GetValue ( WBEM_QUALIFIER_AGENTWRITECOMMUNITYNAME , 0 , & t_Variant ) ;
  764. if ( SUCCEEDED ( result ) & ( t_Variant.vt != VT_EMPTY ) )
  765. {
  766. if ( t_Variant.vt == VT_BSTR )
  767. {
  768. t_Community = t_Variant.bstrVal ;
  769. }
  770. else
  771. {
  772. status = FALSE ;
  773. a_errorObject.SetStatus ( WBEM_SNMP_E_TYPE_MISMATCH ) ;
  774. a_errorObject.SetWbemStatus ( WBEM_E_FAILED ) ;
  775. a_errorObject.SetMessage ( L"Type mismatch for qualifier: AgentWriteCommunityName" ) ;
  776. }
  777. }
  778. }
  779. if ( status & ! t_Community )
  780. {
  781. WbemSnmpQualifier *qualifier = GetSnmpClassObject ()->FindQualifier ( WBEM_QUALIFIER_AGENTWRITECOMMUNITYNAME ) ;
  782. if ( qualifier )
  783. {
  784. SnmpInstanceType *value = qualifier->GetValue () ;
  785. if ( typeid ( *value ) == typeid ( SnmpDisplayStringType ) )
  786. {
  787. SnmpDisplayStringType *stringType = ( SnmpDisplayStringType * ) value ;
  788. t_Community = t_QualifierCommunity = stringType->GetValue () ;
  789. if ( t_QualifierCommunity )
  790. {
  791. }
  792. else
  793. {
  794. status = FALSE ;
  795. a_errorObject.SetStatus ( WBEM_SNMP_E_INVALID_QUALIFIER ) ;
  796. a_errorObject.SetWbemStatus ( WBEM_E_FAILED ) ;
  797. a_errorObject.SetMessage ( L"Type mismatch for qualifier: AgentWriteCommunityName" ) ;
  798. }
  799. }
  800. else
  801. {
  802. status = FALSE ;
  803. a_errorObject.SetStatus ( WBEM_SNMP_E_INVALID_QUALIFIER ) ;
  804. a_errorObject.SetWbemStatus ( WBEM_E_FAILED ) ;
  805. a_errorObject.SetMessage ( L"Type mismatch for qualifier: AgentWriteCommunityName" ) ;
  806. }
  807. }
  808. }
  809. if ( status & ! t_Community )
  810. {
  811. LONG attributeType ;
  812. HRESULT result = namespaceQualifierObject->Get (
  813. WBEM_QUALIFIER_AGENTWRITECOMMUNITYNAME ,
  814. 0,
  815. &t_Variant ,
  816. & attributeType
  817. ) ;
  818. if ( SUCCEEDED ( result ) )
  819. {
  820. if ( t_Variant.vt == VT_BSTR )
  821. {
  822. t_Community = t_Variant.bstrVal ;
  823. }
  824. else
  825. {
  826. status = FALSE ;
  827. a_errorObject.SetStatus ( WBEM_SNMP_E_TYPE_MISMATCH ) ;
  828. a_errorObject.SetWbemStatus ( WBEM_E_FAILED ) ;
  829. a_errorObject.SetMessage ( L"Type mismatch for qualifier: AgentWriteCommunityName" ) ;
  830. }
  831. }
  832. else
  833. {
  834. t_Community = WBEM_AGENTCOMMUNITYNAME ;
  835. }
  836. }
  837. if ( status )
  838. {
  839. agentWriteCommunityName = UnicodeStringDuplicate ( t_Community ) ;
  840. }
  841. VariantClear ( & t_Variant );
  842. delete [] t_QualifierCommunity ;
  843. if ( status )
  844. {
  845. DebugMacro3(
  846. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  847. __FILE__,__LINE__,
  848. L"Using AgentWriteCommunityName ( %s ) " , agentWriteCommunityName
  849. ) ;
  850. )
  851. }
  852. return status ;
  853. }
  854. BOOL SnmpResponseEventObject :: GetAgentRetryCount (
  855. WbemSnmpErrorObject &a_errorObject ,
  856. IWbemQualifierSet *namespaceQualifierObject ,
  857. ULONG &agentRetryCount
  858. )
  859. {
  860. BOOL status = TRUE ;
  861. agentRetryCount = 1 ;
  862. BOOL t_RetryCount = FALSE ;
  863. VARIANT t_Variant ;
  864. VariantInit ( & t_Variant ) ;
  865. if ( m_Context )
  866. {
  867. HRESULT result = m_Context->GetValue ( WBEM_QUALIFIER_AGENTRETRYCOUNT , 0 , & t_Variant ) ;
  868. if ( SUCCEEDED ( result ) & ( t_Variant.vt != VT_EMPTY ) )
  869. {
  870. if ( t_Variant.vt == VT_I4 )
  871. {
  872. t_RetryCount = TRUE ;
  873. agentRetryCount = t_Variant.lVal ;
  874. }
  875. else
  876. {
  877. status = FALSE ;
  878. a_errorObject.SetStatus ( WBEM_SNMP_E_TYPE_MISMATCH ) ;
  879. a_errorObject.SetWbemStatus ( WBEM_E_FAILED ) ;
  880. a_errorObject.SetMessage ( L"Type mismatch for qualifier: AgentRetryCount" ) ;
  881. }
  882. }
  883. }
  884. if ( status & ! t_RetryCount )
  885. {
  886. WbemSnmpQualifier *qualifier = GetSnmpClassObject ()->FindQualifier ( WBEM_QUALIFIER_AGENTRETRYCOUNT ) ;
  887. if ( qualifier )
  888. {
  889. SnmpInstanceType *value = qualifier->GetValue () ;
  890. if ( typeid ( *value ) == typeid ( SnmpIntegerType ) )
  891. {
  892. SnmpIntegerType *integerType = ( SnmpIntegerType * ) value ;
  893. agentRetryCount = integerType->GetValue () ;
  894. }
  895. else
  896. {
  897. status = FALSE ;
  898. a_errorObject.SetStatus ( WBEM_SNMP_E_TYPE_MISMATCH ) ;
  899. a_errorObject.SetWbemStatus ( WBEM_E_FAILED ) ;
  900. a_errorObject.SetMessage ( L"Type mismatch for qualifier: AgentRetryCount" ) ;
  901. }
  902. }
  903. }
  904. if ( status & ! t_RetryCount )
  905. {
  906. LONG attributeType ;
  907. HRESULT result = namespaceQualifierObject->Get (
  908. WBEM_QUALIFIER_AGENTRETRYCOUNT ,
  909. 0,
  910. &t_Variant ,
  911. & attributeType
  912. ) ;
  913. if ( SUCCEEDED ( result ) )
  914. {
  915. if ( t_Variant.vt == VT_I4 )
  916. {
  917. agentRetryCount = t_Variant.lVal ;
  918. }
  919. else
  920. {
  921. status = FALSE ;
  922. a_errorObject.SetStatus ( WBEM_SNMP_E_TYPE_MISMATCH ) ;
  923. a_errorObject.SetWbemStatus ( WBEM_E_FAILED ) ;
  924. a_errorObject.SetMessage ( L"Type mismatch for qualifier: AgentRetryCount" ) ;
  925. }
  926. }
  927. }
  928. VariantClear ( & t_Variant );
  929. if ( status )
  930. {
  931. DebugMacro3(
  932. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  933. __FILE__,__LINE__,
  934. L"Using AgentRetryCount ( %ld ) " , agentRetryCount
  935. ) ;
  936. )
  937. }
  938. return status ;
  939. }
  940. BOOL SnmpResponseEventObject :: GetAgentRetryTimeout(
  941. WbemSnmpErrorObject &a_errorObject ,
  942. IWbemQualifierSet *namespaceQualifierObject ,
  943. ULONG &agentRetryTimeout
  944. )
  945. {
  946. BOOL status = TRUE ;
  947. agentRetryTimeout = 0 ;
  948. BOOL t_RetryTimeout = FALSE ;
  949. VARIANT t_Variant ;
  950. VariantInit ( & t_Variant ) ;
  951. if ( m_Context )
  952. {
  953. HRESULT result = m_Context->GetValue ( WBEM_QUALIFIER_AGENTRETRYTIMEOUT , 0 , & t_Variant ) ;
  954. if ( SUCCEEDED ( result ) & ( t_Variant.vt != VT_EMPTY ) )
  955. {
  956. if ( t_Variant.vt == VT_I4 )
  957. {
  958. t_RetryTimeout = TRUE ;
  959. agentRetryTimeout = t_Variant.lVal ;
  960. }
  961. else
  962. {
  963. status = FALSE ;
  964. a_errorObject.SetStatus ( WBEM_SNMP_E_TYPE_MISMATCH ) ;
  965. a_errorObject.SetWbemStatus ( WBEM_E_FAILED ) ;
  966. a_errorObject.SetMessage ( L"Type mismatch for qualifier: AgentRetryTimeout" ) ;
  967. }
  968. }
  969. }
  970. if ( status & ! t_RetryTimeout )
  971. {
  972. WbemSnmpQualifier *qualifier = GetSnmpClassObject ()->FindQualifier ( WBEM_QUALIFIER_AGENTRETRYTIMEOUT ) ;
  973. if ( qualifier )
  974. {
  975. SnmpInstanceType *value = qualifier->GetValue () ;
  976. if ( typeid ( *value ) == typeid ( SnmpIntegerType ) )
  977. {
  978. SnmpIntegerType *integerType = ( SnmpIntegerType * ) value ;
  979. agentRetryTimeout = integerType->GetValue () ;
  980. }
  981. else
  982. {
  983. status = FALSE ;
  984. a_errorObject.SetStatus ( WBEM_SNMP_E_TYPE_MISMATCH ) ;
  985. a_errorObject.SetWbemStatus ( WBEM_E_FAILED ) ;
  986. a_errorObject.SetMessage ( L"Type mismatch for qualifier: AgentRetryTimeout" ) ;
  987. }
  988. }
  989. }
  990. if ( status & ! t_RetryTimeout )
  991. {
  992. LONG attributeType ;
  993. HRESULT result = namespaceQualifierObject->Get (
  994. WBEM_QUALIFIER_AGENTRETRYTIMEOUT ,
  995. 0,
  996. &t_Variant ,
  997. & attributeType
  998. ) ;
  999. if ( SUCCEEDED ( result ) )
  1000. {
  1001. if ( t_Variant.vt == VT_I4 )
  1002. {
  1003. agentRetryTimeout = t_Variant.lVal ;
  1004. }
  1005. else
  1006. {
  1007. status = FALSE ;
  1008. a_errorObject.SetStatus ( WBEM_SNMP_E_TYPE_MISMATCH ) ;
  1009. a_errorObject.SetWbemStatus ( WBEM_E_FAILED ) ;
  1010. a_errorObject.SetMessage ( L"Type mismatch for qualifier: AgentRetryTimeout" ) ;
  1011. }
  1012. }
  1013. }
  1014. VariantClear ( & t_Variant );
  1015. if ( status )
  1016. {
  1017. DebugMacro3(
  1018. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  1019. __FILE__,__LINE__,
  1020. L"Using AgentRetryTimeout ( %ld ) " , agentRetryTimeout
  1021. ) ;
  1022. )
  1023. }
  1024. return status ;
  1025. }
  1026. BOOL SnmpResponseEventObject :: GetAgentMaxVarBindsPerPdu (
  1027. WbemSnmpErrorObject &a_errorObject ,
  1028. IWbemQualifierSet *namespaceQualifierObject ,
  1029. ULONG &agentVarBindsPerPdu
  1030. )
  1031. {
  1032. BOOL status = TRUE ;
  1033. agentVarBindsPerPdu = 0 ;
  1034. BOOL t_VarBinds = FALSE ;
  1035. VARIANT t_Variant ;
  1036. VariantInit ( & t_Variant ) ;
  1037. if ( m_Context )
  1038. {
  1039. HRESULT result = m_Context->GetValue ( WBEM_QUALIFIER_AGENTVARBINDSPERPDU , 0 , & t_Variant ) ;
  1040. if ( SUCCEEDED ( result ) & ( t_Variant.vt != VT_EMPTY ) )
  1041. {
  1042. if ( t_Variant.vt == VT_I4 )
  1043. {
  1044. t_VarBinds = TRUE ;
  1045. agentVarBindsPerPdu = t_Variant.lVal ;
  1046. }
  1047. else
  1048. {
  1049. status = FALSE ;
  1050. a_errorObject.SetStatus ( WBEM_SNMP_E_TYPE_MISMATCH ) ;
  1051. a_errorObject.SetWbemStatus ( WBEM_E_FAILED ) ;
  1052. a_errorObject.SetMessage ( L"Type mismatch for qualifier: AgentVarBindPerPdu" ) ;
  1053. }
  1054. }
  1055. }
  1056. if ( status & ! t_VarBinds )
  1057. {
  1058. WbemSnmpQualifier *qualifier = GetSnmpClassObject ()->FindQualifier ( WBEM_QUALIFIER_AGENTVARBINDSPERPDU ) ;
  1059. if ( qualifier )
  1060. {
  1061. SnmpInstanceType *value = qualifier->GetValue () ;
  1062. if ( typeid ( *value ) == typeid ( SnmpIntegerType ) )
  1063. {
  1064. SnmpIntegerType *integerType = ( SnmpIntegerType * ) value ;
  1065. agentVarBindsPerPdu = integerType->GetValue () ;
  1066. }
  1067. else
  1068. {
  1069. status = FALSE ;
  1070. a_errorObject.SetStatus ( WBEM_SNMP_E_TYPE_MISMATCH ) ;
  1071. a_errorObject.SetWbemStatus ( WBEM_E_FAILED ) ;
  1072. a_errorObject.SetMessage ( L"Type mismatch for qualifier: AgentVarBindPerPdu" ) ;
  1073. }
  1074. }
  1075. }
  1076. if ( status & ! t_VarBinds )
  1077. {
  1078. LONG attributeType ;
  1079. HRESULT result = namespaceQualifierObject->Get (
  1080. WBEM_QUALIFIER_AGENTVARBINDSPERPDU ,
  1081. 0,
  1082. &t_Variant ,
  1083. & attributeType
  1084. ) ;
  1085. if ( SUCCEEDED ( result ) )
  1086. {
  1087. if ( t_Variant.vt == VT_I4 )
  1088. {
  1089. agentVarBindsPerPdu = t_Variant.lVal ;
  1090. }
  1091. else
  1092. {
  1093. status = FALSE ;
  1094. a_errorObject.SetStatus ( WBEM_SNMP_E_TYPE_MISMATCH ) ;
  1095. a_errorObject.SetWbemStatus ( WBEM_E_FAILED ) ;
  1096. a_errorObject.SetMessage ( L"Type mismatch for qualifier: AgentVarBindPerPdu" ) ;
  1097. }
  1098. }
  1099. }
  1100. VariantClear ( & t_Variant );
  1101. if ( status )
  1102. {
  1103. DebugMacro3(
  1104. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  1105. __FILE__,__LINE__,
  1106. L"Using AgentVarBindsPerPdu ( %ld ) " , agentVarBindsPerPdu
  1107. ) ;
  1108. )
  1109. }
  1110. return status ;
  1111. }
  1112. BOOL SnmpResponseEventObject :: GetAgentFlowControlWindowSize (
  1113. WbemSnmpErrorObject &a_errorObject ,
  1114. IWbemQualifierSet *namespaceQualifierObject ,
  1115. ULONG &agentFlowControlWindowSize
  1116. )
  1117. {
  1118. BOOL status = TRUE ;
  1119. agentFlowControlWindowSize = 0 ;
  1120. BOOL t_WindowSize = FALSE ;
  1121. VARIANT t_Variant ;
  1122. VariantInit ( & t_Variant ) ;
  1123. if ( m_Context )
  1124. {
  1125. HRESULT result = m_Context->GetValue ( WBEM_QUALIFIER_AGENTFLOWCONTROLWINDOWSIZE , 0 , & t_Variant ) ;
  1126. if ( SUCCEEDED ( result ) & ( t_Variant.vt != VT_EMPTY ) )
  1127. {
  1128. if ( t_Variant.vt == VT_I4 )
  1129. {
  1130. t_WindowSize = TRUE ;
  1131. agentFlowControlWindowSize = t_Variant.lVal ;
  1132. }
  1133. else
  1134. {
  1135. status = FALSE ;
  1136. a_errorObject.SetStatus ( WBEM_SNMP_E_TYPE_MISMATCH ) ;
  1137. a_errorObject.SetWbemStatus ( WBEM_E_FAILED ) ;
  1138. a_errorObject.SetMessage ( L"Type mismatch for qualifier: AgentFlowControlWindowSize" ) ;
  1139. }
  1140. }
  1141. }
  1142. if ( status & ! t_WindowSize )
  1143. {
  1144. WbemSnmpQualifier *qualifier = GetSnmpClassObject ()->FindQualifier ( WBEM_QUALIFIER_AGENTFLOWCONTROLWINDOWSIZE ) ;
  1145. if ( qualifier )
  1146. {
  1147. SnmpInstanceType *value = qualifier->GetValue () ;
  1148. if ( typeid ( *value ) == typeid ( SnmpIntegerType ) )
  1149. {
  1150. SnmpIntegerType *integerType = ( SnmpIntegerType * ) value ;
  1151. agentFlowControlWindowSize = integerType->GetValue () ;
  1152. }
  1153. else
  1154. {
  1155. status = FALSE ;
  1156. a_errorObject.SetStatus ( WBEM_SNMP_E_TYPE_MISMATCH ) ;
  1157. a_errorObject.SetWbemStatus ( WBEM_E_FAILED ) ;
  1158. a_errorObject.SetMessage ( L"Type mismatch for qualifier: AgentFlowControlWindowSize" ) ;
  1159. }
  1160. }
  1161. }
  1162. if ( status & ! t_WindowSize )
  1163. {
  1164. LONG attributeType ;
  1165. HRESULT result = namespaceQualifierObject->Get (
  1166. WBEM_QUALIFIER_AGENTFLOWCONTROLWINDOWSIZE ,
  1167. 0,
  1168. &t_Variant ,
  1169. & attributeType
  1170. ) ;
  1171. if ( SUCCEEDED ( result ) )
  1172. {
  1173. if ( t_Variant.vt == VT_I4 )
  1174. {
  1175. agentFlowControlWindowSize = t_Variant.lVal ;
  1176. }
  1177. else
  1178. {
  1179. status = FALSE ;
  1180. a_errorObject.SetStatus ( WBEM_SNMP_E_TYPE_MISMATCH ) ;
  1181. a_errorObject.SetWbemStatus ( WBEM_E_FAILED ) ;
  1182. a_errorObject.SetMessage ( L"Type mismatch for qualifier: AgentFlowControlWindowSize" ) ;
  1183. }
  1184. }
  1185. }
  1186. VariantClear ( & t_Variant );
  1187. if ( status )
  1188. {
  1189. DebugMacro3(
  1190. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  1191. __FILE__,__LINE__,
  1192. L"Using AgentFlowControlWindowSize ( %ld ) " , agentFlowControlWindowSize
  1193. ) ;
  1194. )
  1195. }
  1196. return status ;
  1197. }
  1198. SnmpInstanceClassObject :: SnmpInstanceClassObject (
  1199. const SnmpInstanceClassObject & snmpInstanceClassObject
  1200. ) : SnmpClassObject ( snmpInstanceClassObject )
  1201. {
  1202. }
  1203. SnmpInstanceClassObject :: SnmpInstanceClassObject (
  1204. SnmpResponseEventObject *parentOperation
  1205. ) : SnmpClassObject ( parentOperation )
  1206. {
  1207. }
  1208. SnmpInstanceClassObject :: ~SnmpInstanceClassObject ()
  1209. {
  1210. }
  1211. BOOL SnmpInstanceClassObject :: Check ( WbemSnmpErrorObject &a_errorObject )
  1212. {
  1213. BOOL status = TRUE ;
  1214. snmpVersion = m_parentOperation->SetAgentVersion ( a_errorObject ) ;
  1215. if ( snmpVersion == 0 )
  1216. {
  1217. status = FALSE ;
  1218. }
  1219. WbemSnmpProperty *property ;
  1220. ResetProperty () ;
  1221. while ( status && ( property = NextProperty () ) )
  1222. {
  1223. status = CheckProperty ( a_errorObject , property ) ;
  1224. }
  1225. if ( ! m_accessible )
  1226. {
  1227. status = FALSE ;
  1228. a_errorObject.SetStatus ( WBEM_SNMP_E_NOREADABLEPROPERTIES ) ;
  1229. a_errorObject.SetWbemStatus ( WBEM_E_FAILED ) ;
  1230. a_errorObject.SetMessage ( L"Class must contain at least one property which is accessible" ) ;
  1231. }
  1232. return status ;
  1233. }
  1234. BOOL SnmpInstanceClassObject :: CheckProperty ( WbemSnmpErrorObject &a_errorObject , WbemSnmpProperty *property )
  1235. {
  1236. BOOL status = TRUE ;
  1237. if ( ( snmpVersion == 1 ) && property->IsSNMPV1Type () && property->IsReadable () )
  1238. {
  1239. m_accessible = TRUE ;
  1240. }
  1241. else if ( ( snmpVersion == 2 ) && property->IsSNMPV2CType () && property->IsReadable () )
  1242. {
  1243. m_accessible = TRUE ;
  1244. }
  1245. return status ;
  1246. }
  1247. SnmpInstanceResponseEventObject :: SnmpInstanceResponseEventObject (
  1248. CImpPropProv *providerArg ,
  1249. IWbemContext *a_Context
  1250. ) : SnmpResponseEventObject ( providerArg , a_Context ) ,
  1251. classObject ( NULL ) ,
  1252. instanceObject ( NULL ) ,
  1253. #if 0
  1254. instanceAccessObject ( NULL ) ,
  1255. #endif
  1256. session ( NULL ) ,
  1257. operation ( NULL ) ,
  1258. m_PartitionSet ( NULL ) ,
  1259. #pragma warning (disable:4355)
  1260. snmpObject ( this )
  1261. #pragma warning (default:4355)
  1262. {
  1263. }
  1264. SnmpInstanceResponseEventObject :: ~SnmpInstanceResponseEventObject ()
  1265. {
  1266. #if 0
  1267. if ( instanceAccessObject )
  1268. instanceAccessObject->Release ();
  1269. #endif
  1270. if ( instanceObject )
  1271. instanceObject->Release () ;
  1272. if ( classObject )
  1273. classObject->Release () ;
  1274. }
  1275. BOOL SnmpInstanceResponseEventObject :: SendSnmp ( WbemSnmpErrorObject &a_errorObject )
  1276. {
  1277. DebugMacro3(
  1278. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  1279. __FILE__,__LINE__,
  1280. L"SnmpInstanceResponseEventObject :: SendSnmp ( WbemSnmpErrorObject &a_errorObject )"
  1281. ) ;
  1282. )
  1283. BOOL status = TRUE ;
  1284. IWbemQualifierSet *namespaceQualifierObject = NULL ;
  1285. HRESULT result = m_namespaceObject->GetQualifierSet ( &namespaceQualifierObject ) ;
  1286. if ( SUCCEEDED ( result ) )
  1287. {
  1288. wchar_t *agentAddress = NULL ;
  1289. wchar_t *agentTransport = NULL ;
  1290. wchar_t *agentReadCommunityName = NULL ;
  1291. ULONG agentRetryCount ;
  1292. ULONG agentRetryTimeout ;
  1293. ULONG agentMaxVarBindsPerPdu ;
  1294. ULONG agentFlowControlWindowSize ;
  1295. status = SetAgentVersion ( m_errorObject ) ;
  1296. if ( status ) status = GetAgentAddress ( m_errorObject , namespaceQualifierObject , agentAddress ) ;
  1297. if ( status ) status = GetAgentTransport ( m_errorObject , namespaceQualifierObject , agentTransport ) ;
  1298. if ( status ) status = GetAgentReadCommunityName ( m_errorObject , namespaceQualifierObject , agentReadCommunityName ) ;
  1299. if ( status ) status = GetAgentRetryCount ( m_errorObject , namespaceQualifierObject , agentRetryCount ) ;
  1300. if ( status ) status = GetAgentRetryTimeout ( m_errorObject , namespaceQualifierObject , agentRetryTimeout ) ;
  1301. if ( status ) status = GetAgentMaxVarBindsPerPdu ( m_errorObject , namespaceQualifierObject , agentMaxVarBindsPerPdu ) ;
  1302. if ( status ) status = GetAgentFlowControlWindowSize ( m_errorObject , namespaceQualifierObject , agentFlowControlWindowSize ) ;
  1303. if ( status )
  1304. {
  1305. char *dbcsAgentAddress = UnicodeToDbcsString ( agentAddress ) ;
  1306. if ( dbcsAgentAddress )
  1307. {
  1308. char *dbcsAgentReadCommunityName = UnicodeToDbcsString ( agentReadCommunityName ) ;
  1309. if ( dbcsAgentReadCommunityName )
  1310. {
  1311. if ( _wcsicmp ( agentTransport , WBEM_AGENTIPTRANSPORT ) == 0 )
  1312. {
  1313. char *t_Address ;
  1314. if ( provider->GetIpAddressString () && provider->GetIpAddressValue () && _stricmp ( provider->GetIpAddressString () , dbcsAgentAddress ) == 0 )
  1315. {
  1316. t_Address = provider->GetIpAddressValue () ;
  1317. }
  1318. else
  1319. {
  1320. if ( SnmpTransportIpAddress :: ValidateAddress ( dbcsAgentAddress , SNMP_ADDRESS_RESOLVE_VALUE ) )
  1321. {
  1322. t_Address = dbcsAgentAddress ;
  1323. }
  1324. else
  1325. {
  1326. if ( SnmpTransportIpAddress :: ValidateAddress ( dbcsAgentAddress , SNMP_ADDRESS_RESOLVE_NAME ) )
  1327. {
  1328. t_Address = dbcsAgentAddress ;
  1329. }
  1330. else
  1331. {
  1332. status = FALSE ;
  1333. a_errorObject.SetStatus ( WBEM_SNMP_E_INVALID_TRANSPORTCONTEXT ) ;
  1334. a_errorObject.SetWbemStatus ( WBEM_E_FAILED ) ;
  1335. a_errorObject.SetMessage ( L"Illegal IP address value or unresolvable name for AgentAddress" ) ;
  1336. }
  1337. }
  1338. }
  1339. if ( status )
  1340. {
  1341. if ( m_agentVersion == 1 )
  1342. {
  1343. session = new SnmpV1OverIp (
  1344. t_Address ,
  1345. SNMP_ADDRESS_RESOLVE_NAME | SNMP_ADDRESS_RESOLVE_VALUE ,
  1346. dbcsAgentReadCommunityName ,
  1347. agentRetryCount ,
  1348. agentRetryTimeout ,
  1349. agentMaxVarBindsPerPdu ,
  1350. agentFlowControlWindowSize
  1351. );
  1352. if ( ! (*session)() )
  1353. {
  1354. DebugMacro3(
  1355. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  1356. __FILE__,__LINE__,
  1357. L"SNMPCL Session could not be created"
  1358. ) ;
  1359. )
  1360. delete session ;
  1361. session = NULL ;
  1362. status = FALSE ;
  1363. a_errorObject.SetStatus ( WBEM_SNMP_E_TRANSPORT_ERROR ) ;
  1364. a_errorObject.SetWbemStatus ( WBEM_E_FAILED ) ;
  1365. a_errorObject.SetMessage ( L"Failed to get transport resources" ) ;
  1366. }
  1367. }
  1368. else if ( m_agentVersion == 2 )
  1369. {
  1370. session = new SnmpV2COverIp (
  1371. t_Address ,
  1372. SNMP_ADDRESS_RESOLVE_NAME | SNMP_ADDRESS_RESOLVE_VALUE ,
  1373. dbcsAgentReadCommunityName ,
  1374. agentRetryCount ,
  1375. agentRetryTimeout ,
  1376. agentMaxVarBindsPerPdu ,
  1377. agentFlowControlWindowSize
  1378. );
  1379. if ( ! (*session)() )
  1380. {
  1381. DebugMacro3(
  1382. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  1383. __FILE__,__LINE__,
  1384. L"SNMPCL Session could not be created"
  1385. ) ;
  1386. )
  1387. delete session ;
  1388. session = NULL ;
  1389. status = FALSE ;
  1390. a_errorObject.SetStatus ( WBEM_SNMP_E_TRANSPORT_ERROR ) ;
  1391. a_errorObject.SetWbemStatus ( WBEM_E_FAILED ) ;
  1392. a_errorObject.SetMessage ( L"Failed to get transport resources" ) ;
  1393. }
  1394. }
  1395. else
  1396. {
  1397. status = FALSE ;
  1398. a_errorObject.SetStatus ( WBEM_SNMP_E_INVALID_TRANSPORTCONTEXT ) ;
  1399. a_errorObject.SetWbemStatus ( WBEM_E_FAILED ) ;
  1400. a_errorObject.SetMessage ( L"Illegal value for qualifier: AgentSnmpVersion" ) ;
  1401. }
  1402. }
  1403. }
  1404. else if ( _wcsicmp ( agentTransport , WBEM_AGENTIPXTRANSPORT ) == 0 )
  1405. {
  1406. if ( ! SnmpTransportIpxAddress :: ValidateAddress ( dbcsAgentAddress ) )
  1407. {
  1408. status = FALSE ;
  1409. a_errorObject.SetStatus ( WBEM_SNMP_E_INVALID_TRANSPORTCONTEXT ) ;
  1410. a_errorObject.SetWbemStatus ( WBEM_E_FAILED ) ;
  1411. a_errorObject.SetMessage ( L"Illegal value for qualifier: AgentAddress" ) ;
  1412. }
  1413. if ( status )
  1414. {
  1415. if ( m_agentVersion == 1 )
  1416. {
  1417. session = new SnmpV1OverIpx (
  1418. dbcsAgentAddress ,
  1419. dbcsAgentReadCommunityName ,
  1420. agentRetryCount ,
  1421. agentRetryTimeout ,
  1422. agentMaxVarBindsPerPdu ,
  1423. agentFlowControlWindowSize
  1424. );
  1425. if ( ! (*session)() )
  1426. {
  1427. DebugMacro3(
  1428. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  1429. __FILE__,__LINE__,
  1430. L"SNMPCL Session could not be created"
  1431. ) ;
  1432. )
  1433. delete session ;
  1434. session = NULL ;
  1435. status = FALSE ;
  1436. a_errorObject.SetStatus ( WBEM_SNMP_E_TRANSPORT_ERROR ) ;
  1437. a_errorObject.SetWbemStatus ( WBEM_E_FAILED ) ;
  1438. a_errorObject.SetMessage ( L"Failed to get transport resources" ) ;
  1439. }
  1440. }
  1441. else if ( m_agentVersion == 2 )
  1442. {
  1443. session = new SnmpV2COverIpx (
  1444. dbcsAgentAddress ,
  1445. dbcsAgentReadCommunityName ,
  1446. agentRetryCount ,
  1447. agentRetryTimeout ,
  1448. agentMaxVarBindsPerPdu ,
  1449. agentFlowControlWindowSize
  1450. );
  1451. if ( ! (*session)() )
  1452. {
  1453. DebugMacro3(
  1454. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  1455. __FILE__,__LINE__,
  1456. L"SNMPCL Session could not be created"
  1457. ) ;
  1458. )
  1459. delete session ;
  1460. session = NULL ;
  1461. status = FALSE ;
  1462. a_errorObject.SetStatus ( WBEM_SNMP_E_TRANSPORT_ERROR ) ;
  1463. a_errorObject.SetWbemStatus ( WBEM_E_FAILED ) ;
  1464. a_errorObject.SetMessage ( L"Failed to get transport resources" ) ;
  1465. }
  1466. }
  1467. else
  1468. {
  1469. status = FALSE ;
  1470. a_errorObject.SetStatus ( WBEM_SNMP_E_INVALID_TRANSPORTCONTEXT ) ;
  1471. a_errorObject.SetWbemStatus ( WBEM_E_FAILED ) ;
  1472. a_errorObject.SetMessage ( L"Illegal value for qualifier: AgentSnmpVersion" ) ;
  1473. }
  1474. }
  1475. }
  1476. else
  1477. {
  1478. status = FALSE ;
  1479. a_errorObject.SetStatus ( WBEM_SNMP_E_INVALID_TRANSPORTCONTEXT ) ;
  1480. a_errorObject.SetWbemStatus ( WBEM_E_FAILED ) ;
  1481. a_errorObject.SetMessage ( L"Illegal value for qualifier: AgentTransport" ) ;
  1482. }
  1483. delete [] dbcsAgentReadCommunityName ;
  1484. }
  1485. else
  1486. {
  1487. status = FALSE ;
  1488. a_errorObject.SetStatus ( WBEM_SNMP_E_INVALID_TRANSPORTCONTEXT ) ;
  1489. a_errorObject.SetWbemStatus ( WBEM_E_FAILED ) ;
  1490. a_errorObject.SetMessage ( L"Illegal value for qualifier: AgentReadCommunityName" ) ;
  1491. }
  1492. delete [] dbcsAgentAddress ;
  1493. if ( status )
  1494. {
  1495. operation = new AutoRetrieveOperation(*session,this);
  1496. operation->Send () ;
  1497. }
  1498. }
  1499. else
  1500. {
  1501. status = FALSE ;
  1502. a_errorObject.SetStatus ( WBEM_SNMP_E_INVALID_TRANSPORTCONTEXT ) ;
  1503. a_errorObject.SetWbemStatus ( WBEM_E_FAILED ) ;
  1504. a_errorObject.SetMessage ( L"Illegal value for qualifier: AgentAddress" ) ;
  1505. }
  1506. }
  1507. else
  1508. {
  1509. DebugMacro1(
  1510. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  1511. __FILE__,__LINE__,
  1512. L" TransportInformation settings invalid"
  1513. ) ;
  1514. )
  1515. }
  1516. delete [] agentTransport ;
  1517. delete [] agentAddress ;
  1518. delete [] agentReadCommunityName ;
  1519. namespaceQualifierObject->Release () ;
  1520. }
  1521. else
  1522. {
  1523. status = FALSE ;
  1524. a_errorObject.SetStatus ( WBEM_SNMP_ERROR_CRITICAL_ERROR ) ;
  1525. a_errorObject.SetWbemStatus ( WBEM_ERROR_CRITICAL_ERROR ) ;
  1526. a_errorObject.SetMessage ( L"Failed to get class qualifier set" ) ;
  1527. }
  1528. return status ;
  1529. }
  1530. SnmpInstanceEventObject :: SnmpInstanceEventObject (
  1531. CImpPropProv *providerArg ,
  1532. BSTR ClassArg ,
  1533. IWbemContext *a_Context
  1534. ) : SnmpInstanceResponseEventObject ( providerArg , a_Context ) , Class ( NULL )
  1535. {
  1536. Class = SysAllocString ( ClassArg ) ;
  1537. }
  1538. SnmpInstanceEventObject :: ~SnmpInstanceEventObject ()
  1539. {
  1540. SysFreeString ( Class ) ;
  1541. }
  1542. BOOL SnmpInstanceEventObject :: Instantiate ( WbemSnmpErrorObject &a_errorObject )
  1543. {
  1544. DebugMacro3(
  1545. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  1546. __FILE__,__LINE__,
  1547. L"SnmpInstanceEventObject :: Instantiate ( WbemSnmpErrorObject &a_errorObject )"
  1548. ) ;
  1549. )
  1550. BOOL status = TRUE ;
  1551. IWbemServices *t_Serv = provider->GetServer();
  1552. HRESULT result = WBEM_E_FAILED;
  1553. if (t_Serv)
  1554. {
  1555. result = t_Serv->GetObject (
  1556. Class ,
  1557. 0 ,
  1558. m_Context ,
  1559. & classObject ,
  1560. NULL
  1561. ) ;
  1562. t_Serv->Release();
  1563. }
  1564. if ( SUCCEEDED ( result ) )
  1565. {
  1566. result = classObject->SpawnInstance ( 0 , & instanceObject ) ;
  1567. if ( SUCCEEDED ( result ) )
  1568. {
  1569. if ( status = GetNamespaceObject ( a_errorObject ) )
  1570. {
  1571. if ( status = snmpObject.Set ( a_errorObject , classObject , FALSE ) )
  1572. {
  1573. if ( status = snmpObject.Check ( a_errorObject ) )
  1574. {
  1575. status = SendSnmp ( a_errorObject ) ;
  1576. }
  1577. else
  1578. {
  1579. DebugMacro3(
  1580. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  1581. __FILE__,__LINE__,
  1582. L"Failed During Check : Class definition did not conform to mapping"
  1583. ) ;
  1584. )
  1585. }
  1586. }
  1587. else
  1588. {
  1589. DebugMacro3(
  1590. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  1591. __FILE__,__LINE__,
  1592. L"Failed During Set : Class definition did not conform to mapping"
  1593. ) ;
  1594. )
  1595. }
  1596. }
  1597. }
  1598. }
  1599. else
  1600. {
  1601. DebugMacro3(
  1602. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  1603. __FILE__,__LINE__,
  1604. L"Class definition unknown"
  1605. ) ;
  1606. )
  1607. status = FALSE ;
  1608. a_errorObject.SetStatus ( WBEM_SNMP_E_INVALID_CLASS ) ;
  1609. a_errorObject.SetWbemStatus ( WBEM_E_FAILED ) ;
  1610. a_errorObject.SetMessage ( L"Unknown Class" ) ;
  1611. }
  1612. return status ;
  1613. }
  1614. SnmpInstanceAsyncEventObject :: SnmpInstanceAsyncEventObject (
  1615. CImpPropProv *providerArg ,
  1616. BSTR Class ,
  1617. IWbemObjectSink *notify ,
  1618. IWbemContext *a_Context
  1619. ) : SnmpInstanceEventObject ( providerArg , Class , a_Context ) , notificationHandler ( notify ) , state ( 0 )
  1620. {
  1621. DebugMacro3(
  1622. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  1623. __FILE__,__LINE__,
  1624. L"SnmpInstanceAsyncEventObject :: SnmpInstanceAsyncEventObject ()"
  1625. ) ;
  1626. )
  1627. notify->AddRef () ;
  1628. }
  1629. SnmpInstanceAsyncEventObject :: ~SnmpInstanceAsyncEventObject ()
  1630. {
  1631. DebugMacro3(
  1632. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  1633. __FILE__,__LINE__,
  1634. L"SnmpInstanceAsyncEventObject :: ~SnmpInstanceAsyncEventObject ()"
  1635. ) ;
  1636. )
  1637. if ( FAILED ( m_errorObject.GetWbemStatus () ) )
  1638. {
  1639. // Get Status object
  1640. IWbemClassObject *notifyStatus ;
  1641. BOOL status = GetSnmpNotifyStatusObject ( &notifyStatus ) ;
  1642. if ( status )
  1643. {
  1644. DebugMacro3(
  1645. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  1646. __FILE__,__LINE__,
  1647. L"Sending Status"
  1648. ) ;
  1649. )
  1650. HRESULT result = notificationHandler->SetStatus ( 0 , m_errorObject.GetWbemStatus () , NULL , notifyStatus ) ;
  1651. notifyStatus->Release () ;
  1652. }
  1653. else
  1654. {
  1655. HRESULT result = notificationHandler->SetStatus ( 0 , m_errorObject.GetWbemStatus () , NULL , NULL ) ;
  1656. }
  1657. }
  1658. else
  1659. {
  1660. HRESULT result = notificationHandler->SetStatus ( 0 , m_errorObject.GetWbemStatus () , NULL , NULL ) ;
  1661. }
  1662. ULONG t_Ref = notificationHandler->Release () ;
  1663. DebugMacro3(
  1664. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  1665. __FILE__,__LINE__,
  1666. L"Returning from SnmpInstanceAsyncEventObject :: ~SnmpInstanceAsyncEventObject ()"
  1667. ) ;
  1668. )
  1669. }
  1670. void SnmpInstanceAsyncEventObject :: ReceiveComplete ()
  1671. {
  1672. DebugMacro3(
  1673. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  1674. __FILE__,__LINE__,
  1675. L"SnmpInstanceAsyncEventObject :: ReceiveComplete ()"
  1676. ) ;
  1677. )
  1678. if ( SUCCEEDED ( m_errorObject.GetWbemStatus () ) )
  1679. {
  1680. DebugMacro3(
  1681. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  1682. __FILE__,__LINE__,
  1683. L"Enumeration Succeeded"
  1684. ) ;
  1685. )
  1686. }
  1687. else
  1688. {
  1689. DebugMacro3(
  1690. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  1691. __FILE__,__LINE__,
  1692. L"Enumeration Failed"
  1693. ) ;
  1694. )
  1695. }
  1696. /*
  1697. * Remove worker object from worker thread container
  1698. */
  1699. DebugMacro3(
  1700. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  1701. __FILE__,__LINE__,
  1702. L"Reaping Task"
  1703. ) ;
  1704. )
  1705. AutoRetrieveOperation *t_operation = operation ;
  1706. DebugMacro3(
  1707. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  1708. __FILE__,__LINE__,
  1709. L"Deleting (this)"
  1710. ) ;
  1711. )
  1712. Complete () ;
  1713. DebugMacro3(
  1714. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  1715. __FILE__,__LINE__,
  1716. L"Destroying SNMPCL operation"
  1717. ) ;
  1718. )
  1719. if ( t_operation )
  1720. t_operation->DestroyOperation () ;
  1721. }
  1722. void SnmpInstanceAsyncEventObject :: Process ()
  1723. {
  1724. DebugMacro3(
  1725. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  1726. __FILE__,__LINE__,
  1727. L"SnmpInstanceAsyncEventObject :: Process ()"
  1728. ) ;
  1729. )
  1730. switch ( state )
  1731. {
  1732. case 0:
  1733. {
  1734. BOOL status = Instantiate ( m_errorObject ) ;
  1735. if ( status )
  1736. {
  1737. }
  1738. else
  1739. {
  1740. ReceiveComplete () ;
  1741. }
  1742. }
  1743. break ;
  1744. default:
  1745. {
  1746. }
  1747. break ;
  1748. }
  1749. DebugMacro3(
  1750. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  1751. __FILE__,__LINE__,
  1752. L"Returning from SnmpInstanceAsyncEventObject :: Process ()"
  1753. ) ;
  1754. )
  1755. }
  1756. void SnmpInstanceAsyncEventObject :: ReceiveRow ( IWbemClassObject *snmpObject )
  1757. {
  1758. DebugMacro3(
  1759. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  1760. __FILE__,__LINE__,
  1761. L"SnmpQueryAsyncEventObject :: ReceiveRow ( IWbemClassObject *snmpObject )"
  1762. ) ;
  1763. )
  1764. HRESULT result = S_OK ;
  1765. BOOL status = TRUE ;
  1766. notificationHandler->Indicate ( 1 , & snmpObject ) ;
  1767. if ( ! HasNonNullKeys ( snmpObject ) )
  1768. {
  1769. if ( SUCCEEDED ( m_errorObject.GetWbemStatus () ) )
  1770. {
  1771. m_errorObject.SetStatus ( WBEM_SNMP_E_INVALID_OBJECT ) ;
  1772. m_errorObject.SetWbemStatus ( WBEM_E_FAILED ) ;
  1773. m_errorObject.SetMessage ( L"The SNMP Agent queried returned an instance with NULL key(s)" ) ;
  1774. }
  1775. }
  1776. }
  1777. void SnmpInstanceAsyncEventObject :: ReceiveRow ( SnmpInstanceClassObject *snmpObject )
  1778. {
  1779. DebugMacro3(
  1780. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  1781. __FILE__,__LINE__,
  1782. L"SnmpInstanceAsyncEventObject :: ReceiveRow ( SnmpInstanceClassObject *snmpObject )"
  1783. ) ;
  1784. )
  1785. HRESULT result = S_OK ;
  1786. IWbemClassObject *cloneObject ;
  1787. if ( SUCCEEDED ( result = classObject->SpawnInstance ( 0 , & cloneObject ) ) )
  1788. {
  1789. WbemSnmpErrorObject errorObject ;
  1790. if ( snmpObject->Get ( errorObject , cloneObject ) )
  1791. {
  1792. DebugMacro3(
  1793. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  1794. __FILE__,__LINE__,
  1795. L"Sending Object"
  1796. ) ;
  1797. )
  1798. notificationHandler->Indicate ( 1 , & cloneObject ) ;
  1799. if ( ! HasNonNullKeys ( cloneObject ) )
  1800. {
  1801. if ( SUCCEEDED ( m_errorObject.GetWbemStatus () ) )
  1802. {
  1803. m_errorObject.SetStatus ( WBEM_SNMP_E_INVALID_OBJECT ) ;
  1804. m_errorObject.SetWbemStatus ( WBEM_E_FAILED ) ;
  1805. m_errorObject.SetMessage ( L"The SNMP Agent queried returned an instance with NULL key(s)" ) ;
  1806. }
  1807. }
  1808. }
  1809. else
  1810. {
  1811. DebugMacro3(
  1812. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  1813. __FILE__,__LINE__,
  1814. L"Failed to Convert WbemSnmpClassObject to IWbemClassObject"
  1815. ) ;
  1816. )
  1817. }
  1818. cloneObject->Release () ;
  1819. }
  1820. }