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.

2444 lines
52 KiB

  1. //***************************************************************************
  2. //
  3. // MINISERV.CPP
  4. //
  5. // Module: OLE MS SNMP Property Provider
  6. //
  7. // Purpose: Implementation for the SnmpGetEventObject class.
  8. //
  9. // Copyright (c) 1996-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 "propinst.h"
  40. #include "propquery.h"
  41. #include "snmpnext.h"
  42. QueryPreprocessor :: QuadState SnmpQueryEventObject :: Compare (
  43. LONG a_Operand1 ,
  44. LONG a_Operand2 ,
  45. DWORD a_Operand1Func ,
  46. DWORD a_Operand2Func ,
  47. WmiTreeNode &a_OperatorType
  48. )
  49. {
  50. QueryPreprocessor :: QuadState t_Status = QueryPreprocessor :: QuadState :: State_True ;
  51. switch ( a_Operand1Func )
  52. {
  53. case WmiValueNode :: WmiValueFunction :: Function_None:
  54. {
  55. }
  56. break ;
  57. default:
  58. {
  59. }
  60. break ;
  61. }
  62. switch ( a_Operand2Func )
  63. {
  64. case WmiValueNode :: WmiValueFunction :: Function_None:
  65. {
  66. }
  67. break ;
  68. default:
  69. {
  70. }
  71. break ;
  72. }
  73. if ( typeid ( a_OperatorType ) == typeid ( WmiOperatorEqualNode ) )
  74. {
  75. t_Status = a_Operand1 == a_Operand2
  76. ? QueryPreprocessor :: QuadState :: State_True
  77. : QueryPreprocessor :: QuadState :: State_False ;
  78. }
  79. else if ( typeid ( a_OperatorType ) == typeid ( WmiOperatorNotEqualNode ) )
  80. {
  81. t_Status = a_Operand1 != a_Operand2
  82. ? QueryPreprocessor :: QuadState :: State_True
  83. : QueryPreprocessor :: QuadState :: State_False ;
  84. }
  85. else if ( typeid ( a_OperatorType ) == typeid ( WmiOperatorEqualOrGreaterNode ) )
  86. {
  87. t_Status = a_Operand1 >= a_Operand2
  88. ? QueryPreprocessor :: QuadState :: State_True
  89. : QueryPreprocessor :: QuadState :: State_False ;
  90. }
  91. else if ( typeid ( a_OperatorType ) == typeid ( WmiOperatorEqualOrLessNode ) )
  92. {
  93. t_Status = a_Operand1 <= a_Operand2
  94. ? QueryPreprocessor :: QuadState :: State_True
  95. : QueryPreprocessor :: QuadState :: State_False ;
  96. }
  97. else if ( typeid ( a_OperatorType ) == typeid ( WmiOperatorLessNode ) )
  98. {
  99. t_Status = a_Operand1 < a_Operand2
  100. ? QueryPreprocessor :: QuadState :: State_True
  101. : QueryPreprocessor :: QuadState :: State_False ;
  102. }
  103. else if ( typeid ( a_OperatorType ) == typeid ( WmiOperatorGreaterNode ) )
  104. {
  105. t_Status = a_Operand1 > a_Operand2
  106. ? QueryPreprocessor :: QuadState :: State_True
  107. : QueryPreprocessor :: QuadState :: State_False ;
  108. }
  109. else if ( typeid ( a_OperatorType ) == typeid ( WmiOperatorLikeNode ) )
  110. {
  111. }
  112. else if ( typeid ( a_OperatorType ) == typeid ( WmiOperatorNotLikeNode ) )
  113. {
  114. }
  115. return t_Status ;
  116. }
  117. QueryPreprocessor :: QuadState SnmpQueryEventObject :: Compare (
  118. wchar_t *a_Operand1 ,
  119. wchar_t *a_Operand2 ,
  120. DWORD a_Operand1Func ,
  121. DWORD a_Operand2Func ,
  122. WmiTreeNode &a_OperatorType
  123. )
  124. {
  125. DebugMacro3(
  126. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  127. __FILE__,__LINE__,
  128. L"SnmpQueryEventObject :: Compare ()"
  129. ) ;
  130. )
  131. QueryPreprocessor :: QuadState t_Status = QueryPreprocessor :: QuadState :: State_True ;
  132. wchar_t *a_Operand1AfterFunc = NULL ;
  133. wchar_t *a_Operand2AfterFunc = NULL ;
  134. if (a_Operand1)
  135. {
  136. switch ( a_Operand1Func )
  137. {
  138. case WmiValueNode :: WmiValueFunction :: Function_None:
  139. {
  140. }
  141. break ;
  142. case WmiValueNode :: WmiValueFunction :: Function_Upper:
  143. {
  144. ULONG length = wcslen ( a_Operand1 ) ;
  145. a_Operand1AfterFunc = new wchar_t [ length + 1 ] ;
  146. for ( ULONG index = 0 ; index < length ; index ++ )
  147. {
  148. a_Operand1AfterFunc [ index ] = towupper ( a_Operand1 [ index ] ) ;
  149. }
  150. a_Operand1AfterFunc [ index ] = 0 ;
  151. }
  152. break ;
  153. case WmiValueNode :: WmiValueFunction :: Function_Lower:
  154. {
  155. ULONG length = wcslen ( a_Operand1 ) ;
  156. a_Operand1AfterFunc = new wchar_t [ length + 1 ] ;
  157. for ( ULONG index = 0 ; index < length ; index ++ )
  158. {
  159. a_Operand1AfterFunc [ index ] = towlower ( a_Operand1 [ index ] ) ;
  160. }
  161. a_Operand1AfterFunc [ index ] = 0 ;
  162. }
  163. break ;
  164. default:
  165. {
  166. }
  167. break ;
  168. }
  169. }
  170. if (a_Operand2)
  171. {
  172. switch ( a_Operand2Func )
  173. {
  174. case WmiValueNode :: WmiValueFunction :: Function_None:
  175. {
  176. }
  177. break ;
  178. case WmiValueNode :: WmiValueFunction :: Function_Upper:
  179. {
  180. ULONG length = wcslen ( a_Operand2 ) ;
  181. a_Operand2AfterFunc = new wchar_t [ length + 1 ] ;
  182. for ( ULONG index = 0 ; index < length ; index ++ )
  183. {
  184. a_Operand2AfterFunc [ index ] = towupper ( a_Operand2 [ index ] ) ;
  185. }
  186. a_Operand2AfterFunc [ index ] = 0 ;
  187. }
  188. break ;
  189. case WmiValueNode :: WmiValueFunction :: Function_Lower:
  190. {
  191. ULONG length = wcslen ( a_Operand2 ) ;
  192. a_Operand2AfterFunc = new wchar_t [ length + 1 ] ;
  193. for ( ULONG index = 0 ; index < length ; index ++ )
  194. {
  195. a_Operand2AfterFunc [ index ] = towlower ( a_Operand2 [ index ] ) ;
  196. }
  197. a_Operand2AfterFunc [ index ] = 0 ;
  198. }
  199. break ;
  200. default:
  201. {
  202. }
  203. break ;
  204. }
  205. }
  206. const wchar_t *t_Arg1 = a_Operand1AfterFunc ? a_Operand1AfterFunc : a_Operand1 ;
  207. const wchar_t *t_Arg2 = a_Operand2AfterFunc ? a_Operand2AfterFunc : a_Operand2 ;
  208. if ( typeid ( a_OperatorType ) == typeid ( WmiOperatorEqualNode ) )
  209. {
  210. if ( ( t_Arg1 ) && ( t_Arg2 ) )
  211. {
  212. t_Status = wcscmp ( t_Arg1 , t_Arg2 ) == 0
  213. ? QueryPreprocessor :: QuadState :: State_True
  214. : QueryPreprocessor :: QuadState :: State_False ;
  215. }
  216. else
  217. {
  218. if ( ( t_Arg1 ) || ( t_Arg2 ) )
  219. {
  220. t_Status = QueryPreprocessor :: QuadState :: State_False ;
  221. }
  222. else
  223. {
  224. t_Status = QueryPreprocessor :: QuadState :: State_True ;
  225. }
  226. }
  227. }
  228. else if ( typeid ( a_OperatorType ) == typeid ( WmiOperatorNotEqualNode ) )
  229. {
  230. if ( ( t_Arg1 ) && ( t_Arg2 ) )
  231. {
  232. t_Status = wcscmp ( t_Arg1 , t_Arg2 ) != 0
  233. ? QueryPreprocessor :: QuadState :: State_True
  234. : QueryPreprocessor :: QuadState :: State_False ;
  235. }
  236. else
  237. {
  238. if ( ( t_Arg1 ) || ( t_Arg2 ) )
  239. {
  240. t_Status = QueryPreprocessor :: QuadState :: State_True ;
  241. }
  242. else
  243. {
  244. t_Status = QueryPreprocessor :: QuadState :: State_False ;
  245. }
  246. }
  247. }
  248. else if ( typeid ( a_OperatorType ) == typeid ( WmiOperatorEqualOrGreaterNode ) )
  249. {
  250. if ( ( t_Arg1 ) && ( t_Arg2 ) )
  251. {
  252. t_Status = wcscmp ( t_Arg1 , t_Arg2 ) >= 0
  253. ? QueryPreprocessor :: QuadState :: State_True
  254. : QueryPreprocessor :: QuadState :: State_False ;
  255. }
  256. else
  257. {
  258. if ( t_Arg1 )
  259. {
  260. t_Status = QueryPreprocessor :: QuadState :: State_True ;
  261. }
  262. else
  263. {
  264. if ( t_Arg2 )
  265. {
  266. t_Status = QueryPreprocessor :: QuadState :: State_False ;
  267. }
  268. else
  269. {
  270. t_Status = QueryPreprocessor :: QuadState :: State_True ;
  271. }
  272. }
  273. }
  274. }
  275. else if ( typeid ( a_OperatorType ) == typeid ( WmiOperatorEqualOrLessNode ) )
  276. {
  277. if ( ( t_Arg1 ) && ( t_Arg2 ) )
  278. {
  279. t_Status = wcscmp ( t_Arg1 , t_Arg2 ) <= 0
  280. ? QueryPreprocessor :: QuadState :: State_True
  281. : QueryPreprocessor :: QuadState :: State_False ;
  282. }
  283. else
  284. {
  285. if ( ( t_Arg1 ) )
  286. {
  287. t_Status = QueryPreprocessor :: QuadState :: State_False ;
  288. }
  289. else
  290. {
  291. if ( t_Arg2 )
  292. {
  293. t_Status = QueryPreprocessor :: QuadState :: State_True ;
  294. }
  295. else
  296. {
  297. t_Status = QueryPreprocessor :: QuadState :: State_True ;
  298. }
  299. }
  300. }
  301. }
  302. else if ( typeid ( a_OperatorType ) == typeid ( WmiOperatorLessNode ) )
  303. {
  304. if ( ( t_Arg1 ) && ( t_Arg2 ) )
  305. {
  306. t_Status = wcscmp ( t_Arg1 , t_Arg2 ) < 0
  307. ? QueryPreprocessor :: QuadState :: State_True
  308. : QueryPreprocessor :: QuadState :: State_False ;
  309. }
  310. else
  311. {
  312. if ( ( ! t_Arg1 ) && ( ! t_Arg2 ) )
  313. {
  314. t_Status = QueryPreprocessor :: QuadState :: State_False ;
  315. }
  316. else if ( t_Arg1 )
  317. {
  318. t_Status = QueryPreprocessor :: QuadState :: State_False ;
  319. }
  320. else
  321. {
  322. t_Status = QueryPreprocessor :: QuadState :: State_True ;
  323. }
  324. }
  325. }
  326. else if ( typeid ( a_OperatorType ) == typeid ( WmiOperatorGreaterNode ) )
  327. {
  328. if ( ( t_Arg1 ) && ( t_Arg2 ) )
  329. {
  330. t_Status = wcscmp ( t_Arg1 , t_Arg2 ) > 0
  331. ? QueryPreprocessor :: QuadState :: State_True
  332. : QueryPreprocessor :: QuadState :: State_False ;
  333. }
  334. else
  335. {
  336. if ( ( ! t_Arg1 ) && ( ! t_Arg2 ) )
  337. {
  338. t_Status = QueryPreprocessor :: QuadState :: State_False ;
  339. }
  340. else if ( t_Arg1 )
  341. {
  342. t_Status = QueryPreprocessor :: QuadState :: State_True ;
  343. }
  344. else
  345. {
  346. t_Status = QueryPreprocessor :: QuadState :: State_False ;
  347. }
  348. }
  349. }
  350. else if ( typeid ( a_OperatorType ) == typeid ( WmiOperatorLikeNode ) )
  351. {
  352. }
  353. else if ( typeid ( a_OperatorType ) == typeid ( WmiOperatorNotLikeNode ) )
  354. {
  355. }
  356. delete [] a_Operand1AfterFunc ;
  357. delete [] a_Operand2AfterFunc ;
  358. return t_Status ;
  359. }
  360. WmiTreeNode *SnmpQueryEventObject :: AllocTypeNode (
  361. void *a_Context ,
  362. BSTR a_PropertyName ,
  363. VARIANT &a_Variant ,
  364. WmiValueNode :: WmiValueFunction a_PropertyFunction ,
  365. WmiValueNode :: WmiValueFunction a_ConstantFunction ,
  366. WmiTreeNode *a_Parent
  367. )
  368. {
  369. WmiTreeNode *t_Node = NULL ;
  370. VARTYPE t_VarType = VT_NULL ;
  371. if ( *a_PropertyName == L'_' )
  372. {
  373. // System property
  374. if (( _wcsicmp ( a_PropertyName , SYSTEM_PROPERTY_CLASS ) == 0 ) ||
  375. ( _wcsicmp ( a_PropertyName , SYSTEM_PROPERTY_SUPERCLASS ) == 0 ) ||
  376. ( _wcsicmp ( a_PropertyName , SYSTEM_PROPERTY_SERVER ) == 0 ) ||
  377. ( _wcsicmp ( a_PropertyName , SYSTEM_PROPERTY_NAMESPACE ) == 0 ) ||
  378. ( _wcsicmp ( a_PropertyName , SYSTEM_PROPERTY_DYNASTY ) == 0 ) ||
  379. ( _wcsicmp ( a_PropertyName , SYSTEM_PROPERTY_RELPATH ) == 0 ) ||
  380. ( _wcsicmp ( a_PropertyName , SYSTEM_PROPERTY_PATH ) == 0 ))
  381. {
  382. if (a_Variant.vt == VT_BSTR)
  383. {
  384. t_Node = new WmiStringNode (
  385. a_PropertyName ,
  386. a_Variant.bstrVal ,
  387. a_PropertyFunction ,
  388. a_ConstantFunction ,
  389. 0xFFFFFFFF ,
  390. a_Parent
  391. ) ;
  392. }
  393. else if (V_VT(&a_Variant) == VT_NULL)
  394. {
  395. t_Node = new WmiNullNode (
  396. a_PropertyName ,
  397. 0xFFFFFFFF ,
  398. a_Parent
  399. );
  400. }
  401. }
  402. else if (( _wcsicmp ( a_PropertyName , SYSTEM_PROPERTY_GENUS ) == 0 ) ||
  403. ( _wcsicmp ( a_PropertyName , SYSTEM_PROPERTY_PROPERTY_COUNT ) == 0 ))
  404. {
  405. if (a_Variant.vt == VT_I4)
  406. {
  407. t_Node = new WmiSignedIntegerNode (
  408. a_PropertyName ,
  409. a_Variant.lVal ,
  410. 0xFFFFFFFF ,
  411. a_Parent
  412. ) ;
  413. }
  414. else if (V_VT(&a_Variant) == VT_NULL)
  415. {
  416. t_Node = new WmiNullNode (
  417. a_PropertyName ,
  418. 0xFFFFFFFF ,
  419. a_Parent
  420. );
  421. }
  422. }
  423. else if ( _wcsicmp ( a_PropertyName , SYSTEM_PROPERTY_DERIVATION ) == 0 )
  424. {
  425. }
  426. }
  427. else
  428. {
  429. WbemSnmpProperty *t_Property ;
  430. if ( t_Property = snmpObject.FindProperty ( a_PropertyName ) )
  431. {
  432. t_VarType = t_Property->GetValueVariantEncodedType () ;
  433. }
  434. switch ( t_VarType )
  435. {
  436. case VT_I4:
  437. {
  438. if (a_Variant.vt == VT_I4)
  439. {
  440. t_Node = new WmiSignedIntegerNode (
  441. a_PropertyName ,
  442. a_Variant.lVal ,
  443. t_Property->GetKeyOrder () ,
  444. a_Parent
  445. ) ;
  446. }
  447. else if (V_VT(&a_Variant) == VT_NULL)
  448. {
  449. t_Node = new WmiNullNode (
  450. a_PropertyName ,
  451. t_Property->GetKeyOrder () ,
  452. a_Parent
  453. );
  454. }
  455. }
  456. break ;
  457. case VT_UI4:
  458. {
  459. if ((a_Variant.vt == VT_I4) || (a_Variant.vt == VT_UI4))
  460. {
  461. t_Node = new WmiUnsignedIntegerNode (
  462. a_PropertyName ,
  463. a_Variant.lVal ,
  464. t_Property->GetKeyOrder () ,
  465. a_Parent
  466. ) ;
  467. }
  468. else if (V_VT(&a_Variant) == VT_NULL)
  469. {
  470. t_Node = new WmiNullNode (
  471. a_PropertyName ,
  472. t_Property->GetKeyOrder () ,
  473. a_Parent
  474. );
  475. }
  476. }
  477. break ;
  478. case VT_BSTR:
  479. {
  480. if (a_Variant.vt == VT_BSTR)
  481. {
  482. t_Node = new WmiStringNode (
  483. a_PropertyName ,
  484. a_Variant.bstrVal ,
  485. a_PropertyFunction ,
  486. a_ConstantFunction ,
  487. t_Property->GetKeyOrder () ,
  488. a_Parent
  489. ) ;
  490. }
  491. else if (V_VT(&a_Variant) == VT_NULL)
  492. {
  493. t_Node = new WmiNullNode (
  494. a_PropertyName ,
  495. t_Property->GetKeyOrder () ,
  496. a_Parent
  497. );
  498. }
  499. }
  500. break ;
  501. default:
  502. {
  503. }
  504. break ;
  505. }
  506. }
  507. return t_Node ;
  508. }
  509. QueryPreprocessor :: QuadState SnmpQueryEventObject :: CompareString (
  510. BSTR a_PropertyName ,
  511. WmiTreeNode *a_Operator ,
  512. WmiTreeNode *a_Operand ,
  513. bool a_Class
  514. )
  515. {
  516. QueryPreprocessor :: QuadState t_Status = QueryPreprocessor :: QuadState :: State_True ;
  517. if ( typeid ( *a_Operand ) != typeid ( WmiStringNode ) )
  518. {
  519. return QueryPreprocessor :: QuadState :: State_True ;
  520. }
  521. VARIANT t_Variant ;
  522. VariantInit ( & t_Variant ) ;
  523. WmiStringNode *t_StringNode = ( WmiStringNode * ) a_Operand ;
  524. HRESULT t_Result ;
  525. if ( a_Class )
  526. {
  527. t_Result = GetClassObject ()->Get ( a_PropertyName , 0 , &t_Variant , NULL , NULL ) ;
  528. }
  529. else
  530. {
  531. t_Result = GetInstanceObject ()->Get ( a_PropertyName , 0 , &t_Variant , NULL , NULL ) ;
  532. }
  533. if ( SUCCEEDED ( t_Result ) )
  534. {
  535. if ( t_Variant.vt == VT_BSTR )
  536. {
  537. t_Status = Compare (
  538. t_StringNode->GetValue () ,
  539. t_Variant.bstrVal ,
  540. t_StringNode->GetPropertyFunction () ,
  541. t_StringNode->GetConstantFunction () ,
  542. *a_Operator
  543. ) ;
  544. }
  545. else
  546. {
  547. t_Status = QueryPreprocessor :: QuadState :: State_Error ;
  548. }
  549. }
  550. VariantClear ( & t_Variant ) ;
  551. return t_Status ;
  552. }
  553. QueryPreprocessor :: QuadState SnmpQueryEventObject :: CompareCaseInsensitiveString (
  554. BSTR a_PropertyName ,
  555. WmiTreeNode *a_Operator ,
  556. WmiTreeNode *a_Operand ,
  557. bool a_Class
  558. )
  559. {
  560. QueryPreprocessor :: QuadState t_Status = QueryPreprocessor :: QuadState :: State_True ;
  561. if ( typeid ( *a_Operand ) != typeid ( WmiStringNode ) )
  562. {
  563. return QueryPreprocessor :: QuadState :: State_True ;
  564. }
  565. VARIANT t_Variant ;
  566. VariantInit ( & t_Variant ) ;
  567. WmiStringNode *t_StringNode = ( WmiStringNode * ) a_Operand ;
  568. HRESULT t_Result ;
  569. if ( a_Class )
  570. {
  571. t_Result = GetClassObject ()->Get ( a_PropertyName , 0 , &t_Variant , NULL , NULL ) ;
  572. }
  573. else
  574. {
  575. t_Result = GetInstanceObject ()->Get ( a_PropertyName , 0 , &t_Variant , NULL , NULL ) ;
  576. }
  577. if ( SUCCEEDED ( t_Result ) )
  578. {
  579. if ( t_Variant.vt == VT_BSTR )
  580. {
  581. t_Status = Compare (
  582. t_StringNode->GetValue () ,
  583. t_Variant.bstrVal ,
  584. WmiValueNode :: WmiValueFunction :: Function_Upper ,
  585. WmiValueNode :: WmiValueFunction :: Function_Upper ,
  586. *a_Operator
  587. ) ;
  588. }
  589. else
  590. {
  591. t_Status = QueryPreprocessor :: QuadState :: State_Error ;
  592. }
  593. }
  594. VariantClear ( & t_Variant ) ;
  595. return t_Status ;
  596. }
  597. QueryPreprocessor :: QuadState SnmpQueryEventObject :: CompareInteger (
  598. BSTR a_PropertyName ,
  599. WmiTreeNode *a_Operator ,
  600. WmiTreeNode *a_Operand
  601. )
  602. {
  603. QueryPreprocessor :: QuadState t_Status = QueryPreprocessor :: QuadState :: State_True ;
  604. if ( typeid ( *a_Operand ) != typeid ( WmiSignedIntegerNode ) )
  605. {
  606. return QueryPreprocessor :: QuadState :: State_True ;
  607. }
  608. WmiSignedIntegerNode *t_IntegerNode = ( WmiSignedIntegerNode * ) a_Operand ;
  609. VARIANT t_Variant ;
  610. VariantInit ( & t_Variant ) ;
  611. HRESULT t_Result = GetInstanceObject ()->Get ( a_PropertyName , 0 , &t_Variant , NULL , NULL ) ;
  612. if ( SUCCEEDED ( t_Result ) )
  613. {
  614. if ( t_Variant.vt == VT_I4 )
  615. {
  616. t_Status = Compare (
  617. t_IntegerNode->GetValue () ,
  618. t_Variant.lVal ,
  619. t_IntegerNode->GetPropertyFunction () ,
  620. t_IntegerNode->GetConstantFunction () ,
  621. *a_Operator
  622. ) ;
  623. }
  624. else
  625. {
  626. t_Status = QueryPreprocessor :: QuadState :: State_Error ;
  627. }
  628. }
  629. VariantClear ( & t_Variant ) ;
  630. return t_Status ;
  631. }
  632. QueryPreprocessor :: QuadState SnmpQueryEventObject :: InvariantEvaluate (
  633. void *a_Context ,
  634. WmiTreeNode *a_Operator ,
  635. WmiTreeNode *a_Operand
  636. )
  637. {
  638. WmiValueNode *t_Node = ( WmiValueNode * ) a_Operand ;
  639. BSTR t_PropertyName = t_Node->GetPropertyName () ;
  640. if ( t_PropertyName != NULL )
  641. {
  642. if ( *t_PropertyName == L'_' )
  643. {
  644. // System property, must check values
  645. QueryPreprocessor :: QuadState t_Status = QueryPreprocessor :: QuadState :: State_True ;
  646. if ( _wcsicmp ( t_PropertyName , SYSTEM_PROPERTY_CLASS ) == 0 )
  647. {
  648. t_Status = CompareCaseInsensitiveString (
  649. SYSTEM_PROPERTY_CLASS ,
  650. a_Operator ,
  651. a_Operand
  652. ) ;
  653. }
  654. else if ( _wcsicmp ( t_PropertyName , SYSTEM_PROPERTY_SUPERCLASS ) == 0 )
  655. {
  656. t_Status = CompareCaseInsensitiveString (
  657. SYSTEM_PROPERTY_SUPERCLASS ,
  658. a_Operator ,
  659. a_Operand
  660. ) ;
  661. }
  662. else if ( _wcsicmp ( t_PropertyName , SYSTEM_PROPERTY_GENUS ) == 0 )
  663. {
  664. t_Status = CompareInteger (
  665. SYSTEM_PROPERTY_GENUS ,
  666. a_Operator ,
  667. a_Operand
  668. ) ;
  669. }
  670. else if ( _wcsicmp ( t_PropertyName , SYSTEM_PROPERTY_SERVER ) == 0 )
  671. {
  672. t_Status = CompareCaseInsensitiveString (
  673. SYSTEM_PROPERTY_SERVER ,
  674. a_Operator ,
  675. a_Operand ,
  676. true
  677. ) ;
  678. }
  679. else if ( _wcsicmp ( t_PropertyName , SYSTEM_PROPERTY_NAMESPACE ) == 0 )
  680. {
  681. t_Status = CompareCaseInsensitiveString (
  682. SYSTEM_PROPERTY_NAMESPACE ,
  683. a_Operator ,
  684. a_Operand ,
  685. true
  686. ) ;
  687. }
  688. else if ( _wcsicmp ( t_PropertyName , SYSTEM_PROPERTY_PROPERTY_COUNT ) == 0 )
  689. {
  690. t_Status = CompareInteger (
  691. SYSTEM_PROPERTY_PROPERTY_COUNT ,
  692. a_Operator ,
  693. a_Operand
  694. ) ;
  695. }
  696. else if ( _wcsicmp ( t_PropertyName , SYSTEM_PROPERTY_DYNASTY ) == 0 )
  697. {
  698. }
  699. else if ( _wcsicmp ( t_PropertyName , SYSTEM_PROPERTY_RELPATH ) == 0 )
  700. {
  701. }
  702. else if ( _wcsicmp ( t_PropertyName , SYSTEM_PROPERTY_PATH ) == 0 )
  703. {
  704. }
  705. else if ( _wcsicmp ( t_PropertyName , SYSTEM_PROPERTY_DERIVATION ) == 0 )
  706. {
  707. }
  708. return t_Status ;
  709. }
  710. else
  711. {
  712. WbemSnmpProperty *t_Property ;
  713. if ( t_Property = snmpObject.FindKeyProperty ( t_PropertyName ) )
  714. {
  715. if ( typeid ( *a_Operand ) == typeid ( WmiNullNode ) )
  716. {
  717. return QueryPreprocessor :: QuadState :: State_True ;
  718. }
  719. else
  720. {
  721. return QueryPreprocessor :: QuadState :: State_Undefined ;
  722. }
  723. }
  724. else
  725. {
  726. return QueryPreprocessor :: QuadState :: State_True ;
  727. }
  728. }
  729. }
  730. else
  731. {
  732. return QueryPreprocessor :: QuadState :: State_Undefined ;
  733. }
  734. if ( typeid ( *a_Operand ) == typeid ( WmiNullNode ) )
  735. {
  736. return QueryPreprocessor :: QuadState :: State_True ;
  737. }
  738. #if 0
  739. else if ( typeid ( *a_Operator ) == typeid ( WmiStringNode ) )
  740. {
  741. return QueryPreprocessor :: QuadState :: State_Undefined ;
  742. }
  743. else if ( typeid ( *a_Operator ) == typeid ( WmiUnsignedIntegerNode ) )
  744. {
  745. return QueryPreprocessor :: QuadState :: State_Undefined ;
  746. }
  747. else if ( typeid ( *a_Operator ) == typeid ( WmiSignedIntegerNode ) )
  748. {
  749. return QueryPreprocessor :: QuadState :: State_Undefined ;
  750. }
  751. if ( typeid ( *a_Operator ) == typeid ( WmiOperatorEqualNode ) )
  752. {
  753. return QueryPreprocessor :: QuadState :: State_Undefined ;
  754. }
  755. else if ( typeid ( *a_Operator ) == typeid ( WmiOperatorNotEqualNode ) )
  756. {
  757. return QueryPreprocessor :: QuadState :: State_Undefined ;
  758. }
  759. else if ( typeid ( *a_Operator ) == typeid ( WmiOperatorEqualOrGreaterNode ) )
  760. {
  761. return QueryPreprocessor :: QuadState :: State_Undefined ;
  762. }
  763. else if ( typeid ( *a_Operator ) == typeid ( WmiOperatorEqualOrLessNode ) )
  764. {
  765. return QueryPreprocessor :: QuadState :: State_Undefined ;
  766. }
  767. else if ( typeid ( *a_Operator ) == typeid ( WmiOperatorLessNode ) )
  768. {
  769. return QueryPreprocessor :: QuadState :: State_Undefined ;
  770. }
  771. else if ( typeid ( *a_Operator ) == typeid ( WmiOperatorGreaterNode ) )
  772. {
  773. return QueryPreprocessor :: QuadState :: State_Undefined ;
  774. }
  775. else if ( typeid ( *a_Operator ) == typeid ( WmiOperatorLikeNode ) )
  776. {
  777. return QueryPreprocessor :: QuadState :: State_Undefined ;
  778. }
  779. else if ( typeid ( *a_Operator ) == typeid ( WmiOperatorNotLikeNode ) )
  780. {
  781. return QueryPreprocessor :: QuadState :: State_Undefined ;
  782. }
  783. #endif
  784. return QueryPreprocessor :: QuadState :: State_Undefined ;
  785. }
  786. WmiRangeNode *SnmpQueryEventObject :: AllocInfiniteRangeNode (
  787. void *a_Context ,
  788. BSTR a_PropertyName
  789. )
  790. {
  791. WmiRangeNode *t_RangeNode = NULL ;
  792. VARTYPE t_VarType = VT_NULL ;
  793. WbemSnmpProperty *t_Property ;
  794. if ( t_Property = snmpObject.FindKeyProperty ( a_PropertyName ) )
  795. {
  796. t_VarType = t_Property->GetValueVariantEncodedType () ;
  797. }
  798. switch ( t_VarType )
  799. {
  800. case VT_I4:
  801. {
  802. t_RangeNode = new WmiSignedIntegerRangeNode (
  803. a_PropertyName ,
  804. 0xFFFFFFFF ,
  805. TRUE ,
  806. TRUE ,
  807. FALSE ,
  808. FALSE ,
  809. 0 ,
  810. 0 ,
  811. NULL ,
  812. NULL
  813. ) ;
  814. }
  815. break ;
  816. case VT_UI4:
  817. {
  818. t_RangeNode = new WmiUnsignedIntegerRangeNode (
  819. a_PropertyName ,
  820. 0xFFFFFFFF ,
  821. TRUE ,
  822. TRUE ,
  823. FALSE ,
  824. FALSE ,
  825. 0 ,
  826. 0 ,
  827. NULL ,
  828. NULL
  829. ) ;
  830. }
  831. break ;
  832. case VT_BSTR:
  833. {
  834. t_RangeNode = new WmiStringRangeNode (
  835. a_PropertyName ,
  836. 0x0 ,
  837. TRUE ,
  838. TRUE ,
  839. FALSE ,
  840. FALSE ,
  841. NULL ,
  842. NULL ,
  843. NULL ,
  844. NULL
  845. ) ;
  846. }
  847. break ;
  848. default:
  849. {
  850. }
  851. break ;
  852. }
  853. return t_RangeNode ;
  854. }
  855. void SnmpQueryEventObject :: GetPropertiesToPartition ( ULONG &a_Count , BSTR *&a_Container )
  856. {
  857. a_Count = snmpObject.GetKeyPropertyCount () ;
  858. a_Container = new BSTR [ a_Count ] ;
  859. ULONG t_PropertyIndex = 0 ;
  860. WbemSnmpProperty *t_Property = NULL ;
  861. snmpObject.ResetKeyProperty () ;
  862. while ( t_Property = snmpObject.NextKeyProperty () )
  863. {
  864. a_Container [ t_PropertyIndex ] = SysAllocString ( t_Property->GetName () ) ;
  865. t_PropertyIndex ++ ;
  866. }
  867. }
  868. SnmpQueryEventObject :: SnmpQueryEventObject (
  869. CImpPropProv *providerArg ,
  870. BSTR QueryFormatArg ,
  871. BSTR QueryArg ,
  872. IWbemContext *a_Context
  873. ) : SnmpInstanceResponseEventObject ( providerArg , a_Context ) ,
  874. Query ( NULL ) ,
  875. QueryFormat ( NULL ) ,
  876. parser ( NULL ) ,
  877. source ( NULL ) ,
  878. requestObject ( NULL ) ,
  879. rpnExpression ( NULL )
  880. {
  881. Query = UnicodeStringDuplicate ( QueryArg ) ;
  882. QueryFormat = UnicodeStringDuplicate ( QueryFormatArg ) ;
  883. source.SetString(Query);
  884. parser.SetSource(&source);
  885. }
  886. SnmpQueryEventObject :: ~SnmpQueryEventObject ()
  887. {
  888. delete [] Query ;
  889. delete [] QueryFormat ;
  890. delete rpnExpression ;
  891. delete requestObject ;
  892. }
  893. BOOL SnmpQueryEventObject :: Instantiate ( WbemSnmpErrorObject &a_errorObject )
  894. {
  895. DebugMacro3(
  896. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  897. __FILE__,__LINE__,
  898. L"SnmpQueryEventObject :: Instantiate ( WbemSnmpErrorObject &a_errorObject )"
  899. ) ;
  900. )
  901. BOOL status = TRUE ;
  902. if ( _wcsicmp ( QueryFormat , WBEM_QUERY_LANGUAGE_WQL ) == 0 )
  903. {
  904. status = parser.Parse ( & rpnExpression ) ;
  905. if ( status == FALSE )
  906. {
  907. IWbemServices *t_Serv = provider->GetServer();
  908. HRESULT result = WBEM_E_FAILED;
  909. if (t_Serv)
  910. {
  911. result = t_Serv->GetObject (
  912. rpnExpression->bsClassName,
  913. 0 ,
  914. m_Context ,
  915. & classObject ,
  916. NULL
  917. ) ;
  918. t_Serv->Release();
  919. }
  920. if ( SUCCEEDED ( result ) )
  921. {
  922. result = classObject->SpawnInstance ( 0 , & instanceObject ) ;
  923. if ( SUCCEEDED ( result ) )
  924. {
  925. if ( status = GetNamespaceObject ( a_errorObject ) )
  926. {
  927. if ( status = snmpObject.Set ( a_errorObject , classObject , FALSE ) )
  928. {
  929. if ( status = snmpObject.Check ( a_errorObject ) )
  930. {
  931. if ( status = PreEvaluate ( a_errorObject ) )
  932. {
  933. WmiTreeNode *t_Root = NULL ;
  934. QueryPreprocessor :: QuadState t_State = PreProcess (
  935. m_Context ,
  936. rpnExpression ,
  937. t_Root
  938. ) ;
  939. switch ( t_State )
  940. {
  941. case QueryPreprocessor :: QuadState :: State_True:
  942. {
  943. ULONG t_PropertyContainerCount = 0 ;
  944. BSTR *t_PropertyContainer = NULL ;
  945. GetPropertiesToPartition ( t_PropertyContainerCount , t_PropertyContainer ) ;
  946. try
  947. {
  948. t_State = PreProcess (
  949. m_Context ,
  950. rpnExpression ,
  951. t_Root ,
  952. t_PropertyContainerCount ,
  953. t_PropertyContainer ,
  954. m_PartitionSet
  955. ) ;
  956. }
  957. catch ( ... )
  958. {
  959. // delete properties container
  960. if ( t_PropertyContainerCount )
  961. {
  962. for ( ULONG t_Count = 0; t_Count < t_PropertyContainerCount; t_Count++ )
  963. {
  964. if ( t_PropertyContainer [ t_Count ] )
  965. {
  966. ::SysFreeString ( t_PropertyContainer [ t_Count] );
  967. t_PropertyContainer [ t_Count ] = NULL;
  968. }
  969. }
  970. delete [] t_PropertyContainer;
  971. t_PropertyContainer = NULL;
  972. }
  973. if ( m_PartitionSet )
  974. {
  975. delete m_PartitionSet;
  976. m_PartitionSet = NULL;
  977. }
  978. if ( t_Root )
  979. {
  980. delete t_Root;
  981. t_Root = NULL;
  982. }
  983. throw;
  984. }
  985. // delete properties container
  986. if ( t_PropertyContainerCount )
  987. {
  988. for ( ULONG t_Count = 0; t_Count < t_PropertyContainerCount; t_Count++ )
  989. {
  990. if ( t_PropertyContainer [ t_Count ] )
  991. {
  992. ::SysFreeString ( t_PropertyContainer [ t_Count] );
  993. t_PropertyContainer [ t_Count ] = NULL;
  994. }
  995. }
  996. delete [] t_PropertyContainer;
  997. t_PropertyContainer = NULL;
  998. }
  999. switch ( t_State )
  1000. {
  1001. case QueryPreprocessor :: QuadState :: State_True:
  1002. {
  1003. delete m_PartitionSet ;
  1004. m_PartitionSet = NULL ;
  1005. status = SendSnmp ( a_errorObject ) ;
  1006. }
  1007. break ;
  1008. case QueryPreprocessor :: QuadState :: State_False:
  1009. {
  1010. status = FALSE ;
  1011. delete m_PartitionSet ;
  1012. m_PartitionSet = NULL ;
  1013. a_errorObject.SetStatus ( WBEM_SNMP_NO_ERROR ) ;
  1014. a_errorObject.SetWbemStatus ( WBEM_S_NO_ERROR ) ;
  1015. a_errorObject.SetMessage ( L"" ) ;
  1016. }
  1017. break ;
  1018. case QueryPreprocessor :: QuadState :: State_Undefined:
  1019. {
  1020. status = SendSnmp ( a_errorObject ) ;
  1021. }
  1022. break ;
  1023. default:
  1024. {
  1025. status = FALSE ;
  1026. a_errorObject.SetStatus ( WBEM_SNMP_E_INVALID_QUERY ) ;
  1027. a_errorObject.SetWbemStatus ( WBEM_E_INVALID_QUERY ) ;
  1028. a_errorObject.SetMessage ( L"WQL query was invalid" ) ;
  1029. }
  1030. break ;
  1031. }
  1032. delete t_Root ;
  1033. }
  1034. break ;
  1035. default:
  1036. {
  1037. status = FALSE ;
  1038. a_errorObject.SetStatus ( WBEM_SNMP_E_INVALID_QUERY ) ;
  1039. a_errorObject.SetWbemStatus ( WBEM_E_INVALID_QUERY ) ;
  1040. a_errorObject.SetMessage ( L"WQL query was invalid" ) ;
  1041. }
  1042. break ;
  1043. }
  1044. }
  1045. }
  1046. else
  1047. {
  1048. DebugMacro3(
  1049. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  1050. __FILE__,__LINE__,
  1051. L"Failed During Check : Class definition did not conform to mapping"
  1052. ) ;
  1053. )
  1054. }
  1055. }
  1056. else
  1057. {
  1058. DebugMacro3(
  1059. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  1060. __FILE__,__LINE__,
  1061. L"Failed During Set : Class definition did not conform to mapping"
  1062. ) ;
  1063. )
  1064. }
  1065. }
  1066. }
  1067. }
  1068. else
  1069. {
  1070. DebugMacro3(
  1071. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  1072. __FILE__,__LINE__,
  1073. L"Class definition unknown"
  1074. ) ;
  1075. )
  1076. }
  1077. }
  1078. else
  1079. {
  1080. DebugMacro3(
  1081. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  1082. __FILE__,__LINE__,
  1083. L"Illegal SQL 1 Query"
  1084. ) ;
  1085. )
  1086. status = FALSE ;
  1087. a_errorObject.SetStatus ( WBEM_SNMP_E_INVALID_QUERY ) ;
  1088. a_errorObject.SetWbemStatus ( WBEM_E_INVALID_QUERY ) ;
  1089. a_errorObject.SetMessage ( L"WQL query was invalid" ) ;
  1090. }
  1091. }
  1092. else
  1093. {
  1094. DebugMacro3(
  1095. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  1096. __FILE__,__LINE__,
  1097. L"Query format not known"
  1098. ) ;
  1099. )
  1100. status = FALSE ;
  1101. a_errorObject.SetStatus ( WBEM_SNMP_E_INVALID_QUERY_TYPE ) ;
  1102. a_errorObject.SetWbemStatus ( WBEM_E_INVALID_QUERY_TYPE ) ;
  1103. a_errorObject.SetMessage ( L"Query Language not supported" ) ;
  1104. }
  1105. return status ;
  1106. }
  1107. BOOL SnmpQueryEventObject :: IsSystemProperty (const wchar_t *propertyName )
  1108. {
  1109. DebugMacro3(
  1110. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  1111. __FILE__,__LINE__,
  1112. L"SnmpQueryEventObject :: SnmpQueryEventObject :: IsSystemProperty (const wchar_t *propertyName )"
  1113. ) ;
  1114. )
  1115. //Only SYSTEM properties may start with an '_' character.
  1116. return ( *propertyName == SYTEM_PROPERTY_START_CHARACTER ) ;
  1117. }
  1118. BOOL SnmpQueryEventObject :: PreEvaluate ( WbemSnmpErrorObject &a_errorObject )
  1119. {
  1120. DebugMacro3(
  1121. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  1122. __FILE__,__LINE__,
  1123. L"SnmpQueryEventObject :: PreEvaluate ( WbemSnmpErrorObject &a_errorObject )"
  1124. ) ;
  1125. )
  1126. BOOL status = TRUE ;
  1127. if ( rpnExpression->nNumberOfProperties == 0 )
  1128. {
  1129. // Get All Properties
  1130. DebugMacro3(
  1131. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  1132. __FILE__,__LINE__,
  1133. L"Get All Properties"
  1134. ) ;
  1135. )
  1136. requestObject = new SnmpInstanceClassObject ( snmpObject ) ;
  1137. }
  1138. else if ( snmpObject.IsVirtual () )
  1139. {
  1140. // Get All Properties since some keys are virtuals
  1141. DebugMacro3(
  1142. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  1143. __FILE__,__LINE__,
  1144. L"Get All Properties because some keys are virtual"
  1145. ) ;
  1146. )
  1147. requestObject = new SnmpInstanceClassObject ( snmpObject ) ;
  1148. }
  1149. else
  1150. {
  1151. // Get List of Properties for return and list of properties for filter evaluation
  1152. DebugMacro3(
  1153. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  1154. __FILE__,__LINE__,
  1155. L"Get Subset of Properties"
  1156. ) ;
  1157. )
  1158. requestObject = new SnmpInstanceClassObject ( this );
  1159. status = FilterSelectProperties ( a_errorObject ) ;
  1160. }
  1161. if ( status )
  1162. {
  1163. DebugMacro3(
  1164. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  1165. __FILE__,__LINE__,
  1166. L"Check Where Clause is legal"
  1167. ) ;
  1168. )
  1169. status = PreEvaluateWhereClause ( a_errorObject ) ;
  1170. }
  1171. return status ;
  1172. }
  1173. BOOL SnmpQueryEventObject :: FilterSelectProperties ( WbemSnmpErrorObject &a_errorObject )
  1174. {
  1175. DebugMacro3(
  1176. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  1177. __FILE__,__LINE__,
  1178. L"SnmpQueryEventObject :: FilterSelectProperties ( WbemSnmpErrorObject &a_errorObject )"
  1179. ) ;
  1180. )
  1181. BOOL status = TRUE ;
  1182. LONG varType = 0 ;
  1183. VARIANT variant ;
  1184. VariantInit ( & variant ) ;
  1185. WbemSnmpQualifier *qualifier = NULL ;
  1186. snmpObject.ResetQualifier () ;
  1187. while ( status && ( qualifier = snmpObject.NextQualifier () ) )
  1188. {
  1189. WbemSnmpQualifier *copy = new WbemSnmpQualifier ( *qualifier ) ;
  1190. status = requestObject->AddQualifier ( copy ) ;
  1191. if (!status)
  1192. {
  1193. delete copy;
  1194. }
  1195. }
  1196. int index = 0 ;
  1197. BOOL has_path_property = FALSE ;
  1198. while ( status && ( index < rpnExpression->nNumberOfProperties ) )
  1199. {
  1200. wchar_t *propertyName = rpnExpression->pbsRequestedPropertyNames [ index ] ;
  1201. WbemSnmpProperty *property ;
  1202. if ( property = snmpObject.FindProperty ( propertyName ) )
  1203. {
  1204. status = requestObject->AddProperty ( new WbemSnmpProperty ( *property ) ) ;
  1205. if (!status)
  1206. {
  1207. delete property;
  1208. }
  1209. }
  1210. else if ( IsSystemProperty ( propertyName ) )
  1211. {
  1212. if ( ( _wcsicmp ( propertyName , SYSTEM_PROPERTY_RELPATH ) == 0 ) ||
  1213. ( _wcsicmp ( propertyName , SYSTEM_PROPERTY_PATH ) == 0 ) )
  1214. {
  1215. has_path_property = TRUE;
  1216. }
  1217. }
  1218. else
  1219. {
  1220. DebugMacro3(
  1221. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  1222. __FILE__,__LINE__,
  1223. L"Property in SELECT clause is not a valid class property"
  1224. ) ;
  1225. )
  1226. status = FALSE ;
  1227. a_errorObject.SetStatus ( WBEM_SNMP_E_INVALID_QUERY ) ;
  1228. a_errorObject.SetWbemStatus ( WBEM_E_INVALID_QUERY ) ;
  1229. a_errorObject.SetMessage ( L"SELECT properties of WQL query were invalid" ) ;
  1230. }
  1231. index ++ ;
  1232. }
  1233. if ( status && has_path_property )
  1234. {
  1235. //add in all keys not present...
  1236. WbemSnmpProperty *property = NULL;
  1237. while ( property = snmpObject.NextKeyProperty () )
  1238. {
  1239. if ( ! requestObject->FindProperty ( property->GetName () ) )
  1240. {
  1241. status = requestObject->AddProperty ( new WbemSnmpProperty ( *property ) ) ;
  1242. if (!status)
  1243. {
  1244. delete property;
  1245. }
  1246. }
  1247. }
  1248. }
  1249. if ( status )
  1250. {
  1251. status = requestObject->Check ( a_errorObject ) ;
  1252. }
  1253. return status ;
  1254. }
  1255. BOOL SnmpQueryEventObject :: CheckWhereCondition (
  1256. WbemSnmpErrorObject &a_errorObject ,
  1257. WbemSnmpProperty *property ,
  1258. SQL_LEVEL_1_TOKEN *token
  1259. )
  1260. {
  1261. DebugMacro3(
  1262. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  1263. __FILE__,__LINE__,
  1264. L"SnmpQueryEventObject :: SnmpQueryEventObject :: CheckWhereCondition ( WbemSnmpErrorObject &a_errorObject , WbemSnmpProperty *property , SQL_LEVEL_1_TOKEN *token)"
  1265. ) ;
  1266. )
  1267. BOOL status = TRUE ;
  1268. switch ( property->GetValueVariantEncodedType () )
  1269. {
  1270. case VT_UI4:
  1271. case VT_I4:
  1272. {
  1273. switch ( token->vConstValue.vt )
  1274. {
  1275. case VT_NULL:
  1276. case VT_I4:
  1277. {
  1278. }
  1279. break ;
  1280. default:
  1281. {
  1282. status = FALSE ;
  1283. a_errorObject.SetStatus ( WBEM_SNMP_E_INVALID_QUERY ) ;
  1284. a_errorObject.SetWbemStatus ( WBEM_E_INVALID_QUERY ) ;
  1285. a_errorObject.SetMessage ( L"WHERE clause of WQL query specified type value inconsistent with property value type" ) ;
  1286. }
  1287. break ;
  1288. }
  1289. }
  1290. break ;
  1291. case VT_BSTR:
  1292. {
  1293. switch ( token->vConstValue.vt )
  1294. {
  1295. case VT_NULL:
  1296. case VT_BSTR:
  1297. {
  1298. }
  1299. break ;
  1300. default:
  1301. {
  1302. status = FALSE ;
  1303. a_errorObject.SetStatus ( WBEM_SNMP_E_INVALID_QUERY ) ;
  1304. a_errorObject.SetWbemStatus ( WBEM_E_INVALID_QUERY ) ;
  1305. a_errorObject.SetMessage ( L"WHERE clause of WQL query specified type value inconsistent with property value type" ) ;
  1306. }
  1307. break ;
  1308. }
  1309. }
  1310. break ;
  1311. case VT_NULL:
  1312. {
  1313. switch ( token->vConstValue.vt )
  1314. {
  1315. case VT_NULL:
  1316. {
  1317. }
  1318. break ;
  1319. default:
  1320. {
  1321. status = FALSE ;
  1322. a_errorObject.SetStatus ( WBEM_SNMP_E_INVALID_QUERY ) ;
  1323. a_errorObject.SetWbemStatus ( WBEM_E_INVALID_QUERY ) ;
  1324. a_errorObject.SetMessage ( L"WHERE clause of WQL query specified type value inconsistent with property value type" ) ;
  1325. }
  1326. break ;
  1327. }
  1328. }
  1329. break ;
  1330. default:
  1331. {
  1332. status = FALSE ;
  1333. a_errorObject.SetStatus ( WBEM_SNMP_E_INVALID_QUERY ) ;
  1334. a_errorObject.SetWbemStatus ( WBEM_E_INVALID_QUERY ) ;
  1335. a_errorObject.SetMessage ( L"WHERE clause of WQL query specified type value inconsistent with property value type" ) ;
  1336. }
  1337. break ;
  1338. }
  1339. return status ;
  1340. }
  1341. BOOL SnmpQueryEventObject :: PreEvaluateWhereClause ( WbemSnmpErrorObject &a_errorObject )
  1342. {
  1343. DebugMacro3(
  1344. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  1345. __FILE__,__LINE__,
  1346. L"SnmpQueryEventObject :: PreEvaluateWhereClause ( WbemSnmpErrorObject &a_errorObject )"
  1347. ) ;
  1348. )
  1349. BOOL status = TRUE ;
  1350. int index = 0 ;
  1351. while ( status && ( index < rpnExpression->nNumTokens ) )
  1352. {
  1353. SQL_LEVEL_1_TOKEN *propertyValue = &rpnExpression->pArrayOfTokens [ index ] ;
  1354. if ( propertyValue->nTokenType == SQL_LEVEL_1_TOKEN :: OP_EXPRESSION )
  1355. {
  1356. wchar_t *propertyName = propertyValue->pPropertyName ;
  1357. WbemSnmpProperty *property ;
  1358. if ( property = requestObject->FindProperty ( propertyName ) )
  1359. {
  1360. status = CheckWhereCondition ( a_errorObject , property , propertyValue ) ;
  1361. if ( status )
  1362. {
  1363. requestObject->AddProperty ( new WbemSnmpProperty ( *property ) ) ;
  1364. }
  1365. else
  1366. {
  1367. }
  1368. }
  1369. else if ( ! IsSystemProperty ( propertyName ) )
  1370. {
  1371. // Property Not Found
  1372. status = FALSE ;
  1373. a_errorObject.SetStatus ( WBEM_SNMP_E_NOT_SUPPORTED ) ;
  1374. a_errorObject.SetWbemStatus ( WBEM_E_NOT_SUPPORTED ) ;
  1375. a_errorObject.SetMessage ( L"WHERE clause of WQL query specified unknown property name" ) ;
  1376. }
  1377. }
  1378. index ++ ;
  1379. }
  1380. return status ;
  1381. }
  1382. #ifdef POST_FILTERING_RECEIVED_ROW
  1383. BOOL SnmpQueryEventObject :: Compare (
  1384. const LONG & op1 ,
  1385. const LONG & op2 ,
  1386. const DWORD & op1Func ,
  1387. const DWORD & op2Func ,
  1388. const int & operatorType
  1389. )
  1390. {
  1391. BOOL status = FALSE ;
  1392. switch ( op1Func )
  1393. {
  1394. case SQL_LEVEL_1_TOKEN :: IFUNC_NONE:
  1395. {
  1396. }
  1397. break ;
  1398. default:
  1399. {
  1400. }
  1401. break ;
  1402. }
  1403. switch ( op2Func )
  1404. {
  1405. case SQL_LEVEL_1_TOKEN :: IFUNC_NONE:
  1406. {
  1407. }
  1408. break ;
  1409. default:
  1410. {
  1411. }
  1412. break ;
  1413. }
  1414. switch ( operatorType )
  1415. {
  1416. case SQL_LEVEL_1_TOKEN :: OP_EQUAL:
  1417. {
  1418. status = op1 == op2 ;
  1419. }
  1420. break ;
  1421. case SQL_LEVEL_1_TOKEN :: OP_NOT_EQUAL:
  1422. {
  1423. status = op1 != op2 ;
  1424. }
  1425. break ;
  1426. case SQL_LEVEL_1_TOKEN :: OP_EQUALorGREATERTHAN:
  1427. {
  1428. status = op1 >= op2 ;
  1429. }
  1430. break ;
  1431. case SQL_LEVEL_1_TOKEN :: OP_EQUALorLESSTHAN:
  1432. {
  1433. status = op1 <= op2 ;
  1434. }
  1435. break ;
  1436. case SQL_LEVEL_1_TOKEN :: OP_LESSTHAN:
  1437. {
  1438. status = op1 < op2 ;
  1439. }
  1440. break ;
  1441. case SQL_LEVEL_1_TOKEN :: OP_GREATERTHAN:
  1442. {
  1443. status = op1 > op2 ;
  1444. }
  1445. break ;
  1446. case SQL_LEVEL_1_TOKEN :: OP_LIKE:
  1447. default:
  1448. {
  1449. }
  1450. break ;
  1451. }
  1452. return status ;
  1453. }
  1454. BOOL SnmpQueryEventObject :: Compare (
  1455. const wchar_t * & op1 ,
  1456. const wchar_t * & op2 ,
  1457. const DWORD & op1Func ,
  1458. const DWORD & op2Func ,
  1459. const int & operatorType
  1460. )
  1461. {
  1462. DebugMacro3(
  1463. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  1464. __FILE__,__LINE__,
  1465. L"SnmpQueryEventObject :: Compare ()"
  1466. ) ;
  1467. )
  1468. BOOL status = FALSE ;
  1469. wchar_t *op1AfterFunc = NULL ;
  1470. wchar_t *op2AfterFunc = NULL ;
  1471. switch ( op1Func )
  1472. {
  1473. case SQL_LEVEL_1_TOKEN :: IFUNC_NONE:
  1474. {
  1475. }
  1476. break ;
  1477. case SQL_LEVEL_1_TOKEN :: IFUNC_UPPER:
  1478. {
  1479. ULONG length = wcslen ( op1 ) ;
  1480. wchar_t *op1AfterFunc = new wchar_t [ length + 1 ] ;
  1481. for ( ULONG index = 0 ; index < length ; index ++ )
  1482. {
  1483. op1AfterFunc [ index ] = toupper ( op1 [ index ] ) ;
  1484. }
  1485. }
  1486. break ;
  1487. case SQL_LEVEL_1_TOKEN :: IFUNC_LOWER:
  1488. {
  1489. ULONG length = wcslen ( op1 ) ;
  1490. wchar_t *op1AfterFunc = new wchar_t [ length + 1 ] ;
  1491. for ( ULONG index = 0 ; index < length ; index ++ )
  1492. {
  1493. op1AfterFunc [ index ] = tolower ( op1 [ index ] ) ;
  1494. }
  1495. }
  1496. break ;
  1497. default:
  1498. {
  1499. }
  1500. break ;
  1501. }
  1502. switch ( op2Func )
  1503. {
  1504. case SQL_LEVEL_1_TOKEN :: IFUNC_NONE:
  1505. {
  1506. }
  1507. break ;
  1508. case SQL_LEVEL_1_TOKEN :: IFUNC_UPPER:
  1509. {
  1510. ULONG length = wcslen ( op2 ) ;
  1511. wchar_t *op2AfterFunc = new wchar_t [ length + 1 ] ;
  1512. for ( ULONG index = 0 ; index < length ; index ++ )
  1513. {
  1514. op2AfterFunc [ index ] = toupper ( op2 [ index ] ) ;
  1515. }
  1516. }
  1517. break ;
  1518. case SQL_LEVEL_1_TOKEN :: IFUNC_LOWER:
  1519. {
  1520. ULONG length = wcslen ( op2 ) ;
  1521. wchar_t *op2AfterFunc = new wchar_t [ length + 1 ] ;
  1522. for ( ULONG index = 0 ; index < length ; index ++ )
  1523. {
  1524. op2AfterFunc [ index ] = tolower ( op2 [ index ] ) ;
  1525. }
  1526. }
  1527. break ;
  1528. default:
  1529. {
  1530. }
  1531. break ;
  1532. }
  1533. const wchar_t *arg1 = op1AfterFunc ? op1AfterFunc : op1 ;
  1534. const wchar_t *arg2 = op2AfterFunc ? op2AfterFunc : op2 ;
  1535. switch ( operatorType )
  1536. {
  1537. case SQL_LEVEL_1_TOKEN :: OP_EQUAL:
  1538. {
  1539. status = wcscmp ( arg1 , arg2 ) == 0 ;
  1540. }
  1541. break ;
  1542. case SQL_LEVEL_1_TOKEN :: OP_NOT_EQUAL:
  1543. {
  1544. status = wcscmp ( arg1 , arg2 ) != 0 ;
  1545. }
  1546. break ;
  1547. case SQL_LEVEL_1_TOKEN :: OP_EQUALorGREATERTHAN:
  1548. {
  1549. status = wcscmp ( arg1 , arg2 ) >= 0 ;
  1550. }
  1551. break ;
  1552. case SQL_LEVEL_1_TOKEN :: OP_EQUALorLESSTHAN:
  1553. {
  1554. status = wcscmp ( arg1 , arg2 ) <= 0 ;
  1555. }
  1556. break ;
  1557. case SQL_LEVEL_1_TOKEN :: OP_LESSTHAN:
  1558. {
  1559. status = wcscmp ( arg1 , arg2 ) < 0 ;
  1560. }
  1561. break ;
  1562. case SQL_LEVEL_1_TOKEN :: OP_GREATERTHAN:
  1563. {
  1564. status = wcscmp ( arg1 , arg2 ) > 0 ;
  1565. }
  1566. break ;
  1567. case SQL_LEVEL_1_TOKEN :: OP_LIKE:
  1568. default:
  1569. {
  1570. }
  1571. break ;
  1572. }
  1573. delete [] op1AfterFunc ;
  1574. delete [] op2AfterFunc ;
  1575. return status ;
  1576. }
  1577. BOOL SnmpQueryEventObject :: ExpressionCompare ( SnmpInstanceClassObject *snmpObject , SQL_LEVEL_1_TOKEN *propertyValue )
  1578. {
  1579. DebugMacro3(
  1580. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  1581. __FILE__,__LINE__,
  1582. L"SnmpQueryEventObject :: ExpressionCompare ( SnmpInstanceClassObject *snmpObject , SQL_LEVEL_1_TOKEN *propertyValue )"
  1583. ) ;
  1584. )
  1585. BOOL status = FALSE ;
  1586. wchar_t *propertyName = propertyValue->pPropertyName ;
  1587. WbemSnmpProperty *property ;
  1588. if ( property = snmpObject->FindProperty ( propertyName ) )
  1589. {
  1590. VARIANT variant ;
  1591. VariantInit ( & variant ) ;
  1592. DebugMacro3(
  1593. wchar_t *t_StringValue = ( property->GetValue () ) ? property->GetValue ()->GetStringValue () : NULL ;
  1594. if ( t_StringValue )
  1595. {
  1596. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  1597. __FILE__,__LINE__,
  1598. L"Property (%s),(%s)",
  1599. propertyName ,
  1600. t_StringValue
  1601. ) ;
  1602. }
  1603. delete [] t_StringValue ;
  1604. )
  1605. CIMTYPE varType ;
  1606. if ( property->GetValue ( variant , cimType ) )
  1607. {
  1608. switch ( variant.vt )
  1609. {
  1610. case VT_NULL:
  1611. {
  1612. switch ( propertyValue->vConstValue.vt )
  1613. {
  1614. case VT_NULL:
  1615. {
  1616. status = TRUE ;
  1617. }
  1618. break ;
  1619. default:
  1620. {
  1621. }
  1622. break ;
  1623. }
  1624. }
  1625. break;
  1626. case VT_I4:
  1627. {
  1628. switch ( propertyValue->vConstValue.vt )
  1629. {
  1630. case VT_I4:
  1631. {
  1632. status = Compare (
  1633. variant.lVal ,
  1634. propertyValue->vConstValue.lVal ,
  1635. propertyValue->dwPropertyFunction ,
  1636. propertyValue->dwConstFunction ,
  1637. propertyValue->nOperator
  1638. ) ;
  1639. }
  1640. break ;
  1641. default:
  1642. {
  1643. }
  1644. break ;
  1645. }
  1646. }
  1647. break ;
  1648. case VT_BSTR:
  1649. {
  1650. switch ( propertyValue->vConstValue.vt )
  1651. {
  1652. case VT_BSTR:
  1653. {
  1654. status = Compare (
  1655. variant.bstrVal ,
  1656. propertyValue->vConstValue.bstrVal ,
  1657. propertyValue->dwPropertyFunction ,
  1658. propertyValue->dwConstFunction ,
  1659. propertyValue->nOperator
  1660. ) ;
  1661. }
  1662. break ;
  1663. default:
  1664. {
  1665. }
  1666. break ;
  1667. }
  1668. }
  1669. break ;
  1670. default:
  1671. {
  1672. }
  1673. break ;
  1674. }
  1675. VariantClear ( &variant ) ;
  1676. }
  1677. else
  1678. {
  1679. // Problem Here
  1680. }
  1681. }
  1682. else
  1683. {
  1684. // Problem Here
  1685. }
  1686. return status ;
  1687. }
  1688. BOOL SnmpQueryEventObject :: PostEvaluateWhereClause ( SnmpInstanceClassObject *snmpObject )
  1689. {
  1690. DebugMacro3(
  1691. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  1692. __FILE__,__LINE__,
  1693. L"SnmpQueryEventObject :: PostEvaluateWhereClause ( SnmpInstanceClassObject *snmpObject )"
  1694. ) ;
  1695. )
  1696. BOOL t_Status = TRUE ;
  1697. if ( rpnExpression->nNumTokens )
  1698. {
  1699. int count = rpnExpression->nNumTokens - 1 ;
  1700. t_Status = RecursivePostEvaluateWhereClause ( snmpObject , count ) ;
  1701. }
  1702. else
  1703. {
  1704. }
  1705. DebugMacro3(
  1706. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  1707. __FILE__,__LINE__,
  1708. L"PostEvaluation Status = (%lu)" ,
  1709. ( ULONG ) t_Status
  1710. ) ;
  1711. )
  1712. return t_Status ;
  1713. }
  1714. BOOL SnmpQueryEventObject :: RecursivePostEvaluateWhereClause ( SnmpInstanceClassObject *snmpObject , int &index )
  1715. {
  1716. DebugMacro3(
  1717. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  1718. __FILE__,__LINE__,
  1719. L"SnmpQueryEventObject :: RecursivePostEvaluateWhereClause ( SnmpInstanceClassObject *snmpObject , int &index )"
  1720. ) ;
  1721. )
  1722. BOOL status = FALSE ;
  1723. SQL_LEVEL_1_TOKEN *propertyValue = & ( rpnExpression->pArrayOfTokens [ index ] ) ;
  1724. index -- ;
  1725. switch ( propertyValue->nTokenType )
  1726. {
  1727. case SQL_LEVEL_1_TOKEN :: OP_EXPRESSION:
  1728. {
  1729. DebugMacro3(
  1730. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  1731. __FILE__,__LINE__,
  1732. L"Operation = OP_EXPESSION"
  1733. ) ;
  1734. )
  1735. status = ExpressionCompare ( snmpObject , propertyValue ) ;
  1736. }
  1737. break ;
  1738. case SQL_LEVEL_1_TOKEN :: TOKEN_AND:
  1739. {
  1740. status = RecursivePostEvaluateWhereClause ( snmpObject , index ) &&
  1741. RecursivePostEvaluateWhereClause ( snmpObject , index ) ;
  1742. DebugMacro3(
  1743. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  1744. __FILE__,__LINE__,
  1745. L"Operation = TOKEN_AND"
  1746. ) ;
  1747. )
  1748. }
  1749. break ;
  1750. case SQL_LEVEL_1_TOKEN :: TOKEN_OR:
  1751. {
  1752. status = RecursivePostEvaluateWhereClause ( snmpObject , index ) ||
  1753. RecursivePostEvaluateWhereClause ( snmpObject , index ) ;
  1754. DebugMacro3(
  1755. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  1756. __FILE__,__LINE__,
  1757. L"Operation = TOKEN_OR"
  1758. ) ;
  1759. )
  1760. }
  1761. break ;
  1762. case SQL_LEVEL_1_TOKEN :: TOKEN_NOT:
  1763. {
  1764. status = ! RecursivePostEvaluateWhereClause ( snmpObject , index ) ;
  1765. DebugMacro3(
  1766. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  1767. __FILE__,__LINE__,
  1768. L"Operation = TOKEN_NOT"
  1769. ) ;
  1770. )
  1771. }
  1772. break ;
  1773. }
  1774. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  1775. __FILE__,__LINE__,
  1776. L"RecursivePostEvaluation Status = (%lu)" ,
  1777. ( ULONG ) status
  1778. ) ;
  1779. return status ;
  1780. }
  1781. #endif //POST_FILTERING_RECEIVED_ROW
  1782. SnmpQueryAsyncEventObject :: SnmpQueryAsyncEventObject (
  1783. CImpPropProv *providerArg ,
  1784. BSTR QueryFormat ,
  1785. BSTR Query,
  1786. IWbemObjectSink *notify ,
  1787. IWbemContext *a_Context
  1788. ) : SnmpQueryEventObject ( providerArg , QueryFormat , Query , a_Context ) , notificationHandler ( notify ) , state ( 0 )
  1789. {
  1790. DebugMacro3(
  1791. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  1792. __FILE__,__LINE__,
  1793. L"SnmpQueryAsyncEventObject :: SnmpQueryAsyncEventObject ()"
  1794. ) ;
  1795. )
  1796. notify->AddRef () ;
  1797. }
  1798. SnmpQueryAsyncEventObject :: ~SnmpQueryAsyncEventObject ()
  1799. {
  1800. DebugMacro3(
  1801. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  1802. __FILE__,__LINE__,
  1803. L"SnmpQueryAsyncEventObject :: ~SnmpQueryAsyncEventObject ()"
  1804. ) ;
  1805. )
  1806. // Get Status object
  1807. if ( FAILED ( m_errorObject.GetWbemStatus () ) )
  1808. {
  1809. IWbemClassObject *notifyStatus = NULL;
  1810. BOOL status = GetSnmpNotifyStatusObject ( &notifyStatus ) ;
  1811. if ( status && (notifyStatus != NULL))
  1812. {
  1813. DebugMacro3(
  1814. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  1815. __FILE__,__LINE__,
  1816. L"Sending Status"
  1817. ) ;
  1818. )
  1819. #ifndef POST_FILTERING_RECEIVED_ROW
  1820. if ( SUCCEEDED ( m_errorObject.GetWbemStatus () ) )
  1821. {
  1822. //let CIMOM do the post filtering!
  1823. WBEMSTATUS t_wbemStatus = WBEM_S_FALSE ;
  1824. VARIANT t_variant ;
  1825. VariantInit( & t_variant ) ;
  1826. t_variant.vt = VT_I4 ;
  1827. t_variant.lVal = WBEM_S_FALSE ;
  1828. HRESULT result = notifyStatus->Put ( WBEM_PROPERTY_STATUSCODE , 0 , & t_variant , 0 ) ;
  1829. VariantClear ( &t_variant ) ;
  1830. if ( SUCCEEDED ( result ) )
  1831. {
  1832. result = notificationHandler->SetStatus ( 0 , t_wbemStatus , NULL , notifyStatus ) ;
  1833. }
  1834. else
  1835. {
  1836. result = notificationHandler->SetStatus ( 0 , WBEM_E_PROVIDER_FAILURE , NULL , NULL ) ;
  1837. }
  1838. }
  1839. else
  1840. {
  1841. HRESULT result = notificationHandler->SetStatus ( 0 , m_errorObject.GetWbemStatus () , NULL , notifyStatus ) ;
  1842. }
  1843. }
  1844. #else
  1845. HRESULT result = notificationHandler->SetStatus ( 0 , m_errorObject.GetWbemStatus () , NULL , notifyStatus ) ;
  1846. #endif //POST_FILTERING_RECEIVED_ROW
  1847. notifyStatus->Release () ;
  1848. }
  1849. else
  1850. {
  1851. HRESULT t_Result = notificationHandler->SetStatus ( 0 , m_errorObject.GetWbemStatus () , NULL , NULL ) ;
  1852. }
  1853. notificationHandler->Release () ;
  1854. DebugMacro3(
  1855. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  1856. __FILE__,__LINE__,
  1857. L"Returning from SnmpQueryAsyncEventObject :: ~SnmpQueryAsyncEventObject ()"
  1858. ) ;
  1859. )
  1860. }
  1861. void SnmpQueryAsyncEventObject :: ReceiveComplete ()
  1862. {
  1863. DebugMacro3(
  1864. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  1865. __FILE__,__LINE__,
  1866. L"SnmpQueryAsyncEventObject :: ReceiveComplete ()"
  1867. ) ;
  1868. )
  1869. if ( SUCCEEDED ( m_errorObject.GetWbemStatus () ) )
  1870. {
  1871. DebugMacro3(
  1872. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  1873. __FILE__,__LINE__,
  1874. L"Query Succeeded"
  1875. ) ;
  1876. )
  1877. }
  1878. else
  1879. {
  1880. DebugMacro3(
  1881. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  1882. __FILE__,__LINE__,
  1883. L"Query Failed"
  1884. ) ;
  1885. )
  1886. }
  1887. /*
  1888. * Remove worker object from worker thread container
  1889. */
  1890. DebugMacro3(
  1891. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  1892. __FILE__,__LINE__,
  1893. L"Reaping Task"
  1894. ) ;
  1895. )
  1896. AutoRetrieveOperation *t_operation = operation ;
  1897. DebugMacro3(
  1898. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  1899. __FILE__,__LINE__,
  1900. L"Deleting (this)"
  1901. ) ;
  1902. )
  1903. Complete () ;
  1904. DebugMacro3(
  1905. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  1906. __FILE__,__LINE__,
  1907. L"Destroying SNMPCL operation"
  1908. ) ;
  1909. )
  1910. if ( t_operation )
  1911. t_operation->DestroyOperation () ;
  1912. }
  1913. void SnmpQueryAsyncEventObject :: Process ()
  1914. {
  1915. DebugMacro3(
  1916. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  1917. __FILE__,__LINE__,
  1918. L"SnmpQueryAsyncEventObject :: Process ()"
  1919. ) ;
  1920. )
  1921. switch ( state )
  1922. {
  1923. case 0:
  1924. {
  1925. BOOL status = Instantiate ( m_errorObject ) ;
  1926. if ( status )
  1927. {
  1928. }
  1929. else
  1930. {
  1931. ReceiveComplete () ;
  1932. }
  1933. }
  1934. break ;
  1935. default:
  1936. {
  1937. }
  1938. break ;
  1939. }
  1940. DebugMacro3(
  1941. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  1942. __FILE__,__LINE__,
  1943. L"Returning from SnmpQueryAsyncEventObject :: Process ()"
  1944. ) ;
  1945. )
  1946. }
  1947. void SnmpQueryAsyncEventObject :: ReceiveRow ( IWbemClassObject *snmpObject )
  1948. {
  1949. DebugMacro3(
  1950. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  1951. __FILE__,__LINE__,
  1952. L"SnmpQueryAsyncEventObject :: ReceiveRow ( IWbemClassObject *snmpObject )"
  1953. ) ;
  1954. )
  1955. HRESULT result = S_OK ;
  1956. BOOL status = TRUE ;
  1957. notificationHandler->Indicate ( 1 , & snmpObject ) ;
  1958. if ( ! HasNonNullKeys ( snmpObject ) )
  1959. {
  1960. if ( SUCCEEDED ( m_errorObject.GetWbemStatus () ) )
  1961. {
  1962. m_errorObject.SetStatus ( WBEM_SNMP_E_INVALID_OBJECT ) ;
  1963. m_errorObject.SetWbemStatus ( WBEM_E_FAILED ) ;
  1964. m_errorObject.SetMessage ( L"The SNMP Agent queried returned an instance with NULL key(s)" ) ;
  1965. }
  1966. }
  1967. }
  1968. void SnmpQueryAsyncEventObject :: ReceiveRow ( SnmpInstanceClassObject*snmpObject )
  1969. {
  1970. DebugMacro3(
  1971. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  1972. __FILE__,__LINE__,
  1973. L"SnmpQueryAsyncEventObject :: ReceiveRow ( SnmpInstanceClassObject *snmpObject )"
  1974. ) ;
  1975. )
  1976. HRESULT result = S_OK ;
  1977. BOOL status = TRUE ;
  1978. #ifdef POST_FILTERING_RECEIVED_ROW
  1979. if ( status = PostEvaluateWhereClause ( snmpObject ) )
  1980. #endif //POST_FILTERING_RECEIVED_ROW
  1981. {
  1982. IWbemClassObject *cloneObject ;
  1983. if ( SUCCEEDED ( result = classObject->SpawnInstance ( 0 , & cloneObject ) ) )
  1984. {
  1985. WbemSnmpErrorObject errorObject ;
  1986. if ( status = snmpObject->Get ( errorObject , cloneObject ) )
  1987. {
  1988. DebugMacro3(
  1989. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  1990. __FILE__,__LINE__,
  1991. L"Sending Object"
  1992. ) ;
  1993. )
  1994. notificationHandler->Indicate ( 1 , & cloneObject ) ;
  1995. if ( ! HasNonNullKeys ( cloneObject ) )
  1996. {
  1997. if ( SUCCEEDED ( m_errorObject.GetWbemStatus () ) )
  1998. {
  1999. m_errorObject.SetStatus ( WBEM_SNMP_E_INVALID_OBJECT ) ;
  2000. m_errorObject.SetWbemStatus ( WBEM_E_FAILED ) ;
  2001. m_errorObject.SetMessage ( L"The SNMP Agent queried returned an instance with NULL key(s)" ) ;
  2002. }
  2003. }
  2004. }
  2005. else
  2006. {
  2007. DebugMacro3(
  2008. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  2009. __FILE__,__LINE__,
  2010. L"Failed to Convert WbemSnmpClassObject to IWbemClassObject"
  2011. ) ;
  2012. )
  2013. }
  2014. cloneObject->Release () ;
  2015. }
  2016. }
  2017. #ifdef POST_FILTERING_RECEIVED_ROW
  2018. else
  2019. {
  2020. DebugMacro3(
  2021. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  2022. __FILE__,__LINE__,
  2023. L"Object discarded due to query filter "
  2024. ) ;
  2025. )
  2026. }
  2027. #endif //POST_FILTERING_RECEIVED_ROW
  2028. }