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.

828 lines
18 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 <snmplog.h>
  22. #include <snmpcl.h>
  23. #include <snmpcont.h>
  24. #include <snmptype.h>
  25. #include <snmpauto.h>
  26. #include <snmpevt.h>
  27. #include <snmpthrd.h>
  28. #include <snmpobj.h>
  29. #include <smir.h>
  30. #include <notify.h>
  31. #include <evtdefs.h>
  32. #include <evtthrd.h>
  33. #include <evtmap.h>
  34. #include <evtprov.h>
  35. #include <evtreft.h>
  36. extern CEventProviderWorkerThread* g_pWorkerThread ;
  37. CReferentMapper::CReferentMapper()
  38. {
  39. }
  40. CReferentMapper::~CReferentMapper()
  41. {
  42. }
  43. HRESULT CReferentMapper::GetTypeAndIndexQuals(const wchar_t* prop, CIMTypeStruct& type, ULONG& index)
  44. {
  45. IWbemClassObject* propObj = NULL;
  46. GetClassInstance(&propObj);
  47. if (NULL == propObj)
  48. {
  49. return WBEM_E_FAILED;
  50. }
  51. IWbemQualifierSet* pQuals = NULL;
  52. HRESULT result = propObj->GetPropertyQualifierSet((wchar_t*)prop, &pQuals);
  53. if (FAILED(result))
  54. {
  55. return result;
  56. }
  57. VARIANT v;
  58. result = pQuals->Get(EVENT_VBINDEX_QUAL, 0, &v, NULL);
  59. if (FAILED(result))
  60. {
  61. pQuals->Release();
  62. return result;
  63. }
  64. if (VT_I4 != v.vt)
  65. {
  66. VariantClear(&v);
  67. return WBEM_E_FAILED;
  68. }
  69. index = v.lVal;
  70. VariantClear(&v);
  71. result = pQuals->Get(EVENT_CIMTYPE_QUAL, 0, &v, NULL);
  72. pQuals->Release();
  73. if (FAILED(result))
  74. {
  75. return result;
  76. }
  77. if (VT_BSTR != v.vt)
  78. {
  79. VariantClear(&v);
  80. return WBEM_E_FAILED;
  81. }
  82. #ifdef WHITESPACE_IN_CIMTYPE
  83. //Get rid of whitespace...
  84. CString cimtype;
  85. wchar_t* tmp = wcstok(v.bstrVal, WHITE_SPACE_CHARS);
  86. while (NULL != tmp)
  87. {
  88. cimtype += tmp;
  89. tmp = wcstok(NULL, WHITE_SPACE_CHARS);
  90. }
  91. #else //WHITESPACE_IN_CIMTYPE
  92. CString cimtype = v.bstrVal;
  93. #endif //WHITESPACE_IN_CIMTYPE
  94. VariantClear(&v);
  95. //determine if we're an object. If so get the classname...
  96. CString temp = cimtype.Left(OBJECT_STR_LEN);
  97. temp.MakeLower();
  98. if (temp == OBJECT_STR)
  99. {
  100. type.strType = cimtype.Mid(OBJECT_STR_LEN, cimtype.GetLength());
  101. type.fObject = TRUE;
  102. }
  103. else
  104. {
  105. type.fObject = FALSE;
  106. }
  107. return WBEM_NO_ERROR;
  108. }
  109. HRESULT CReferentMapper::GetSpecificPropertyValue(long lNumElements, MYWBEM_NAME_ELEMENT *aElements,
  110. long lFlags, VARIANT *pvValue)
  111. {
  112. if ((lNumElements <= 0) || (NULL == aElements) || (NULL == pvValue))
  113. {
  114. DebugMacro9(
  115. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  116. __FILE__,__LINE__,
  117. L"CReferentMapper::GetSpecificPropertyValue invalid parms\r\n");
  118. )
  119. return WBEM_E_INVALID_PARAMETER;
  120. }
  121. HRESULT status = WBEM_E_FAILED;
  122. //specific properties after first two varbinds
  123. if ((0 == aElements[0].m_nType) && (m_vbs.length > 2))
  124. {
  125. //first check it has the correct VBIndex and CIMType qualifiers...
  126. CIMTypeStruct proptype;
  127. ULONG propvbindex;
  128. if (FAILED(GetTypeAndIndexQuals(aElements[0].Element.m_wszPropertyName,
  129. proptype, propvbindex)))
  130. {
  131. DebugMacro9(
  132. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  133. __FILE__,__LINE__,
  134. L"CReferentMapper::GetSpecificPropertyValue failed to get index quals\r\n");
  135. )
  136. return status;
  137. }
  138. if (propvbindex >= m_vbs.length)
  139. {
  140. DebugMacro9(
  141. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  142. __FILE__,__LINE__,
  143. L"CReferentMapper::GetSpecificPropertyValue invalid index return TRUE\r\n");
  144. )
  145. return WBEM_NO_ERROR;
  146. }
  147. //we're zero indexed in this world!
  148. propvbindex--;
  149. if (lNumElements == 1)
  150. {
  151. if (m_vbs.vbs[propvbindex].fDone)
  152. {
  153. //we've done this one already,
  154. //just get the property value and return it...
  155. DebugMacro9(
  156. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  157. __FILE__,__LINE__,
  158. L"CReferentMapper::GetSpecificPropertyValue return value\r\n");
  159. )
  160. return m_object->Get(aElements[0].Element.m_wszPropertyName, 0, pvValue, 0, 0);
  161. }
  162. if (proptype.fObject)
  163. {
  164. //get the embedded class object in full for the property asked for
  165. IWbemClassObject* pObj = NULL;
  166. if (SUCCEEDED(CreateEmbeddedProperty(&pObj, propvbindex,
  167. aElements[0].Element.m_wszPropertyName, proptype.strType)))
  168. {
  169. //created the property, set the variant value and return successfully
  170. //NOTE: as soon as the variant is cleared, the object will be released
  171. pvValue->vt = VT_UNKNOWN;
  172. pvValue->punkVal = pObj;
  173. }
  174. DebugMacro9(
  175. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  176. __FILE__,__LINE__,
  177. L"CReferentMapper::GetSpecificPropertyValue return value\r\n");
  178. )
  179. return WBEM_NO_ERROR;
  180. }
  181. else
  182. {
  183. //MUST be an embedded property otherwise fail!
  184. DebugMacro9(
  185. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  186. __FILE__,__LINE__,
  187. L"CReferentMapper::GetSpecificPropertyValue invlaid params\r\n");
  188. )
  189. return WBEM_E_FAILED;
  190. }
  191. }
  192. #ifdef FILTERING
  193. will not compile as there are still a couple of TO DOs left undone...
  194. else if (0 == aElements[1].m_nType)
  195. {
  196. if (lNumElements == 2)
  197. {
  198. //TO DO:
  199. //======
  200. //get a single property value of the embedded object
  201. }
  202. else if ((lNumElements == 3) && (1 == aElements[1].m_nType))
  203. {
  204. //TO DO:
  205. //======
  206. //only if we're an array property of the embedded object
  207. }
  208. }
  209. #endif //FILTERING
  210. }
  211. return status;
  212. }
  213. HRESULT CReferentMapper::CreateEmbeddedProperty(IWbemClassObject** ppObj,
  214. ULONG index,
  215. const wchar_t* propertyName,
  216. const wchar_t* className)
  217. {
  218. if (NULL == ppObj)
  219. {
  220. //invalid out parameter
  221. DebugMacro9(
  222. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  223. __FILE__,__LINE__,
  224. L"CReferentMapper::CreateEmbeddedProperty invalid parameter\r\n");
  225. )
  226. return WBEM_E_INVALID_PARAMETER;
  227. }
  228. IWbemClassObject* pClass = NULL;
  229. //specify no correlation to the class provider
  230. IWbemContext *pCtx = NULL;
  231. HRESULT result = CoCreateInstance(CLSID_WbemContext, NULL,
  232. CLSCTX_INPROC_SERVER | CLSCTX_LOCAL_SERVER,
  233. IID_IWbemContext, (void**)&pCtx);
  234. if (SUCCEEDED(result))
  235. {
  236. VARIANT vCtx;
  237. VariantInit (&vCtx);
  238. vCtx.vt = VT_BOOL;
  239. vCtx.boolVal = VARIANT_FALSE;
  240. result = pCtx->SetValue(WBEM_CLASS_CORRELATE_CONTEXT_PROP, 0, &vCtx);
  241. VariantClear(&vCtx);
  242. if (FAILED(result))
  243. {
  244. pCtx->Release();
  245. pCtx = NULL;
  246. }
  247. }
  248. else
  249. {
  250. pCtx = NULL;
  251. }
  252. BSTR t_className = SysAllocString(className);
  253. result = m_nspace->GetObject(t_className, pCtx, &pClass);
  254. SysFreeString(t_className);
  255. if (pCtx != NULL)
  256. {
  257. pCtx->Release();
  258. }
  259. if (FAILED(result))
  260. {
  261. return result;
  262. }
  263. result = pClass->SpawnInstance(0, ppObj);
  264. if (FAILED(result))
  265. {
  266. pClass->Release();
  267. return result;
  268. }
  269. //set the varbind as decoded and make sure the notification instance has been created...
  270. IWbemClassObject* ptmpObj = NULL;
  271. GetClassInstance(&ptmpObj);
  272. if (NULL == m_object)
  273. {
  274. pClass->Release();
  275. return WBEM_E_FAILED;
  276. }
  277. m_vbs.vbs[index].fDone = TRUE;
  278. WbemSnmpClassObject snmpObj;
  279. WbemSnmpErrorObject errorObj;
  280. if (!snmpObj.Set(errorObj, pClass, FALSE))
  281. {
  282. pClass->Release();
  283. (*ppObj)->Release();
  284. *ppObj = NULL;
  285. return WBEM_E_FAILED;
  286. }
  287. snmpObj.SetIsClass(FALSE);
  288. snmpObj.ResetProperty () ;
  289. WbemSnmpProperty *snmpProp = snmpObj.NextProperty ();
  290. //set all properties to NULL...
  291. while (snmpProp != NULL)
  292. {
  293. snmpProp->SetValue(*ppObj, (SnmpValue*)NULL);
  294. snmpProp = snmpObj.NextProperty ();
  295. }
  296. snmpProp = snmpObj.FindProperty((wchar_t*)propertyName);
  297. if (NULL == snmpProp)
  298. {
  299. pClass->Release();
  300. (*ppObj)->Release();
  301. *ppObj = NULL;
  302. return WBEM_E_FAILED;
  303. }
  304. BOOL bSetKeyValue = FALSE;
  305. if (!snmpProp->SetValue(&(m_vbs.vbs[index].pVarBind->GetValue())))
  306. {
  307. snmpProp->AddQualifier ( WBEM_QUALIFIER_TYPE_MISMATCH ) ;
  308. WbemSnmpQualifier *qualifier = snmpProp->FindQualifier ( WBEM_QUALIFIER_TYPE_MISMATCH ) ;
  309. if ( qualifier )
  310. {
  311. VARIANT tmp_V;
  312. VariantInit(&tmp_V);
  313. tmp_V.vt = VT_BOOL;
  314. tmp_V.boolVal = VARIANT_TRUE;
  315. qualifier->SetValue(tmp_V);
  316. VariantClear(&tmp_V);
  317. }
  318. }
  319. else
  320. {
  321. WbemSnmpQualifier *qualifier = snmpProp->FindQualifier ( WBEM_QUALIFIER_KEY ) ;
  322. if ( qualifier )
  323. {
  324. VARIANT tmp_V;
  325. VariantInit(&tmp_V);
  326. if (qualifier->GetValue(tmp_V))
  327. {
  328. if ((VT_BOOL == tmp_V.vt) && (VARIANT_TRUE == tmp_V.boolVal))
  329. {
  330. bSetKeyValue = TRUE;
  331. }
  332. }
  333. VariantClear(&tmp_V);
  334. }
  335. }
  336. //have set the property, now set the key properties...
  337. //first get the instance info...
  338. const SnmpObjectIdentifier& id = m_vbs.vbs[index].pVarBind->GetInstance();
  339. IWbemQualifierSet* pQuals = NULL;
  340. result = pClass->GetPropertyQualifierSet((wchar_t*)propertyName, &pQuals);
  341. if (FAILED(result))
  342. {
  343. pClass->Release();
  344. (*ppObj)->Release();
  345. *ppObj = NULL;
  346. return WBEM_E_FAILED;
  347. }
  348. VARIANT v;
  349. result = pQuals->Get(OID_ATTRIBUTE, 0, &v, NULL);
  350. pQuals->Release();
  351. if ((FAILED(result)) || (VT_BSTR != v.vt))
  352. {
  353. pClass->Release();
  354. VariantClear(&v);
  355. (*ppObj)->Release();
  356. *ppObj = NULL;
  357. return WBEM_E_FAILED;
  358. }
  359. SnmpObjectIdentifierType propoidtype(v.bstrVal);
  360. VariantClear(&v);
  361. if (!propoidtype.IsValid())
  362. {
  363. pClass->Release();
  364. (*ppObj)->Release();
  365. *ppObj = NULL;
  366. return WBEM_E_FAILED;
  367. }
  368. SnmpObjectIdentifier propoid(propoidtype.GetValue(), propoidtype.GetValueLength());
  369. SnmpObjectIdentifier* prefix = id.Cut(propoid);
  370. BOOL fsuccess = FALSE;
  371. SnmpObjectIdentifier* instinfo = new SnmpObjectIdentifier ( NULL , 0 ) ;
  372. if ((prefix != NULL) && (*prefix == propoid))
  373. {
  374. fsuccess = id.Suffix(propoid.GetValueLength(),*instinfo);
  375. if (instinfo->GetValue() == NULL)
  376. {
  377. fsuccess = FALSE;
  378. snmpProp->AddQualifier ( WBEM_QUALIFIER_TYPE_MISMATCH ) ;
  379. WbemSnmpQualifier *qualifier = snmpProp->FindQualifier ( WBEM_QUALIFIER_TYPE_MISMATCH ) ;
  380. if ( qualifier )
  381. {
  382. VARIANT tmp_V;
  383. VariantInit(&tmp_V);
  384. tmp_V.vt = VT_BOOL;
  385. tmp_V.boolVal = VARIANT_TRUE;
  386. qualifier->SetValue(tmp_V);
  387. VariantClear(&tmp_V);
  388. }
  389. }
  390. }
  391. if (prefix != NULL)
  392. {
  393. delete prefix;
  394. }
  395. if ( fsuccess )
  396. {
  397. if (snmpObj.IsKeyed())
  398. {
  399. snmpObj.ResetKeyProperty() ;
  400. while ( fsuccess && (snmpProp = snmpObj.NextKeyProperty()) )
  401. {
  402. //set all the key properties using the instance info...
  403. SnmpInstanceType *decodeValue = snmpProp->GetValue()->Copy();
  404. SnmpObjectIdentifier t_DecodedValue = decodeValue->Decode(*instinfo) ;
  405. SnmpObjectIdentifier *decodedObject = new SnmpObjectIdentifier( t_DecodedValue ) ;
  406. if (*decodeValue)
  407. {
  408. if (!snmpProp->SetValue(decodeValue))
  409. {
  410. fsuccess = FALSE;
  411. }
  412. }
  413. else
  414. {
  415. fsuccess = FALSE;
  416. }
  417. delete decodeValue ;
  418. delete instinfo ;
  419. instinfo = decodedObject ;
  420. snmpProp = snmpObj.NextKeyProperty();
  421. }
  422. if (fsuccess && instinfo->GetValueLength())
  423. {
  424. //instance info left after keys have been set
  425. fsuccess = FALSE;
  426. }
  427. }
  428. else
  429. {
  430. if ( (0 != *(instinfo->GetValue())) || (1 != instinfo->GetValueLength()) )
  431. {
  432. //invalid instance info for scalar...
  433. fsuccess = FALSE;
  434. }
  435. }
  436. }
  437. delete instinfo;
  438. pClass->Release();
  439. if (!fsuccess)
  440. {
  441. snmpObj.ResetKeyProperty () ;
  442. VARIANT tmp_V;
  443. VariantInit(&tmp_V);
  444. tmp_V.vt = VT_BOOL;
  445. tmp_V.boolVal = VARIANT_TRUE;
  446. while ( snmpProp = snmpObj.NextKeyProperty () )
  447. {
  448. WbemSnmpQualifier *qualifier = NULL ;
  449. snmpProp->AddQualifier ( WBEM_QUALIFIER_TYPE_MISMATCH ) ;
  450. if ( qualifier = snmpProp->FindQualifier ( WBEM_QUALIFIER_TYPE_MISMATCH ) )
  451. {
  452. qualifier->SetValue(tmp_V);
  453. }
  454. else
  455. {
  456. // Problem Here
  457. }
  458. }
  459. if (snmpProp = snmpObj.FindProperty((wchar_t*)propertyName))
  460. {
  461. WbemSnmpQualifier *qualifier = NULL ;
  462. snmpProp->AddQualifier ( WBEM_QUALIFIER_TYPE_MISMATCH ) ;
  463. if ( qualifier = snmpProp->FindQualifier ( WBEM_QUALIFIER_TYPE_MISMATCH ) )
  464. {
  465. qualifier->SetValue(tmp_V);
  466. }
  467. else
  468. {
  469. // Problem Here
  470. }
  471. }
  472. VariantClear(&tmp_V);
  473. }
  474. //check that setting the key values hasn't altered our value, it may be a key
  475. if ( bSetKeyValue && (snmpProp = snmpObj.FindProperty((wchar_t*)propertyName)) )
  476. {
  477. if (*(snmpProp->GetValue()->GetValueEncoding()) != m_vbs.vbs[index].pVarBind->GetValue())
  478. {
  479. //set it back to the varbind value and set the error qualifier on the property
  480. snmpProp->SetValue(&(m_vbs.vbs[index].pVarBind->GetValue()));
  481. WbemSnmpQualifier *qualifier = NULL ;
  482. snmpProp->AddQualifier ( WBEM_QUALIFIER_VALUE_MISMATCH ) ;
  483. if ( qualifier = snmpProp->FindQualifier ( WBEM_QUALIFIER_VALUE_MISMATCH ) )
  484. {
  485. VARIANT tmp_V;
  486. VariantInit(&tmp_V);
  487. tmp_V.vt = VT_BOOL;
  488. tmp_V.boolVal = VARIANT_TRUE;
  489. qualifier->SetValue(tmp_V);
  490. VariantClear(&tmp_V);
  491. }
  492. else
  493. {
  494. // Problem Here
  495. }
  496. }
  497. }
  498. //generate class object from snmpObj and return success
  499. if (snmpObj.Get(errorObj, *ppObj))
  500. {
  501. //add the property to the notification object...
  502. VARIANT vObj;
  503. vObj.vt = VT_UNKNOWN;
  504. vObj.punkVal = *ppObj;
  505. (*ppObj)->AddRef();
  506. result = m_object->Put((wchar_t*)propertyName, 0, &vObj, 0);
  507. if (SUCCEEDED(result))
  508. {
  509. VariantClear(&vObj);
  510. DebugMacro9(
  511. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  512. __FILE__,__LINE__,
  513. L"CReferentMapper::CreateEmbeddedProperty succeeded\r\n");
  514. )
  515. return WBEM_NO_ERROR;
  516. }
  517. else
  518. {
  519. VariantClear(&vObj);
  520. (*ppObj)->Release();
  521. *ppObj = NULL;
  522. return WBEM_E_FAILED;
  523. }
  524. }
  525. return WBEM_E_FAILED;
  526. }
  527. void CReferentMapper::GenerateInstance(IWbemClassObject** ppInst)
  528. {
  529. if (NULL == ppInst)
  530. {
  531. DebugMacro9(
  532. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  533. __FILE__,__LINE__,
  534. L"CReferentMapper::GenerateInstance invalid parameter\r\n");
  535. )
  536. //invalid out parameter
  537. return;
  538. }
  539. //set out parameter to NULL;
  540. *ppInst = NULL;
  541. IWbemClassObject *pObj = NULL;
  542. GetClassInstance(&pObj);
  543. if (NULL == pObj)
  544. {
  545. //failed to get class instance
  546. DebugMacro9(
  547. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  548. __FILE__,__LINE__,
  549. L"CReferentMapper::GenerateInstance failed to get class defn\r\n");
  550. )
  551. return;
  552. }
  553. //get all the property names and set their values...
  554. SAFEARRAY* pPropNames;
  555. HRESULT result = pObj->GetNames(NULL, WBEM_FLAG_NONSYSTEM_ONLY, NULL, &pPropNames);
  556. if (FAILED(result))
  557. {
  558. //failed to get the property names
  559. DebugMacro9(
  560. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  561. __FILE__,__LINE__,
  562. L"CReferentMapper::GenerateInstance failed to get property array\r\n");
  563. )
  564. return;
  565. }
  566. //time to <insert expletive> around with a safearray...
  567. //work out the size of the safearray and access the data
  568. if(SafeArrayGetDim(pPropNames) != 1)
  569. {
  570. //wrong dimensions in this array
  571. SafeArrayDestroy(pPropNames);
  572. DebugMacro9(
  573. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  574. __FILE__,__LINE__,
  575. L"CReferentMapper::GenerateInstance property array has wrong DIM\r\n");
  576. )
  577. return;
  578. }
  579. LONG arraylen = pPropNames->rgsabound[0].cElements;
  580. BSTR *pbstr;
  581. result = SafeArrayAccessData(pPropNames, (void **)&pbstr);
  582. if(FAILED(result))
  583. {
  584. SafeArrayDestroy(pPropNames);
  585. DebugMacro9(
  586. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  587. __FILE__,__LINE__,
  588. L"CReferentMapper::GenerateInstance failed to access property array\r\n");
  589. )
  590. return;
  591. }
  592. DebugMacro9(
  593. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  594. __FILE__,__LINE__,
  595. L"CReferentMapper::GenerateInstance set properties\r\n");
  596. )
  597. BOOL t_bSetProp = FALSE;
  598. //iterate through the names and set the properties...
  599. for (LONG i = 0; i < arraylen; i++)
  600. {
  601. VARIANT v;
  602. MYWBEM_NAME_ELEMENT property_struct;
  603. property_struct.m_nType = 0; //string value
  604. property_struct.Element.m_wszPropertyName = pbstr[i];
  605. result = GetPropertyValue(1, &property_struct, 0, &v);
  606. if (FAILED(result))
  607. {
  608. DebugMacro9(
  609. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  610. __FILE__,__LINE__,
  611. L"CReferentMapper::GenerateInstance failed to get value for %s\r\n",
  612. pbstr[i]);
  613. )
  614. continue;
  615. }
  616. else
  617. {
  618. t_bSetProp = TRUE;
  619. }
  620. if ((v.vt != VT_NULL) && (v.vt != VT_EMPTY))
  621. {
  622. DebugMacro9(
  623. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  624. __FILE__,__LINE__,
  625. L"CReferentMapper::GenerateInstance setting value for %s\r\n",
  626. pbstr[i]);
  627. )
  628. result = pObj->Put(pbstr[i], 0, &v, 0);
  629. DebugMacro9(
  630. if (FAILED(result))
  631. {
  632. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  633. __FILE__,__LINE__,
  634. L"CReferentMapper::GenerateInstance failed setting value for %s\r\n",
  635. pbstr[i]);
  636. }
  637. )
  638. }
  639. VariantClear(&v);
  640. }
  641. SafeArrayUnaccessData(pPropNames);
  642. SafeArrayDestroy(pPropNames);
  643. //if a single property has been put send it on....
  644. if (t_bSetProp)
  645. {
  646. pObj->AddRef();
  647. *ppInst = pObj;
  648. }
  649. DebugMacro9(
  650. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  651. __FILE__,__LINE__,
  652. L"CReferentMapper::GenerateInstance finished\r\n");
  653. )
  654. }
  655. void CReferentMapper::ResetData()
  656. {
  657. //do class specific stuff then call parent class's reset
  658. CMapToEvent::ResetData();
  659. }
  660. BOOL CReferentMapper::GetSpecificClass()
  661. {
  662. //Build path of mapper instance...
  663. CString path(EXTMAPPER_CLASS_PATH_PREFIX);
  664. path += m_oid;
  665. path += '\"';
  666. BSTR pathstr = path.AllocSysString();
  667. IWbemClassObject *pObj = NULL;
  668. HRESULT result = g_pWorkerThread->GetServerWrap ()->GetMapperObject(pathstr, NULL, & pObj );
  669. SysFreeString(pathstr);
  670. if (result == S_OK)
  671. {
  672. VARIANT v;
  673. VariantInit(&v);
  674. result = pObj->Get(MAPPER_CLASS_EVENTCLASSPROP, 0, &v, NULL, NULL);
  675. pObj->Release();
  676. if (SUCCEEDED(result) && (VT_BSTR == v.vt))
  677. {
  678. m_class = v.bstrVal;
  679. VariantClear(&v);
  680. DebugMacro9(
  681. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  682. __FILE__,__LINE__,
  683. L"CReferentMapper::GetSpecificClass got the specific class defn\r\n");
  684. )
  685. return TRUE;
  686. }
  687. else
  688. {
  689. VariantClear(&v);
  690. }
  691. }
  692. DebugMacro9(
  693. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  694. __FILE__,__LINE__,
  695. L"CReferentMapper::GetSpecificClass failed to get specific class defn\r\n");
  696. )
  697. return FALSE;
  698. }