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.

8940 lines
237 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 <objbase.h>
  18. #include <winerror.h>
  19. #include <initguid.h>
  20. #ifndef INITGUID
  21. #define INITGUID
  22. #endif
  23. #include <wbemidl.h>
  24. #include <snmplog.h>
  25. #include <snmpcl.h>
  26. #include <snmpcont.h>
  27. #include <snmptype.h>
  28. #include <snmpobj.h>
  29. static SnmpMap <wchar_t *,wchar_t *,ULONG,ULONG> mibTypeMap ;
  30. BOOL InitialiseMibTypeMap ()
  31. {
  32. mibTypeMap [ WBEM_TYPE_INTEGER ] = WBEM_INDEX_TYPE_INTEGER ;
  33. mibTypeMap [ WBEM_TYPE_INTEGER32 ] = WBEM_INDEX_TYPE_INTEGER32 ;
  34. mibTypeMap [ WBEM_TYPE_OCTETSTRING ] = WBEM_INDEX_TYPE_OCTETSTRING ;
  35. mibTypeMap [ WBEM_TYPE_OBJECTIDENTIFIER ] = WBEM_INDEX_TYPE_OBJECTIDENTIFIER ;
  36. mibTypeMap [ WBEM_TYPE_NULL ] = WBEM_INDEX_TYPE_NULL ;
  37. mibTypeMap [ WBEM_TYPE_IPADDRESS ] = WBEM_INDEX_TYPE_IPADDRESS ;
  38. mibTypeMap [ WBEM_TYPE_COUNTER ] = WBEM_INDEX_TYPE_COUNTER ;
  39. mibTypeMap [ WBEM_TYPE_GAUGE ] = WBEM_INDEX_TYPE_GAUGE ;
  40. mibTypeMap [ WBEM_TYPE_TIMETICKS ] = WBEM_INDEX_TYPE_TIMETICKS ;
  41. mibTypeMap [ WBEM_TYPE_OPAQUE ] = WBEM_INDEX_TYPE_OPAQUE ;
  42. mibTypeMap [ WBEM_TYPE_NETWORKADDRESS ] = WBEM_INDEX_TYPE_NETWORKADDRESS ;
  43. mibTypeMap [ WBEM_TYPE_COUNTER32 ] = WBEM_INDEX_TYPE_COUNTER32 ;
  44. mibTypeMap [ WBEM_TYPE_COUNTER64 ] = WBEM_INDEX_TYPE_COUNTER64 ;
  45. mibTypeMap [ WBEM_TYPE_GAUGE32 ] = WBEM_INDEX_TYPE_GAUGE32 ;
  46. mibTypeMap [ WBEM_TYPE_UNSIGNED32 ] = WBEM_INDEX_TYPE_UNSIGNED32;
  47. return TRUE ;
  48. }
  49. BOOL initialisedMibTypeMap = InitialiseMibTypeMap () ;
  50. static SnmpMap <wchar_t *,wchar_t *,ULONG,ULONG> textualConventionMap ;
  51. BOOL InitialiseTextualConventionMap ()
  52. {
  53. textualConventionMap [ WBEM_TYPE_INTEGER ] = WBEM_INDEX_TYPE_INTEGER ;
  54. textualConventionMap [ WBEM_TYPE_INTEGER32 ] = WBEM_INDEX_TYPE_INTEGER32 ;
  55. textualConventionMap [ WBEM_TYPE_OCTETSTRING ] = WBEM_INDEX_TYPE_OCTETSTRING ;
  56. textualConventionMap [ WBEM_TYPE_OBJECTIDENTIFIER ] = WBEM_INDEX_TYPE_OBJECTIDENTIFIER ;
  57. textualConventionMap [ WBEM_TYPE_NULL ] = WBEM_INDEX_TYPE_NULL ;
  58. textualConventionMap [ WBEM_TYPE_IPADDRESS ] = WBEM_INDEX_TYPE_IPADDRESS ;
  59. textualConventionMap [ WBEM_TYPE_COUNTER ] = WBEM_INDEX_TYPE_COUNTER ;
  60. textualConventionMap [ WBEM_TYPE_GAUGE ] = WBEM_INDEX_TYPE_GAUGE ;
  61. textualConventionMap [ WBEM_TYPE_TIMETICKS ] = WBEM_INDEX_TYPE_TIMETICKS ;
  62. textualConventionMap [ WBEM_TYPE_OPAQUE ] = WBEM_INDEX_TYPE_OPAQUE ;
  63. textualConventionMap [ WBEM_TYPE_NETWORKADDRESS ] = WBEM_INDEX_TYPE_NETWORKADDRESS ;
  64. textualConventionMap [ WBEM_TYPE_DISPLAYSTRING ] = WBEM_INDEX_TYPE_DISPLAYSTRING ;
  65. textualConventionMap [ WBEM_TYPE_MACADDRESS ] = WBEM_INDEX_TYPE_MACADDRESS ;
  66. textualConventionMap [ WBEM_TYPE_PHYSADDRESS ] = WBEM_INDEX_TYPE_PHYSADDRESS ;
  67. textualConventionMap [ WBEM_TYPE_ENUMERATEDINTEGER ] = WBEM_INDEX_TYPE_ENUMERATEDINTEGER ;
  68. textualConventionMap [ WBEM_TYPE_COUNTER32 ] = WBEM_INDEX_TYPE_COUNTER32 ;
  69. textualConventionMap [ WBEM_TYPE_COUNTER64 ] = WBEM_INDEX_TYPE_COUNTER64 ;
  70. textualConventionMap [ WBEM_TYPE_GAUGE32 ] = WBEM_INDEX_TYPE_GAUGE32 ;
  71. textualConventionMap [ WBEM_TYPE_UNSIGNED32 ] = WBEM_INDEX_TYPE_UNSIGNED32 ;
  72. textualConventionMap [ WBEM_TYPE_DATETIME ] = WBEM_INDEX_TYPE_DATETIME ;
  73. textualConventionMap [ WBEM_TYPE_BITS ] = WBEM_INDEX_TYPE_BITS ;
  74. textualConventionMap [ WBEM_TYPE_SNMPOSIADDRESS ] = WBEM_INDEX_TYPE_SNMPOSIADDRESS ;
  75. textualConventionMap [ WBEM_TYPE_SNMPUDPADDRESS ] = WBEM_INDEX_TYPE_SNMPUDPADDRESS ;
  76. textualConventionMap [ WBEM_TYPE_SNMPIPXADDRESS ] = WBEM_INDEX_TYPE_SNMPIPXADDRESS ;
  77. textualConventionMap [ WBEM_TYPE_ROWSTATUS ] = WBEM_INDEX_TYPE_ROWSTATUS ;
  78. return TRUE ;
  79. }
  80. BOOL initialisedTextualConventionMap = InitialiseTextualConventionMap () ;
  81. static SnmpMap <ULONG,ULONG,CIMTYPE,CIMTYPE> cimTypeMap ;
  82. BOOL InitialiseCimTypeMap ()
  83. {
  84. cimTypeMap [ WBEM_INDEX_TYPE_INTEGER ] = CIM_SINT32 ;
  85. cimTypeMap [ WBEM_INDEX_TYPE_INTEGER32 ] = CIM_SINT32 ;
  86. cimTypeMap [ WBEM_INDEX_TYPE_OCTETSTRING ] = CIM_STRING ;
  87. cimTypeMap [ WBEM_INDEX_TYPE_OBJECTIDENTIFIER ] = CIM_STRING ;
  88. cimTypeMap [ WBEM_INDEX_TYPE_NULL ] = CIM_STRING ;
  89. cimTypeMap [ WBEM_INDEX_TYPE_IPADDRESS ] = CIM_STRING ;
  90. cimTypeMap [ WBEM_INDEX_TYPE_COUNTER ] = CIM_UINT32 ;
  91. cimTypeMap [ WBEM_INDEX_TYPE_GAUGE ] = CIM_UINT32 ;
  92. cimTypeMap [ WBEM_INDEX_TYPE_TIMETICKS ] = CIM_UINT32 ;
  93. cimTypeMap [ WBEM_INDEX_TYPE_OPAQUE ] = CIM_STRING ;
  94. cimTypeMap [ WBEM_INDEX_TYPE_NETWORKADDRESS ] = CIM_STRING ;
  95. cimTypeMap [ WBEM_INDEX_TYPE_DISPLAYSTRING ] = CIM_STRING ;
  96. cimTypeMap [ WBEM_INDEX_TYPE_MACADDRESS ] = CIM_STRING ;
  97. cimTypeMap [ WBEM_INDEX_TYPE_PHYSADDRESS ] = CIM_STRING ;
  98. cimTypeMap [ WBEM_INDEX_TYPE_ENUMERATEDINTEGER ] = CIM_STRING ;
  99. cimTypeMap [ WBEM_INDEX_TYPE_COUNTER32 ] = CIM_UINT32 ;
  100. cimTypeMap [ WBEM_INDEX_TYPE_COUNTER64 ] = CIM_STRING ;
  101. cimTypeMap [ WBEM_INDEX_TYPE_GAUGE32 ] = CIM_UINT32 ;
  102. cimTypeMap [ WBEM_INDEX_TYPE_UNSIGNED32 ] = CIM_UINT32 ;
  103. cimTypeMap [ WBEM_INDEX_TYPE_DATETIME ] = CIM_STRING ;
  104. cimTypeMap [ WBEM_INDEX_TYPE_BITS ] = CIM_STRING | CIM_FLAG_ARRAY ;
  105. cimTypeMap [ WBEM_INDEX_TYPE_SNMPOSIADDRESS ] = CIM_STRING ;
  106. cimTypeMap [ WBEM_INDEX_TYPE_SNMPUDPADDRESS ] = CIM_STRING ;
  107. cimTypeMap [ WBEM_INDEX_TYPE_SNMPIPXADDRESS ] = CIM_STRING ;
  108. cimTypeMap [ WBEM_INDEX_TYPE_ROWSTATUS ] = CIM_STRING ;
  109. return TRUE ;
  110. }
  111. BOOL initialisedCimTypeMap = InitialiseCimTypeMap () ;
  112. static SnmpMap <wchar_t *,wchar_t *,ULONG,ULONG> validQualifierMap ;
  113. BOOL InitialiseQualifierMap ()
  114. {
  115. validQualifierMap [ WBEM_QUALIFIER_TEXTUAL_CONVENTION ] = WBEM_INDEX_QUALIFIER_TEXTUAL_CONVENTION ;
  116. validQualifierMap [ WBEM_QUALIFIER_SYNTAX ] = WBEM_INDEX_QUALIFIER_SYNTAX ;
  117. validQualifierMap [ WBEM_QUALIFIER_OBJECT_IDENTIFIER ] = WBEM_INDEX_QUALIFIER_OBJECT_IDENTIFIER ;
  118. validQualifierMap [ WBEM_QUALIFIER_ENCODING ] = WBEM_INDEX_QUALIFIER_ENCODING ;
  119. validQualifierMap [ WBEM_QUALIFIER_FIXED_LENGTH ] = WBEM_INDEX_QUALIFIER_FIXED_LENGTH ;
  120. validQualifierMap [ WBEM_QUALIFIER_VARIABLE_LENGTH ] = WBEM_INDEX_QUALIFIER_VARIABLE_LENGTH ;
  121. validQualifierMap [ WBEM_QUALIFIER_VARIABLE_VALUE ] = WBEM_INDEX_QUALIFIER_VARIABLE_VALUE ;
  122. validQualifierMap [ WBEM_QUALIFIER_ENUMERATION ] = WBEM_INDEX_QUALIFIER_ENUMERATION ;
  123. validQualifierMap [ WBEM_QUALIFIER_BITS ] = WBEM_INDEX_QUALIFIER_BITS ;
  124. validQualifierMap [ WBEM_QUALIFIER_DISPLAY_HINT ] = WBEM_INDEX_QUALIFIER_DISPLAY_HINT ;
  125. validQualifierMap [ WBEM_QUALIFIER_KEY ] = WBEM_INDEX_QUALIFIER_KEY ;
  126. validQualifierMap [ WBEM_QUALIFIER_KEY_ORDER ] = WBEM_INDEX_QUALIFIER_KEY_ORDER ;
  127. validQualifierMap [ WBEM_QUALIFIER_VIRTUAL_KEY ] = WBEM_INDEX_QUALIFIER_VIRTUAL_KEY ;
  128. validQualifierMap [ WBEM_QUALIFIER_READ ] = WBEM_INDEX_QUALIFIER_READ ;
  129. validQualifierMap [ WBEM_QUALIFIER_WRITE ] = WBEM_INDEX_QUALIFIER_WRITE ;
  130. validQualifierMap [ WBEM_QUALIFIER_NOT_AVAILABLE ] = WBEM_INDEX_QUALIFIER_NOT_AVAILABLE ;
  131. validQualifierMap [ WBEM_QUALIFIER_TYPE_MISMATCH ] = WBEM_INDEX_QUALIFIER_TYPE_MISMATCH ;
  132. validQualifierMap [ WBEM_QUALIFIER_VALUE_MISMATCH ] = WBEM_INDEX_QUALIFIER_VALUE_MISMATCH ;
  133. validQualifierMap [ WBEM_QUALIFIER_AGENTSNMPVERSION ] = WBEM_INDEX_QUALIFIER_AGENTSNMPVERSION ;
  134. validQualifierMap [ WBEM_QUALIFIER_AGENTTRANSPORT ] = WBEM_INDEX_QUALIFIER_AGENTTRANSPORT ;
  135. validQualifierMap [ WBEM_QUALIFIER_AGENTADDRESS ] = WBEM_INDEX_QUALIFIER_AGENTADDRESS ;
  136. validQualifierMap [ WBEM_QUALIFIER_AGENTREADCOMMUNITYNAME ] = WBEM_INDEX_QUALIFIER_AGENTREADCOMMUNITYNAME ;
  137. validQualifierMap [ WBEM_QUALIFIER_AGENTWRITECOMMUNITYNAME ] = WBEM_INDEX_QUALIFIER_AGENTWRITECOMMUNITYNAME ;
  138. validQualifierMap [ WBEM_QUALIFIER_AGENTRETRYCOUNT ] = WBEM_INDEX_QUALIFIER_AGENTRETRYCOUNT ;
  139. validQualifierMap [ WBEM_QUALIFIER_AGENTRETRYTIMEOUT ] = WBEM_INDEX_QUALIFIER_AGENTRETRYTIMEOUT ;
  140. validQualifierMap [ WBEM_QUALIFIER_AGENTVARBINDSPERPDU ] = WBEM_INDEX_QUALIFIER_AGENTVARBINDSPERPDU ;
  141. validQualifierMap [ WBEM_QUALIFIER_AGENTFLOWCONTROLWINDOWSIZE ] = WBEM_INDEX_QUALIFIER_AGENTFLOWCONTROLWINDOWSIZE ;
  142. validQualifierMap [ WBEM_QUALIFIER_SINGLETON ] = WBEM_INDEX_QUALIFIER_SINGLETON ;
  143. validQualifierMap [ WBEM_QUALIFIER_TABLECLASS ] = WBEM_INDEX_QUALIFIER_TABLECLASS;
  144. validQualifierMap [ WBEM_QUALIFIER_KEYTYPES ] = WBEM_INDEX_QUALIFIER_KEYTYPES;
  145. validQualifierMap [ WBEM_QUALIFIER_KEYVALUES ] = WBEM_INDEX_QUALIFIER_KEYVALUES;
  146. validQualifierMap [ WBEM_QUALIFIER_VARBINDINDEX ] = WBEM_INDEX_QUALIFIER_VARBINDINDEX;
  147. validQualifierMap [ WBEM_QUALIFIER_ROWSTATUS ] = WBEM_INDEX_QUALIFIER_ROWSTATUS;
  148. return TRUE ;
  149. }
  150. BOOL initialisedQualifierMap = InitialiseQualifierMap () ;
  151. WbemSnmpQualifier :: WbemSnmpQualifier (
  152. const wchar_t *qualifierNameArg ,
  153. const SnmpInstanceType *typeValueArg
  154. ) : typeValue ( NULL ) , qualifierName (NULL )
  155. {
  156. DebugMacro7(
  157. wchar_t *t_StringValue = ( typeValueArg ) ? typeValueArg->GetStringValue () : NULL ;
  158. if ( t_StringValue )
  159. {
  160. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  161. __FILE__,__LINE__,
  162. L"WbemSnmpQualifier :: WbemSnmpQualifier ( const wchar_t *qualifierNameArg = (%s) , const SnmpInstanceType *typeValueArg = (%lx),(%s) )" ,
  163. qualifierNameArg ,
  164. typeValueArg ,
  165. t_StringValue
  166. ) ;
  167. }
  168. else
  169. {
  170. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  171. __FILE__,__LINE__,
  172. L"WbemSnmpQualifier :: WbemSnmpQualifier ( const wchar_t *qualifierNameArg = (%s) , const SnmpInstanceType *typeValueArg = (NULL) )" ,
  173. qualifierNameArg ,
  174. typeValueArg
  175. ) ;
  176. }
  177. delete [] t_StringValue ;
  178. )
  179. qualifierName = new wchar_t [ wcslen ( qualifierNameArg ) + 1 ] ;
  180. wcscpy ( qualifierName , qualifierNameArg ) ;
  181. if ( typeValueArg )
  182. {
  183. typeValue = typeValueArg->Copy () ;
  184. }
  185. }
  186. WbemSnmpQualifier :: WbemSnmpQualifier ( const WbemSnmpQualifier &copy ) : qualifierName ( NULL ), typeValue ( NULL )
  187. {
  188. DebugMacro7(
  189. wchar_t *t_StringValue = ( copy.typeValue ) ? copy.typeValue->GetStringValue () : NULL ;
  190. if ( t_StringValue )
  191. {
  192. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  193. __FILE__,__LINE__,
  194. L"WbemSnmpQualifier :: const WbemSnmpQualifier &copy (%s),(%s) )" ,
  195. copy.qualifierName ,
  196. t_StringValue
  197. ) ;
  198. }
  199. else
  200. {
  201. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  202. __FILE__,__LINE__,
  203. L"WbemSnmpQualifier :: const WbemSnmpQualifier &copy (%s),(NULL)" ,
  204. copy.qualifierName
  205. ) ;
  206. }
  207. delete [] t_StringValue ;
  208. )
  209. qualifierName = new wchar_t [ wcslen ( copy.qualifierName ) + 1 ] ;
  210. wcscpy ( qualifierName , copy.qualifierName ) ;
  211. if ( copy.typeValue )
  212. {
  213. typeValue = copy.typeValue->Copy () ;
  214. }
  215. }
  216. WbemSnmpQualifier :: ~WbemSnmpQualifier ()
  217. {
  218. DebugMacro7(
  219. wchar_t *t_StringValue = ( typeValue ) ? typeValue->GetStringValue () : NULL ;
  220. if ( t_StringValue )
  221. {
  222. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  223. __FILE__,__LINE__,L"WbemSnmpQualifier :: ~WbemSnmpQualifier ( (%s),(%s) )" ,
  224. qualifierName ? qualifierName : L"!!NULL!!",
  225. t_StringValue
  226. ) ;
  227. }
  228. else
  229. {
  230. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  231. __FILE__,__LINE__,L"WbemSnmpQualifier :: ~WbemSnmpQualifier ( (%s),(NULL) )" ,
  232. qualifierName ? qualifierName : L"!!NULL!!"
  233. ) ;
  234. }
  235. delete [] t_StringValue ;
  236. )
  237. delete [] qualifierName ;
  238. delete typeValue ;
  239. }
  240. wchar_t *WbemSnmpQualifier :: GetName () const
  241. {
  242. DebugMacro7(
  243. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  244. __FILE__,__LINE__,
  245. L"WbemSnmpQualifier :: GetName ( %s )" ,
  246. qualifierName
  247. )
  248. )
  249. return qualifierName ;
  250. }
  251. SnmpInstanceType *WbemSnmpQualifier :: GetValue () const
  252. {
  253. DebugMacro7(
  254. wchar_t *t_StringValue = ( typeValue ) ? typeValue->GetStringValue () : NULL ;
  255. if ( t_StringValue )
  256. {
  257. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  258. __FILE__,__LINE__,
  259. L"WbemSnmpQualifier :: GetValue ( (%s), (%s) )" ,
  260. qualifierName ,
  261. t_StringValue
  262. ) ;
  263. }
  264. else
  265. {
  266. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  267. __FILE__,__LINE__,
  268. L"WbemSnmpQualifier :: GetValue ( (%s) , (NULL) )" ,
  269. qualifierName
  270. ) ;
  271. }
  272. delete [] t_StringValue ;
  273. )
  274. return typeValue ;
  275. }
  276. BOOL WbemSnmpQualifier :: GetValue ( VARIANT &variant ) const
  277. {
  278. DebugMacro7(
  279. wchar_t *t_StringValue = ( typeValue ) ? typeValue->GetStringValue () : NULL ;
  280. if ( t_StringValue )
  281. {
  282. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  283. __FILE__,__LINE__,
  284. L"WbemSnmpQualifier :: GetValue ( VARIANT &variant ( (%s),(%s) )" ,
  285. qualifierName ,
  286. t_StringValue
  287. ) ;
  288. }
  289. else
  290. {
  291. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  292. __FILE__,__LINE__,
  293. L"WbemSnmpQualifier :: GetValue ( VARIANT &variant ( (%s),(NULL) )" ,
  294. qualifierName
  295. ) ;
  296. }
  297. delete [] t_StringValue ;
  298. )
  299. BOOL status = TRUE ;
  300. ULONG qualifierIndex ;
  301. if ( validQualifierMap.Lookup ( qualifierName , qualifierIndex ) )
  302. {
  303. switch ( qualifierIndex )
  304. {
  305. case WBEM_INDEX_QUALIFIER_OBJECT_IDENTIFIER:
  306. {
  307. if ( typeid ( *typeValue ) == typeid ( SnmpObjectIdentifierType ) )
  308. {
  309. SnmpObjectIdentifierType *objectIdentifier = ( SnmpObjectIdentifierType * ) typeValue ;
  310. wchar_t *string = objectIdentifier ->GetStringValue () ;
  311. variant.vt = VT_BSTR ;
  312. variant.bstrVal = SysAllocString ( string ) ;
  313. delete [] string ;
  314. }
  315. else
  316. {
  317. status = FALSE ;
  318. variant.vt = VT_NULL ;
  319. }
  320. }
  321. break ;
  322. case WBEM_INDEX_QUALIFIER_AGENTADDRESS:
  323. case WBEM_INDEX_QUALIFIER_TEXTUAL_CONVENTION:
  324. case WBEM_INDEX_QUALIFIER_SYNTAX:
  325. case WBEM_INDEX_QUALIFIER_ENCODING:
  326. case WBEM_INDEX_QUALIFIER_VARIABLE_LENGTH:
  327. case WBEM_INDEX_QUALIFIER_VARIABLE_VALUE:
  328. case WBEM_INDEX_QUALIFIER_DISPLAY_HINT:
  329. case WBEM_INDEX_QUALIFIER_ENUMERATION:
  330. case WBEM_INDEX_QUALIFIER_AGENTSNMPVERSION:
  331. case WBEM_INDEX_QUALIFIER_AGENTTRANSPORT:
  332. case WBEM_INDEX_QUALIFIER_AGENTREADCOMMUNITYNAME:
  333. case WBEM_INDEX_QUALIFIER_AGENTWRITECOMMUNITYNAME:
  334. case WBEM_INDEX_QUALIFIER_TABLECLASS:
  335. case WBEM_INDEX_QUALIFIER_KEYTYPES:
  336. case WBEM_INDEX_QUALIFIER_KEYVALUES:
  337. {
  338. if ( typeid ( *typeValue ) == typeid ( SnmpDisplayStringType ) )
  339. {
  340. SnmpDisplayStringType *displayString = ( SnmpDisplayStringType * ) typeValue ;
  341. wchar_t *string = displayString->GetValue () ;
  342. variant.vt = VT_BSTR ;
  343. variant.bstrVal = SysAllocString ( string ) ;
  344. delete [] string ;
  345. }
  346. else
  347. {
  348. status = FALSE ;
  349. variant.vt = VT_NULL ;
  350. }
  351. }
  352. break ;
  353. case WBEM_INDEX_QUALIFIER_KEY:
  354. case WBEM_INDEX_QUALIFIER_VIRTUAL_KEY:
  355. case WBEM_INDEX_QUALIFIER_READ:
  356. case WBEM_INDEX_QUALIFIER_WRITE:
  357. case WBEM_INDEX_QUALIFIER_NOT_AVAILABLE:
  358. case WBEM_INDEX_QUALIFIER_TYPE_MISMATCH:
  359. case WBEM_INDEX_QUALIFIER_VALUE_MISMATCH:
  360. case WBEM_INDEX_QUALIFIER_SINGLETON:
  361. case WBEM_INDEX_QUALIFIER_ROWSTATUS:
  362. {
  363. if ( typeid ( *typeValue ) == typeid ( SnmpIntegerType ) )
  364. {
  365. SnmpIntegerType *integer = ( SnmpIntegerType * ) typeValue ;
  366. variant.vt = VT_BOOL ;
  367. variant.boolVal = integer->GetValue () ? VARIANT_TRUE : VARIANT_FALSE ;
  368. }
  369. else
  370. {
  371. status = FALSE ;
  372. variant.vt = VT_NULL ;
  373. }
  374. }
  375. break ;
  376. case WBEM_INDEX_QUALIFIER_FIXED_LENGTH:
  377. case WBEM_INDEX_QUALIFIER_KEY_ORDER:
  378. case WBEM_INDEX_QUALIFIER_AGENTRETRYCOUNT:
  379. case WBEM_INDEX_QUALIFIER_AGENTRETRYTIMEOUT:
  380. case WBEM_INDEX_QUALIFIER_AGENTVARBINDSPERPDU:
  381. case WBEM_INDEX_QUALIFIER_AGENTFLOWCONTROLWINDOWSIZE:
  382. case WBEM_INDEX_QUALIFIER_VARBINDINDEX:
  383. {
  384. if ( typeid ( *typeValue ) == typeid ( SnmpIntegerType ) )
  385. {
  386. SnmpIntegerType *integer = ( SnmpIntegerType * ) typeValue ;
  387. variant.vt = VT_I4 ;
  388. variant.lVal = integer->GetValue () ;
  389. }
  390. else
  391. {
  392. status = FALSE ;
  393. variant.vt = VT_NULL ;
  394. }
  395. }
  396. break ;
  397. default:
  398. {
  399. status = FALSE ;
  400. variant.vt = VT_NULL ;
  401. }
  402. }
  403. }
  404. else
  405. {
  406. status = FALSE ;
  407. variant.vt = VT_NULL ;
  408. }
  409. return status ;
  410. }
  411. VARTYPE WbemSnmpQualifier :: GetValueVariantType () const
  412. {
  413. DebugMacro7( SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine ( __FILE__,__LINE__,L"WbemSnmpQualifier :: GetValueVariantType ()" ) )
  414. VARTYPE varType = VT_NULL ;
  415. ULONG qualifierIndex ;
  416. if ( validQualifierMap.Lookup ( qualifierName , qualifierIndex ) )
  417. {
  418. switch ( qualifierIndex )
  419. {
  420. case WBEM_INDEX_QUALIFIER_TEXTUAL_CONVENTION:
  421. case WBEM_INDEX_QUALIFIER_SYNTAX:
  422. case WBEM_INDEX_QUALIFIER_OBJECT_IDENTIFIER:
  423. case WBEM_INDEX_QUALIFIER_ENCODING:
  424. case WBEM_INDEX_QUALIFIER_VARIABLE_LENGTH:
  425. case WBEM_INDEX_QUALIFIER_VARIABLE_VALUE:
  426. case WBEM_INDEX_QUALIFIER_DISPLAY_HINT:
  427. case WBEM_INDEX_QUALIFIER_ENUMERATION:
  428. case WBEM_INDEX_QUALIFIER_AGENTSNMPVERSION:
  429. case WBEM_INDEX_QUALIFIER_AGENTTRANSPORT:
  430. case WBEM_INDEX_QUALIFIER_AGENTADDRESS:
  431. case WBEM_INDEX_QUALIFIER_AGENTREADCOMMUNITYNAME:
  432. case WBEM_INDEX_QUALIFIER_AGENTWRITECOMMUNITYNAME:
  433. case WBEM_INDEX_QUALIFIER_TABLECLASS:
  434. case WBEM_INDEX_QUALIFIER_KEYTYPES:
  435. case WBEM_INDEX_QUALIFIER_KEYVALUES:
  436. {
  437. varType = VT_BSTR ;
  438. }
  439. break ;
  440. case WBEM_INDEX_QUALIFIER_KEY:
  441. case WBEM_INDEX_QUALIFIER_VIRTUAL_KEY:
  442. case WBEM_INDEX_QUALIFIER_READ:
  443. case WBEM_INDEX_QUALIFIER_WRITE:
  444. case WBEM_INDEX_QUALIFIER_NOT_AVAILABLE:
  445. case WBEM_INDEX_QUALIFIER_TYPE_MISMATCH:
  446. case WBEM_INDEX_QUALIFIER_VALUE_MISMATCH:
  447. case WBEM_INDEX_QUALIFIER_SINGLETON:
  448. case WBEM_INDEX_QUALIFIER_ROWSTATUS:
  449. {
  450. varType = VT_BOOL ;
  451. }
  452. break ;
  453. case WBEM_INDEX_QUALIFIER_FIXED_LENGTH:
  454. case WBEM_INDEX_QUALIFIER_KEY_ORDER:
  455. case WBEM_INDEX_QUALIFIER_AGENTRETRYCOUNT:
  456. case WBEM_INDEX_QUALIFIER_AGENTRETRYTIMEOUT:
  457. case WBEM_INDEX_QUALIFIER_AGENTVARBINDSPERPDU:
  458. case WBEM_INDEX_QUALIFIER_AGENTFLOWCONTROLWINDOWSIZE:
  459. case WBEM_INDEX_QUALIFIER_VARBINDINDEX:
  460. {
  461. varType = VT_I4 ;
  462. }
  463. break ;
  464. default:
  465. {
  466. varType = VT_NULL ;
  467. }
  468. }
  469. }
  470. else
  471. {
  472. varType = VT_NULL ;
  473. }
  474. return varType ;
  475. }
  476. BOOL WbemSnmpQualifier :: IsPropagatable () const
  477. {
  478. DebugMacro7( SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine ( __FILE__,__LINE__,L"WbemSnmpQualifier :: IsPropagatable ()" ) )
  479. BOOL status = FALSE ;
  480. ULONG qualifierIndex ;
  481. if ( validQualifierMap.Lookup ( qualifierName , qualifierIndex ) )
  482. {
  483. switch ( qualifierIndex )
  484. {
  485. case WBEM_INDEX_QUALIFIER_TEXTUAL_CONVENTION:
  486. case WBEM_INDEX_QUALIFIER_SYNTAX:
  487. case WBEM_INDEX_QUALIFIER_OBJECT_IDENTIFIER:
  488. case WBEM_INDEX_QUALIFIER_ENCODING:
  489. case WBEM_INDEX_QUALIFIER_VARIABLE_LENGTH:
  490. case WBEM_INDEX_QUALIFIER_VARIABLE_VALUE:
  491. case WBEM_INDEX_QUALIFIER_DISPLAY_HINT:
  492. case WBEM_INDEX_QUALIFIER_ENUMERATION:
  493. case WBEM_INDEX_QUALIFIER_AGENTSNMPVERSION:
  494. case WBEM_INDEX_QUALIFIER_AGENTTRANSPORT:
  495. case WBEM_INDEX_QUALIFIER_AGENTADDRESS:
  496. case WBEM_INDEX_QUALIFIER_AGENTREADCOMMUNITYNAME:
  497. case WBEM_INDEX_QUALIFIER_AGENTWRITECOMMUNITYNAME:
  498. case WBEM_INDEX_QUALIFIER_KEY:
  499. case WBEM_INDEX_QUALIFIER_VIRTUAL_KEY:
  500. case WBEM_INDEX_QUALIFIER_READ:
  501. case WBEM_INDEX_QUALIFIER_WRITE:
  502. case WBEM_INDEX_QUALIFIER_FIXED_LENGTH:
  503. case WBEM_INDEX_QUALIFIER_KEY_ORDER:
  504. case WBEM_INDEX_QUALIFIER_AGENTRETRYCOUNT:
  505. case WBEM_INDEX_QUALIFIER_AGENTRETRYTIMEOUT:
  506. case WBEM_INDEX_QUALIFIER_AGENTVARBINDSPERPDU:
  507. case WBEM_INDEX_QUALIFIER_AGENTFLOWCONTROLWINDOWSIZE:
  508. case WBEM_INDEX_QUALIFIER_SINGLETON:
  509. case WBEM_INDEX_QUALIFIER_VARBINDINDEX:
  510. case WBEM_INDEX_QUALIFIER_TABLECLASS:
  511. case WBEM_INDEX_QUALIFIER_KEYTYPES:
  512. case WBEM_INDEX_QUALIFIER_KEYVALUES:
  513. case WBEM_INDEX_QUALIFIER_ROWSTATUS:
  514. {
  515. status = FALSE ;
  516. }
  517. break ;
  518. case WBEM_INDEX_QUALIFIER_NOT_AVAILABLE:
  519. case WBEM_INDEX_QUALIFIER_TYPE_MISMATCH:
  520. case WBEM_INDEX_QUALIFIER_VALUE_MISMATCH:
  521. {
  522. status = TRUE ;
  523. }
  524. break ;
  525. default:
  526. {
  527. status = FALSE ;
  528. }
  529. }
  530. }
  531. else
  532. {
  533. status = FALSE ;
  534. }
  535. return status ;
  536. }
  537. BOOL WbemSnmpQualifier :: SetValue ( IWbemQualifierSet *a_Qualifier , const SnmpInstanceType &value )
  538. {
  539. VARIANT t_Variant ;
  540. VariantInit ( & t_Variant ) ;
  541. t_Variant.vt = VT_NULL ;
  542. BOOL status = FALSE ;
  543. ULONG qualifierIndex ;
  544. if ( validQualifierMap.Lookup ( qualifierName , qualifierIndex ) )
  545. {
  546. switch ( qualifierIndex )
  547. {
  548. case WBEM_INDEX_QUALIFIER_TEXTUAL_CONVENTION:
  549. {
  550. if ( (typeid ( value ) == typeid ( SnmpDisplayStringType )) && typeValue)
  551. {
  552. SnmpDisplayStringType *displayString = ( SnmpDisplayStringType * ) & value ;
  553. ULONG stringItem ;
  554. wchar_t *string = displayString->GetValue () ;
  555. if ( textualConventionMap.Lookup ( string , stringItem ) )
  556. {
  557. status = TRUE ;
  558. SnmpDisplayStringType *displayString = ( SnmpDisplayStringType * ) typeValue ;
  559. wchar_t *string = displayString->GetValue () ;
  560. t_Variant.vt = VT_BSTR ;
  561. t_Variant.bstrVal = SysAllocString ( string ) ;
  562. }
  563. delete [] string ;
  564. }
  565. }
  566. break ;
  567. case WBEM_INDEX_QUALIFIER_ENCODING:
  568. {
  569. if ( ( typeid ( value ) == typeid ( SnmpDisplayStringType ) ) && typeValue )
  570. {
  571. SnmpDisplayStringType *displayString = ( SnmpDisplayStringType * ) & value ;
  572. ULONG stringItem ;
  573. wchar_t *string = displayString->GetValue () ;
  574. if ( mibTypeMap.Lookup ( string , stringItem ) )
  575. {
  576. status = TRUE ;
  577. SnmpDisplayStringType *displayString = ( SnmpDisplayStringType * ) typeValue ;
  578. wchar_t *string = displayString->GetValue () ;
  579. t_Variant.vt = VT_BSTR ;
  580. t_Variant.bstrVal = SysAllocString ( string ) ;
  581. }
  582. delete [] string ;
  583. }
  584. }
  585. break ;
  586. case WBEM_INDEX_QUALIFIER_OBJECT_IDENTIFIER:
  587. {
  588. if ( (typeid ( value ) == typeid ( SnmpObjectIdentifierType ) ) && typeValue )
  589. {
  590. status = TRUE ;
  591. SnmpDisplayStringType *displayString = ( SnmpDisplayStringType * ) typeValue ;
  592. wchar_t *string = displayString->GetValue () ;
  593. t_Variant.vt = VT_BSTR ;
  594. t_Variant.bstrVal = SysAllocString ( string ) ;
  595. }
  596. }
  597. break ;
  598. case WBEM_INDEX_QUALIFIER_SYNTAX:
  599. case WBEM_INDEX_QUALIFIER_VARIABLE_LENGTH:
  600. case WBEM_INDEX_QUALIFIER_VARIABLE_VALUE:
  601. case WBEM_INDEX_QUALIFIER_DISPLAY_HINT:
  602. case WBEM_INDEX_QUALIFIER_ENUMERATION:
  603. case WBEM_INDEX_QUALIFIER_AGENTSNMPVERSION:
  604. case WBEM_INDEX_QUALIFIER_AGENTTRANSPORT:
  605. case WBEM_INDEX_QUALIFIER_AGENTADDRESS:
  606. case WBEM_INDEX_QUALIFIER_AGENTREADCOMMUNITYNAME:
  607. case WBEM_INDEX_QUALIFIER_AGENTWRITECOMMUNITYNAME:
  608. case WBEM_INDEX_QUALIFIER_TABLECLASS:
  609. case WBEM_INDEX_QUALIFIER_KEYTYPES:
  610. case WBEM_INDEX_QUALIFIER_KEYVALUES:
  611. {
  612. if ( ( typeid ( value ) == typeid ( SnmpDisplayStringType ) ) && typeValue)
  613. {
  614. status = TRUE ;
  615. SnmpDisplayStringType *displayString = ( SnmpDisplayStringType * ) typeValue ;
  616. wchar_t *string = displayString->GetValue () ;
  617. t_Variant.vt = VT_BSTR ;
  618. t_Variant.bstrVal = SysAllocString ( string ) ;
  619. }
  620. }
  621. break ;
  622. case WBEM_INDEX_QUALIFIER_NOT_AVAILABLE:
  623. case WBEM_INDEX_QUALIFIER_TYPE_MISMATCH:
  624. case WBEM_INDEX_QUALIFIER_VALUE_MISMATCH:
  625. {
  626. if ( typeid ( value ) == typeid ( SnmpIntegerType ) )
  627. {
  628. status = TRUE ;
  629. SnmpIntegerType *integer = typeValue ? ( SnmpIntegerType * ) typeValue : ( SnmpIntegerType * ) &value;
  630. t_Variant.vt = VT_BOOL ;
  631. t_Variant.boolVal = integer->GetValue () ? VARIANT_TRUE : VARIANT_FALSE ;
  632. }
  633. }
  634. break ;
  635. case WBEM_INDEX_QUALIFIER_KEY:
  636. case WBEM_INDEX_QUALIFIER_VIRTUAL_KEY:
  637. case WBEM_INDEX_QUALIFIER_READ:
  638. case WBEM_INDEX_QUALIFIER_WRITE:
  639. case WBEM_INDEX_QUALIFIER_SINGLETON:
  640. case WBEM_INDEX_QUALIFIER_ROWSTATUS:
  641. {
  642. if ( ( typeid ( value ) == typeid ( SnmpIntegerType ) ) && typeValue)
  643. {
  644. status = TRUE ;
  645. SnmpIntegerType *integer = ( SnmpIntegerType * ) typeValue ;
  646. t_Variant.vt = VT_BOOL ;
  647. t_Variant.boolVal = integer->GetValue () ? VARIANT_TRUE : VARIANT_FALSE ;
  648. }
  649. }
  650. break ;
  651. case WBEM_INDEX_QUALIFIER_FIXED_LENGTH:
  652. case WBEM_INDEX_QUALIFIER_KEY_ORDER:
  653. case WBEM_INDEX_QUALIFIER_AGENTRETRYCOUNT:
  654. case WBEM_INDEX_QUALIFIER_AGENTRETRYTIMEOUT:
  655. case WBEM_INDEX_QUALIFIER_AGENTVARBINDSPERPDU:
  656. case WBEM_INDEX_QUALIFIER_AGENTFLOWCONTROLWINDOWSIZE:
  657. case WBEM_INDEX_QUALIFIER_VARBINDINDEX:
  658. {
  659. if ( ( typeid ( value ) == typeid ( SnmpIntegerType ) ) && typeValue )
  660. {
  661. status = TRUE ;
  662. SnmpIntegerType *integer = ( SnmpIntegerType * ) typeValue ;
  663. t_Variant.vt = VT_I4 ;
  664. t_Variant.lVal = integer->GetValue () ;
  665. }
  666. }
  667. break ;
  668. default:
  669. {
  670. status = FALSE ;
  671. }
  672. }
  673. }
  674. else
  675. {
  676. status = FALSE ;
  677. }
  678. if ( status )
  679. {
  680. if ( value.IsValid () )
  681. {
  682. a_Qualifier->Put ( qualifierName , &t_Variant , WBEM_CLASS_PROPAGATION ) ;
  683. }
  684. else
  685. {
  686. status = FALSE ;
  687. }
  688. VariantClear ( &t_Variant ) ;
  689. }
  690. return status ;
  691. }
  692. BOOL WbemSnmpQualifier :: SetValue ( const SnmpInstanceType *value )
  693. {
  694. DebugMacro7(
  695. wchar_t *t_StringValue = ( typeValue ) ? typeValue->GetStringValue () : NULL ;
  696. if ( t_StringValue )
  697. {
  698. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  699. __FILE__,__LINE__,
  700. L"WbemSnmpQualifier :: SetValue ( const SnmpInstanceType *value ( (%s),(%s) ) )" ,
  701. qualifierName ,
  702. t_StringValue
  703. ) ;
  704. }
  705. else
  706. {
  707. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  708. __FILE__,__LINE__,
  709. L"WbemSnmpQualifier :: SetValue ( const SnmpInstanceType *value ( (%s),(NULL) ) )" ,
  710. qualifierName
  711. ) ;
  712. }
  713. delete [] t_StringValue ;
  714. )
  715. BOOL status = FALSE ;
  716. ULONG qualifierIndex ;
  717. if ( validQualifierMap.Lookup ( qualifierName , qualifierIndex ) )
  718. {
  719. switch ( qualifierIndex )
  720. {
  721. case WBEM_INDEX_QUALIFIER_TEXTUAL_CONVENTION:
  722. {
  723. if ( typeid ( *value ) == typeid ( SnmpDisplayStringType ) )
  724. {
  725. SnmpDisplayStringType *displayString = ( SnmpDisplayStringType * ) value ;
  726. ULONG stringItem ;
  727. wchar_t *string = displayString->GetValue () ;
  728. if ( textualConventionMap.Lookup ( string , stringItem ) )
  729. {
  730. status = TRUE ;
  731. }
  732. delete [] string ;
  733. }
  734. }
  735. break ;
  736. case WBEM_INDEX_QUALIFIER_ENCODING:
  737. {
  738. if ( typeid ( *value ) == typeid ( SnmpDisplayStringType ) )
  739. {
  740. SnmpDisplayStringType *displayString = ( SnmpDisplayStringType * ) value ;
  741. ULONG stringItem ;
  742. wchar_t *string = displayString->GetValue () ;
  743. if ( mibTypeMap.Lookup ( string , stringItem ) )
  744. {
  745. status = TRUE ;
  746. }
  747. delete [] string ;
  748. }
  749. }
  750. break ;
  751. case WBEM_INDEX_QUALIFIER_OBJECT_IDENTIFIER:
  752. {
  753. if ( typeid ( *value ) == typeid ( SnmpObjectIdentifierType ) )
  754. {
  755. status = TRUE ;
  756. }
  757. }
  758. break ;
  759. case WBEM_INDEX_QUALIFIER_SYNTAX:
  760. case WBEM_INDEX_QUALIFIER_VARIABLE_LENGTH:
  761. case WBEM_INDEX_QUALIFIER_VARIABLE_VALUE:
  762. case WBEM_INDEX_QUALIFIER_DISPLAY_HINT:
  763. case WBEM_INDEX_QUALIFIER_ENUMERATION:
  764. case WBEM_INDEX_QUALIFIER_AGENTSNMPVERSION:
  765. case WBEM_INDEX_QUALIFIER_AGENTTRANSPORT:
  766. case WBEM_INDEX_QUALIFIER_AGENTADDRESS:
  767. case WBEM_INDEX_QUALIFIER_AGENTREADCOMMUNITYNAME:
  768. case WBEM_INDEX_QUALIFIER_AGENTWRITECOMMUNITYNAME:
  769. case WBEM_INDEX_QUALIFIER_TABLECLASS:
  770. case WBEM_INDEX_QUALIFIER_KEYTYPES:
  771. case WBEM_INDEX_QUALIFIER_KEYVALUES:
  772. {
  773. if ( typeid ( *value ) == typeid ( SnmpDisplayStringType ) )
  774. {
  775. status = TRUE ;
  776. }
  777. }
  778. break ;
  779. case WBEM_INDEX_QUALIFIER_KEY:
  780. case WBEM_INDEX_QUALIFIER_VIRTUAL_KEY:
  781. case WBEM_INDEX_QUALIFIER_READ:
  782. case WBEM_INDEX_QUALIFIER_WRITE:
  783. case WBEM_INDEX_QUALIFIER_NOT_AVAILABLE:
  784. case WBEM_INDEX_QUALIFIER_TYPE_MISMATCH:
  785. case WBEM_INDEX_QUALIFIER_VALUE_MISMATCH:
  786. case WBEM_INDEX_QUALIFIER_SINGLETON:
  787. case WBEM_INDEX_QUALIFIER_ROWSTATUS:
  788. {
  789. if ( typeid ( *value ) == typeid ( SnmpIntegerType ) )
  790. {
  791. status = TRUE ;
  792. }
  793. }
  794. break ;
  795. case WBEM_INDEX_QUALIFIER_FIXED_LENGTH:
  796. case WBEM_INDEX_QUALIFIER_KEY_ORDER:
  797. case WBEM_INDEX_QUALIFIER_AGENTRETRYCOUNT:
  798. case WBEM_INDEX_QUALIFIER_AGENTRETRYTIMEOUT:
  799. case WBEM_INDEX_QUALIFIER_AGENTVARBINDSPERPDU:
  800. case WBEM_INDEX_QUALIFIER_AGENTFLOWCONTROLWINDOWSIZE:
  801. case WBEM_INDEX_QUALIFIER_VARBINDINDEX:
  802. {
  803. if ( typeid ( *value ) == typeid ( SnmpIntegerType ) )
  804. {
  805. status = TRUE ;
  806. }
  807. }
  808. break ;
  809. default:
  810. {
  811. status = FALSE ;
  812. }
  813. }
  814. }
  815. else
  816. {
  817. status = FALSE ;
  818. }
  819. if ( status )
  820. {
  821. if ( value && value->IsValid () )
  822. {
  823. delete typeValue ;
  824. typeValue = value->Copy () ;
  825. }
  826. else
  827. {
  828. status = FALSE ;
  829. }
  830. }
  831. return status ;
  832. }
  833. BOOL WbemSnmpQualifier :: SetValue ( const VARIANT &variant )
  834. {
  835. DebugMacro7( SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine ( __FILE__,__LINE__,L"WbemSnmpQualifier :: SetValue ( const VARIANT &variant )" ) )
  836. BOOL status = FALSE ;
  837. SnmpInstanceType *value = NULL ;
  838. ULONG qualifierIndex ;
  839. if ( validQualifierMap.Lookup ( qualifierName , qualifierIndex ) )
  840. {
  841. switch ( qualifierIndex )
  842. {
  843. case WBEM_INDEX_QUALIFIER_TEXTUAL_CONVENTION:
  844. {
  845. if ( variant.vt == VT_BSTR )
  846. {
  847. ULONG stringItem ;
  848. wchar_t *string = variant.bstrVal ;
  849. if ( textualConventionMap.Lookup ( string , stringItem ) )
  850. {
  851. value = new SnmpDisplayStringType ( string , NULL ) ;
  852. status = TRUE ;
  853. }
  854. }
  855. }
  856. break ;
  857. case WBEM_INDEX_QUALIFIER_ENCODING:
  858. {
  859. if ( variant.vt == VT_BSTR )
  860. {
  861. ULONG stringItem ;
  862. wchar_t *string = variant.bstrVal ;
  863. if ( mibTypeMap.Lookup ( string , stringItem ) )
  864. {
  865. value = new SnmpDisplayStringType ( string , NULL ) ;
  866. status = TRUE ;
  867. }
  868. }
  869. }
  870. break ;
  871. case WBEM_INDEX_QUALIFIER_OBJECT_IDENTIFIER:
  872. {
  873. if ( variant.vt == VT_BSTR )
  874. {
  875. value = new SnmpObjectIdentifierType ( variant.bstrVal ) ;
  876. status = TRUE ;
  877. }
  878. }
  879. break ;
  880. case WBEM_INDEX_QUALIFIER_SYNTAX:
  881. case WBEM_INDEX_QUALIFIER_VARIABLE_LENGTH:
  882. case WBEM_INDEX_QUALIFIER_VARIABLE_VALUE:
  883. case WBEM_INDEX_QUALIFIER_DISPLAY_HINT:
  884. case WBEM_INDEX_QUALIFIER_ENUMERATION:
  885. case WBEM_INDEX_QUALIFIER_BITS:
  886. case WBEM_INDEX_QUALIFIER_AGENTSNMPVERSION:
  887. case WBEM_INDEX_QUALIFIER_AGENTTRANSPORT:
  888. case WBEM_INDEX_QUALIFIER_AGENTADDRESS:
  889. case WBEM_INDEX_QUALIFIER_AGENTREADCOMMUNITYNAME:
  890. case WBEM_INDEX_QUALIFIER_AGENTWRITECOMMUNITYNAME:
  891. case WBEM_INDEX_QUALIFIER_TABLECLASS:
  892. case WBEM_INDEX_QUALIFIER_KEYTYPES:
  893. case WBEM_INDEX_QUALIFIER_KEYVALUES:
  894. {
  895. if ( variant.vt == VT_BSTR )
  896. {
  897. value = new SnmpDisplayStringType ( variant.bstrVal , NULL ) ;
  898. status = TRUE ;
  899. }
  900. }
  901. break ;
  902. case WBEM_INDEX_QUALIFIER_KEY:
  903. case WBEM_INDEX_QUALIFIER_VIRTUAL_KEY:
  904. case WBEM_INDEX_QUALIFIER_READ:
  905. case WBEM_INDEX_QUALIFIER_WRITE:
  906. case WBEM_INDEX_QUALIFIER_NOT_AVAILABLE:
  907. case WBEM_INDEX_QUALIFIER_TYPE_MISMATCH:
  908. case WBEM_INDEX_QUALIFIER_VALUE_MISMATCH:
  909. case WBEM_INDEX_QUALIFIER_SINGLETON:
  910. case WBEM_INDEX_QUALIFIER_ROWSTATUS:
  911. {
  912. if ( variant.vt == VT_UI1 )
  913. {
  914. value = new SnmpIntegerType ( variant.bVal , NULL ) ;
  915. status = TRUE ;
  916. }
  917. else if ( variant.vt == VT_I4 )
  918. {
  919. value = new SnmpIntegerType ( variant.lVal , NULL ) ;
  920. status = TRUE ;
  921. }
  922. else if ( variant.vt == VT_BOOL )
  923. {
  924. value = new SnmpIntegerType ( (variant.boolVal == VARIANT_FALSE) ? 0 : 1, NULL ) ;
  925. status = TRUE ;
  926. }
  927. }
  928. break ;
  929. case WBEM_INDEX_QUALIFIER_FIXED_LENGTH:
  930. case WBEM_INDEX_QUALIFIER_KEY_ORDER:
  931. case WBEM_INDEX_QUALIFIER_AGENTRETRYCOUNT:
  932. case WBEM_INDEX_QUALIFIER_AGENTRETRYTIMEOUT:
  933. case WBEM_INDEX_QUALIFIER_AGENTVARBINDSPERPDU:
  934. case WBEM_INDEX_QUALIFIER_AGENTFLOWCONTROLWINDOWSIZE:
  935. case WBEM_INDEX_QUALIFIER_VARBINDINDEX:
  936. {
  937. if ( variant.vt == VT_UI1 )
  938. {
  939. value = new SnmpIntegerType ( variant.bVal , NULL ) ;
  940. status = TRUE ;
  941. }
  942. else if ( variant.vt == VT_I4 )
  943. {
  944. value = new SnmpIntegerType ( variant.lVal , NULL ) ;
  945. status = TRUE ;
  946. }
  947. }
  948. break ;
  949. default:
  950. {
  951. status = FALSE ;
  952. }
  953. }
  954. }
  955. else
  956. {
  957. status = FALSE ;
  958. }
  959. if ( status )
  960. {
  961. if ( value && value->IsValid () )
  962. {
  963. typeValue = value ;
  964. }
  965. else
  966. {
  967. status = FALSE ;
  968. delete value ;
  969. }
  970. }
  971. else
  972. {
  973. delete value ;
  974. }
  975. return status ;
  976. }
  977. WbemSnmpProperty :: WbemSnmpProperty ( const wchar_t *propertyNameArg ) : propertyValue ( NULL ) ,
  978. qualifierPosition ( NULL ) ,
  979. tagged ( FALSE ) ,
  980. m_IsNull ( TRUE ) ,
  981. m_isKey ( FALSE ) ,
  982. m_isVirtualKey ( FALSE ) ,
  983. m_isReadable ( FALSE ) ,
  984. m_isWritable ( FALSE ) ,
  985. m_keyOrder ( 0 ) ,
  986. m_TextualConvention ( 0 ) ,
  987. m_Handle ( 0 ) ,
  988. propertyName ( NULL )
  989. {
  990. DebugMacro7(
  991. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  992. __FILE__,__LINE__,
  993. L"WbemSnmpProperty :: WbemSnmpProperty ( const wchar_t *propertyNameArg (%s) )" ,
  994. propertyNameArg
  995. ) ;
  996. )
  997. propertyValue = new SnmpNullType ;
  998. propertyName = new wchar_t [ wcslen ( propertyNameArg ) + 1 ] ;
  999. wcscpy ( propertyName , propertyNameArg ) ;
  1000. }
  1001. WbemSnmpProperty :: WbemSnmpProperty ( const WbemSnmpProperty &copy ) : propertyValue ( NULL ) ,
  1002. qualifierPosition ( NULL ) ,
  1003. tagged ( FALSE ) ,
  1004. m_IsNull ( TRUE ) ,
  1005. m_isKey ( FALSE ) ,
  1006. m_isVirtualKey ( FALSE ) ,
  1007. m_isReadable ( FALSE ) ,
  1008. m_isWritable ( FALSE ) ,
  1009. m_TextualConvention ( 0 ) ,
  1010. m_Handle ( 0 ) ,
  1011. propertyName ( NULL )
  1012. {
  1013. DebugMacro7(
  1014. wchar_t *t_StringValue = ( propertyValue ) ? propertyValue->GetStringValue () : NULL ;
  1015. if ( t_StringValue )
  1016. {
  1017. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  1018. __FILE__,__LINE__,
  1019. L"WbemSnmpProperty :: WbemSnmpProperty ( const WbemSnmpProperty &copy ( (%s),(%s)) )" ,
  1020. copy.propertyName ,
  1021. t_StringValue
  1022. ) ;
  1023. }
  1024. else
  1025. {
  1026. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  1027. __FILE__,__LINE__,
  1028. L"WbemSnmpProperty :: WbemSnmpProperty ( const WbemSnmpProperty &copy ( (%s),(NULL))" ,
  1029. copy.propertyName
  1030. ) ;
  1031. }
  1032. delete [] t_StringValue ;
  1033. )
  1034. m_isReadable = copy.m_isReadable ;
  1035. m_isWritable = copy.m_isWritable ;
  1036. m_isKey = copy.m_isKey ;
  1037. m_isVirtualKey = copy.m_isVirtualKey ;
  1038. m_IsNull = copy.m_IsNull ;
  1039. tagged = copy.tagged ;
  1040. m_keyOrder = copy.m_keyOrder ;
  1041. m_TextualConvention = copy.m_TextualConvention ;
  1042. m_Handle = copy.m_Handle ;
  1043. if ( copy.propertyValue )
  1044. {
  1045. propertyValue = copy.propertyValue->Copy () ;
  1046. }
  1047. if ( copy.propertyName )
  1048. {
  1049. propertyName = new wchar_t [ wcslen ( copy.propertyName ) + 1 ] ;
  1050. wcscpy ( propertyName , copy.propertyName ) ;
  1051. }
  1052. POSITION position = copy.qualifierMap.GetStartPosition () ;
  1053. while ( position )
  1054. {
  1055. wchar_t *qualifierName ;
  1056. WbemSnmpQualifier *qualifier ;
  1057. copy.qualifierMap.GetNextAssoc ( position , qualifierName , qualifier ) ;
  1058. WbemSnmpQualifier *copyQualifier = new WbemSnmpQualifier ( *qualifier ) ;
  1059. qualifierMap [ copyQualifier->GetName () ] = copyQualifier ;
  1060. }
  1061. }
  1062. WbemSnmpProperty :: ~WbemSnmpProperty ()
  1063. {
  1064. DebugMacro7(
  1065. wchar_t *t_StringValue = ( propertyValue ) ? propertyValue->GetStringValue () : NULL ;
  1066. if ( t_StringValue )
  1067. {
  1068. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  1069. __FILE__,__LINE__,
  1070. L"WbemSnmpProperty :: ~WbemSnmpProperty ( ((%s),(%s)) )" ,
  1071. propertyName ? propertyName : L"!!NULL!!",
  1072. t_StringValue
  1073. ) ;
  1074. }
  1075. else
  1076. {
  1077. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  1078. __FILE__,__LINE__,
  1079. L"WbemSnmpProperty :: ~WbemSnmpProperty ( ((%s),(NULL)) )" ,
  1080. propertyName ? propertyName : L"!!NULL!!"
  1081. ) ;
  1082. }
  1083. delete [] t_StringValue ;
  1084. )
  1085. delete [] propertyName ;
  1086. delete propertyValue ;
  1087. POSITION position = qualifierMap.GetStartPosition () ;
  1088. while ( position )
  1089. {
  1090. wchar_t *qualifierName ;
  1091. WbemSnmpQualifier *qualifier ;
  1092. qualifierMap.GetNextAssoc ( position , qualifierName , qualifier ) ;
  1093. delete qualifier ;
  1094. }
  1095. qualifierMap.RemoveAll () ;
  1096. }
  1097. void WbemSnmpProperty :: SetTag ( BOOL tag )
  1098. {
  1099. tagged = tag ;
  1100. }
  1101. BOOL WbemSnmpProperty :: GetTag ()
  1102. {
  1103. return tagged ;
  1104. }
  1105. BOOL WbemSnmpProperty :: IsNull ()
  1106. {
  1107. if ( propertyValue )
  1108. return propertyValue->IsNull () ;
  1109. else
  1110. return TRUE ;
  1111. }
  1112. BOOL WbemSnmpProperty :: IsKey ()
  1113. {
  1114. return m_isKey ;
  1115. }
  1116. BOOL WbemSnmpProperty :: IsVirtualKey ()
  1117. {
  1118. return m_isVirtualKey ;
  1119. }
  1120. void WbemSnmpProperty :: SetKey ( BOOL a_isKey )
  1121. {
  1122. m_isKey = a_isKey ;
  1123. }
  1124. void WbemSnmpProperty :: SetVirtualKey ( BOOL a_isVirtualKey )
  1125. {
  1126. m_isVirtualKey = a_isVirtualKey ;
  1127. }
  1128. BOOL WbemSnmpProperty :: IsWritable ()
  1129. {
  1130. return m_isWritable ;
  1131. }
  1132. BOOL WbemSnmpProperty :: IsReadable ()
  1133. {
  1134. return m_isReadable ;
  1135. }
  1136. ULONG WbemSnmpProperty :: GetKeyOrder ()
  1137. {
  1138. return m_keyOrder ;
  1139. }
  1140. void WbemSnmpProperty :: SetWritable ( BOOL a_isWritable )
  1141. {
  1142. m_isWritable = a_isWritable ;
  1143. }
  1144. void WbemSnmpProperty :: SetReadable ( BOOL a_isReadable )
  1145. {
  1146. m_isReadable = a_isReadable ;
  1147. }
  1148. void WbemSnmpProperty :: SetKeyOrder ( ULONG a_keyOrder )
  1149. {
  1150. m_keyOrder = a_keyOrder ;
  1151. }
  1152. void WbemSnmpProperty :: SetTextualConvention ( ULONG a_TextualConvention )
  1153. {
  1154. m_TextualConvention = a_TextualConvention ;
  1155. }
  1156. ULONG WbemSnmpProperty :: GetTextualConvention ()
  1157. {
  1158. return m_TextualConvention ;
  1159. }
  1160. CIMTYPE WbemSnmpProperty :: GetCimType ()
  1161. {
  1162. CIMTYPE t_Type = VT_EMPTY ;
  1163. cimTypeMap.Lookup ( m_TextualConvention , t_Type ) ;
  1164. return t_Type ;
  1165. }
  1166. long WbemSnmpProperty :: GetHandle ()
  1167. {
  1168. return m_Handle ;
  1169. }
  1170. void WbemSnmpProperty :: SetHandle ( long a_Handle )
  1171. {
  1172. m_Handle = a_Handle ;
  1173. }
  1174. BOOL WbemSnmpProperty :: SetValue ( const VARIANT &variant , const CIMTYPE & type , WbemPropertyValueCheck check )
  1175. {
  1176. DebugMacro7( SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine ( __FILE__,__LINE__,L"WbemSnmpProperty :: SetValue ( const VARIANT &variant )" ) )
  1177. SnmpInstanceType *value = NULL ;
  1178. if ( type == CIM_EMPTY )
  1179. {
  1180. value = new SnmpNullType ;
  1181. }
  1182. else
  1183. {
  1184. WbemSnmpQualifier *qualifier = FindQualifier ( WBEM_QUALIFIER_TEXTUAL_CONVENTION ) ;
  1185. if ( qualifier )
  1186. {
  1187. SnmpDisplayStringType *displayString = ( SnmpDisplayStringType * ) qualifier->GetValue () ;
  1188. wchar_t *textualConvention = displayString->GetValue () ;
  1189. if ( textualConvention )
  1190. {
  1191. ULONG qualifierIndex ;
  1192. if ( textualConventionMap.Lookup ( textualConvention , qualifierIndex ) )
  1193. {
  1194. switch ( qualifierIndex )
  1195. {
  1196. case WBEM_INDEX_TYPE_INTEGER:
  1197. case WBEM_INDEX_TYPE_INTEGER32:
  1198. {
  1199. if ( type == CIM_SINT32 )
  1200. {
  1201. if ( variant.vt == VT_I4 )
  1202. {
  1203. value = new SnmpIntegerType ( variant.lVal , NULL ) ;
  1204. }
  1205. else if ( variant.vt == VT_NULL )
  1206. {
  1207. value = new SnmpIntegerType ;
  1208. }
  1209. }
  1210. }
  1211. break ;
  1212. case WBEM_INDEX_TYPE_COUNTER:
  1213. case WBEM_INDEX_TYPE_COUNTER32:
  1214. {
  1215. if ( type == CIM_UINT32 )
  1216. {
  1217. if ( variant.vt == VT_I4 )
  1218. {
  1219. value = new SnmpCounterType ( variant.lVal ) ;
  1220. }
  1221. else if ( variant.vt == VT_NULL )
  1222. {
  1223. value = new SnmpCounterType ;
  1224. }
  1225. }
  1226. }
  1227. break ;
  1228. case WBEM_INDEX_TYPE_COUNTER64:
  1229. {
  1230. if ( type == CIM_STRING )
  1231. {
  1232. if ( variant.vt == VT_BSTR )
  1233. {
  1234. value = new SnmpCounter64Type ( variant.bstrVal ) ;
  1235. }
  1236. else if ( variant.vt == VT_NULL )
  1237. {
  1238. value = new SnmpCounter64Type ;
  1239. }
  1240. }
  1241. }
  1242. break ;
  1243. case WBEM_INDEX_TYPE_UNSIGNED32:
  1244. {
  1245. if ( type == CIM_UINT32 )
  1246. {
  1247. if ( variant.vt == VT_I4 )
  1248. {
  1249. value = new SnmpUInteger32Type ( variant.lVal , NULL ) ;
  1250. }
  1251. else if ( variant.vt == VT_NULL )
  1252. {
  1253. value = new SnmpUInteger32Type ;
  1254. }
  1255. }
  1256. }
  1257. break;
  1258. case WBEM_INDEX_TYPE_GAUGE:
  1259. case WBEM_INDEX_TYPE_GAUGE32:
  1260. {
  1261. if ( type == CIM_UINT32 )
  1262. {
  1263. if ( variant.vt == VT_I4 )
  1264. {
  1265. value = new SnmpGaugeType ( variant.lVal , NULL ) ;
  1266. }
  1267. else if ( variant.vt == VT_NULL )
  1268. {
  1269. value = new SnmpGaugeType ;
  1270. }
  1271. }
  1272. }
  1273. break ;
  1274. case WBEM_INDEX_TYPE_OCTETSTRING:
  1275. {
  1276. if ( type == CIM_STRING )
  1277. {
  1278. WbemSnmpQualifier *qualifier = FindQualifier ( WBEM_QUALIFIER_FIXED_LENGTH ) ;
  1279. if ( qualifier )
  1280. {
  1281. SnmpInstanceType *typeValue = qualifier->GetValue () ;
  1282. if ( typeid ( *typeValue ) == typeid ( SnmpIntegerType ) )
  1283. {
  1284. SnmpIntegerType *integer = ( SnmpIntegerType * ) typeValue ;
  1285. LONG fixed = integer->GetValue () ;
  1286. if ( variant.vt == VT_BSTR )
  1287. {
  1288. value = new SnmpFixedLengthOctetStringType ( fixed , variant.bstrVal ) ;
  1289. }
  1290. else if ( variant.vt == VT_NULL )
  1291. {
  1292. value = new SnmpFixedLengthOctetStringType ( fixed ) ;
  1293. }
  1294. }
  1295. else
  1296. {
  1297. // Problem Here
  1298. }
  1299. }
  1300. else
  1301. {
  1302. WbemSnmpQualifier *qualifier = FindQualifier ( WBEM_QUALIFIER_VARIABLE_LENGTH ) ;
  1303. if ( qualifier )
  1304. {
  1305. SnmpInstanceType *typeValue = qualifier->GetValue () ;
  1306. if ( typeid ( *typeValue ) == typeid ( SnmpDisplayStringType ) )
  1307. {
  1308. SnmpDisplayStringType *string = ( SnmpDisplayStringType * ) typeValue ;
  1309. wchar_t *rangeValues = string->GetStringValue () ;
  1310. if ( variant.vt == VT_BSTR )
  1311. {
  1312. value = new SnmpOctetStringType ( variant.bstrVal , rangeValues ) ;
  1313. }
  1314. else if ( variant.vt == VT_NULL )
  1315. {
  1316. value = new SnmpOctetStringType ( rangeValues ) ;
  1317. }
  1318. delete [] rangeValues ;
  1319. }
  1320. else
  1321. {
  1322. }
  1323. }
  1324. else
  1325. {
  1326. if ( variant.vt == VT_BSTR )
  1327. {
  1328. value = new SnmpOctetStringType ( variant.bstrVal , NULL ) ;
  1329. }
  1330. else if ( variant.vt == VT_NULL )
  1331. {
  1332. value = new SnmpOctetStringType ;
  1333. }
  1334. }
  1335. }
  1336. }
  1337. }
  1338. break ;
  1339. case WBEM_INDEX_TYPE_OBJECTIDENTIFIER:
  1340. {
  1341. if ( type == CIM_STRING )
  1342. {
  1343. if ( variant.vt == VT_BSTR )
  1344. {
  1345. value = new SnmpObjectIdentifierType ( variant.bstrVal ) ;
  1346. }
  1347. else if ( variant.vt == VT_NULL )
  1348. {
  1349. value = new SnmpObjectIdentifierType ;
  1350. }
  1351. }
  1352. }
  1353. break ;
  1354. case WBEM_INDEX_TYPE_NULL:
  1355. {
  1356. if ( type == CIM_STRING )
  1357. {
  1358. if ( variant.vt == VT_NULL )
  1359. {
  1360. value = new SnmpNullType ;
  1361. }
  1362. else if ( variant.vt == VT_BSTR )
  1363. {
  1364. value = new SnmpNullType ;
  1365. }
  1366. }
  1367. }
  1368. break;
  1369. case WBEM_INDEX_TYPE_IPADDRESS:
  1370. {
  1371. if ( type == CIM_STRING )
  1372. {
  1373. if ( variant.vt == VT_BSTR )
  1374. {
  1375. value = new SnmpIpAddressType ( variant.bstrVal ) ;
  1376. }
  1377. else if ( variant.vt == VT_NULL )
  1378. {
  1379. value = new SnmpIpAddressType ;
  1380. }
  1381. }
  1382. }
  1383. break ;
  1384. case WBEM_INDEX_TYPE_TIMETICKS:
  1385. {
  1386. if ( type == CIM_UINT32 )
  1387. {
  1388. if ( variant.vt == VT_I4 )
  1389. {
  1390. value = new SnmpTimeTicksType ( variant.lVal ) ;
  1391. }
  1392. else if ( variant.vt == VT_NULL )
  1393. {
  1394. value = new SnmpTimeTicksType ;
  1395. }
  1396. }
  1397. }
  1398. break ;
  1399. case WBEM_INDEX_TYPE_OPAQUE:
  1400. {
  1401. if ( type == CIM_STRING )
  1402. {
  1403. WbemSnmpQualifier *qualifier = FindQualifier ( WBEM_QUALIFIER_FIXED_LENGTH ) ;
  1404. if ( qualifier )
  1405. {
  1406. SnmpInstanceType *typeValue = qualifier->GetValue () ;
  1407. if ( typeid ( *typeValue ) == typeid ( SnmpIntegerType ) )
  1408. {
  1409. SnmpIntegerType *integer = ( SnmpIntegerType * ) typeValue ;
  1410. LONG fixed = integer->GetValue () ;
  1411. if ( variant.vt == VT_BSTR )
  1412. {
  1413. value = new SnmpFixedLengthOpaqueType ( fixed , variant.bstrVal ) ;
  1414. }
  1415. else if ( variant.vt == VT_NULL )
  1416. {
  1417. value = new SnmpFixedLengthOpaqueType ( fixed ) ;
  1418. }
  1419. }
  1420. else
  1421. {
  1422. // Problem Here
  1423. }
  1424. }
  1425. else
  1426. {
  1427. WbemSnmpQualifier *qualifier = FindQualifier ( WBEM_QUALIFIER_VARIABLE_LENGTH ) ;
  1428. if ( qualifier )
  1429. {
  1430. SnmpInstanceType *typeValue = qualifier->GetValue () ;
  1431. if ( typeid ( *typeValue ) == typeid ( SnmpDisplayStringType ) )
  1432. {
  1433. SnmpDisplayStringType *string = ( SnmpDisplayStringType * ) typeValue ;
  1434. wchar_t *rangeValues = string->GetStringValue () ;
  1435. if ( variant.vt == VT_BSTR )
  1436. {
  1437. value = new SnmpOpaqueType ( variant.bstrVal , rangeValues ) ;
  1438. }
  1439. else if ( variant.vt == VT_NULL )
  1440. {
  1441. value = new SnmpOpaqueType ( rangeValues ) ;
  1442. }
  1443. delete [] rangeValues ;
  1444. }
  1445. else
  1446. {
  1447. }
  1448. }
  1449. else
  1450. {
  1451. if ( variant.vt == VT_BSTR )
  1452. {
  1453. value = new SnmpOpaqueType ( variant.bstrVal , NULL ) ;
  1454. }
  1455. else
  1456. {
  1457. value = new SnmpOpaqueType ;
  1458. }
  1459. }
  1460. }
  1461. }
  1462. }
  1463. break ;
  1464. case WBEM_INDEX_TYPE_NETWORKADDRESS:
  1465. {
  1466. if ( type == CIM_STRING )
  1467. {
  1468. if ( variant.vt == VT_BSTR )
  1469. {
  1470. value = new SnmpNetworkAddressType ( variant.bstrVal ) ;
  1471. }
  1472. else if ( variant.vt == VT_NULL )
  1473. {
  1474. value = new SnmpNetworkAddressType ;
  1475. }
  1476. }
  1477. }
  1478. break ;
  1479. case WBEM_INDEX_TYPE_DISPLAYSTRING:
  1480. {
  1481. if ( type == CIM_STRING )
  1482. {
  1483. WbemSnmpQualifier *qualifier = FindQualifier ( WBEM_QUALIFIER_FIXED_LENGTH ) ;
  1484. if ( qualifier )
  1485. {
  1486. SnmpInstanceType *typeValue = qualifier->GetValue () ;
  1487. if ( typeid ( *typeValue ) == typeid ( SnmpIntegerType ) )
  1488. {
  1489. SnmpIntegerType *integer = ( SnmpIntegerType * ) typeValue ;
  1490. LONG fixed = integer->GetValue () ;
  1491. if ( variant.vt == VT_BSTR )
  1492. {
  1493. value = new SnmpFixedLengthDisplayStringType ( fixed , variant.bstrVal ) ;
  1494. }
  1495. else if ( variant.vt == VT_NULL )
  1496. {
  1497. value = new SnmpFixedLengthDisplayStringType ( fixed ) ;
  1498. }
  1499. }
  1500. else
  1501. {
  1502. // Problem Here
  1503. }
  1504. }
  1505. else
  1506. {
  1507. WbemSnmpQualifier *qualifier = FindQualifier ( WBEM_QUALIFIER_VARIABLE_LENGTH ) ;
  1508. if ( qualifier )
  1509. {
  1510. SnmpInstanceType *typeValue = qualifier->GetValue () ;
  1511. if ( typeid ( *typeValue ) == typeid ( SnmpDisplayStringType ) )
  1512. {
  1513. SnmpDisplayStringType *string = ( SnmpDisplayStringType * ) typeValue ;
  1514. wchar_t *rangeValues = string->GetStringValue () ;
  1515. if ( variant.vt == VT_BSTR )
  1516. {
  1517. value = new SnmpDisplayStringType ( variant.bstrVal , rangeValues ) ;
  1518. }
  1519. else
  1520. {
  1521. value = new SnmpDisplayStringType ( rangeValues ) ;
  1522. }
  1523. delete [] rangeValues ;
  1524. }
  1525. else
  1526. {
  1527. }
  1528. }
  1529. else
  1530. {
  1531. if ( variant.vt == VT_BSTR )
  1532. {
  1533. value = new SnmpDisplayStringType ( variant.bstrVal , NULL ) ;
  1534. }
  1535. else
  1536. {
  1537. value = new SnmpDisplayStringType ;
  1538. }
  1539. }
  1540. }
  1541. }
  1542. }
  1543. break ;
  1544. case WBEM_INDEX_TYPE_MACADDRESS:
  1545. {
  1546. if ( type == CIM_STRING )
  1547. {
  1548. if ( variant.vt == VT_BSTR )
  1549. {
  1550. value = new SnmpMacAddressType ( variant.bstrVal ) ;
  1551. }
  1552. else if ( variant.vt == VT_NULL )
  1553. {
  1554. value = new SnmpMacAddressType ;
  1555. }
  1556. }
  1557. }
  1558. break ;
  1559. case WBEM_INDEX_TYPE_PHYSADDRESS:
  1560. {
  1561. if ( type == CIM_STRING )
  1562. {
  1563. WbemSnmpQualifier *qualifier = FindQualifier ( WBEM_QUALIFIER_FIXED_LENGTH ) ;
  1564. if ( qualifier )
  1565. {
  1566. SnmpInstanceType *typeValue = qualifier->GetValue () ;
  1567. if ( typeid ( *typeValue ) == typeid ( SnmpIntegerType ) )
  1568. {
  1569. SnmpIntegerType *integer = ( SnmpIntegerType * ) typeValue ;
  1570. LONG fixed = integer->GetValue () ;
  1571. if ( variant.vt == VT_BSTR )
  1572. {
  1573. value = new SnmpFixedLengthPhysAddressType ( fixed , variant.bstrVal ) ;
  1574. }
  1575. else if ( variant.vt == VT_NULL )
  1576. {
  1577. value = new SnmpFixedLengthPhysAddressType ( fixed ) ;
  1578. }
  1579. }
  1580. else
  1581. {
  1582. // Problem Here
  1583. }
  1584. }
  1585. else
  1586. {
  1587. WbemSnmpQualifier *qualifier = FindQualifier ( WBEM_QUALIFIER_VARIABLE_LENGTH ) ;
  1588. if ( qualifier )
  1589. {
  1590. SnmpInstanceType *typeValue = qualifier->GetValue () ;
  1591. if ( typeid ( *typeValue ) == typeid ( SnmpDisplayStringType ) )
  1592. {
  1593. SnmpDisplayStringType *string = ( SnmpDisplayStringType * ) typeValue ;
  1594. wchar_t *rangeValues = string->GetStringValue () ;
  1595. if ( variant.vt == VT_BSTR )
  1596. {
  1597. value = new SnmpPhysAddressType ( variant.bstrVal , rangeValues ) ;
  1598. }
  1599. else if ( variant.vt == VT_NULL )
  1600. {
  1601. value = new SnmpPhysAddressType ( rangeValues ) ;
  1602. }
  1603. delete [] rangeValues ;
  1604. }
  1605. else
  1606. {
  1607. }
  1608. }
  1609. else
  1610. {
  1611. if ( variant.vt == VT_BSTR )
  1612. {
  1613. value = new SnmpPhysAddressType ( variant.bstrVal , NULL ) ;
  1614. }
  1615. else if ( variant.vt == VT_NULL )
  1616. {
  1617. value = new SnmpPhysAddressType ;
  1618. }
  1619. }
  1620. }
  1621. }
  1622. }
  1623. break ;
  1624. case WBEM_INDEX_TYPE_ENUMERATEDINTEGER:
  1625. {
  1626. if ( type == CIM_STRING )
  1627. {
  1628. WbemSnmpQualifier *qualifier = FindQualifier ( WBEM_QUALIFIER_ENUMERATION ) ;
  1629. if ( qualifier )
  1630. {
  1631. SnmpInstanceType *typeValue = qualifier->GetValue () ;
  1632. if ( typeid ( *typeValue ) == typeid ( SnmpDisplayStringType ) )
  1633. {
  1634. SnmpDisplayStringType *string = ( SnmpDisplayStringType * ) typeValue ;
  1635. wchar_t *enumerationValues = string->GetStringValue () ;
  1636. if ( variant.vt == VT_BSTR )
  1637. {
  1638. value = new SnmpEnumeratedType ( enumerationValues , variant.bstrVal ) ;
  1639. }
  1640. else if ( variant.vt == VT_NULL )
  1641. {
  1642. value = new SnmpEnumeratedType ( enumerationValues ) ;
  1643. }
  1644. delete [] enumerationValues ;
  1645. }
  1646. }
  1647. }
  1648. }
  1649. break ;
  1650. case WBEM_INDEX_TYPE_BITS:
  1651. {
  1652. if ( type == ( CIM_STRING | CIM_FLAG_ARRAY ) )
  1653. {
  1654. WbemSnmpQualifier *qualifier = FindQualifier ( WBEM_QUALIFIER_BITS ) ;
  1655. if ( qualifier )
  1656. {
  1657. SnmpInstanceType *typeValue = qualifier->GetValue () ;
  1658. if ( typeid ( *typeValue ) == typeid ( SnmpDisplayStringType ) )
  1659. {
  1660. SnmpDisplayStringType *string = ( SnmpDisplayStringType * ) typeValue ;
  1661. wchar_t *bitStringValues = string->GetStringValue () ;
  1662. if ( variant.vt == ( VT_BSTR | VT_ARRAY ) )
  1663. {
  1664. if ( SafeArrayGetDim ( variant.parray ) == 1 )
  1665. {
  1666. LONG dimension = 1 ;
  1667. LONG lower ;
  1668. SafeArrayGetLBound ( variant.parray , dimension , & lower ) ;
  1669. LONG upper ;
  1670. SafeArrayGetUBound ( variant.parray , dimension , & upper ) ;
  1671. LONG count = ( upper - lower ) + 1 ;
  1672. wchar_t **array = new wchar_t * [ count ] ;
  1673. for ( LONG elementIndex = lower ; elementIndex <= upper ; elementIndex ++ )
  1674. {
  1675. BSTR element ;
  1676. SafeArrayGetElement ( variant.parray , &elementIndex , & element ) ;
  1677. array [ elementIndex - lower ] = element ;
  1678. }
  1679. value = new SnmpBitStringType ( bitStringValues , ( const wchar_t ** ) array , count ) ;
  1680. for ( elementIndex = 0 ; elementIndex < count ; elementIndex ++ )
  1681. {
  1682. SysFreeString ( array [ elementIndex ] ) ;
  1683. }
  1684. delete [] array ;
  1685. }
  1686. }
  1687. else if ( variant.vt == VT_NULL )
  1688. {
  1689. value = new SnmpBitStringType ( bitStringValues ) ;
  1690. }
  1691. delete [] bitStringValues ;
  1692. }
  1693. }
  1694. }
  1695. }
  1696. break ;
  1697. case WBEM_INDEX_TYPE_DATETIME:
  1698. {
  1699. if ( type == CIM_STRING )
  1700. {
  1701. if ( variant.vt == VT_BSTR )
  1702. {
  1703. value = new SnmpDateTimeType ( variant.bstrVal ) ;
  1704. }
  1705. else if ( variant.vt == VT_NULL )
  1706. {
  1707. value = new SnmpDateTimeType ;
  1708. }
  1709. }
  1710. }
  1711. break ;
  1712. case WBEM_INDEX_TYPE_SNMPOSIADDRESS:
  1713. {
  1714. if ( type == CIM_STRING )
  1715. {
  1716. if ( variant.vt == VT_BSTR )
  1717. {
  1718. value = new SnmpOSIAddressType ( variant.bstrVal ) ;
  1719. }
  1720. else if ( variant.vt == VT_NULL )
  1721. {
  1722. value = new SnmpOSIAddressType ;
  1723. }
  1724. }
  1725. }
  1726. break ;
  1727. case WBEM_INDEX_TYPE_SNMPUDPADDRESS:
  1728. {
  1729. if ( type == CIM_STRING )
  1730. {
  1731. if ( variant.vt == VT_BSTR )
  1732. {
  1733. value = new SnmpUDPAddressType ( variant.bstrVal ) ;
  1734. }
  1735. else if ( variant.vt == VT_NULL )
  1736. {
  1737. value = new SnmpUDPAddressType ;
  1738. }
  1739. }
  1740. }
  1741. break ;
  1742. case WBEM_INDEX_TYPE_SNMPIPXADDRESS:
  1743. {
  1744. if ( type == CIM_STRING )
  1745. {
  1746. if ( variant.vt == VT_BSTR )
  1747. {
  1748. value = new SnmpIPXAddressType ( variant.bstrVal ) ;
  1749. }
  1750. else if ( variant.vt == VT_NULL )
  1751. {
  1752. value = new SnmpIPXAddressType ;
  1753. }
  1754. }
  1755. }
  1756. break ;
  1757. case WBEM_INDEX_TYPE_ROWSTATUS:
  1758. {
  1759. if ( type == CIM_STRING )
  1760. {
  1761. if ( variant.vt == VT_BSTR )
  1762. {
  1763. value = new SnmpRowStatusType ( variant.bstrVal ) ;
  1764. }
  1765. else if ( variant.vt == VT_NULL )
  1766. {
  1767. value = new SnmpRowStatusType ;
  1768. }
  1769. }
  1770. }
  1771. break ;
  1772. default:
  1773. {
  1774. }
  1775. break ;
  1776. }
  1777. }
  1778. }
  1779. delete [] textualConvention ;
  1780. }
  1781. }
  1782. BOOL status = TRUE ;
  1783. if ( value )
  1784. {
  1785. switch ( check )
  1786. {
  1787. case SetValueRegardlessReturnCheck:
  1788. {
  1789. if ( value->IsValid () )
  1790. {
  1791. delete propertyValue ;
  1792. propertyValue = value ;
  1793. }
  1794. else
  1795. {
  1796. delete propertyValue ;
  1797. propertyValue = value ;
  1798. status = FALSE ;
  1799. }
  1800. }
  1801. break ;
  1802. case SetValueRegardlessDontReturnCheck:
  1803. {
  1804. delete propertyValue ;
  1805. propertyValue = value ;
  1806. }
  1807. break ;
  1808. case DontSetValueReturnCheck:
  1809. {
  1810. if ( value->IsValid () )
  1811. {
  1812. delete value ;
  1813. }
  1814. else
  1815. {
  1816. delete value ;
  1817. status = FALSE ;
  1818. }
  1819. }
  1820. break ;
  1821. case SetValueIfCheckOk:
  1822. {
  1823. if ( value->IsValid () )
  1824. {
  1825. delete propertyValue ;
  1826. propertyValue = value ;
  1827. }
  1828. else
  1829. {
  1830. delete value ;
  1831. status = FALSE ;
  1832. }
  1833. }
  1834. break ;
  1835. }
  1836. }
  1837. else
  1838. {
  1839. status = FALSE ;
  1840. }
  1841. return status ;
  1842. }
  1843. BOOL WbemSnmpProperty :: SetValue ( const wchar_t *valueString , WbemPropertyValueCheck check )
  1844. {
  1845. DebugMacro7( SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine ( __FILE__,__LINE__,L"WbemSnmpProperty :: SetValue ( const wchar_t *valueString )" ) )
  1846. SnmpInstanceType *value = NULL ;
  1847. WbemSnmpQualifier *qualifier = FindQualifier ( WBEM_QUALIFIER_TEXTUAL_CONVENTION ) ;
  1848. if ( qualifier )
  1849. {
  1850. SnmpDisplayStringType *displayString = ( SnmpDisplayStringType * ) qualifier->GetValue () ;
  1851. wchar_t *textualConvention = displayString->GetValue () ;
  1852. if ( textualConvention )
  1853. {
  1854. ULONG qualifierIndex ;
  1855. if ( textualConventionMap.Lookup ( textualConvention , qualifierIndex ) )
  1856. {
  1857. switch ( qualifierIndex )
  1858. {
  1859. case WBEM_INDEX_TYPE_INTEGER:
  1860. case WBEM_INDEX_TYPE_INTEGER32:
  1861. {
  1862. value = new SnmpIntegerType ( valueString , NULL ) ;
  1863. }
  1864. break ;
  1865. case WBEM_INDEX_TYPE_COUNTER:
  1866. case WBEM_INDEX_TYPE_COUNTER32:
  1867. {
  1868. value = new SnmpCounterType ( valueString ) ;
  1869. }
  1870. break ;
  1871. case WBEM_INDEX_TYPE_COUNTER64:
  1872. {
  1873. value = new SnmpCounter64Type ( valueString ) ;
  1874. }
  1875. break ;
  1876. case WBEM_INDEX_TYPE_UNSIGNED32:
  1877. {
  1878. value = new SnmpUInteger32Type ( valueString , NULL ) ;
  1879. }
  1880. break;
  1881. case WBEM_INDEX_TYPE_GAUGE:
  1882. case WBEM_INDEX_TYPE_GAUGE32:
  1883. {
  1884. value = new SnmpGaugeType ( valueString , NULL ) ;
  1885. }
  1886. break ;
  1887. case WBEM_INDEX_TYPE_OCTETSTRING:
  1888. {
  1889. WbemSnmpQualifier *qualifier = FindQualifier ( WBEM_QUALIFIER_FIXED_LENGTH ) ;
  1890. if ( qualifier )
  1891. {
  1892. SnmpInstanceType *typeValue = qualifier->GetValue () ;
  1893. if ( typeid ( *typeValue ) == typeid ( SnmpIntegerType ) )
  1894. {
  1895. SnmpIntegerType *integer = ( SnmpIntegerType * ) typeValue ;
  1896. LONG fixed = integer->GetValue () ;
  1897. value = new SnmpFixedLengthOctetStringType ( fixed , valueString ) ;
  1898. }
  1899. else
  1900. {
  1901. // Problem Here
  1902. }
  1903. }
  1904. else
  1905. {
  1906. WbemSnmpQualifier *qualifier = FindQualifier ( WBEM_QUALIFIER_VARIABLE_LENGTH ) ;
  1907. if ( qualifier )
  1908. {
  1909. SnmpInstanceType *typeValue = qualifier->GetValue () ;
  1910. if ( typeid ( *typeValue ) == typeid ( SnmpDisplayStringType ) )
  1911. {
  1912. SnmpDisplayStringType *string = ( SnmpDisplayStringType * ) typeValue ;
  1913. wchar_t *rangeValues = string->GetStringValue () ;
  1914. value = new SnmpOctetStringType ( valueString , rangeValues ) ;
  1915. delete [] rangeValues ;
  1916. }
  1917. else
  1918. {
  1919. }
  1920. }
  1921. else
  1922. {
  1923. value = new SnmpOctetStringType ( valueString , NULL ) ;
  1924. }
  1925. }
  1926. }
  1927. break ;
  1928. case WBEM_INDEX_TYPE_OBJECTIDENTIFIER:
  1929. {
  1930. value = new SnmpObjectIdentifierType ( valueString ) ;
  1931. }
  1932. break ;
  1933. case WBEM_INDEX_TYPE_NULL:
  1934. {
  1935. value = new SnmpNullType ;
  1936. }
  1937. break ;
  1938. case WBEM_INDEX_TYPE_IPADDRESS:
  1939. {
  1940. value = new SnmpIpAddressType ( valueString ) ;
  1941. }
  1942. break ;
  1943. case WBEM_INDEX_TYPE_TIMETICKS:
  1944. {
  1945. value = new SnmpTimeTicksType ( valueString ) ;
  1946. }
  1947. break ;
  1948. case WBEM_INDEX_TYPE_OPAQUE:
  1949. {
  1950. WbemSnmpQualifier *qualifier = FindQualifier ( WBEM_QUALIFIER_FIXED_LENGTH ) ;
  1951. if ( qualifier )
  1952. {
  1953. SnmpInstanceType *typeValue = qualifier->GetValue () ;
  1954. if ( typeid ( *typeValue ) == typeid ( SnmpIntegerType ) )
  1955. {
  1956. SnmpIntegerType *integer = ( SnmpIntegerType * ) typeValue ;
  1957. LONG fixed = integer->GetValue () ;
  1958. value = new SnmpFixedLengthOpaqueType ( fixed , valueString ) ;
  1959. }
  1960. else
  1961. {
  1962. // Problem Here
  1963. }
  1964. }
  1965. else
  1966. {
  1967. WbemSnmpQualifier *qualifier = FindQualifier ( WBEM_QUALIFIER_VARIABLE_LENGTH ) ;
  1968. if ( qualifier )
  1969. {
  1970. SnmpInstanceType *typeValue = qualifier->GetValue () ;
  1971. if ( typeid ( *typeValue ) == typeid ( SnmpDisplayStringType ) )
  1972. {
  1973. SnmpDisplayStringType *string = ( SnmpDisplayStringType * ) typeValue ;
  1974. wchar_t *rangeValues = string->GetStringValue () ;
  1975. value = new SnmpOpaqueType ( valueString , rangeValues ) ;
  1976. delete [] rangeValues ;
  1977. }
  1978. else
  1979. {
  1980. }
  1981. }
  1982. else
  1983. {
  1984. value = new SnmpOpaqueType ( valueString , NULL ) ;
  1985. }
  1986. }
  1987. }
  1988. break ;
  1989. case WBEM_INDEX_TYPE_NETWORKADDRESS:
  1990. {
  1991. value = new SnmpNetworkAddressType ( valueString ) ;
  1992. }
  1993. break ;
  1994. case WBEM_INDEX_TYPE_DISPLAYSTRING:
  1995. {
  1996. WbemSnmpQualifier *qualifier = FindQualifier ( WBEM_QUALIFIER_FIXED_LENGTH ) ;
  1997. if ( qualifier )
  1998. {
  1999. SnmpInstanceType *typeValue = qualifier->GetValue () ;
  2000. if ( typeid ( *typeValue ) == typeid ( SnmpIntegerType ) )
  2001. {
  2002. SnmpIntegerType *integer = ( SnmpIntegerType * ) typeValue ;
  2003. LONG fixed = integer->GetValue () ;
  2004. value = new SnmpFixedLengthDisplayStringType ( fixed , valueString ) ;
  2005. }
  2006. else
  2007. {
  2008. // Problem Here
  2009. }
  2010. }
  2011. else
  2012. {
  2013. WbemSnmpQualifier *qualifier = FindQualifier ( WBEM_QUALIFIER_VARIABLE_LENGTH ) ;
  2014. if ( qualifier )
  2015. {
  2016. SnmpInstanceType *typeValue = qualifier->GetValue () ;
  2017. if ( typeid ( *typeValue ) == typeid ( SnmpDisplayStringType ) )
  2018. {
  2019. SnmpDisplayStringType *string = ( SnmpDisplayStringType * ) typeValue ;
  2020. wchar_t *rangeValues = string->GetStringValue () ;
  2021. value = new SnmpDisplayStringType ( valueString , rangeValues ) ;
  2022. delete [] rangeValues ;
  2023. }
  2024. else
  2025. {
  2026. }
  2027. }
  2028. else
  2029. {
  2030. value = new SnmpDisplayStringType ( valueString , NULL ) ;
  2031. }
  2032. }
  2033. }
  2034. break ;
  2035. case WBEM_INDEX_TYPE_MACADDRESS:
  2036. {
  2037. value = new SnmpMacAddressType ( valueString ) ;
  2038. }
  2039. break ;
  2040. case WBEM_INDEX_TYPE_PHYSADDRESS:
  2041. {
  2042. WbemSnmpQualifier *qualifier = FindQualifier ( WBEM_QUALIFIER_FIXED_LENGTH ) ;
  2043. if ( qualifier )
  2044. {
  2045. SnmpInstanceType *typeValue = qualifier->GetValue () ;
  2046. if ( typeid ( *typeValue ) == typeid ( SnmpIntegerType ) )
  2047. {
  2048. SnmpIntegerType *integer = ( SnmpIntegerType * ) typeValue ;
  2049. LONG fixed = integer->GetValue () ;
  2050. value = new SnmpFixedLengthPhysAddressType ( fixed , valueString ) ;
  2051. }
  2052. else
  2053. {
  2054. // Problem Here
  2055. }
  2056. }
  2057. else
  2058. {
  2059. WbemSnmpQualifier *qualifier = FindQualifier ( WBEM_QUALIFIER_VARIABLE_LENGTH ) ;
  2060. if ( qualifier )
  2061. {
  2062. SnmpInstanceType *typeValue = qualifier->GetValue () ;
  2063. if ( typeid ( *typeValue ) == typeid ( SnmpDisplayStringType ) )
  2064. {
  2065. SnmpDisplayStringType *string = ( SnmpDisplayStringType * ) typeValue ;
  2066. wchar_t *rangeValues = string->GetStringValue () ;
  2067. value = new SnmpPhysAddressType ( valueString , rangeValues ) ;
  2068. delete [] rangeValues ;
  2069. }
  2070. else
  2071. {
  2072. }
  2073. }
  2074. else
  2075. {
  2076. value = new SnmpPhysAddressType ( valueString , NULL ) ;
  2077. }
  2078. }
  2079. }
  2080. break ;
  2081. case WBEM_INDEX_TYPE_ENUMERATEDINTEGER:
  2082. {
  2083. WbemSnmpQualifier *qualifier = FindQualifier ( WBEM_QUALIFIER_ENUMERATION ) ;
  2084. if ( qualifier )
  2085. {
  2086. SnmpInstanceType *typeValue = qualifier->GetValue () ;
  2087. if ( typeid ( *typeValue ) == typeid ( SnmpDisplayStringType ) )
  2088. {
  2089. SnmpDisplayStringType *string = ( SnmpDisplayStringType * ) typeValue ;
  2090. wchar_t *enumerationValues = string->GetStringValue () ;
  2091. value = new SnmpEnumeratedType ( enumerationValues , valueString ) ;
  2092. delete [] enumerationValues ;
  2093. }
  2094. }
  2095. }
  2096. break ;
  2097. case WBEM_INDEX_TYPE_BITS:
  2098. {
  2099. WbemSnmpQualifier *qualifier = FindQualifier ( WBEM_QUALIFIER_BITS ) ;
  2100. if ( qualifier )
  2101. {
  2102. SnmpInstanceType *typeValue = qualifier->GetValue () ;
  2103. if ( typeid ( *typeValue ) == typeid ( SnmpDisplayStringType ) )
  2104. {
  2105. SnmpDisplayStringType *string = ( SnmpDisplayStringType * ) typeValue ;
  2106. wchar_t *bitStringValues = string->GetStringValue () ;
  2107. value = new SnmpBitStringType ( bitStringValues , NULL , 0 ) ;
  2108. delete [] bitStringValues ;
  2109. }
  2110. }
  2111. }
  2112. break ;
  2113. case WBEM_INDEX_TYPE_DATETIME:
  2114. {
  2115. value = new SnmpDateTimeType ( valueString ) ;
  2116. }
  2117. break ;
  2118. case WBEM_INDEX_TYPE_SNMPOSIADDRESS:
  2119. {
  2120. value = new SnmpOSIAddressType ( valueString ) ;
  2121. }
  2122. break ;
  2123. case WBEM_INDEX_TYPE_SNMPUDPADDRESS:
  2124. {
  2125. value = new SnmpUDPAddressType ( valueString ) ;
  2126. }
  2127. break ;
  2128. case WBEM_INDEX_TYPE_SNMPIPXADDRESS:
  2129. {
  2130. value = new SnmpIPXAddressType ( valueString ) ;
  2131. }
  2132. break ;
  2133. case WBEM_INDEX_TYPE_ROWSTATUS:
  2134. {
  2135. value = new SnmpRowStatusType ( valueString ) ;
  2136. }
  2137. break ;
  2138. default:
  2139. {
  2140. }
  2141. break ;
  2142. }
  2143. }
  2144. }
  2145. delete [] textualConvention ;
  2146. }
  2147. BOOL status = TRUE ;
  2148. if ( value )
  2149. {
  2150. switch ( check )
  2151. {
  2152. case SetValueRegardlessReturnCheck:
  2153. {
  2154. if ( value->IsValid () )
  2155. {
  2156. delete propertyValue ;
  2157. propertyValue = value ;
  2158. }
  2159. else
  2160. {
  2161. delete propertyValue ;
  2162. propertyValue = value ;
  2163. status = FALSE ;
  2164. }
  2165. }
  2166. break ;
  2167. case SetValueRegardlessDontReturnCheck:
  2168. {
  2169. delete propertyValue ;
  2170. propertyValue = value ;
  2171. }
  2172. break ;
  2173. case DontSetValueReturnCheck:
  2174. {
  2175. if ( value->IsValid () )
  2176. {
  2177. delete value ;
  2178. }
  2179. else
  2180. {
  2181. delete value ;
  2182. status = FALSE ;
  2183. }
  2184. }
  2185. break ;
  2186. case SetValueIfCheckOk:
  2187. {
  2188. if ( value->IsValid () )
  2189. {
  2190. delete propertyValue ;
  2191. propertyValue = value ;
  2192. }
  2193. else
  2194. {
  2195. delete value ;
  2196. status = FALSE ;
  2197. }
  2198. }
  2199. break ;
  2200. }
  2201. }
  2202. else
  2203. {
  2204. status = FALSE ;
  2205. }
  2206. return status ;
  2207. }
  2208. BOOL WbemSnmpProperty :: SetValue ( const SnmpInstanceType *value , WbemPropertyValueCheck check )
  2209. {
  2210. DebugMacro7( SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine ( __FILE__,__LINE__,L"WbemSnmpProperty :: SetValue ( const SnmpInstanceType *value )" ) )
  2211. BOOL status = FALSE ;
  2212. BOOL validValue = FALSE ;
  2213. if ( value )
  2214. {
  2215. WbemSnmpQualifier *qualifier = FindQualifier ( WBEM_QUALIFIER_TEXTUAL_CONVENTION ) ;
  2216. if ( qualifier )
  2217. {
  2218. SnmpDisplayStringType *displayString = ( SnmpDisplayStringType * ) qualifier->GetValue () ;
  2219. wchar_t *textualConvention = displayString->GetValue () ;
  2220. if ( textualConvention )
  2221. {
  2222. ULONG qualifierIndex ;
  2223. if ( textualConventionMap.Lookup ( textualConvention , qualifierIndex ) )
  2224. {
  2225. switch ( qualifierIndex )
  2226. {
  2227. case WBEM_INDEX_TYPE_INTEGER:
  2228. case WBEM_INDEX_TYPE_INTEGER32:
  2229. {
  2230. if ( typeid ( *value ) == typeid ( SnmpIntegerType ) )
  2231. {
  2232. validValue = TRUE ;
  2233. status = TRUE ;
  2234. }
  2235. }
  2236. break ;
  2237. case WBEM_INDEX_TYPE_COUNTER:
  2238. case WBEM_INDEX_TYPE_COUNTER32:
  2239. {
  2240. if ( typeid ( *value ) == typeid ( SnmpCounterType ) )
  2241. {
  2242. validValue = TRUE ;
  2243. status = TRUE ;
  2244. }
  2245. }
  2246. break ;
  2247. case WBEM_INDEX_TYPE_COUNTER64:
  2248. {
  2249. if ( typeid ( *value ) == typeid ( SnmpCounter64Type ) )
  2250. {
  2251. validValue = TRUE ;
  2252. status = TRUE ;
  2253. }
  2254. }
  2255. break ;
  2256. case WBEM_INDEX_TYPE_UNSIGNED32:
  2257. {
  2258. if ( typeid ( *value ) == typeid ( SnmpUInteger32Type ) )
  2259. {
  2260. validValue = TRUE ;
  2261. status = TRUE ;
  2262. }
  2263. }
  2264. break;
  2265. case WBEM_INDEX_TYPE_GAUGE:
  2266. case WBEM_INDEX_TYPE_GAUGE32:
  2267. {
  2268. if ( typeid ( *value ) == typeid ( SnmpGaugeType ) )
  2269. {
  2270. validValue = TRUE ;
  2271. status = TRUE ;
  2272. }
  2273. }
  2274. break ;
  2275. case WBEM_INDEX_TYPE_OCTETSTRING:
  2276. {
  2277. WbemSnmpQualifier *qualifier = FindQualifier ( WBEM_QUALIFIER_FIXED_LENGTH ) ;
  2278. if ( qualifier )
  2279. {
  2280. if ( typeid ( *value ) == typeid ( SnmpFixedLengthOctetStringType ) )
  2281. {
  2282. SnmpInstanceType *typeValue = qualifier->GetValue () ;
  2283. if ( typeid ( *typeValue ) == typeid ( SnmpIntegerType ) )
  2284. {
  2285. validValue = TRUE ;
  2286. SnmpIntegerType *integer = ( SnmpIntegerType * ) typeValue ;
  2287. LONG fixed = integer->GetValue () ;
  2288. SnmpFixedLengthOctetStringType *octetString = ( SnmpFixedLengthOctetStringType * ) value ;
  2289. LONG octetStringFixed = octetString->GetValueLength () ;
  2290. if ( fixed == octetStringFixed )
  2291. {
  2292. status = TRUE ;
  2293. }
  2294. }
  2295. else
  2296. {
  2297. // Problem Here
  2298. }
  2299. }
  2300. }
  2301. else
  2302. {
  2303. if ( typeid ( *value ) == typeid ( SnmpOctetStringType ) )
  2304. {
  2305. validValue = TRUE ;
  2306. status = TRUE ;
  2307. }
  2308. }
  2309. }
  2310. break ;
  2311. case WBEM_INDEX_TYPE_OBJECTIDENTIFIER:
  2312. {
  2313. if ( typeid ( *value ) == typeid ( SnmpObjectIdentifierType ) )
  2314. {
  2315. validValue = TRUE ;
  2316. status = TRUE ;
  2317. }
  2318. }
  2319. break ;
  2320. case WBEM_INDEX_TYPE_NULL:
  2321. {
  2322. if ( typeid ( *value ) == typeid ( SnmpNullType ) )
  2323. {
  2324. validValue = TRUE ;
  2325. status = TRUE ;
  2326. }
  2327. }
  2328. break ;
  2329. case WBEM_INDEX_TYPE_IPADDRESS:
  2330. {
  2331. if ( typeid ( *value ) == typeid ( SnmpIpAddressType ) )
  2332. {
  2333. validValue = TRUE ;
  2334. status = TRUE ;
  2335. }
  2336. }
  2337. break ;
  2338. case WBEM_INDEX_TYPE_TIMETICKS:
  2339. {
  2340. if ( typeid ( *value ) == typeid ( SnmpTimeTicksType ) )
  2341. {
  2342. validValue = TRUE ;
  2343. status = TRUE ;
  2344. }
  2345. }
  2346. break ;
  2347. case WBEM_INDEX_TYPE_OPAQUE:
  2348. {
  2349. WbemSnmpQualifier *qualifier = FindQualifier ( WBEM_QUALIFIER_FIXED_LENGTH ) ;
  2350. if ( qualifier )
  2351. {
  2352. if ( typeid ( *value ) == typeid ( SnmpFixedLengthOpaqueType ) )
  2353. {
  2354. validValue = TRUE ;
  2355. SnmpInstanceType *typeValue = qualifier->GetValue () ;
  2356. if ( typeid ( *typeValue ) == typeid ( SnmpIntegerType ) )
  2357. {
  2358. SnmpIntegerType *integer = ( SnmpIntegerType * ) typeValue ;
  2359. LONG fixed = integer->GetValue () ;
  2360. SnmpFixedLengthOpaqueType *opaque = ( SnmpFixedLengthOpaqueType * ) value ;
  2361. LONG opaqueFixed = opaque->GetValueLength () ;
  2362. if ( fixed == opaqueFixed )
  2363. {
  2364. status = TRUE ;
  2365. }
  2366. }
  2367. else
  2368. {
  2369. // Problem Here
  2370. }
  2371. }
  2372. }
  2373. else
  2374. {
  2375. if ( typeid ( *value ) == typeid ( SnmpOpaqueType ) )
  2376. {
  2377. validValue = TRUE ;
  2378. status = TRUE ;
  2379. }
  2380. }
  2381. }
  2382. break ;
  2383. case WBEM_INDEX_TYPE_NETWORKADDRESS:
  2384. {
  2385. if ( typeid ( *value ) == typeid ( SnmpNetworkAddressType ) )
  2386. {
  2387. validValue = TRUE ;
  2388. status = TRUE ;
  2389. }
  2390. }
  2391. break ;
  2392. case WBEM_INDEX_TYPE_DISPLAYSTRING:
  2393. {
  2394. WbemSnmpQualifier *qualifier = FindQualifier ( WBEM_QUALIFIER_FIXED_LENGTH ) ;
  2395. if ( qualifier )
  2396. {
  2397. if ( typeid ( *value ) == typeid ( SnmpFixedLengthDisplayStringType ) )
  2398. {
  2399. validValue = TRUE ;
  2400. SnmpInstanceType *typeValue = qualifier->GetValue () ;
  2401. if ( typeid ( *typeValue ) == typeid ( SnmpIntegerType ) )
  2402. {
  2403. SnmpIntegerType *integer = ( SnmpIntegerType * ) typeValue ;
  2404. LONG fixed = integer->GetValue () ;
  2405. SnmpFixedLengthDisplayStringType *displayString = ( SnmpFixedLengthDisplayStringType * ) value ;
  2406. LONG displayStringFixed = displayString->GetValueLength () ;
  2407. if ( fixed == displayStringFixed )
  2408. {
  2409. status = TRUE ;
  2410. }
  2411. }
  2412. else
  2413. {
  2414. // Problem Here
  2415. }
  2416. }
  2417. }
  2418. else
  2419. {
  2420. if ( typeid ( *value ) == typeid ( SnmpDisplayStringType ) )
  2421. {
  2422. validValue = TRUE ;
  2423. status = TRUE ;
  2424. }
  2425. }
  2426. }
  2427. break ;
  2428. case WBEM_INDEX_TYPE_MACADDRESS:
  2429. {
  2430. if ( typeid ( *value ) == typeid ( SnmpMacAddressType ) )
  2431. {
  2432. validValue = TRUE ;
  2433. status = TRUE ;
  2434. }
  2435. }
  2436. break ;
  2437. case WBEM_INDEX_TYPE_PHYSADDRESS:
  2438. {
  2439. WbemSnmpQualifier *qualifier = FindQualifier ( WBEM_QUALIFIER_FIXED_LENGTH ) ;
  2440. if ( qualifier )
  2441. {
  2442. if ( typeid ( *value ) == typeid ( SnmpFixedLengthPhysAddressType ) )
  2443. {
  2444. validValue = TRUE ;
  2445. SnmpInstanceType *typeValue = qualifier->GetValue () ;
  2446. if ( typeid ( *typeValue ) == typeid ( SnmpIntegerType ) )
  2447. {
  2448. SnmpIntegerType *integer = ( SnmpIntegerType * ) typeValue ;
  2449. LONG fixed = integer->GetValue () ;
  2450. SnmpFixedLengthPhysAddressType *displayString = ( SnmpFixedLengthPhysAddressType * ) value ;
  2451. LONG displayStringFixed = displayString->GetValueLength () ;
  2452. if ( fixed == displayStringFixed )
  2453. {
  2454. status = TRUE ;
  2455. }
  2456. }
  2457. else
  2458. {
  2459. // Problem Here
  2460. }
  2461. }
  2462. }
  2463. else
  2464. {
  2465. if ( typeid ( *value ) == typeid ( SnmpPhysAddressType ) )
  2466. {
  2467. validValue = TRUE ;
  2468. status = TRUE ;
  2469. }
  2470. }
  2471. }
  2472. break ;
  2473. case WBEM_INDEX_TYPE_ENUMERATEDINTEGER:
  2474. {
  2475. if ( typeid ( *value ) == typeid ( SnmpEnumeratedType ) )
  2476. {
  2477. validValue = TRUE ;
  2478. status = TRUE ;
  2479. }
  2480. }
  2481. break ;
  2482. case WBEM_INDEX_TYPE_BITS:
  2483. {
  2484. if ( typeid ( *value ) == typeid ( SnmpBitStringType ) )
  2485. {
  2486. validValue = TRUE ;
  2487. status = TRUE ;
  2488. }
  2489. }
  2490. break ;
  2491. case WBEM_INDEX_TYPE_DATETIME:
  2492. {
  2493. if ( typeid ( *value ) == typeid ( SnmpDateTimeType ) )
  2494. {
  2495. validValue = TRUE ;
  2496. status = TRUE ;
  2497. }
  2498. }
  2499. break ;
  2500. case WBEM_INDEX_TYPE_SNMPOSIADDRESS:
  2501. {
  2502. if ( typeid ( *value ) == typeid ( SnmpOSIAddressType ) )
  2503. {
  2504. validValue = TRUE ;
  2505. status = TRUE ;
  2506. }
  2507. }
  2508. break ;
  2509. case WBEM_INDEX_TYPE_SNMPUDPADDRESS:
  2510. {
  2511. if ( typeid ( *value ) == typeid ( SnmpUDPAddressType ) )
  2512. {
  2513. validValue = TRUE ;
  2514. status = TRUE ;
  2515. }
  2516. }
  2517. break ;
  2518. case WBEM_INDEX_TYPE_SNMPIPXADDRESS:
  2519. {
  2520. if ( typeid ( *value ) == typeid ( SnmpIPXAddressType ) )
  2521. {
  2522. validValue = TRUE ;
  2523. status = TRUE ;
  2524. }
  2525. }
  2526. break ;
  2527. case WBEM_INDEX_TYPE_ROWSTATUS:
  2528. {
  2529. if ( typeid ( *value ) == typeid ( SnmpRowStatusType ) )
  2530. {
  2531. validValue = TRUE ;
  2532. status = TRUE ;
  2533. }
  2534. }
  2535. break ;
  2536. default:
  2537. {
  2538. }
  2539. break ;
  2540. }
  2541. }
  2542. if ( validValue )
  2543. {
  2544. switch ( check )
  2545. {
  2546. case SetValueRegardlessReturnCheck:
  2547. {
  2548. if ( value->IsValid () )
  2549. {
  2550. delete propertyValue ;
  2551. propertyValue = value->Copy () ;
  2552. }
  2553. else
  2554. {
  2555. delete propertyValue ;
  2556. propertyValue = value->Copy () ;
  2557. status = FALSE ;
  2558. }
  2559. }
  2560. break ;
  2561. case SetValueRegardlessDontReturnCheck:
  2562. {
  2563. delete propertyValue ;
  2564. propertyValue = value->Copy () ;
  2565. }
  2566. break ;
  2567. case DontSetValueReturnCheck:
  2568. {
  2569. if ( value->IsValid () )
  2570. {
  2571. }
  2572. else
  2573. {
  2574. status = FALSE ;
  2575. }
  2576. }
  2577. break ;
  2578. case SetValueIfCheckOk:
  2579. {
  2580. if ( value->IsValid () )
  2581. {
  2582. delete propertyValue ;
  2583. propertyValue = value->Copy () ;
  2584. }
  2585. else
  2586. {
  2587. status = FALSE ;
  2588. }
  2589. }
  2590. break ;
  2591. }
  2592. }
  2593. else
  2594. {
  2595. status = FALSE ;
  2596. }
  2597. }
  2598. delete [] textualConvention ;
  2599. }
  2600. }
  2601. return status ;
  2602. }
  2603. BOOL WbemSnmpProperty :: SetValue ( const SnmpValue *valueArg , WbemPropertyValueCheck check )
  2604. {
  2605. DebugMacro7( SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine ( __FILE__,__LINE__,L"WbemSnmpProperty :: SetValue ( const SnmpValue *valueArg )" ) )
  2606. BOOL status = FALSE ;
  2607. SnmpInstanceType *value = NULL ;
  2608. WbemSnmpQualifier *qualifier = FindQualifier ( WBEM_QUALIFIER_TEXTUAL_CONVENTION ) ;
  2609. if ( qualifier )
  2610. {
  2611. SnmpDisplayStringType *displayString = ( SnmpDisplayStringType * ) qualifier->GetValue () ;
  2612. wchar_t *textualConvention = displayString->GetValue () ;
  2613. if ( textualConvention )
  2614. {
  2615. ULONG qualifierIndex ;
  2616. if ( textualConventionMap.Lookup ( textualConvention , qualifierIndex ) )
  2617. {
  2618. switch ( qualifierIndex )
  2619. {
  2620. case WBEM_INDEX_TYPE_INTEGER:
  2621. case WBEM_INDEX_TYPE_INTEGER32:
  2622. {
  2623. if ( ! valueArg )
  2624. {
  2625. value = new SnmpIntegerType ;
  2626. status = TRUE ;
  2627. }
  2628. else if ( typeid ( *valueArg ) == typeid ( SnmpInteger ) )
  2629. {
  2630. SnmpInteger *integer = ( SnmpInteger * ) valueArg ;
  2631. value = new SnmpIntegerType ( *integer , NULL ) ;
  2632. status = TRUE ;
  2633. }
  2634. }
  2635. break ;
  2636. case WBEM_INDEX_TYPE_COUNTER:
  2637. case WBEM_INDEX_TYPE_COUNTER32:
  2638. {
  2639. if ( ! valueArg )
  2640. {
  2641. value = new SnmpCounterType ;
  2642. status = TRUE ;
  2643. }
  2644. else if ( typeid ( *valueArg ) == typeid ( SnmpCounter ) )
  2645. {
  2646. SnmpCounter *counter = ( SnmpCounter * ) valueArg ;
  2647. value = new SnmpCounterType ( *counter ) ;
  2648. status = TRUE ;
  2649. }
  2650. }
  2651. break ;
  2652. case WBEM_INDEX_TYPE_COUNTER64:
  2653. {
  2654. if ( ! valueArg )
  2655. {
  2656. value = new SnmpCounter64Type ;
  2657. }
  2658. else
  2659. {
  2660. SnmpCounter64 *counter = ( SnmpCounter64 * ) valueArg ;
  2661. value = new SnmpCounter64Type ( *counter ) ;
  2662. }
  2663. status = TRUE ;
  2664. }
  2665. break ;
  2666. case WBEM_INDEX_TYPE_UNSIGNED32:
  2667. {
  2668. if ( ! valueArg )
  2669. {
  2670. value = new SnmpUInteger32Type ;
  2671. status = TRUE ;
  2672. }
  2673. else if ( typeid ( *valueArg ) == typeid ( SnmpUInteger32 ) )
  2674. {
  2675. SnmpUInteger32 *ui_integer32 = ( SnmpUInteger32 * ) valueArg ;
  2676. value = new SnmpUInteger32Type ( *ui_integer32 , NULL ) ;
  2677. status = TRUE ;
  2678. }
  2679. }
  2680. break;
  2681. case WBEM_INDEX_TYPE_GAUGE:
  2682. case WBEM_INDEX_TYPE_GAUGE32:
  2683. {
  2684. if ( ! valueArg )
  2685. {
  2686. value = new SnmpGaugeType ;
  2687. status = TRUE ;
  2688. }
  2689. else if ( typeid ( *valueArg ) == typeid ( SnmpGauge ) )
  2690. {
  2691. SnmpGauge *gauge = ( SnmpGauge * ) valueArg ;
  2692. value = new SnmpGaugeType ( *gauge , NULL ) ;
  2693. status = TRUE ;
  2694. }
  2695. }
  2696. break ;
  2697. case WBEM_INDEX_TYPE_OCTETSTRING:
  2698. {
  2699. WbemSnmpQualifier *qualifier = FindQualifier ( WBEM_QUALIFIER_FIXED_LENGTH ) ;
  2700. if ( qualifier )
  2701. {
  2702. if ( ! valueArg )
  2703. {
  2704. SnmpInstanceType *typeValue = qualifier->GetValue () ;
  2705. if ( typeid ( *typeValue ) == typeid ( SnmpIntegerType ) )
  2706. {
  2707. SnmpIntegerType *integer = ( SnmpIntegerType * ) typeValue ;
  2708. LONG fixed = integer->GetValue () ;
  2709. value = new SnmpFixedLengthOctetStringType ( fixed ) ;
  2710. status = TRUE ;
  2711. }
  2712. else
  2713. {
  2714. // Problem Here
  2715. }
  2716. }
  2717. else if ( typeid ( *valueArg ) == typeid ( SnmpOctetString ) )
  2718. {
  2719. SnmpInstanceType *typeValue = qualifier->GetValue () ;
  2720. if ( typeid ( *typeValue ) == typeid ( SnmpIntegerType ) )
  2721. {
  2722. SnmpIntegerType *integer = ( SnmpIntegerType * ) typeValue ;
  2723. LONG fixed = integer->GetValue () ;
  2724. SnmpOctetString *octetString = ( SnmpOctetString * ) valueArg ;
  2725. value = new SnmpFixedLengthOctetStringType ( fixed , *octetString ) ;
  2726. status = TRUE ;
  2727. }
  2728. else
  2729. {
  2730. // Problem Here
  2731. }
  2732. }
  2733. }
  2734. else
  2735. {
  2736. WbemSnmpQualifier *qualifier = FindQualifier ( WBEM_QUALIFIER_VARIABLE_LENGTH ) ;
  2737. if ( qualifier )
  2738. {
  2739. if ( ! valueArg )
  2740. {
  2741. SnmpInstanceType *typeValue = qualifier->GetValue () ;
  2742. if ( typeid ( *typeValue ) == typeid ( SnmpDisplayStringType ) )
  2743. {
  2744. SnmpDisplayStringType *string = ( SnmpDisplayStringType * ) typeValue ;
  2745. wchar_t *rangeValues = string->GetStringValue () ;
  2746. value = new SnmpOctetStringType ( rangeValues ) ;
  2747. delete [] rangeValues ;
  2748. status = TRUE ;
  2749. }
  2750. else
  2751. {
  2752. }
  2753. }
  2754. else if ( typeid ( *valueArg ) == typeid ( SnmpOctetString ) )
  2755. {
  2756. SnmpInstanceType *typeValue = qualifier->GetValue () ;
  2757. if ( typeid ( *typeValue ) == typeid ( SnmpDisplayStringType ) )
  2758. {
  2759. SnmpOctetString *octetString = ( SnmpOctetString * ) valueArg ;
  2760. SnmpDisplayStringType *string = ( SnmpDisplayStringType * ) typeValue ;
  2761. wchar_t *rangeValues = string->GetStringValue () ;
  2762. value = new SnmpOctetStringType ( *octetString , rangeValues ) ;
  2763. delete [] rangeValues ;
  2764. status = TRUE ;
  2765. }
  2766. else
  2767. {
  2768. }
  2769. }
  2770. }
  2771. else
  2772. {
  2773. if ( ! valueArg )
  2774. {
  2775. value = new SnmpOctetStringType ;
  2776. status = TRUE ;
  2777. }
  2778. else if ( typeid ( *valueArg ) == typeid ( SnmpOctetString ) )
  2779. {
  2780. SnmpOctetString *octetString = ( SnmpOctetString * ) valueArg ;
  2781. value = new SnmpOctetStringType ( *octetString , NULL ) ;
  2782. status = TRUE ;
  2783. }
  2784. }
  2785. }
  2786. }
  2787. break ;
  2788. case WBEM_INDEX_TYPE_OBJECTIDENTIFIER:
  2789. {
  2790. if ( ! valueArg )
  2791. {
  2792. value = new SnmpObjectIdentifierType ;
  2793. status = TRUE ;
  2794. }
  2795. else if ( typeid ( *valueArg ) == typeid ( SnmpObjectIdentifier ) )
  2796. {
  2797. SnmpObjectIdentifier *objectIdentifier = ( SnmpObjectIdentifier * ) valueArg ;
  2798. value = new SnmpObjectIdentifierType ( *objectIdentifier ) ;
  2799. status = TRUE ;
  2800. }
  2801. }
  2802. break ;
  2803. case WBEM_INDEX_TYPE_NULL:
  2804. {
  2805. if ( ! valueArg )
  2806. {
  2807. value = new SnmpNullType ;
  2808. status = TRUE ;
  2809. }
  2810. else if ( typeid ( *valueArg ) == typeid ( SnmpNull ) )
  2811. {
  2812. value = new SnmpNullType ;
  2813. status = TRUE ;
  2814. }
  2815. }
  2816. break ;
  2817. case WBEM_INDEX_TYPE_IPADDRESS:
  2818. {
  2819. if ( ! valueArg )
  2820. {
  2821. value = new SnmpIpAddressType ;
  2822. status = TRUE ;
  2823. }
  2824. else if ( typeid ( *valueArg ) == typeid ( SnmpIpAddress ) )
  2825. {
  2826. SnmpIpAddress *ipAddress = ( SnmpIpAddress * ) valueArg ;
  2827. value = new SnmpIpAddressType ( *ipAddress ) ;
  2828. status = TRUE ;
  2829. }
  2830. }
  2831. break ;
  2832. case WBEM_INDEX_TYPE_TIMETICKS:
  2833. {
  2834. if ( ! valueArg )
  2835. {
  2836. value = new SnmpTimeTicksType ;
  2837. status = TRUE ;
  2838. }
  2839. else if ( typeid ( *valueArg ) == typeid ( SnmpTimeTicks ) )
  2840. {
  2841. SnmpTimeTicks *timeTicks = ( SnmpTimeTicks * ) valueArg ;
  2842. value = new SnmpTimeTicksType ( *timeTicks ) ;
  2843. status = TRUE ;
  2844. }
  2845. }
  2846. break ;
  2847. case WBEM_INDEX_TYPE_OPAQUE:
  2848. {
  2849. WbemSnmpQualifier *qualifier = FindQualifier ( WBEM_QUALIFIER_FIXED_LENGTH ) ;
  2850. if ( qualifier )
  2851. {
  2852. if ( ! valueArg )
  2853. {
  2854. SnmpInstanceType *typeValue = qualifier->GetValue () ;
  2855. if ( typeid ( *typeValue ) == typeid ( SnmpIntegerType ) )
  2856. {
  2857. SnmpIntegerType *integer = ( SnmpIntegerType * ) typeValue ;
  2858. LONG fixed = integer->GetValue () ;
  2859. value = new SnmpFixedLengthOpaqueType ( fixed ) ;
  2860. status = TRUE ;
  2861. }
  2862. else
  2863. {
  2864. // Problem Here
  2865. }
  2866. }
  2867. else if ( typeid ( *valueArg ) == typeid ( SnmpOpaque ) )
  2868. {
  2869. SnmpInstanceType *typeValue = qualifier->GetValue () ;
  2870. if ( typeid ( *typeValue ) == typeid ( SnmpIntegerType ) )
  2871. {
  2872. SnmpIntegerType *integer = ( SnmpIntegerType * ) typeValue ;
  2873. LONG fixed = integer->GetValue () ;
  2874. SnmpOpaque *opaque = ( SnmpOpaque * ) valueArg ;
  2875. value = new SnmpFixedLengthOpaqueType ( fixed , *opaque ) ;
  2876. status = TRUE ;
  2877. }
  2878. else
  2879. {
  2880. // Problem Here
  2881. }
  2882. }
  2883. }
  2884. else
  2885. {
  2886. WbemSnmpQualifier *qualifier = FindQualifier ( WBEM_QUALIFIER_VARIABLE_LENGTH ) ;
  2887. if ( qualifier )
  2888. {
  2889. if ( ! valueArg )
  2890. {
  2891. SnmpInstanceType *typeValue = qualifier->GetValue () ;
  2892. if ( typeid ( *typeValue ) == typeid ( SnmpDisplayStringType ) )
  2893. {
  2894. SnmpDisplayStringType *string = ( SnmpDisplayStringType * ) typeValue ;
  2895. wchar_t *rangeValues = string->GetStringValue () ;
  2896. value = new SnmpOpaqueType ( rangeValues ) ;
  2897. delete [] rangeValues ;
  2898. status = TRUE ;
  2899. }
  2900. else
  2901. {
  2902. }
  2903. }
  2904. else if ( typeid ( *valueArg ) == typeid ( SnmpOctetString ) )
  2905. {
  2906. SnmpInstanceType *typeValue = qualifier->GetValue () ;
  2907. if ( typeid ( *typeValue ) == typeid ( SnmpDisplayStringType ) )
  2908. {
  2909. SnmpOpaque *opaque = ( SnmpOpaque * ) valueArg ;
  2910. SnmpDisplayStringType *string = ( SnmpDisplayStringType * ) typeValue ;
  2911. wchar_t *rangeValues = string->GetStringValue () ;
  2912. value = new SnmpOpaqueType ( *opaque , rangeValues ) ;
  2913. delete [] rangeValues ;
  2914. status = TRUE ;
  2915. }
  2916. else
  2917. {
  2918. }
  2919. }
  2920. }
  2921. else
  2922. {
  2923. if ( ! valueArg )
  2924. {
  2925. value = new SnmpOpaqueType ;
  2926. status = TRUE ;
  2927. }
  2928. else if ( typeid ( *valueArg ) == typeid ( SnmpOpaque ) )
  2929. {
  2930. SnmpOpaque *opaque = ( SnmpOpaque * ) valueArg ;
  2931. value = new SnmpOpaqueType ( *opaque , NULL ) ;
  2932. status = TRUE ;
  2933. }
  2934. }
  2935. }
  2936. }
  2937. break ;
  2938. case WBEM_INDEX_TYPE_NETWORKADDRESS:
  2939. {
  2940. if ( ! valueArg )
  2941. {
  2942. value = new SnmpNetworkAddressType ;
  2943. status = TRUE ;
  2944. }
  2945. else if ( typeid ( *valueArg ) == typeid ( SnmpIpAddress ) )
  2946. {
  2947. SnmpIpAddress *ipAddress = ( SnmpIpAddress * ) valueArg ;
  2948. value = new SnmpNetworkAddressType ( *ipAddress ) ;
  2949. status = TRUE ;
  2950. }
  2951. }
  2952. break ;
  2953. case WBEM_INDEX_TYPE_DISPLAYSTRING:
  2954. {
  2955. WbemSnmpQualifier *qualifier = FindQualifier ( WBEM_QUALIFIER_FIXED_LENGTH ) ;
  2956. if ( qualifier )
  2957. {
  2958. if ( ! valueArg )
  2959. {
  2960. SnmpInstanceType *typeValue = qualifier->GetValue () ;
  2961. if ( typeid ( *typeValue ) == typeid ( SnmpIntegerType ) )
  2962. {
  2963. SnmpIntegerType *integer = ( SnmpIntegerType * ) typeValue ;
  2964. LONG fixed = integer->GetValue () ;
  2965. value = new SnmpFixedLengthDisplayStringType ( fixed ) ;
  2966. status = TRUE ;
  2967. }
  2968. else
  2969. {
  2970. // Problem Here
  2971. }
  2972. }
  2973. else if ( typeid ( *valueArg ) == typeid ( SnmpOctetString ) )
  2974. {
  2975. SnmpInstanceType *typeValue = qualifier->GetValue () ;
  2976. if ( typeid ( *typeValue ) == typeid ( SnmpIntegerType ) )
  2977. {
  2978. SnmpIntegerType *integer = ( SnmpIntegerType * ) typeValue ;
  2979. LONG fixed = integer->GetValue () ;
  2980. SnmpOctetString *octetString = ( SnmpOctetString * ) valueArg ;
  2981. value = new SnmpFixedLengthDisplayStringType ( fixed , *octetString ) ;
  2982. status = TRUE ;
  2983. }
  2984. else
  2985. {
  2986. // Problem Here
  2987. }
  2988. }
  2989. }
  2990. else
  2991. {
  2992. WbemSnmpQualifier *qualifier = FindQualifier ( WBEM_QUALIFIER_VARIABLE_LENGTH ) ;
  2993. if ( qualifier )
  2994. {
  2995. if ( ! valueArg )
  2996. {
  2997. SnmpInstanceType *typeValue = qualifier->GetValue () ;
  2998. if ( typeid ( *typeValue ) == typeid ( SnmpDisplayStringType ) )
  2999. {
  3000. SnmpDisplayStringType *string = ( SnmpDisplayStringType * ) typeValue ;
  3001. wchar_t *rangeValues = string->GetStringValue () ;
  3002. value = new SnmpDisplayStringType ( rangeValues ) ;
  3003. delete [] rangeValues ;
  3004. status = TRUE ;
  3005. }
  3006. else
  3007. {
  3008. }
  3009. }
  3010. else if ( typeid ( *valueArg ) == typeid ( SnmpOctetString ) )
  3011. {
  3012. SnmpInstanceType *typeValue = qualifier->GetValue () ;
  3013. if ( typeid ( *typeValue ) == typeid ( SnmpDisplayStringType ) )
  3014. {
  3015. SnmpOctetString *octetString = ( SnmpOctetString * ) valueArg ;
  3016. SnmpDisplayStringType *string = ( SnmpDisplayStringType * ) typeValue ;
  3017. wchar_t *rangeValues = string->GetStringValue () ;
  3018. value = new SnmpDisplayStringType ( *octetString , rangeValues ) ;
  3019. delete [] rangeValues ;
  3020. status = TRUE ;
  3021. }
  3022. else
  3023. {
  3024. }
  3025. }
  3026. }
  3027. else
  3028. {
  3029. if ( ! valueArg )
  3030. {
  3031. value = new SnmpDisplayStringType ;
  3032. status = TRUE ;
  3033. }
  3034. else if ( typeid ( *valueArg ) == typeid ( SnmpOctetString ) )
  3035. {
  3036. SnmpOctetString *octetString = ( SnmpOctetString * ) valueArg ;
  3037. value = new SnmpDisplayStringType ( *octetString , NULL ) ;
  3038. status = TRUE ;
  3039. }
  3040. }
  3041. }
  3042. }
  3043. break ;
  3044. case WBEM_INDEX_TYPE_MACADDRESS:
  3045. {
  3046. if ( ! valueArg )
  3047. {
  3048. value = new SnmpMacAddressType ;
  3049. status = TRUE ;
  3050. }
  3051. else if ( typeid ( *valueArg ) == typeid ( SnmpOctetString ) )
  3052. {
  3053. SnmpOctetString *octetString = ( SnmpOctetString * ) valueArg ;
  3054. value = new SnmpMacAddressType ( *octetString ) ;
  3055. status = TRUE ;
  3056. }
  3057. }
  3058. break ;
  3059. case WBEM_INDEX_TYPE_PHYSADDRESS:
  3060. {
  3061. WbemSnmpQualifier *qualifier = FindQualifier ( WBEM_QUALIFIER_FIXED_LENGTH ) ;
  3062. if ( qualifier )
  3063. {
  3064. if ( ! valueArg )
  3065. {
  3066. SnmpInstanceType *typeValue = qualifier->GetValue () ;
  3067. if ( typeid ( *typeValue ) == typeid ( SnmpIntegerType ) )
  3068. {
  3069. SnmpIntegerType *integer = ( SnmpIntegerType * ) typeValue ;
  3070. LONG fixed = integer->GetValue () ;
  3071. value = new SnmpFixedLengthPhysAddressType ( fixed ) ;
  3072. status = TRUE ;
  3073. }
  3074. else
  3075. {
  3076. // Problem Here
  3077. }
  3078. }
  3079. else if ( typeid ( *valueArg ) == typeid ( SnmpOctetString ) )
  3080. {
  3081. SnmpInstanceType *typeValue = qualifier->GetValue () ;
  3082. if ( typeid ( *typeValue ) == typeid ( SnmpIntegerType ) )
  3083. {
  3084. SnmpIntegerType *integer = ( SnmpIntegerType * ) typeValue ;
  3085. LONG fixed = integer->GetValue () ;
  3086. SnmpOctetString *octetString = ( SnmpOctetString * ) valueArg ;
  3087. value = new SnmpFixedLengthPhysAddressType ( fixed , *octetString ) ;
  3088. status = TRUE ;
  3089. }
  3090. else
  3091. {
  3092. // Problem Here
  3093. }
  3094. }
  3095. }
  3096. else
  3097. {
  3098. WbemSnmpQualifier *qualifier = FindQualifier ( WBEM_QUALIFIER_VARIABLE_LENGTH ) ;
  3099. if ( qualifier )
  3100. {
  3101. if ( ! valueArg )
  3102. {
  3103. SnmpInstanceType *typeValue = qualifier->GetValue () ;
  3104. if ( typeid ( *typeValue ) == typeid ( SnmpDisplayStringType ) )
  3105. {
  3106. SnmpDisplayStringType *string = ( SnmpDisplayStringType * ) typeValue ;
  3107. wchar_t *rangeValues = string->GetStringValue () ;
  3108. value = new SnmpPhysAddressType ( rangeValues ) ;
  3109. delete [] rangeValues ;
  3110. status = TRUE ;
  3111. }
  3112. else
  3113. {
  3114. }
  3115. }
  3116. else if ( typeid ( *valueArg ) == typeid ( SnmpOctetString ) )
  3117. {
  3118. SnmpInstanceType *typeValue = qualifier->GetValue () ;
  3119. if ( typeid ( *typeValue ) == typeid ( SnmpDisplayStringType ) )
  3120. {
  3121. SnmpOctetString *octetString = ( SnmpOctetString * ) valueArg ;
  3122. SnmpDisplayStringType *string = ( SnmpDisplayStringType * ) typeValue ;
  3123. wchar_t *rangeValues = string->GetStringValue () ;
  3124. value = new SnmpPhysAddressType ( *octetString , rangeValues ) ;
  3125. delete [] rangeValues ;
  3126. status = TRUE ;
  3127. }
  3128. else
  3129. {
  3130. }
  3131. }
  3132. }
  3133. else
  3134. {
  3135. if ( ! valueArg )
  3136. {
  3137. value = new SnmpPhysAddressType ;
  3138. status = TRUE ;
  3139. }
  3140. else if ( typeid ( *valueArg ) == typeid ( SnmpOctetString ) )
  3141. {
  3142. SnmpOctetString *octetString = ( SnmpOctetString * ) valueArg ;
  3143. value = new SnmpPhysAddressType ( *octetString , NULL ) ;
  3144. status = TRUE ;
  3145. }
  3146. }
  3147. }
  3148. }
  3149. break ;
  3150. case WBEM_INDEX_TYPE_ENUMERATEDINTEGER:
  3151. {
  3152. if ( ! valueArg )
  3153. {
  3154. WbemSnmpQualifier *qualifier = FindQualifier ( WBEM_QUALIFIER_ENUMERATION ) ;
  3155. if ( qualifier )
  3156. {
  3157. SnmpInstanceType *typeValue = qualifier->GetValue () ;
  3158. if ( typeid ( *typeValue ) == typeid ( SnmpDisplayStringType ) )
  3159. {
  3160. SnmpDisplayStringType *string = ( SnmpDisplayStringType * ) typeValue ;
  3161. wchar_t *enumerationValues = string->GetStringValue () ;
  3162. value = new SnmpEnumeratedType ( enumerationValues ) ;
  3163. delete [] enumerationValues ;
  3164. status = TRUE ;
  3165. }
  3166. }
  3167. }
  3168. else if ( typeid ( *valueArg ) == typeid ( SnmpInteger ) )
  3169. {
  3170. SnmpInteger *integer = ( SnmpInteger * ) valueArg ;
  3171. WbemSnmpQualifier *qualifier = FindQualifier ( WBEM_QUALIFIER_ENUMERATION ) ;
  3172. if ( qualifier )
  3173. {
  3174. SnmpInstanceType *typeValue = qualifier->GetValue () ;
  3175. if ( typeid ( *typeValue ) == typeid ( SnmpDisplayStringType ) )
  3176. {
  3177. SnmpDisplayStringType *string = ( SnmpDisplayStringType * ) typeValue ;
  3178. wchar_t *enumerationValues = string->GetStringValue () ;
  3179. value = new SnmpEnumeratedType ( enumerationValues , integer->GetValue () ) ;
  3180. delete [] enumerationValues ;
  3181. status = TRUE ;
  3182. }
  3183. }
  3184. }
  3185. }
  3186. break ;
  3187. case WBEM_INDEX_TYPE_BITS:
  3188. {
  3189. if ( ! valueArg )
  3190. {
  3191. WbemSnmpQualifier *qualifier = FindQualifier ( WBEM_QUALIFIER_BITS ) ;
  3192. if ( qualifier )
  3193. {
  3194. SnmpInstanceType *typeValue = qualifier->GetValue () ;
  3195. if ( typeid ( *typeValue ) == typeid ( SnmpDisplayStringType ) )
  3196. {
  3197. SnmpDisplayStringType *string = ( SnmpDisplayStringType * ) typeValue ;
  3198. wchar_t *bitStringValues = string->GetStringValue () ;
  3199. value = new SnmpBitStringType ( bitStringValues ) ;
  3200. status = TRUE ;
  3201. delete [] bitStringValues ;
  3202. }
  3203. }
  3204. }
  3205. else if ( typeid ( *valueArg ) == typeid ( SnmpOctetString ) )
  3206. {
  3207. WbemSnmpQualifier *qualifier = FindQualifier ( WBEM_QUALIFIER_BITS ) ;
  3208. if ( qualifier )
  3209. {
  3210. SnmpInstanceType *typeValue = qualifier->GetValue () ;
  3211. if ( typeid ( *typeValue ) == typeid ( SnmpDisplayStringType ) )
  3212. {
  3213. SnmpDisplayStringType *string = ( SnmpDisplayStringType * ) typeValue ;
  3214. wchar_t *bitStringValues = string->GetStringValue () ;
  3215. SnmpOctetString *octetString = ( SnmpOctetString * ) valueArg ;
  3216. value = new SnmpBitStringType ( bitStringValues , *octetString ) ;
  3217. status = TRUE ;
  3218. delete [] bitStringValues ;
  3219. }
  3220. }
  3221. }
  3222. }
  3223. break ;
  3224. case WBEM_INDEX_TYPE_DATETIME:
  3225. {
  3226. if ( ! valueArg )
  3227. {
  3228. value = new SnmpDateTimeType ;
  3229. status = TRUE ;
  3230. }
  3231. else if ( typeid ( *valueArg ) == typeid ( SnmpOctetString ) )
  3232. {
  3233. SnmpOctetString *octetString = ( SnmpOctetString * ) valueArg ;
  3234. value = new SnmpDateTimeType ( *octetString ) ;
  3235. status = TRUE ;
  3236. }
  3237. }
  3238. break ;
  3239. case WBEM_INDEX_TYPE_SNMPOSIADDRESS:
  3240. {
  3241. if ( ! valueArg )
  3242. {
  3243. value = new SnmpOSIAddressType ;
  3244. status = TRUE ;
  3245. }
  3246. else if ( typeid ( *valueArg ) == typeid ( SnmpOctetString ) )
  3247. {
  3248. SnmpOctetString *octetString = ( SnmpOctetString * ) valueArg ;
  3249. value = new SnmpOSIAddressType ( *octetString ) ;
  3250. status = TRUE ;
  3251. }
  3252. }
  3253. break ;
  3254. case WBEM_INDEX_TYPE_SNMPUDPADDRESS:
  3255. {
  3256. if ( ! valueArg )
  3257. {
  3258. value = new SnmpUDPAddressType ;
  3259. status = TRUE ;
  3260. }
  3261. else if ( typeid ( *valueArg ) == typeid ( SnmpOctetString ) )
  3262. {
  3263. SnmpOctetString *octetString = ( SnmpOctetString * ) valueArg ;
  3264. value = new SnmpUDPAddressType ( *octetString ) ;
  3265. status = TRUE ;
  3266. }
  3267. }
  3268. break ;
  3269. case WBEM_INDEX_TYPE_SNMPIPXADDRESS:
  3270. {
  3271. if ( ! valueArg )
  3272. {
  3273. value = new SnmpIPXAddressType ;
  3274. status = TRUE ;
  3275. }
  3276. else if ( typeid ( *valueArg ) == typeid ( SnmpOctetString ) )
  3277. {
  3278. SnmpOctetString *octetString = ( SnmpOctetString * ) valueArg ;
  3279. value = new SnmpIPXAddressType ( *octetString ) ;
  3280. status = TRUE ;
  3281. }
  3282. }
  3283. break ;
  3284. case WBEM_INDEX_TYPE_ROWSTATUS:
  3285. {
  3286. if ( ! valueArg )
  3287. {
  3288. value = new SnmpRowStatusType ;
  3289. status = TRUE ;
  3290. }
  3291. else if ( typeid ( *valueArg ) == typeid ( SnmpInteger ) )
  3292. {
  3293. SnmpInteger *integer = ( SnmpInteger * ) valueArg ;
  3294. value = new SnmpRowStatusType ( *integer ) ;
  3295. status = TRUE ;
  3296. }
  3297. }
  3298. break ;
  3299. default:
  3300. {
  3301. }
  3302. break ;
  3303. }
  3304. }
  3305. delete [] textualConvention ;
  3306. }
  3307. }
  3308. if ( value )
  3309. {
  3310. switch ( check )
  3311. {
  3312. case SetValueRegardlessReturnCheck:
  3313. {
  3314. if ( value->IsValid () )
  3315. {
  3316. delete propertyValue ;
  3317. propertyValue = value ;
  3318. }
  3319. else
  3320. {
  3321. delete propertyValue ;
  3322. propertyValue = value ;
  3323. status = FALSE ;
  3324. }
  3325. }
  3326. break ;
  3327. case SetValueRegardlessDontReturnCheck:
  3328. {
  3329. delete propertyValue ;
  3330. propertyValue = value ;
  3331. }
  3332. break ;
  3333. case DontSetValueReturnCheck:
  3334. {
  3335. if ( value->IsValid () )
  3336. {
  3337. delete value ;
  3338. }
  3339. else
  3340. {
  3341. delete value ;
  3342. status = FALSE ;
  3343. }
  3344. }
  3345. break ;
  3346. case SetValueIfCheckOk:
  3347. {
  3348. if ( value->IsValid () )
  3349. {
  3350. delete propertyValue ;
  3351. propertyValue = value ;
  3352. }
  3353. else
  3354. {
  3355. delete value ;
  3356. status = FALSE ;
  3357. }
  3358. }
  3359. break ;
  3360. }
  3361. }
  3362. else
  3363. {
  3364. status = FALSE ;
  3365. }
  3366. return status ;
  3367. }
  3368. HRESULT SetStringProp ( IWbemClassObject *a_Object , BSTR propertyName , VARIANT &t_Variant )
  3369. {
  3370. HRESULT t_Result = WBEM_E_INVALID_PARAMETER;
  3371. if ( a_Object )
  3372. {
  3373. t_Result = a_Object->Put ( propertyName , 0 , &t_Variant , 0 ) ;
  3374. }
  3375. return t_Result ;
  3376. }
  3377. HRESULT SetProp ( IWbemClassObject *a_Object , BSTR propertyName , VARIANT &t_Variant )
  3378. {
  3379. HRESULT t_Result = WBEM_E_INVALID_PARAMETER;
  3380. if ( a_Object )
  3381. {
  3382. t_Result = a_Object->Put ( propertyName , 0 , &t_Variant , 0 ) ;
  3383. }
  3384. return t_Result ;
  3385. }
  3386. #if 0
  3387. BOOL WbemSnmpProperty :: SetDWORD ( BOOL a_Status , IWbemObjectAccess *a_Object , DWORD a_Value , WbemPropertyValueCheck check )
  3388. {
  3389. BOOL status = a_Status ;
  3390. switch ( check )
  3391. {
  3392. case SetValueRegardlessReturnCheck:
  3393. {
  3394. if ( status )
  3395. {
  3396. HRESULT result = a_Object->WriteDWORD (
  3397. GetHandle (),
  3398. a_Value
  3399. );
  3400. status = SUCCEEDED (result) ;
  3401. }
  3402. }
  3403. break ;
  3404. case SetValueRegardlessDontReturnCheck:
  3405. {
  3406. HRESULT result = a_Object->WriteDWORD (
  3407. GetHandle (),
  3408. a_Value
  3409. );
  3410. status = TRUE ;
  3411. }
  3412. break ;
  3413. case DontSetValueReturnCheck:
  3414. {
  3415. }
  3416. break ;
  3417. case SetValueIfCheckOk:
  3418. {
  3419. if ( status )
  3420. {
  3421. HRESULT result = a_Object->WriteDWORD (
  3422. GetHandle (),
  3423. a_Value
  3424. );
  3425. status = SUCCEEDED (result) ;
  3426. }
  3427. }
  3428. break ;
  3429. }
  3430. return status ;
  3431. }
  3432. BOOL WbemSnmpProperty :: SetNULL ( BOOL a_Status , IWbemObjectAccess *a_Object , WbemPropertyValueCheck check )
  3433. {
  3434. BOOL status = a_Status ;
  3435. switch ( check )
  3436. {
  3437. case SetValueRegardlessReturnCheck:
  3438. {
  3439. if ( status )
  3440. {
  3441. HRESULT result = a_Object->WritePropertyValue (
  3442. GetHandle () ,
  3443. 0 ,
  3444. NULL
  3445. );
  3446. status = SUCCEEDED (result) ;
  3447. }
  3448. }
  3449. break ;
  3450. case SetValueRegardlessDontReturnCheck:
  3451. {
  3452. HRESULT result = a_Object->WritePropertyValue (
  3453. GetHandle () ,
  3454. 0 ,
  3455. NULL
  3456. );
  3457. status = TRUE ;
  3458. }
  3459. break ;
  3460. case DontSetValueReturnCheck:
  3461. {
  3462. }
  3463. break ;
  3464. case SetValueIfCheckOk:
  3465. {
  3466. if ( status )
  3467. {
  3468. HRESULT result = a_Object->WritePropertyValue (
  3469. GetHandle () ,
  3470. 0 ,
  3471. NULL
  3472. );
  3473. status = SUCCEEDED (result) ;
  3474. }
  3475. }
  3476. break ;
  3477. }
  3478. return status ;
  3479. }
  3480. BOOL WbemSnmpProperty :: SetSTRING ( BOOL a_Status , IWbemObjectAccess *a_Object , wchar_t *t_Value , ULONG t_ValueLength , WbemPropertyValueCheck check )
  3481. {
  3482. BOOL status = a_Status ;
  3483. switch ( check )
  3484. {
  3485. case SetValueRegardlessReturnCheck:
  3486. {
  3487. if ( status )
  3488. {
  3489. HRESULT result = a_Object->WritePropertyValue (
  3490. GetHandle () ,
  3491. t_Value ,
  3492. t_ValueLength
  3493. );
  3494. status = SUCCEEDED (result) ;
  3495. }
  3496. }
  3497. break ;
  3498. case SetValueRegardlessDontReturnCheck:
  3499. {
  3500. HRESULT result = a_Object->WritePropertyValue (
  3501. GetHandle () ,
  3502. t_Value ,
  3503. t_ValueLength
  3504. );
  3505. status = TRUE ;
  3506. }
  3507. break ;
  3508. case DontSetValueReturnCheck:
  3509. {
  3510. }
  3511. break ;
  3512. case SetValueIfCheckOk:
  3513. {
  3514. if ( status )
  3515. {
  3516. HRESULT result = a_Object->WritePropertyValue (
  3517. GetHandle () ,
  3518. t_Value ,
  3519. t_ValueLength
  3520. );
  3521. status = SUCCEEDED (result) ;
  3522. }
  3523. }
  3524. break ;
  3525. }
  3526. return status ;
  3527. }
  3528. BOOL WbemSnmpProperty :: SetSTRINGARRAY ( BOOL a_Status , IWbemObjectAccess *a_Object , wchar_t **t_Value , ULONG t_ValueLength , WbemPropertyValueCheck check )
  3529. {
  3530. BOOL status = a_Status ;
  3531. switch ( check )
  3532. {
  3533. case SetValueRegardlessReturnCheck:
  3534. {
  3535. if ( status )
  3536. {
  3537. HRESULT result = a_Object->WritePropertyValue (
  3538. GetHandle () ,
  3539. t_Value ,
  3540. t_ValueLength
  3541. );
  3542. status = SUCCEEDED (result) ;
  3543. }
  3544. }
  3545. break ;
  3546. case SetValueRegardlessDontReturnCheck:
  3547. {
  3548. HRESULT result = a_Object->WritePropertyValue (
  3549. GetHandle () ,
  3550. t_Value ,
  3551. t_ValueLength
  3552. );
  3553. status = TRUE ;
  3554. }
  3555. break ;
  3556. case DontSetValueReturnCheck:
  3557. {
  3558. }
  3559. break ;
  3560. case SetValueIfCheckOk:
  3561. {
  3562. if ( status )
  3563. {
  3564. HRESULT result = a_Object->WritePropertyValue (
  3565. GetHandle () ,
  3566. t_Value ,
  3567. t_ValueLength
  3568. );
  3569. status = SUCCEEDED (result) ;
  3570. }
  3571. }
  3572. break ;
  3573. }
  3574. return status ;
  3575. }
  3576. BOOL WbemSnmpProperty :: SetValue ( IWbemObjectAccess *a_Object , const SnmpValue *valueArg , WbemPropertyValueCheck check )
  3577. {
  3578. DebugMacro7( SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine ( __FILE__,__LINE__,L"WbemSnmpProperty :: SetValue ( const SnmpValue *valueArg )" ) )
  3579. BOOL status = FALSE ;
  3580. SnmpInstanceType *value = NULL ;
  3581. switch ( GetTextualConvention () )
  3582. {
  3583. case WBEM_INDEX_TYPE_INTEGER:
  3584. case WBEM_INDEX_TYPE_INTEGER32:
  3585. {
  3586. if ( ! valueArg )
  3587. {
  3588. status = SetNull ( status , a_Object , check ) ;
  3589. }
  3590. else if ( typeid ( *valueArg ) == typeid ( SnmpInteger ) )
  3591. {
  3592. SnmpInteger *integer = ( SnmpInteger * ) valueArg ;
  3593. status = SetDWORD ( status , a_Object , (DWORD)integer->GetValue () , check ) ;
  3594. }
  3595. }
  3596. break ;
  3597. case WBEM_INDEX_TYPE_COUNTER:
  3598. case WBEM_INDEX_TYPE_COUNTER32:
  3599. {
  3600. if ( ! valueArg )
  3601. {
  3602. status = SetNull ( status , a_Object , check ) ;
  3603. }
  3604. else if ( typeid ( *valueArg ) == typeid ( SnmpCounter ) )
  3605. {
  3606. SnmpCounter *counter = ( SnmpCounter * ) valueArg ;
  3607. status = SetDWORD ( status , a_Object , (DWORD)counter->GetValue () , check ) ;
  3608. }
  3609. }
  3610. break ;
  3611. case WBEM_INDEX_TYPE_COUNTER64:
  3612. {
  3613. if ( ! valueArg )
  3614. {
  3615. status = SetNull ( status , a_Object , check ) ;
  3616. }
  3617. else
  3618. {
  3619. SnmpCounter64 *counter = ( SnmpCounter64 * ) valueArg ;
  3620. SnmpCounter64Type t_Counter ( *counter ) ;
  3621. wchar_t *value = t_Counter.GetStringValue () ;
  3622. status = SetSTRING ( status , a_Object , value , wcslen ( value ) , check ) ;
  3623. delete [] value ;
  3624. status = TRUE ;
  3625. }
  3626. }
  3627. break ;
  3628. case WBEM_INDEX_TYPE_UNSIGNED32:
  3629. {
  3630. if ( ! valueArg )
  3631. {
  3632. status = SetNull ( status , a_Object , check ) ;
  3633. }
  3634. else if ( typeid ( *valueArg ) == typeid ( SnmpUInteger32 ) )
  3635. {
  3636. SnmpUInteger32 *ui_integer32 = ( SnmpUInteger32 * ) valueArg ;
  3637. status = SetDWORD ( status , a_Object , (DWORD)ui_integer32->GetValue () , check ) ;
  3638. }
  3639. }
  3640. break;
  3641. case WBEM_INDEX_TYPE_GAUGE:
  3642. case WBEM_INDEX_TYPE_GAUGE32:
  3643. {
  3644. if ( ! valueArg )
  3645. {
  3646. status = SetNull ( status , a_Object , check ) ;
  3647. }
  3648. else if ( typeid ( *valueArg ) == typeid ( SnmpGauge ) )
  3649. {
  3650. SnmpGauge *gauge = ( SnmpGauge * ) valueArg ;
  3651. status = SetDWORD ( status , a_Object , (DWORD)gauge->GetValue () , check ) ;
  3652. }
  3653. }
  3654. break ;
  3655. case WBEM_INDEX_TYPE_OCTETSTRING:
  3656. {
  3657. if ( ! valueArg )
  3658. {
  3659. status = SetNull ( status , a_Object , check ) ;
  3660. }
  3661. else
  3662. {
  3663. if ( typeid ( *valueArg ) == typeid ( SnmpOctetString ) )
  3664. {
  3665. WbemSnmpQualifier *qualifier = FindQualifier ( WBEM_QUALIFIER_FIXED_LENGTH ) ;
  3666. if ( qualifier )
  3667. {
  3668. SnmpInstanceType *typeValue = qualifier->GetValue () ;
  3669. if ( typeid ( *typeValue ) == typeid ( SnmpIntegerType ) )
  3670. {
  3671. SnmpIntegerType *integer = ( SnmpIntegerType * ) typeValue ;
  3672. LONG fixed = integer->GetValue () ;
  3673. SnmpOctetString *octetString = ( SnmpOctetString * ) valueArg ;
  3674. SnmpFixedLengthOctetStringType octetStringType ( fixed , *octetString ) ;
  3675. wchar_t *value = octetStringType.GetStringValue () ;
  3676. status = SetSTRING ( status , a_Object , value , wcslen ( value ) , check ) ;
  3677. delete [] value ;
  3678. }
  3679. }
  3680. else
  3681. {
  3682. WbemSnmpQualifier *qualifier = FindQualifier ( WBEM_QUALIFIER_VARIABLE_LENGTH ) ;
  3683. if ( qualifier )
  3684. {
  3685. SnmpInstanceType *typeValue = qualifier->GetValue () ;
  3686. if ( typeid ( *typeValue ) == typeid ( SnmpDisplayStringType ) )
  3687. {
  3688. SnmpOctetString *octetString = ( SnmpOctetString * ) valueArg ;
  3689. SnmpDisplayStringType *string = ( SnmpDisplayStringType * ) typeValue ;
  3690. wchar_t *rangeValues = string->GetStringValue () ;
  3691. SnmpOctetStringType octetStringType ( *octetString , rangeValues ) ;
  3692. delete [] rangeValues ;
  3693. wchar_t *value = octetStringType.GetStringValue () ;
  3694. status = SetSTRING ( status , a_Object , value , wcslen ( value ) , check ) ;
  3695. delete [] value ;
  3696. }
  3697. else
  3698. {
  3699. }
  3700. }
  3701. else
  3702. {
  3703. SnmpOctetString *octetString = ( SnmpOctetString * ) valueArg ;
  3704. SnmpOctetStringType octetStringType ( *octetString , NULL ) ;
  3705. wchar_t *value = octetStringType.GetStringValue () ;
  3706. status = SetSTRING ( status , a_Object , value , wcslen ( value ) , check ) ;
  3707. delete [] value ;
  3708. }
  3709. }
  3710. }
  3711. else
  3712. {
  3713. }
  3714. }
  3715. }
  3716. break ;
  3717. case WBEM_INDEX_TYPE_OBJECTIDENTIFIER:
  3718. {
  3719. if ( ! valueArg )
  3720. {
  3721. status = SetNull ( status , a_Object , check ) ;
  3722. }
  3723. else if ( typeid ( *valueArg ) == typeid ( SnmpObjectIdentifier ) )
  3724. {
  3725. SnmpObjectIdentifier *objectIdentifier = ( SnmpObjectIdentifier * ) valueArg ;
  3726. SnmpObjectIdentifierType objectIdentifierType ( *objectIdentifier ) ;
  3727. wchar_t *value = objectIdentifierType.GetStringValue () ;
  3728. status = SetSTRING ( status , a_Object , value , wcslen ( value ) , check ) ;
  3729. delete [] value ;
  3730. }
  3731. }
  3732. break ;
  3733. case WBEM_INDEX_TYPE_NULL:
  3734. {
  3735. status = SetNull ( status , a_Object , check ) ;
  3736. }
  3737. break ;
  3738. case WBEM_INDEX_TYPE_IPADDRESS:
  3739. {
  3740. if ( ! valueArg )
  3741. {
  3742. status = SetNull ( status , a_Object , check ) ;
  3743. }
  3744. else if ( typeid ( *valueArg ) == typeid ( SnmpIpAddress ) )
  3745. {
  3746. SnmpIpAddress *ipAddress = ( SnmpIpAddress * ) valueArg ;
  3747. SnmpIpAddressType ipAddressType ( *ipAddress ) ;
  3748. wchar_t *value = ipAddressType.GetStringValue () ;
  3749. status = SetSTRING ( status , a_Object , value , wcslen ( value ) , check ) ;
  3750. delete [] value ;
  3751. }
  3752. }
  3753. break ;
  3754. case WBEM_INDEX_TYPE_TIMETICKS:
  3755. {
  3756. if ( ! valueArg )
  3757. {
  3758. status = SetNull ( status , a_Object , check ) ;
  3759. }
  3760. else if ( typeid ( *valueArg ) == typeid ( SnmpTimeTicks ) )
  3761. {
  3762. SnmpTimeTicks *timeTicks = ( SnmpTimeTicks * ) valueArg ;
  3763. status = SetDWORD ( status , a_Object , (DWORD)timeTicks->GetValue () , check ) ;
  3764. }
  3765. }
  3766. break ;
  3767. case WBEM_INDEX_TYPE_OPAQUE:
  3768. {
  3769. if ( ! valueArg )
  3770. {
  3771. status = SetNull ( status , a_Object , check ) ;
  3772. }
  3773. else
  3774. {
  3775. if ( typeid ( *valueArg ) == typeid ( SnmpOpaque ) )
  3776. {
  3777. WbemSnmpQualifier *qualifier = FindQualifier ( WBEM_QUALIFIER_FIXED_LENGTH ) ;
  3778. if ( qualifier )
  3779. {
  3780. SnmpInstanceType *typeValue = qualifier->GetValue () ;
  3781. if ( typeid ( *typeValue ) == typeid ( SnmpIntegerType ) )
  3782. {
  3783. SnmpIntegerType *integer = ( SnmpIntegerType * ) typeValue ;
  3784. LONG fixed = integer->GetValue () ;
  3785. SnmpOpaque *opaque = ( SnmpOpaque * ) valueArg ;
  3786. SnmpFixedLengthOpaqueType opaqueType ( fixed , *opaque ) ;
  3787. wchar_t *value = opaqueType.GetStringValue () ;
  3788. status = SetSTRING ( status , a_Object , value , wcslen ( value ) , check ) ;
  3789. delete [] value ;
  3790. }
  3791. }
  3792. else
  3793. {
  3794. WbemSnmpQualifier *qualifier = FindQualifier ( WBEM_QUALIFIER_VARIABLE_LENGTH ) ;
  3795. if ( qualifier )
  3796. {
  3797. SnmpInstanceType *typeValue = qualifier->GetValue () ;
  3798. if ( typeid ( *typeValue ) == typeid ( SnmpDisplayStringType ) )
  3799. {
  3800. SnmpOpaque *opaque = ( SnmpOpaque * ) valueArg ;
  3801. SnmpDisplayStringType *string = ( SnmpDisplayStringType * ) typeValue ;
  3802. wchar_t *rangeValues = string->GetStringValue () ;
  3803. SnmpOpaqueType opaqueType ( *opaque , rangeValues ) ;
  3804. delete [] rangeValues ;
  3805. wchar_t *value = opaqueType.GetStringValue () ;
  3806. status = SetSTRING ( status , a_Object , value , wcslen ( value ) , check ) ;
  3807. delete [] value ;
  3808. }
  3809. else
  3810. {
  3811. }
  3812. }
  3813. else
  3814. {
  3815. SnmpOpaque *opaque = ( SnmpOpaque * ) valueArg ;
  3816. SnmpOpaqueType opaqueType ( *opaque , NULL ) ;
  3817. wchar_t *value = opaqueType.GetStringValue () ;
  3818. status = SetSTRING ( status , a_Object , value , wcslen ( value ) , check ) ;
  3819. delete [] value ;
  3820. }
  3821. }
  3822. }
  3823. }
  3824. }
  3825. break ;
  3826. case WBEM_INDEX_TYPE_NETWORKADDRESS:
  3827. {
  3828. if ( ! valueArg )
  3829. {
  3830. status = SetNull ( status , a_Object , check ) ;
  3831. }
  3832. else if ( typeid ( *valueArg ) == typeid ( SnmpIpAddress ) )
  3833. {
  3834. SnmpIpAddress *ipAddress = ( SnmpIpAddress * ) valueArg ;
  3835. SnmpNetworkAddressType ipAddressType ( *ipAddress ) ;
  3836. wchar_t *value = ipAddressType.GetStringValue () ;
  3837. status = SetSTRING ( status , a_Object , value , wcslen ( value ) , check ) ;
  3838. delete [] value ;
  3839. }
  3840. }
  3841. break ;
  3842. case WBEM_INDEX_TYPE_DISPLAYSTRING:
  3843. {
  3844. if ( ! valueArg )
  3845. {
  3846. status = SetNull ( status , a_Object , check ) ;
  3847. }
  3848. else
  3849. {
  3850. if ( typeid ( *valueArg ) == typeid ( SnmpOctetString ) )
  3851. {
  3852. WbemSnmpQualifier *qualifier = FindQualifier ( WBEM_QUALIFIER_FIXED_LENGTH ) ;
  3853. if ( qualifier )
  3854. {
  3855. SnmpInstanceType *typeValue = qualifier->GetValue () ;
  3856. if ( typeid ( *typeValue ) == typeid ( SnmpIntegerType ) )
  3857. {
  3858. SnmpIntegerType *integer = ( SnmpIntegerType * ) typeValue ;
  3859. LONG fixed = integer->GetValue () ;
  3860. SnmpOctetString *octetString = ( SnmpOctetString * ) valueArg ;
  3861. SnmpFixedLengthDisplayStringType octetStringType ( fixed , *octetString ) ;
  3862. wchar_t *value = octetStringType.GetStringValue () ;
  3863. status = SetSTRING ( status , a_Object , value , wcslen ( value ) , check ) ;
  3864. delete [] value ;
  3865. }
  3866. else
  3867. {
  3868. // Problem Here
  3869. }
  3870. }
  3871. else
  3872. {
  3873. WbemSnmpQualifier *qualifier = FindQualifier ( WBEM_QUALIFIER_VARIABLE_LENGTH ) ;
  3874. if ( qualifier )
  3875. {
  3876. SnmpInstanceType *typeValue = qualifier->GetValue () ;
  3877. if ( typeid ( *typeValue ) == typeid ( SnmpDisplayStringType ) )
  3878. {
  3879. SnmpOctetString *octetString = ( SnmpOctetString * ) valueArg ;
  3880. SnmpDisplayStringType *string = ( SnmpDisplayStringType * ) typeValue ;
  3881. wchar_t *rangeValues = string->GetStringValue () ;
  3882. SnmpDisplayStringType octetStringType ( *octetString , rangeValues ) ;
  3883. delete [] rangeValues ;
  3884. wchar_t *value = octetStringType.GetStringValue () ;
  3885. status = SetSTRING ( status , a_Object , value , wcslen ( value ) , check ) ;
  3886. delete [] value ;
  3887. }
  3888. else
  3889. {
  3890. }
  3891. }
  3892. else
  3893. {
  3894. SnmpOctetString *octetString = ( SnmpOctetString * ) valueArg ;
  3895. SnmpDisplayStringType octetStringType ( *octetString , NULL ) ;
  3896. wchar_t *value = octetStringType.GetStringValue () ;
  3897. status = SetSTRING ( status , a_Object , value , wcslen ( value ) , check ) ;
  3898. delete [] value ;
  3899. }
  3900. }
  3901. }
  3902. }
  3903. }
  3904. break ;
  3905. case WBEM_INDEX_TYPE_MACADDRESS:
  3906. {
  3907. if ( ! valueArg )
  3908. {
  3909. status = SetNull ( status , a_Object , check ) ;
  3910. }
  3911. else if ( typeid ( *valueArg ) == typeid ( SnmpOctetString ) )
  3912. {
  3913. SnmpOctetString *octetString = ( SnmpOctetString * ) valueArg ;
  3914. SnmpMacAddressType octetStringType ( *octetString ) ;
  3915. wchar_t *value = octetStringType.GetStringValue () ;
  3916. status = SetSTRING ( status , a_Object , value , wcslen ( value ) , check ) ;
  3917. delete [] value ;
  3918. }
  3919. }
  3920. break ;
  3921. case WBEM_INDEX_TYPE_PHYSADDRESS:
  3922. {
  3923. if ( ! valueArg )
  3924. {
  3925. status = SetNull ( status , a_Object , check ) ;
  3926. }
  3927. else
  3928. {
  3929. if ( typeid ( *valueArg ) == typeid ( SnmpOctetString ) )
  3930. {
  3931. WbemSnmpQualifier *qualifier = FindQualifier ( WBEM_QUALIFIER_FIXED_LENGTH ) ;
  3932. if ( qualifier )
  3933. {
  3934. SnmpInstanceType *typeValue = qualifier->GetValue () ;
  3935. if ( typeid ( *typeValue ) == typeid ( SnmpIntegerType ) )
  3936. {
  3937. SnmpIntegerType *integer = ( SnmpIntegerType * ) typeValue ;
  3938. LONG fixed = integer->GetValue () ;
  3939. SnmpOctetString *octetString = ( SnmpOctetString * ) valueArg ;
  3940. SnmpFixedLengthPhysAddressType octetStringType ( fixed , *octetString ) ;
  3941. wchar_t *value = octetStringType.GetStringValue () ;
  3942. status = SetSTRING ( status , a_Object , value , wcslen ( value ) , check ) ;
  3943. delete [] value ;
  3944. }
  3945. else
  3946. {
  3947. // Problem Here
  3948. }
  3949. }
  3950. else
  3951. {
  3952. WbemSnmpQualifier *qualifier = FindQualifier ( WBEM_QUALIFIER_VARIABLE_LENGTH ) ;
  3953. if ( qualifier )
  3954. {
  3955. SnmpInstanceType *typeValue = qualifier->GetValue () ;
  3956. if ( typeid ( *typeValue ) == typeid ( SnmpDisplayStringType ) )
  3957. {
  3958. SnmpOctetString *octetString = ( SnmpOctetString * ) valueArg ;
  3959. SnmpDisplayStringType *string = ( SnmpDisplayStringType * ) typeValue ;
  3960. wchar_t *rangeValues = string->GetStringValue () ;
  3961. SnmpPhysAddressType octetStringType ( *octetString , rangeValues ) ;
  3962. delete [] rangeValues ;
  3963. wchar_t *value = octetStringType.GetStringValue () ;
  3964. status = SetSTRING ( status , a_Object , value , wcslen ( value ) , check ) ;
  3965. delete [] value ;
  3966. status = TRUE ;
  3967. }
  3968. else
  3969. {
  3970. }
  3971. }
  3972. else
  3973. {
  3974. SnmpOctetString *octetString = ( SnmpOctetString * ) valueArg ;
  3975. SnmpPhysAddressType octetStringType ( *octetString , NULL ) ;
  3976. wchar_t *value = octetStringType.GetStringValue () ;
  3977. status = SetSTRING ( status , a_Object , value , wcslen ( value ) , check ) ;
  3978. delete [] value ;
  3979. }
  3980. }
  3981. }
  3982. }
  3983. }
  3984. break ;
  3985. case WBEM_INDEX_TYPE_ENUMERATEDINTEGER:
  3986. {
  3987. if ( ! valueArg )
  3988. {
  3989. status = SetNull ( status , a_Object , check ) ;
  3990. }
  3991. else if ( typeid ( *valueArg ) == typeid ( SnmpInteger ) )
  3992. {
  3993. SnmpInteger *integer = ( SnmpInteger * ) valueArg ;
  3994. WbemSnmpQualifier *qualifier = FindQualifier ( WBEM_QUALIFIER_ENUMERATION ) ;
  3995. if ( qualifier )
  3996. {
  3997. SnmpInstanceType *typeValue = qualifier->GetValue () ;
  3998. if ( typeid ( *typeValue ) == typeid ( SnmpDisplayStringType ) )
  3999. {
  4000. SnmpDisplayStringType *string = ( SnmpDisplayStringType * ) typeValue ;
  4001. wchar_t *enumerationValues = string->GetStringValue () ;
  4002. SnmpEnumeratedType integerType ( enumerationValues , integer->GetValue () ) ;
  4003. delete [] enumerationValues ;
  4004. wchar_t *value = integerType.GetStringValue () ;
  4005. status = SetSTRING ( status , a_Object , value , wcslen ( value ) , check ) ;
  4006. delete [] value ;
  4007. }
  4008. }
  4009. }
  4010. }
  4011. break ;
  4012. case WBEM_INDEX_TYPE_BITS:
  4013. {
  4014. if ( ! valueArg )
  4015. {
  4016. status = SetNull ( status , a_Object , check ) ;
  4017. }
  4018. else if ( typeid ( *valueArg ) == typeid ( SnmpOctetString ) )
  4019. {
  4020. WbemSnmpQualifier *qualifier = FindQualifier ( WBEM_QUALIFIER_BITS ) ;
  4021. if ( qualifier )
  4022. {
  4023. SnmpInstanceType *typeValue = qualifier->GetValue () ;
  4024. if ( typeid ( *typeValue ) == typeid ( SnmpDisplayStringType ) )
  4025. {
  4026. SnmpDisplayStringType *string = ( SnmpDisplayStringType * ) typeValue ;
  4027. wchar_t *bitStringValues = string->GetStringValue () ;
  4028. SnmpOctetString *octetString = ( SnmpOctetString * ) valueArg ;
  4029. SnmpBitStringType octetStringType ( bitStringValues , *octetString ) ;
  4030. delete [] bitStringValues ;
  4031. wchar_t **array ;
  4032. LONG count = octetStringType.GetValue ( array ) ;
  4033. SAFEARRAY *safeArray ;
  4034. SAFEARRAYBOUND safeArrayBounds [ 1 ] ;
  4035. safeArrayBounds[0].lLbound = 0 ;
  4036. safeArrayBounds[0].cElements = count ;
  4037. safeArray = SafeArrayCreate ( VT_BSTR , 1 , safeArrayBounds ) ;
  4038. for ( LONG index = 0 ; index < count ; index ++ )
  4039. {
  4040. BSTR element = SysAllocString ( array [ index ] ) ;
  4041. SafeArrayPutElement ( safeArray , & index , element ) ;
  4042. SysFreeString ( element ) ;
  4043. delete [] ( array [ index ] ) ;
  4044. }
  4045. delete [] array ;
  4046. t_Variant.vt = t_VarType = VT_ARRAY | VT_BSTR ;
  4047. t_Variant.parray = safeArray ;
  4048. status = TRUE ;
  4049. }
  4050. }
  4051. }
  4052. }
  4053. break ;
  4054. case WBEM_INDEX_TYPE_DATETIME:
  4055. {
  4056. if ( ! valueArg )
  4057. {
  4058. status = SetNull ( status , a_Object , check ) ;
  4059. }
  4060. else if ( typeid ( *valueArg ) == typeid ( SnmpOctetString ) )
  4061. {
  4062. SnmpOctetString *octetString = ( SnmpOctetString * ) valueArg ;
  4063. SnmpDateTimeType octetStringType ( *octetString ) ;
  4064. wchar_t *value = octetStringType.GetStringValue () ;
  4065. status = SetSTRING ( status , a_Object , value , wcslen ( value ) , check ) ;
  4066. delete [] value ;
  4067. }
  4068. }
  4069. break ;
  4070. case WBEM_INDEX_TYPE_SNMPOSIADDRESS:
  4071. {
  4072. if ( ! valueArg )
  4073. {
  4074. status = SetNull ( status , a_Object , check ) ;
  4075. }
  4076. else if ( typeid ( *valueArg ) == typeid ( SnmpOctetString ) )
  4077. {
  4078. SnmpOctetString *octetString = ( SnmpOctetString * ) valueArg ;
  4079. SnmpOSIAddressType octetStringType ( *octetString ) ;
  4080. wchar_t *value = octetStringType.GetStringValue () ;
  4081. status = SetSTRING ( status , a_Object , value , wcslen ( value ) , check ) ;
  4082. delete [] value ;
  4083. }
  4084. }
  4085. break ;
  4086. case WBEM_INDEX_TYPE_SNMPUDPADDRESS:
  4087. {
  4088. if ( ! valueArg )
  4089. {
  4090. status = SetNull ( status , a_Object , check ) ;
  4091. }
  4092. else if ( typeid ( *valueArg ) == typeid ( SnmpOctetString ) )
  4093. {
  4094. SnmpOctetString *octetString = ( SnmpOctetString * ) valueArg ;
  4095. SnmpUDPAddressType octetStringType ( *octetString ) ;
  4096. wchar_t *value = octetStringType.GetStringValue () ;
  4097. status = SetSTRING ( status , a_Object , value , wcslen ( value ) , check ) ;
  4098. delete [] value ;
  4099. }
  4100. }
  4101. break ;
  4102. case WBEM_INDEX_TYPE_SNMPIPXADDRESS:
  4103. {
  4104. if ( ! valueArg )
  4105. {
  4106. status = SetNull ( status , a_Object , check ) ;
  4107. }
  4108. else if ( typeid ( *valueArg ) == typeid ( SnmpOctetString ) )
  4109. {
  4110. SnmpOctetString *octetString = ( SnmpOctetString * ) valueArg ;
  4111. SnmpIPXAddressType octetStringType ( *octetString ) ;
  4112. wchar_t *value = octetStringType.GetStringValue () ;
  4113. status = SetSTRING ( status , a_Object , value , wcslen ( value ) , check ) ;
  4114. delete [] value ;
  4115. }
  4116. }
  4117. break ;
  4118. case WBEM_INDEX_TYPE_ROWSTATUS:
  4119. {
  4120. if ( ! valueArg )
  4121. {
  4122. status = SetNull ( status , a_Object , check ) ;
  4123. }
  4124. else if ( typeid ( *valueArg ) == typeid ( SnmpInteger ) )
  4125. {
  4126. SnmpInteger *integer = ( SnmpInteger * ) valueArg ;
  4127. SnmpRowStatusType integerType ( *integer ) ;
  4128. wchar_t *value = integerType.GetStringValue () ;
  4129. status = SetSTRING ( status , a_Object , value , wcslen ( value ) , check ) ;
  4130. delete [] value ;
  4131. }
  4132. }
  4133. break ;
  4134. default:
  4135. {
  4136. }
  4137. break ;
  4138. }
  4139. return status ;
  4140. }
  4141. #endif
  4142. BOOL WbemSnmpProperty :: SetValue ( IWbemClassObject *a_Object , const SnmpValue *valueArg , WbemPropertyValueCheck check )
  4143. {
  4144. DebugMacro7( SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine ( __FILE__,__LINE__,L"WbemSnmpProperty :: SetValue ( const SnmpValue *valueArg )" ) )
  4145. VARIANT t_Variant ;
  4146. VariantInit ( & t_Variant ) ;
  4147. VARTYPE t_VarType = VT_NULL ;
  4148. BOOL status = FALSE ;
  4149. SnmpInstanceType *value = NULL ;
  4150. if ( a_Object )
  4151. {
  4152. switch ( GetTextualConvention () )
  4153. {
  4154. case WBEM_INDEX_TYPE_INTEGER:
  4155. case WBEM_INDEX_TYPE_INTEGER32:
  4156. {
  4157. if ( ! valueArg )
  4158. {
  4159. t_Variant.vt = VT_NULL ;
  4160. t_VarType = VT_I4 ;
  4161. status = TRUE ;
  4162. }
  4163. else if ( typeid ( *valueArg ) == typeid ( SnmpInteger ) )
  4164. {
  4165. WbemSnmpQualifier *qualifier = FindQualifier ( WBEM_QUALIFIER_VARIABLE_VALUE ) ;
  4166. if ( qualifier )
  4167. {
  4168. SnmpInstanceType *typeValue = qualifier->GetValue () ;
  4169. if ( typeid ( *typeValue ) == typeid ( SnmpDisplayStringType ) )
  4170. {
  4171. SnmpDisplayStringType *string = ( SnmpDisplayStringType * ) typeValue ;
  4172. wchar_t *rangeValues = string->GetStringValue () ;
  4173. SnmpInteger *integer = ( SnmpInteger * ) valueArg ;
  4174. SnmpIntegerType integerType ( *integer , rangeValues ) ;
  4175. delete [] rangeValues ;
  4176. t_Variant.vt = t_VarType = VT_I4 ;
  4177. t_Variant.lVal = integer->GetValue () ;
  4178. status = integerType.SnmpInstanceType :: IsValid () ;
  4179. }
  4180. }
  4181. else
  4182. {
  4183. SnmpInteger *integer = ( SnmpInteger * ) valueArg ;
  4184. t_Variant.vt = t_VarType = VT_I4 ;
  4185. t_Variant.lVal = integer->GetValue () ;
  4186. status = TRUE ;
  4187. }
  4188. }
  4189. }
  4190. break ;
  4191. case WBEM_INDEX_TYPE_COUNTER:
  4192. case WBEM_INDEX_TYPE_COUNTER32:
  4193. {
  4194. if ( ! valueArg )
  4195. {
  4196. t_Variant.vt = VT_NULL ;
  4197. t_VarType = VT_I4 ;
  4198. status = TRUE ;
  4199. }
  4200. else if ( typeid ( *valueArg ) == typeid ( SnmpCounter ) )
  4201. {
  4202. SnmpCounter *counter = ( SnmpCounter * ) valueArg ;
  4203. t_Variant.vt = VT_I4 ;
  4204. t_VarType = VT_UI4 ;
  4205. t_Variant.lVal = counter->GetValue () ;
  4206. status = TRUE ;
  4207. }
  4208. }
  4209. break ;
  4210. case WBEM_INDEX_TYPE_COUNTER64:
  4211. {
  4212. if ( ! valueArg )
  4213. {
  4214. t_Variant.vt = VT_NULL ;
  4215. t_VarType = VT_BSTR ;
  4216. status = TRUE ;
  4217. }
  4218. else
  4219. {
  4220. SnmpCounter64 *counter = ( SnmpCounter64 * ) valueArg ;
  4221. SnmpCounter64Type t_Counter ( *counter ) ;
  4222. t_Variant.vt = t_VarType = VT_BSTR ;
  4223. wchar_t *value = t_Counter.GetStringValue () ;
  4224. t_Variant.bstrVal = SysAllocString ( value ) ;
  4225. delete [] value ;
  4226. status = TRUE ;
  4227. }
  4228. }
  4229. break ;
  4230. case WBEM_INDEX_TYPE_UNSIGNED32:
  4231. {
  4232. if ( ! valueArg )
  4233. {
  4234. t_Variant.vt = VT_NULL ;
  4235. t_VarType = VT_UI4 ;
  4236. status = TRUE ;
  4237. }
  4238. else if ( typeid ( *valueArg ) == typeid ( SnmpUInteger32 ) )
  4239. {
  4240. WbemSnmpQualifier *qualifier = FindQualifier ( WBEM_QUALIFIER_VARIABLE_VALUE ) ;
  4241. if ( qualifier )
  4242. {
  4243. SnmpInstanceType *typeValue = qualifier->GetValue () ;
  4244. if ( typeid ( *typeValue ) == typeid ( SnmpDisplayStringType ) )
  4245. {
  4246. SnmpDisplayStringType *string = ( SnmpDisplayStringType * ) typeValue ;
  4247. wchar_t *rangeValues = string->GetStringValue () ;
  4248. SnmpUInteger32 *ui_integer32 = ( SnmpUInteger32 * ) valueArg ;
  4249. SnmpUInteger32Type ui_integer32Type ( *ui_integer32 , rangeValues ) ;
  4250. delete [] rangeValues ;
  4251. t_Variant.vt = VT_I4 ;
  4252. t_VarType = VT_UI4 ;
  4253. t_Variant.lVal = ui_integer32->GetValue () ;
  4254. status = ui_integer32Type.SnmpInstanceType :: IsValid () ;
  4255. }
  4256. }
  4257. else
  4258. {
  4259. SnmpUInteger32 *ui_integer32 = ( SnmpUInteger32 * ) valueArg ;
  4260. SnmpUInteger32Type ui_integer32Type ( *ui_integer32 , NULL ) ;
  4261. t_Variant.vt = VT_I4 ;
  4262. t_VarType = VT_UI4 ;
  4263. t_Variant.lVal = ui_integer32->GetValue () ;
  4264. status = TRUE ;
  4265. }
  4266. }
  4267. }
  4268. break;
  4269. case WBEM_INDEX_TYPE_GAUGE:
  4270. case WBEM_INDEX_TYPE_GAUGE32:
  4271. {
  4272. if ( ! valueArg )
  4273. {
  4274. t_Variant.vt = VT_NULL ;
  4275. t_VarType = VT_UI4 ;
  4276. status = TRUE ;
  4277. }
  4278. else if ( typeid ( *valueArg ) == typeid ( SnmpGauge ) )
  4279. {
  4280. WbemSnmpQualifier *qualifier = FindQualifier ( WBEM_QUALIFIER_VARIABLE_VALUE ) ;
  4281. if ( qualifier )
  4282. {
  4283. SnmpInstanceType *typeValue = qualifier->GetValue () ;
  4284. if ( typeid ( *typeValue ) == typeid ( SnmpDisplayStringType ) )
  4285. {
  4286. SnmpDisplayStringType *string = ( SnmpDisplayStringType * ) typeValue ;
  4287. wchar_t *rangeValues = string->GetStringValue () ;
  4288. SnmpGauge *gauge = ( SnmpGauge * ) valueArg ;
  4289. SnmpGaugeType gaugeType ( *gauge , rangeValues ) ;
  4290. delete [] rangeValues ;
  4291. t_Variant.vt = VT_I4 ;
  4292. t_VarType = VT_UI4 ;
  4293. t_Variant.lVal = gauge->GetValue () ;
  4294. status = gaugeType.SnmpInstanceType :: IsValid () ;
  4295. }
  4296. }
  4297. else
  4298. {
  4299. SnmpGauge *gauge = ( SnmpGauge * ) valueArg ;
  4300. SnmpGaugeType gaugeType ( *gauge , NULL ) ;
  4301. t_Variant.vt = VT_I4 ;
  4302. t_VarType = VT_UI4 ;
  4303. t_Variant.lVal = gauge->GetValue () ;
  4304. status = TRUE ;
  4305. }
  4306. }
  4307. }
  4308. break ;
  4309. case WBEM_INDEX_TYPE_OCTETSTRING:
  4310. {
  4311. if ( ! valueArg )
  4312. {
  4313. t_Variant.vt = VT_NULL ;
  4314. t_VarType = VT_BSTR ;
  4315. status = TRUE ;
  4316. }
  4317. else
  4318. {
  4319. if ( typeid ( *valueArg ) == typeid ( SnmpOctetString ) )
  4320. {
  4321. WbemSnmpQualifier *qualifier = FindQualifier ( WBEM_QUALIFIER_FIXED_LENGTH ) ;
  4322. if ( qualifier )
  4323. {
  4324. SnmpInstanceType *typeValue = qualifier->GetValue () ;
  4325. if ( typeid ( *typeValue ) == typeid ( SnmpIntegerType ) )
  4326. {
  4327. SnmpIntegerType *integer = ( SnmpIntegerType * ) typeValue ;
  4328. LONG fixed = integer->GetValue () ;
  4329. SnmpOctetString *octetString = ( SnmpOctetString * ) valueArg ;
  4330. SnmpFixedLengthOctetStringType octetStringType ( fixed , *octetString ) ;
  4331. wchar_t *value = octetStringType.GetStringValue () ;
  4332. t_Variant.bstrVal = SysAllocString ( value ) ;
  4333. t_Variant.vt = t_VarType = VT_BSTR ;
  4334. delete [] value ;
  4335. status = octetStringType.SnmpInstanceType :: IsValid () ;
  4336. }
  4337. }
  4338. else
  4339. {
  4340. WbemSnmpQualifier *qualifier = FindQualifier ( WBEM_QUALIFIER_VARIABLE_LENGTH ) ;
  4341. if ( qualifier )
  4342. {
  4343. SnmpInstanceType *typeValue = qualifier->GetValue () ;
  4344. if ( typeid ( *typeValue ) == typeid ( SnmpDisplayStringType ) )
  4345. {
  4346. SnmpOctetString *octetString = ( SnmpOctetString * ) valueArg ;
  4347. SnmpDisplayStringType *string = ( SnmpDisplayStringType * ) typeValue ;
  4348. wchar_t *rangeValues = string->GetStringValue () ;
  4349. SnmpOctetStringType octetStringType ( *octetString , rangeValues ) ;
  4350. delete [] rangeValues ;
  4351. wchar_t *value = octetStringType.GetStringValue () ;
  4352. t_Variant.bstrVal = SysAllocString ( value ) ;
  4353. t_Variant.vt = t_VarType = VT_BSTR ;
  4354. delete [] value ;
  4355. status = octetStringType.SnmpInstanceType :: IsValid () ;
  4356. }
  4357. else
  4358. {
  4359. }
  4360. }
  4361. else
  4362. {
  4363. SnmpOctetString *octetString = ( SnmpOctetString * ) valueArg ;
  4364. SnmpOctetStringType octetStringType ( *octetString , NULL ) ;
  4365. wchar_t *value = octetStringType.GetStringValue () ;
  4366. t_Variant.bstrVal = SysAllocString ( value ) ;
  4367. t_Variant.vt = t_VarType = VT_BSTR ;
  4368. delete [] value ;
  4369. status = octetStringType.SnmpInstanceType :: IsValid () ;
  4370. }
  4371. }
  4372. }
  4373. else
  4374. {
  4375. }
  4376. }
  4377. }
  4378. break ;
  4379. case WBEM_INDEX_TYPE_OBJECTIDENTIFIER:
  4380. {
  4381. if ( ! valueArg )
  4382. {
  4383. t_Variant.vt = VT_NULL ;
  4384. t_VarType = VT_BSTR ;
  4385. status = TRUE ;
  4386. }
  4387. else if ( typeid ( *valueArg ) == typeid ( SnmpObjectIdentifier ) )
  4388. {
  4389. SnmpObjectIdentifier *objectIdentifier = ( SnmpObjectIdentifier * ) valueArg ;
  4390. SnmpObjectIdentifierType objectIdentifierType ( *objectIdentifier ) ;
  4391. wchar_t *value = objectIdentifierType.GetStringValue () ;
  4392. t_Variant.bstrVal = SysAllocString ( value ) ;
  4393. t_Variant.vt = t_VarType = VT_BSTR ;
  4394. delete [] value ;
  4395. status = objectIdentifierType.IsValid () ;
  4396. }
  4397. }
  4398. break ;
  4399. case WBEM_INDEX_TYPE_NULL:
  4400. {
  4401. t_Variant.vt = t_VarType = VT_NULL ;
  4402. status = TRUE ;
  4403. }
  4404. break ;
  4405. case WBEM_INDEX_TYPE_IPADDRESS:
  4406. {
  4407. if ( ! valueArg )
  4408. {
  4409. t_Variant.vt = VT_NULL ;
  4410. t_VarType = VT_BSTR ;
  4411. status = TRUE ;
  4412. }
  4413. else if ( typeid ( *valueArg ) == typeid ( SnmpIpAddress ) )
  4414. {
  4415. SnmpIpAddress *ipAddress = ( SnmpIpAddress * ) valueArg ;
  4416. SnmpIpAddressType ipAddressType ( *ipAddress ) ;
  4417. wchar_t *value = ipAddressType.GetStringValue () ;
  4418. t_Variant.bstrVal = SysAllocString ( value ) ;
  4419. t_Variant.vt = t_VarType = VT_BSTR ;
  4420. delete [] value ;
  4421. status = ipAddressType.IsValid () ;
  4422. }
  4423. }
  4424. break ;
  4425. case WBEM_INDEX_TYPE_TIMETICKS:
  4426. {
  4427. if ( ! valueArg )
  4428. {
  4429. t_Variant.vt = VT_NULL ;
  4430. t_VarType = VT_UI4 ;
  4431. status = TRUE ;
  4432. }
  4433. else if ( typeid ( *valueArg ) == typeid ( SnmpTimeTicks ) )
  4434. {
  4435. SnmpTimeTicks *timeTicks = ( SnmpTimeTicks * ) valueArg ;
  4436. SnmpTimeTicksType timeTicksType ( *timeTicks ) ;
  4437. t_Variant.vt = VT_I4 ;
  4438. t_VarType = VT_UI4 ;
  4439. t_Variant.lVal = timeTicksType.GetValue () ;
  4440. status = timeTicksType.IsValid () ;
  4441. }
  4442. }
  4443. break ;
  4444. case WBEM_INDEX_TYPE_OPAQUE:
  4445. {
  4446. if ( ! valueArg )
  4447. {
  4448. t_Variant.vt = VT_NULL ;
  4449. t_VarType = VT_BSTR ;
  4450. status = TRUE ;
  4451. }
  4452. else
  4453. {
  4454. if ( typeid ( *valueArg ) == typeid ( SnmpOpaque ) )
  4455. {
  4456. WbemSnmpQualifier *qualifier = FindQualifier ( WBEM_QUALIFIER_FIXED_LENGTH ) ;
  4457. if ( qualifier )
  4458. {
  4459. SnmpInstanceType *typeValue = qualifier->GetValue () ;
  4460. if ( typeid ( *typeValue ) == typeid ( SnmpIntegerType ) )
  4461. {
  4462. SnmpIntegerType *integer = ( SnmpIntegerType * ) typeValue ;
  4463. LONG fixed = integer->GetValue () ;
  4464. SnmpOpaque *opaque = ( SnmpOpaque * ) valueArg ;
  4465. SnmpFixedLengthOpaqueType opaqueType ( fixed , *opaque ) ;
  4466. wchar_t *value = opaqueType.GetStringValue () ;
  4467. t_Variant.bstrVal = SysAllocString ( value ) ;
  4468. t_Variant.vt = t_VarType = VT_BSTR ;
  4469. delete [] value ;
  4470. status = opaqueType.SnmpInstanceType :: IsValid () ;
  4471. }
  4472. }
  4473. else
  4474. {
  4475. WbemSnmpQualifier *qualifier = FindQualifier ( WBEM_QUALIFIER_VARIABLE_LENGTH ) ;
  4476. if ( qualifier )
  4477. {
  4478. SnmpInstanceType *typeValue = qualifier->GetValue () ;
  4479. if ( typeid ( *typeValue ) == typeid ( SnmpDisplayStringType ) )
  4480. {
  4481. SnmpOpaque *opaque = ( SnmpOpaque * ) valueArg ;
  4482. SnmpDisplayStringType *string = ( SnmpDisplayStringType * ) typeValue ;
  4483. wchar_t *rangeValues = string->GetStringValue () ;
  4484. SnmpOpaqueType opaqueType ( *opaque , rangeValues ) ;
  4485. delete [] rangeValues ;
  4486. wchar_t *value = opaqueType.GetStringValue () ;
  4487. t_Variant.bstrVal = SysAllocString ( value ) ;
  4488. t_Variant.vt = t_VarType = VT_BSTR ;
  4489. delete [] value ;
  4490. status = opaqueType.SnmpInstanceType :: IsValid () ;
  4491. }
  4492. else
  4493. {
  4494. }
  4495. }
  4496. else
  4497. {
  4498. SnmpOpaque *opaque = ( SnmpOpaque * ) valueArg ;
  4499. SnmpOpaqueType opaqueType ( *opaque , NULL ) ;
  4500. wchar_t *value = opaqueType.GetStringValue () ;
  4501. t_Variant.bstrVal = SysAllocString ( value ) ;
  4502. t_Variant.vt = t_VarType = VT_BSTR ;
  4503. delete [] value ;
  4504. status = opaqueType.SnmpInstanceType :: IsValid () ;
  4505. }
  4506. }
  4507. }
  4508. }
  4509. }
  4510. break ;
  4511. case WBEM_INDEX_TYPE_NETWORKADDRESS:
  4512. {
  4513. if ( ! valueArg )
  4514. {
  4515. t_Variant.vt = VT_NULL ;
  4516. t_VarType = VT_BSTR ;
  4517. status = TRUE ;
  4518. }
  4519. else if ( typeid ( *valueArg ) == typeid ( SnmpIpAddress ) )
  4520. {
  4521. SnmpIpAddress *ipAddress = ( SnmpIpAddress * ) valueArg ;
  4522. SnmpNetworkAddressType ipAddressType ( *ipAddress ) ;
  4523. wchar_t *value = ipAddressType.GetStringValue () ;
  4524. t_Variant.bstrVal = SysAllocString ( value ) ;
  4525. t_Variant.vt = t_VarType = VT_BSTR ;
  4526. delete [] value ;
  4527. status = ipAddressType.IsValid () ;
  4528. }
  4529. }
  4530. break ;
  4531. case WBEM_INDEX_TYPE_DISPLAYSTRING:
  4532. {
  4533. if ( ! valueArg )
  4534. {
  4535. t_Variant.vt = VT_NULL ;
  4536. t_VarType = VT_BSTR ;
  4537. status = TRUE ;
  4538. }
  4539. else
  4540. {
  4541. if ( typeid ( *valueArg ) == typeid ( SnmpOctetString ) )
  4542. {
  4543. WbemSnmpQualifier *qualifier = FindQualifier ( WBEM_QUALIFIER_FIXED_LENGTH ) ;
  4544. if ( qualifier )
  4545. {
  4546. SnmpInstanceType *typeValue = qualifier->GetValue () ;
  4547. if ( typeid ( *typeValue ) == typeid ( SnmpIntegerType ) )
  4548. {
  4549. SnmpIntegerType *integer = ( SnmpIntegerType * ) typeValue ;
  4550. LONG fixed = integer->GetValue () ;
  4551. SnmpOctetString *octetString = ( SnmpOctetString * ) valueArg ;
  4552. SnmpFixedLengthDisplayStringType octetStringType ( fixed , *octetString ) ;
  4553. t_Variant.vt = t_VarType = VT_BSTR ;
  4554. wchar_t *value = octetStringType.GetStringValue () ;
  4555. t_Variant.bstrVal = SysAllocString ( value ) ;
  4556. delete [] value ;
  4557. status = octetStringType.SnmpInstanceType :: IsValid () ;
  4558. }
  4559. else
  4560. {
  4561. // Problem Here
  4562. }
  4563. }
  4564. else
  4565. {
  4566. WbemSnmpQualifier *qualifier = FindQualifier ( WBEM_QUALIFIER_VARIABLE_LENGTH ) ;
  4567. if ( qualifier )
  4568. {
  4569. SnmpInstanceType *typeValue = qualifier->GetValue () ;
  4570. if ( typeid ( *typeValue ) == typeid ( SnmpDisplayStringType ) )
  4571. {
  4572. SnmpOctetString *octetString = ( SnmpOctetString * ) valueArg ;
  4573. SnmpDisplayStringType *string = ( SnmpDisplayStringType * ) typeValue ;
  4574. wchar_t *rangeValues = string->GetStringValue () ;
  4575. SnmpDisplayStringType octetStringType ( *octetString , rangeValues ) ;
  4576. delete [] rangeValues ;
  4577. t_Variant.vt = t_VarType = VT_BSTR ;
  4578. wchar_t *value = octetStringType.GetStringValue () ;
  4579. t_Variant.bstrVal = SysAllocString ( value ) ;
  4580. delete [] value ;
  4581. status = octetStringType.SnmpInstanceType :: IsValid () ;
  4582. }
  4583. else
  4584. {
  4585. }
  4586. }
  4587. else
  4588. {
  4589. SnmpOctetString *octetString = ( SnmpOctetString * ) valueArg ;
  4590. SnmpDisplayStringType octetStringType ( *octetString , NULL ) ;
  4591. t_Variant.vt = t_VarType = VT_BSTR ;
  4592. wchar_t *value = octetStringType.GetStringValue () ;
  4593. t_Variant.bstrVal = SysAllocString ( value ) ;
  4594. delete [] value ;
  4595. status = octetStringType.SnmpInstanceType :: IsValid () ;
  4596. }
  4597. }
  4598. }
  4599. }
  4600. }
  4601. break ;
  4602. case WBEM_INDEX_TYPE_MACADDRESS:
  4603. {
  4604. if ( ! valueArg )
  4605. {
  4606. t_Variant.vt = VT_NULL ;
  4607. t_VarType = VT_BSTR ;
  4608. status = TRUE ;
  4609. }
  4610. else if ( typeid ( *valueArg ) == typeid ( SnmpOctetString ) )
  4611. {
  4612. SnmpOctetString *octetString = ( SnmpOctetString * ) valueArg ;
  4613. SnmpMacAddressType octetStringType ( *octetString ) ;
  4614. t_Variant.vt = t_VarType = VT_BSTR ;
  4615. wchar_t *value = octetStringType.GetStringValue () ;
  4616. t_Variant.bstrVal = SysAllocString ( value ) ;
  4617. delete [] value ;
  4618. status = octetStringType.SnmpInstanceType :: IsValid () ;
  4619. }
  4620. }
  4621. break ;
  4622. case WBEM_INDEX_TYPE_PHYSADDRESS:
  4623. {
  4624. if ( ! valueArg )
  4625. {
  4626. t_Variant.vt = VT_NULL ;
  4627. t_VarType = VT_BSTR ;
  4628. status = TRUE ;
  4629. }
  4630. else
  4631. {
  4632. if ( typeid ( *valueArg ) == typeid ( SnmpOctetString ) )
  4633. {
  4634. WbemSnmpQualifier *qualifier = FindQualifier ( WBEM_QUALIFIER_FIXED_LENGTH ) ;
  4635. if ( qualifier )
  4636. {
  4637. SnmpInstanceType *typeValue = qualifier->GetValue () ;
  4638. if ( typeid ( *typeValue ) == typeid ( SnmpIntegerType ) )
  4639. {
  4640. SnmpIntegerType *integer = ( SnmpIntegerType * ) typeValue ;
  4641. LONG fixed = integer->GetValue () ;
  4642. SnmpOctetString *octetString = ( SnmpOctetString * ) valueArg ;
  4643. SnmpFixedLengthPhysAddressType octetStringType ( fixed , *octetString ) ;
  4644. t_Variant.vt = t_VarType = VT_BSTR ;
  4645. wchar_t *value = octetStringType.GetStringValue () ;
  4646. t_Variant.bstrVal = SysAllocString ( value ) ;
  4647. delete [] value ;
  4648. status = octetStringType.SnmpInstanceType :: IsValid () ;
  4649. }
  4650. else
  4651. {
  4652. // Problem Here
  4653. }
  4654. }
  4655. else
  4656. {
  4657. WbemSnmpQualifier *qualifier = FindQualifier ( WBEM_QUALIFIER_VARIABLE_LENGTH ) ;
  4658. if ( qualifier )
  4659. {
  4660. SnmpInstanceType *typeValue = qualifier->GetValue () ;
  4661. if ( typeid ( *typeValue ) == typeid ( SnmpDisplayStringType ) )
  4662. {
  4663. SnmpOctetString *octetString = ( SnmpOctetString * ) valueArg ;
  4664. SnmpDisplayStringType *string = ( SnmpDisplayStringType * ) typeValue ;
  4665. wchar_t *rangeValues = string->GetStringValue () ;
  4666. SnmpPhysAddressType octetStringType ( *octetString , rangeValues ) ;
  4667. delete [] rangeValues ;
  4668. t_Variant.vt = t_VarType = VT_BSTR ;
  4669. wchar_t *value = octetStringType.GetStringValue () ;
  4670. t_Variant.bstrVal = SysAllocString ( value ) ;
  4671. delete [] value ;
  4672. status = octetStringType.SnmpInstanceType :: IsValid () ;
  4673. }
  4674. else
  4675. {
  4676. }
  4677. }
  4678. else
  4679. {
  4680. SnmpOctetString *octetString = ( SnmpOctetString * ) valueArg ;
  4681. SnmpPhysAddressType octetStringType ( *octetString , NULL ) ;
  4682. t_Variant.vt = t_VarType = VT_BSTR ;
  4683. wchar_t *value = octetStringType.GetStringValue () ;
  4684. t_Variant.bstrVal = SysAllocString ( value ) ;
  4685. delete [] value ;
  4686. status = octetStringType.SnmpInstanceType :: IsValid () ;
  4687. }
  4688. }
  4689. }
  4690. }
  4691. }
  4692. break ;
  4693. case WBEM_INDEX_TYPE_ENUMERATEDINTEGER:
  4694. {
  4695. if ( ! valueArg )
  4696. {
  4697. t_Variant.vt = VT_NULL ;
  4698. t_VarType = VT_BSTR ;
  4699. status = TRUE ;
  4700. }
  4701. else if ( typeid ( *valueArg ) == typeid ( SnmpInteger ) )
  4702. {
  4703. SnmpInteger *integer = ( SnmpInteger * ) valueArg ;
  4704. WbemSnmpQualifier *qualifier = FindQualifier ( WBEM_QUALIFIER_ENUMERATION ) ;
  4705. if ( qualifier )
  4706. {
  4707. SnmpInstanceType *typeValue = qualifier->GetValue () ;
  4708. if ( typeid ( *typeValue ) == typeid ( SnmpDisplayStringType ) )
  4709. {
  4710. SnmpDisplayStringType *string = ( SnmpDisplayStringType * ) typeValue ;
  4711. wchar_t *enumerationValues = string->GetStringValue () ;
  4712. SnmpEnumeratedType integerType ( enumerationValues , integer->GetValue () ) ;
  4713. delete [] enumerationValues ;
  4714. t_Variant.vt = t_VarType = VT_BSTR ;
  4715. wchar_t *value = integerType.GetStringValue () ;
  4716. t_Variant.bstrVal = SysAllocString ( value ) ;
  4717. delete [] value ;
  4718. status = integerType.SnmpInstanceType :: IsValid () ;
  4719. }
  4720. }
  4721. }
  4722. }
  4723. break ;
  4724. case WBEM_INDEX_TYPE_BITS:
  4725. {
  4726. if ( ! valueArg )
  4727. {
  4728. t_Variant.vt = VT_NULL ;
  4729. t_VarType = VT_BSTR ;
  4730. status = TRUE ;
  4731. }
  4732. else if ( typeid ( *valueArg ) == typeid ( SnmpOctetString ) )
  4733. {
  4734. WbemSnmpQualifier *qualifier = FindQualifier ( WBEM_QUALIFIER_BITS ) ;
  4735. if ( qualifier )
  4736. {
  4737. SnmpInstanceType *typeValue = qualifier->GetValue () ;
  4738. if ( typeid ( *typeValue ) == typeid ( SnmpDisplayStringType ) )
  4739. {
  4740. SnmpDisplayStringType *string = ( SnmpDisplayStringType * ) typeValue ;
  4741. wchar_t *bitStringValues = string->GetStringValue () ;
  4742. SnmpOctetString *octetString = ( SnmpOctetString * ) valueArg ;
  4743. SnmpBitStringType octetStringType ( bitStringValues , *octetString ) ;
  4744. delete [] bitStringValues ;
  4745. wchar_t **array ;
  4746. LONG count = octetStringType.GetValue ( array ) ;
  4747. SAFEARRAY *safeArray ;
  4748. SAFEARRAYBOUND safeArrayBounds [ 1 ] ;
  4749. safeArrayBounds[0].lLbound = 0 ;
  4750. safeArrayBounds[0].cElements = count ;
  4751. safeArray = SafeArrayCreate ( VT_BSTR , 1 , safeArrayBounds ) ;
  4752. for ( LONG index = 0 ; index < count ; index ++ )
  4753. {
  4754. BSTR element = SysAllocString ( array [ index ] ) ;
  4755. SafeArrayPutElement ( safeArray , & index , element ) ;
  4756. SysFreeString ( element ) ;
  4757. delete [] ( array [ index ] ) ;
  4758. }
  4759. delete [] array ;
  4760. t_Variant.vt = t_VarType = VT_ARRAY | VT_BSTR ;
  4761. t_Variant.parray = safeArray ;
  4762. status = octetStringType.SnmpInstanceType :: IsValid () ;
  4763. }
  4764. }
  4765. }
  4766. }
  4767. break ;
  4768. case WBEM_INDEX_TYPE_DATETIME:
  4769. {
  4770. if ( ! valueArg )
  4771. {
  4772. t_Variant.vt = VT_NULL ;
  4773. t_VarType = VT_BSTR ;
  4774. status = TRUE ;
  4775. }
  4776. else if ( typeid ( *valueArg ) == typeid ( SnmpOctetString ) )
  4777. {
  4778. SnmpOctetString *octetString = ( SnmpOctetString * ) valueArg ;
  4779. SnmpDateTimeType octetStringType ( *octetString ) ;
  4780. t_Variant.vt = t_VarType = VT_BSTR ;
  4781. wchar_t *value = octetStringType.GetStringValue () ;
  4782. t_Variant.bstrVal = SysAllocString ( value ) ;
  4783. delete [] value ;
  4784. status = octetStringType.SnmpInstanceType :: IsValid () ;
  4785. }
  4786. }
  4787. break ;
  4788. case WBEM_INDEX_TYPE_SNMPOSIADDRESS:
  4789. {
  4790. if ( ! valueArg )
  4791. {
  4792. t_Variant.vt = VT_NULL ;
  4793. t_VarType = VT_BSTR ;
  4794. status = TRUE ;
  4795. }
  4796. else if ( typeid ( *valueArg ) == typeid ( SnmpOctetString ) )
  4797. {
  4798. SnmpOctetString *octetString = ( SnmpOctetString * ) valueArg ;
  4799. SnmpOSIAddressType octetStringType ( *octetString ) ;
  4800. t_Variant.vt = t_VarType = VT_BSTR ;
  4801. wchar_t *value = octetStringType.GetStringValue () ;
  4802. t_Variant.bstrVal = SysAllocString ( value ) ;
  4803. delete [] value ;
  4804. status = octetStringType.SnmpInstanceType :: IsValid () ;
  4805. }
  4806. }
  4807. break ;
  4808. case WBEM_INDEX_TYPE_SNMPUDPADDRESS:
  4809. {
  4810. if ( ! valueArg )
  4811. {
  4812. t_Variant.vt = VT_NULL ;
  4813. t_VarType = VT_BSTR ;
  4814. status = TRUE ;
  4815. }
  4816. else if ( typeid ( *valueArg ) == typeid ( SnmpOctetString ) )
  4817. {
  4818. SnmpOctetString *octetString = ( SnmpOctetString * ) valueArg ;
  4819. SnmpUDPAddressType octetStringType ( *octetString ) ;
  4820. t_Variant.vt = t_VarType = VT_BSTR ;
  4821. wchar_t *value = octetStringType.GetStringValue () ;
  4822. t_Variant.bstrVal = SysAllocString ( value ) ;
  4823. delete [] value ;
  4824. status = octetStringType.SnmpInstanceType :: IsValid () ;
  4825. }
  4826. }
  4827. break ;
  4828. case WBEM_INDEX_TYPE_SNMPIPXADDRESS:
  4829. {
  4830. if ( ! valueArg )
  4831. {
  4832. t_Variant.vt = VT_NULL ;
  4833. t_VarType = VT_BSTR ;
  4834. status = TRUE ;
  4835. }
  4836. else if ( typeid ( *valueArg ) == typeid ( SnmpOctetString ) )
  4837. {
  4838. SnmpOctetString *octetString = ( SnmpOctetString * ) valueArg ;
  4839. SnmpIPXAddressType octetStringType ( *octetString ) ;
  4840. t_Variant.vt = t_VarType = VT_BSTR ;
  4841. wchar_t *value = octetStringType.GetStringValue () ;
  4842. t_Variant.bstrVal = SysAllocString ( value ) ;
  4843. delete [] value ;
  4844. status = octetStringType.SnmpInstanceType :: IsValid () ;
  4845. }
  4846. }
  4847. break ;
  4848. case WBEM_INDEX_TYPE_ROWSTATUS:
  4849. {
  4850. if ( ! valueArg )
  4851. {
  4852. t_Variant.vt = VT_NULL ;
  4853. t_VarType = VT_BSTR ;
  4854. status = TRUE ;
  4855. }
  4856. else if ( typeid ( *valueArg ) == typeid ( SnmpInteger ) )
  4857. {
  4858. SnmpInteger *integer = ( SnmpInteger * ) valueArg ;
  4859. SnmpRowStatusType integerType ( *integer ) ;
  4860. t_Variant.vt = t_VarType = VT_BSTR ;
  4861. wchar_t *value = integerType.GetStringValue () ;
  4862. t_Variant.bstrVal = SysAllocString ( value ) ;
  4863. delete [] value ;
  4864. status = integerType.SnmpInstanceType :: IsValid () ;
  4865. }
  4866. }
  4867. break ;
  4868. default:
  4869. {
  4870. }
  4871. break ;
  4872. }
  4873. switch ( check )
  4874. {
  4875. case SetValueRegardlessReturnCheck:
  4876. {
  4877. #if 0
  4878. switch ( GetTextualConvention () )
  4879. {
  4880. case WBEM_INDEX_TYPE_OCTETSTRING:
  4881. {
  4882. HRESULT t_Result = SetStringProp ( a_Object , propertyName , t_Variant ) ;
  4883. if ( FAILED ( t_Result ) )
  4884. {
  4885. status = FALSE ;
  4886. }
  4887. }
  4888. break ;
  4889. default:
  4890. {
  4891. HRESULT t_Result = SetProp ( a_Object , propertyName , t_Variant ) ;
  4892. if ( FAILED ( t_Result ) )
  4893. {
  4894. status = FALSE ;
  4895. }
  4896. }
  4897. break ;
  4898. }
  4899. #else
  4900. HRESULT t_Result = a_Object->Put ( propertyName , 0 , &t_Variant , 0 ) ;
  4901. if ( FAILED ( t_Result ) )
  4902. {
  4903. status = FALSE ;
  4904. }
  4905. #endif
  4906. }
  4907. break ;
  4908. case SetValueRegardlessDontReturnCheck:
  4909. {
  4910. #if 1
  4911. HRESULT t_Result = a_Object->Put ( propertyName , 0 , &t_Variant , 0 ) ;
  4912. #else
  4913. HRESULT t_Result = SetProp ( a_Object , propertyName , t_Variant ) ;
  4914. #endif
  4915. status = SUCCEEDED ( t_Result ) ;
  4916. }
  4917. break ;
  4918. case DontSetValueReturnCheck:
  4919. {
  4920. }
  4921. break ;
  4922. case SetValueIfCheckOk:
  4923. {
  4924. if ( status )
  4925. {
  4926. #if 1
  4927. HRESULT t_Result = a_Object->Put ( propertyName , 0 , &t_Variant , 0 ) ;
  4928. #else
  4929. HRESULT t_Result = SetProp ( a_Object , propertyName , t_Variant ) ;
  4930. #endif
  4931. status = SUCCEEDED ( t_Result ) ;
  4932. }
  4933. }
  4934. break ;
  4935. }
  4936. }
  4937. VariantClear ( & t_Variant ) ;
  4938. return status ;
  4939. }
  4940. BOOL WbemSnmpProperty :: Encode ( const VARIANT &variant , SnmpObjectIdentifier &a_Encode )
  4941. {
  4942. DebugMacro7( SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine ( __FILE__,__LINE__,L"WbemSnmpProperty :: Encode ( const VARIANT &variant )" ) )
  4943. BOOL t_Status = FALSE ;
  4944. WbemSnmpQualifier *qualifier = FindQualifier ( WBEM_QUALIFIER_TEXTUAL_CONVENTION ) ;
  4945. if ( qualifier )
  4946. {
  4947. SnmpDisplayStringType *displayString = ( SnmpDisplayStringType * ) qualifier->GetValue () ;
  4948. wchar_t *textualConvention = displayString->GetValue () ;
  4949. if ( textualConvention )
  4950. {
  4951. ULONG qualifierIndex ;
  4952. if ( textualConventionMap.Lookup ( textualConvention , qualifierIndex ) )
  4953. {
  4954. switch ( qualifierIndex )
  4955. {
  4956. case WBEM_INDEX_TYPE_INTEGER:
  4957. case WBEM_INDEX_TYPE_INTEGER32:
  4958. {
  4959. if ( variant.vt == VT_I4 )
  4960. {
  4961. SnmpIntegerType t_Integer ( variant.lVal , NULL ) ;
  4962. a_Encode = t_Integer.Encode ( a_Encode ) ;
  4963. }
  4964. }
  4965. break ;
  4966. case WBEM_INDEX_TYPE_COUNTER:
  4967. case WBEM_INDEX_TYPE_COUNTER32:
  4968. {
  4969. if ( variant.vt == VT_I4 )
  4970. {
  4971. SnmpCounterType t_Counter ( variant.lVal ) ;
  4972. a_Encode = t_Counter.Encode ( a_Encode ) ;
  4973. }
  4974. }
  4975. break ;
  4976. case WBEM_INDEX_TYPE_COUNTER64:
  4977. {
  4978. if ( variant.vt == VT_BSTR )
  4979. {
  4980. SnmpCounter64Type t_Counter ( variant.bstrVal ) ;
  4981. a_Encode = t_Counter.Encode ( a_Encode ) ;
  4982. }
  4983. }
  4984. break ;
  4985. case WBEM_INDEX_TYPE_UNSIGNED32:
  4986. {
  4987. if ( variant.vt == VT_I4 )
  4988. {
  4989. SnmpUInteger32Type t_UIInteger32 ( variant.lVal , NULL ) ;
  4990. a_Encode = t_UIInteger32.Encode ( a_Encode ) ;
  4991. }
  4992. }
  4993. break;
  4994. case WBEM_INDEX_TYPE_GAUGE:
  4995. case WBEM_INDEX_TYPE_GAUGE32:
  4996. {
  4997. if ( variant.vt == VT_I4 )
  4998. {
  4999. SnmpGaugeType t_Gauge ( variant.lVal , NULL ) ;
  5000. a_Encode = t_Gauge.Encode ( a_Encode ) ;
  5001. }
  5002. }
  5003. break ;
  5004. case WBEM_INDEX_TYPE_OCTETSTRING:
  5005. {
  5006. WbemSnmpQualifier *qualifier = FindQualifier ( WBEM_QUALIFIER_FIXED_LENGTH ) ;
  5007. if ( qualifier )
  5008. {
  5009. SnmpInstanceType *typeValue = qualifier->GetValue () ;
  5010. if ( typeid ( *typeValue ) == typeid ( SnmpIntegerType ) )
  5011. {
  5012. SnmpIntegerType *integer = ( SnmpIntegerType * ) typeValue ;
  5013. LONG fixed = integer->GetValue () ;
  5014. if ( variant.vt == VT_BSTR )
  5015. {
  5016. SnmpFixedLengthOctetStringType t_Octet ( fixed , variant.bstrVal ) ;
  5017. a_Encode = t_Octet.Encode ( a_Encode ) ;
  5018. }
  5019. }
  5020. else
  5021. {
  5022. // Problem Here
  5023. }
  5024. }
  5025. else
  5026. {
  5027. WbemSnmpQualifier *qualifier = FindQualifier ( WBEM_QUALIFIER_VARIABLE_LENGTH ) ;
  5028. if ( qualifier )
  5029. {
  5030. SnmpInstanceType *typeValue = qualifier->GetValue () ;
  5031. if ( typeid ( *typeValue ) == typeid ( SnmpDisplayStringType ) )
  5032. {
  5033. SnmpDisplayStringType *string = ( SnmpDisplayStringType * ) typeValue ;
  5034. wchar_t *rangeValues = string->GetStringValue () ;
  5035. if ( variant.vt == VT_BSTR )
  5036. {
  5037. SnmpOctetStringType t_Octet ( variant.bstrVal , rangeValues ) ;
  5038. a_Encode = t_Octet.Encode ( a_Encode ) ;
  5039. }
  5040. delete [] rangeValues ;
  5041. }
  5042. else
  5043. {
  5044. }
  5045. }
  5046. else
  5047. {
  5048. if ( variant.vt == VT_BSTR )
  5049. {
  5050. SnmpOctetStringType t_Octet ( variant.bstrVal , NULL ) ;
  5051. a_Encode = t_Octet.Encode ( a_Encode ) ;
  5052. }
  5053. }
  5054. }
  5055. }
  5056. break ;
  5057. case WBEM_INDEX_TYPE_OBJECTIDENTIFIER:
  5058. {
  5059. if ( variant.vt == VT_BSTR )
  5060. {
  5061. SnmpObjectIdentifierType t_ObjectIdentifier ( variant.bstrVal ) ;
  5062. a_Encode = t_ObjectIdentifier.Encode ( a_Encode ) ;
  5063. }
  5064. }
  5065. break ;
  5066. case WBEM_INDEX_TYPE_NULL:
  5067. {
  5068. }
  5069. break;
  5070. case WBEM_INDEX_TYPE_IPADDRESS:
  5071. {
  5072. if ( variant.vt == VT_BSTR )
  5073. {
  5074. SnmpIpAddressType t_IpAddress ( variant.bstrVal ) ;
  5075. a_Encode = t_IpAddress.Encode ( a_Encode ) ;
  5076. }
  5077. }
  5078. break ;
  5079. case WBEM_INDEX_TYPE_TIMETICKS:
  5080. {
  5081. if ( variant.vt == VT_I4 )
  5082. {
  5083. SnmpTimeTicksType t_TimeTicks ( variant.lVal ) ;
  5084. a_Encode = t_TimeTicks.Encode ( a_Encode ) ;
  5085. }
  5086. }
  5087. break ;
  5088. case WBEM_INDEX_TYPE_OPAQUE:
  5089. {
  5090. WbemSnmpQualifier *qualifier = FindQualifier ( WBEM_QUALIFIER_FIXED_LENGTH ) ;
  5091. if ( qualifier )
  5092. {
  5093. SnmpInstanceType *typeValue = qualifier->GetValue () ;
  5094. if ( typeid ( *typeValue ) == typeid ( SnmpIntegerType ) )
  5095. {
  5096. SnmpIntegerType *integer = ( SnmpIntegerType * ) typeValue ;
  5097. LONG fixed = integer->GetValue () ;
  5098. if ( variant.vt == VT_BSTR )
  5099. {
  5100. SnmpFixedLengthOpaqueType t_Opaque ( fixed , variant.bstrVal ) ;
  5101. a_Encode = t_Opaque.Encode ( a_Encode ) ;
  5102. }
  5103. }
  5104. else
  5105. {
  5106. // Problem Here
  5107. }
  5108. }
  5109. else
  5110. {
  5111. WbemSnmpQualifier *qualifier = FindQualifier ( WBEM_QUALIFIER_VARIABLE_LENGTH ) ;
  5112. if ( qualifier )
  5113. {
  5114. SnmpInstanceType *typeValue = qualifier->GetValue () ;
  5115. if ( typeid ( *typeValue ) == typeid ( SnmpDisplayStringType ) )
  5116. {
  5117. SnmpDisplayStringType *string = ( SnmpDisplayStringType * ) typeValue ;
  5118. wchar_t *rangeValues = string->GetStringValue () ;
  5119. if ( variant.vt == VT_BSTR )
  5120. {
  5121. SnmpOpaqueType t_Opaque ( variant.bstrVal , rangeValues ) ;
  5122. a_Encode = t_Opaque.Encode ( a_Encode ) ;
  5123. }
  5124. delete [] rangeValues ;
  5125. }
  5126. else
  5127. {
  5128. }
  5129. }
  5130. else
  5131. {
  5132. if ( variant.vt == VT_BSTR )
  5133. {
  5134. SnmpOpaqueType t_Opaque ( variant.bstrVal , NULL ) ;
  5135. a_Encode = t_Opaque.Encode ( a_Encode ) ;
  5136. }
  5137. }
  5138. }
  5139. }
  5140. break ;
  5141. case WBEM_INDEX_TYPE_NETWORKADDRESS:
  5142. {
  5143. if ( variant.vt == VT_BSTR )
  5144. {
  5145. SnmpNetworkAddressType t_NetworkAddress ( variant.bstrVal ) ;
  5146. a_Encode = t_NetworkAddress.Encode ( a_Encode ) ;
  5147. }
  5148. }
  5149. break ;
  5150. case WBEM_INDEX_TYPE_DISPLAYSTRING:
  5151. {
  5152. WbemSnmpQualifier *qualifier = FindQualifier ( WBEM_QUALIFIER_FIXED_LENGTH ) ;
  5153. if ( qualifier )
  5154. {
  5155. SnmpInstanceType *typeValue = qualifier->GetValue () ;
  5156. if ( typeid ( *typeValue ) == typeid ( SnmpIntegerType ) )
  5157. {
  5158. SnmpIntegerType *integer = ( SnmpIntegerType * ) typeValue ;
  5159. LONG fixed = integer->GetValue () ;
  5160. if ( variant.vt == VT_BSTR )
  5161. {
  5162. SnmpFixedLengthDisplayStringType t_DisplayString ( fixed , variant.bstrVal ) ;
  5163. a_Encode = t_DisplayString.Encode ( a_Encode ) ;
  5164. }
  5165. }
  5166. else
  5167. {
  5168. // Problem Here
  5169. }
  5170. }
  5171. else
  5172. {
  5173. WbemSnmpQualifier *qualifier = FindQualifier ( WBEM_QUALIFIER_VARIABLE_LENGTH ) ;
  5174. if ( qualifier )
  5175. {
  5176. SnmpInstanceType *typeValue = qualifier->GetValue () ;
  5177. if ( typeid ( *typeValue ) == typeid ( SnmpDisplayStringType ) )
  5178. {
  5179. SnmpDisplayStringType *string = ( SnmpDisplayStringType * ) typeValue ;
  5180. wchar_t *rangeValues = string->GetStringValue () ;
  5181. if ( variant.vt == VT_BSTR )
  5182. {
  5183. SnmpDisplayStringType t_DisplayString ( variant.bstrVal , rangeValues ) ;
  5184. a_Encode = t_DisplayString.Encode ( a_Encode ) ;
  5185. }
  5186. delete [] rangeValues ;
  5187. }
  5188. else
  5189. {
  5190. }
  5191. }
  5192. else
  5193. {
  5194. if ( variant.vt == VT_BSTR )
  5195. {
  5196. SnmpDisplayStringType t_DisplayString ( variant.bstrVal , NULL ) ;
  5197. a_Encode = t_DisplayString.Encode ( a_Encode ) ;
  5198. }
  5199. }
  5200. }
  5201. }
  5202. break ;
  5203. case WBEM_INDEX_TYPE_MACADDRESS:
  5204. {
  5205. if ( variant.vt == VT_BSTR )
  5206. {
  5207. SnmpMacAddressType t_MacAddress ( variant.bstrVal ) ;
  5208. a_Encode = t_MacAddress.Encode ( a_Encode ) ;
  5209. }
  5210. }
  5211. break ;
  5212. case WBEM_INDEX_TYPE_PHYSADDRESS:
  5213. {
  5214. WbemSnmpQualifier *qualifier = FindQualifier ( WBEM_QUALIFIER_FIXED_LENGTH ) ;
  5215. if ( qualifier )
  5216. {
  5217. SnmpInstanceType *typeValue = qualifier->GetValue () ;
  5218. if ( typeid ( *typeValue ) == typeid ( SnmpIntegerType ) )
  5219. {
  5220. SnmpIntegerType *integer = ( SnmpIntegerType * ) typeValue ;
  5221. LONG fixed = integer->GetValue () ;
  5222. if ( variant.vt == VT_BSTR )
  5223. {
  5224. SnmpFixedLengthPhysAddressType t_PhysAddress ( fixed , variant.bstrVal ) ;
  5225. a_Encode = t_PhysAddress.Encode ( a_Encode ) ;
  5226. }
  5227. }
  5228. else
  5229. {
  5230. // Problem Here
  5231. }
  5232. }
  5233. else
  5234. {
  5235. WbemSnmpQualifier *qualifier = FindQualifier ( WBEM_QUALIFIER_VARIABLE_LENGTH ) ;
  5236. if ( qualifier )
  5237. {
  5238. SnmpInstanceType *typeValue = qualifier->GetValue () ;
  5239. if ( typeid ( *typeValue ) == typeid ( SnmpDisplayStringType ) )
  5240. {
  5241. SnmpDisplayStringType *string = ( SnmpDisplayStringType * ) typeValue ;
  5242. wchar_t *rangeValues = string->GetStringValue () ;
  5243. if ( variant.vt == VT_BSTR )
  5244. {
  5245. SnmpPhysAddressType t_PhysAddress ( variant.bstrVal , rangeValues ) ;
  5246. a_Encode = t_PhysAddress.Encode ( a_Encode ) ;
  5247. }
  5248. delete [] rangeValues ;
  5249. }
  5250. else
  5251. {
  5252. }
  5253. }
  5254. else
  5255. {
  5256. if ( variant.vt == VT_BSTR )
  5257. {
  5258. SnmpPhysAddressType t_PhysAddress ( variant.bstrVal , NULL ) ;
  5259. a_Encode = t_PhysAddress.Encode ( a_Encode ) ;
  5260. }
  5261. }
  5262. }
  5263. }
  5264. break ;
  5265. case WBEM_INDEX_TYPE_ENUMERATEDINTEGER:
  5266. {
  5267. WbemSnmpQualifier *qualifier = FindQualifier ( WBEM_QUALIFIER_ENUMERATION ) ;
  5268. if ( qualifier )
  5269. {
  5270. SnmpInstanceType *typeValue = qualifier->GetValue () ;
  5271. if ( typeid ( *typeValue ) == typeid ( SnmpDisplayStringType ) )
  5272. {
  5273. SnmpDisplayStringType *string = ( SnmpDisplayStringType * ) typeValue ;
  5274. wchar_t *enumerationValues = string->GetStringValue () ;
  5275. if ( variant.vt == VT_BSTR )
  5276. {
  5277. SnmpEnumeratedType t_Enumeration ( enumerationValues , variant.bstrVal ) ;
  5278. a_Encode = t_Enumeration.Encode ( a_Encode ) ;
  5279. ; }
  5280. delete [] enumerationValues ;
  5281. }
  5282. }
  5283. }
  5284. break ;
  5285. case WBEM_INDEX_TYPE_BITS:
  5286. {
  5287. WbemSnmpQualifier *qualifier = FindQualifier ( WBEM_QUALIFIER_BITS ) ;
  5288. if ( qualifier )
  5289. {
  5290. SnmpInstanceType *typeValue = qualifier->GetValue () ;
  5291. if ( typeid ( *typeValue ) == typeid ( SnmpDisplayStringType ) )
  5292. {
  5293. SnmpDisplayStringType *string = ( SnmpDisplayStringType * ) typeValue ;
  5294. wchar_t *bitStringValues = string->GetStringValue () ;
  5295. if ( variant.vt == ( VT_BSTR | VT_ARRAY ) )
  5296. {
  5297. if ( SafeArrayGetDim ( variant.parray ) == 1 )
  5298. {
  5299. LONG dimension = 1 ;
  5300. LONG lower ;
  5301. SafeArrayGetLBound ( variant.parray , dimension , & lower ) ;
  5302. LONG upper ;
  5303. SafeArrayGetUBound ( variant.parray , dimension , & upper ) ;
  5304. LONG count = ( upper - lower ) + 1 ;
  5305. wchar_t **array = new wchar_t * [ count ] ;
  5306. for ( LONG elementIndex = lower ; elementIndex <= upper ; elementIndex ++ )
  5307. {
  5308. BSTR element ;
  5309. SafeArrayGetElement ( variant.parray , &elementIndex , & element ) ;
  5310. array [ elementIndex - lower ] = element ;
  5311. }
  5312. SnmpBitStringType t_BitString ( bitStringValues , ( const wchar_t ** ) array , count ) ;
  5313. a_Encode = t_BitString.Encode ( a_Encode ) ;
  5314. for ( elementIndex = 0 ; elementIndex < count ; elementIndex ++ )
  5315. {
  5316. SysFreeString ( array [ elementIndex ] ) ;
  5317. }
  5318. delete [] array ;
  5319. }
  5320. }
  5321. delete [] bitStringValues ;
  5322. }
  5323. }
  5324. }
  5325. break ;
  5326. case WBEM_INDEX_TYPE_DATETIME:
  5327. {
  5328. if ( variant.vt == VT_BSTR )
  5329. {
  5330. SnmpDateTimeType t_DateTime ( variant.bstrVal ) ;
  5331. a_Encode = t_DateTime.SnmpOctetStringType :: Encode ( a_Encode ) ;
  5332. }
  5333. }
  5334. break ;
  5335. case WBEM_INDEX_TYPE_SNMPOSIADDRESS:
  5336. {
  5337. if ( variant.vt == VT_BSTR )
  5338. {
  5339. SnmpOSIAddressType t_OSIAddress ( variant.bstrVal ) ;
  5340. a_Encode = t_OSIAddress.Encode ( a_Encode ) ;
  5341. }
  5342. }
  5343. break ;
  5344. case WBEM_INDEX_TYPE_SNMPUDPADDRESS:
  5345. {
  5346. if ( variant.vt == VT_BSTR )
  5347. {
  5348. SnmpUDPAddressType t_UDPAddress ( variant.bstrVal ) ;
  5349. a_Encode = t_UDPAddress.Encode ( a_Encode ) ;
  5350. }
  5351. }
  5352. break ;
  5353. case WBEM_INDEX_TYPE_SNMPIPXADDRESS:
  5354. {
  5355. if ( variant.vt == VT_BSTR )
  5356. {
  5357. SnmpIPXAddressType t_IPXAddress ( variant.bstrVal ) ;
  5358. a_Encode = t_IPXAddress.Encode ( a_Encode ) ;
  5359. }
  5360. }
  5361. break ;
  5362. case WBEM_INDEX_TYPE_ROWSTATUS:
  5363. {
  5364. if ( variant.vt == VT_BSTR )
  5365. {
  5366. SnmpRowStatusType t_RowStatus ( variant.bstrVal ) ;
  5367. a_Encode = t_RowStatus.Encode ( a_Encode ) ;
  5368. }
  5369. }
  5370. break ;
  5371. default:
  5372. {
  5373. }
  5374. break ;
  5375. }
  5376. }
  5377. }
  5378. delete [] textualConvention ;
  5379. }
  5380. return t_Status ;
  5381. }
  5382. wchar_t *WbemSnmpProperty :: GetName () const
  5383. {
  5384. DebugMacro7(
  5385. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  5386. __FILE__,__LINE__,L"WbemSnmpProperty :: GetName ( (%s) )" ,
  5387. propertyName
  5388. )
  5389. )
  5390. return propertyName ;
  5391. }
  5392. SnmpInstanceType *WbemSnmpProperty :: GetValue () const
  5393. {
  5394. DebugMacro7(
  5395. wchar_t *t_StringValue = ( propertyValue ) ? propertyValue->GetStringValue () : NULL ;
  5396. if ( t_StringValue )
  5397. {
  5398. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  5399. __FILE__,__LINE__,
  5400. L"WbemSnmpProperty :: GetValue ( (%s),(%s) )" ,
  5401. propertyName ,
  5402. t_StringValue
  5403. ) ;
  5404. }
  5405. else
  5406. {
  5407. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  5408. __FILE__,__LINE__,
  5409. L"WbemSnmpProperty :: GetValue ( (%s),(NULL) )" ,
  5410. propertyName
  5411. ) ;
  5412. }
  5413. delete [] t_StringValue ;
  5414. )
  5415. return propertyValue ;
  5416. }
  5417. BOOL WbemSnmpProperty :: GetValue ( VARIANT &variant , CIMTYPE& cimType ) const
  5418. {
  5419. DebugMacro7( SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine ( __FILE__,__LINE__,L"WbemSnmpProperty :: GetValue ( VARIANT &variant )" ) )
  5420. BOOL status = FALSE ;
  5421. if ( propertyValue )
  5422. {
  5423. if ( typeid ( *propertyValue ) == typeid ( SnmpIntegerType ) )
  5424. {
  5425. SnmpIntegerType *integer = ( SnmpIntegerType * ) propertyValue ;
  5426. if ( integer->IsNull () )
  5427. {
  5428. variant.vt = VT_NULL ;
  5429. }
  5430. else
  5431. {
  5432. variant.vt = VT_I4 ;
  5433. variant.lVal = integer->GetValue () ;
  5434. }
  5435. cimType = CIM_SINT32;
  5436. status = TRUE ;
  5437. }
  5438. else if ( typeid ( *propertyValue ) == typeid ( SnmpCounterType ) )
  5439. {
  5440. SnmpCounterType *counter = ( SnmpCounterType * ) propertyValue ;
  5441. if ( counter->IsNull () )
  5442. {
  5443. variant.vt = VT_NULL ;
  5444. }
  5445. else
  5446. {
  5447. variant.vt = VT_I4 ;
  5448. variant.lVal = counter->GetValue () ;
  5449. }
  5450. cimType = CIM_UINT32;
  5451. status = TRUE ;
  5452. }
  5453. else if ( typeid ( *propertyValue ) == typeid ( SnmpCounter64Type ) )
  5454. {
  5455. SnmpCounter64Type *counter = ( SnmpCounter64Type * ) propertyValue ;
  5456. if ( counter->IsNull () )
  5457. {
  5458. variant.vt = VT_NULL ;
  5459. }
  5460. else
  5461. {
  5462. variant.vt = VT_BSTR ;
  5463. wchar_t *value = counter->GetStringValue () ;
  5464. variant.bstrVal = SysAllocString ( value ) ;
  5465. delete [] value ;
  5466. }
  5467. cimType = CIM_STRING;
  5468. status = TRUE ;
  5469. }
  5470. else if ( typeid ( *propertyValue ) == typeid ( SnmpGaugeType ) )
  5471. {
  5472. SnmpGaugeType *gauge = ( SnmpGaugeType * ) propertyValue ;
  5473. if ( gauge->IsNull () )
  5474. {
  5475. variant.vt = VT_NULL ;
  5476. }
  5477. else
  5478. {
  5479. variant.vt = VT_I4 ;
  5480. variant.lVal = gauge->GetValue () ;
  5481. }
  5482. cimType = CIM_UINT32;
  5483. status = TRUE ;
  5484. }
  5485. else if ( typeid ( *propertyValue ) == typeid ( SnmpFixedLengthOctetStringType ) )
  5486. {
  5487. SnmpFixedLengthOctetStringType *octetString = ( SnmpFixedLengthOctetStringType * ) propertyValue ;
  5488. if ( octetString->IsNull () )
  5489. {
  5490. variant.vt = VT_NULL ;
  5491. }
  5492. else
  5493. {
  5494. variant.vt = VT_BSTR ;
  5495. wchar_t *value = octetString->GetStringValue () ;
  5496. variant.bstrVal = SysAllocString ( value ) ;
  5497. delete [] value ;
  5498. }
  5499. cimType = CIM_STRING;
  5500. status = TRUE ;
  5501. }
  5502. else if ( typeid ( *propertyValue ) == typeid ( SnmpOctetStringType ) )
  5503. {
  5504. SnmpOctetStringType *octetString = ( SnmpOctetStringType * ) propertyValue ;
  5505. if ( octetString->IsNull () )
  5506. {
  5507. variant.vt = VT_NULL ;
  5508. }
  5509. else
  5510. {
  5511. variant.vt = VT_BSTR ;
  5512. wchar_t *value = octetString->GetStringValue () ;
  5513. variant.bstrVal = SysAllocString ( value ) ;
  5514. delete [] value ;
  5515. }
  5516. cimType = CIM_STRING;
  5517. status = TRUE ;
  5518. }
  5519. else if ( typeid ( *propertyValue ) == typeid ( SnmpObjectIdentifierType ) )
  5520. {
  5521. SnmpObjectIdentifierType *objectIdentifier = ( SnmpObjectIdentifierType * ) propertyValue ;
  5522. if ( objectIdentifier->IsNull () )
  5523. {
  5524. variant.vt = VT_NULL ;
  5525. }
  5526. else
  5527. {
  5528. variant.vt = VT_BSTR ;
  5529. wchar_t *value = objectIdentifier->GetStringValue () ;
  5530. variant.bstrVal = SysAllocString ( value ) ;
  5531. delete [] value ;
  5532. }
  5533. cimType = CIM_STRING;
  5534. status = TRUE ;
  5535. }
  5536. else if ( typeid ( *propertyValue ) == typeid ( SnmpNullType ) )
  5537. {
  5538. variant.vt = VT_NULL ;
  5539. cimType = CIM_EMPTY;
  5540. status = TRUE ;
  5541. }
  5542. else if ( typeid ( *propertyValue ) == typeid ( SnmpIpAddressType ) )
  5543. {
  5544. SnmpIpAddressType *ipAddress = ( SnmpIpAddressType * ) propertyValue ;
  5545. if ( ipAddress->IsNull () )
  5546. {
  5547. variant.vt = VT_NULL ;
  5548. }
  5549. else
  5550. {
  5551. variant.vt = VT_BSTR ;
  5552. wchar_t *value = ipAddress->GetStringValue () ;
  5553. variant.bstrVal = SysAllocString ( value ) ;
  5554. delete [] value ;
  5555. }
  5556. cimType = CIM_STRING;
  5557. status = TRUE ;
  5558. }
  5559. else if ( typeid ( *propertyValue ) == typeid ( SnmpTimeTicksType ) )
  5560. {
  5561. SnmpTimeTicksType *timeTicks = ( SnmpTimeTicksType * ) propertyValue ;
  5562. if ( timeTicks->IsNull () )
  5563. {
  5564. variant.vt = VT_NULL ;
  5565. }
  5566. else
  5567. {
  5568. variant.vt = VT_I4 ;
  5569. variant.lVal = timeTicks->GetValue () ;
  5570. }
  5571. cimType = CIM_SINT32;
  5572. status = TRUE ;
  5573. }
  5574. else if ( typeid ( *propertyValue ) == typeid ( SnmpFixedLengthOpaqueType ) )
  5575. {
  5576. SnmpFixedLengthOpaqueType *opaque = ( SnmpFixedLengthOpaqueType * ) propertyValue ;
  5577. if ( opaque->IsNull () )
  5578. {
  5579. variant.vt = VT_NULL ;
  5580. }
  5581. else
  5582. {
  5583. variant.vt = VT_BSTR ;
  5584. wchar_t *value = opaque->GetStringValue () ;
  5585. variant.bstrVal = SysAllocString ( value ) ;
  5586. delete [] value ;
  5587. }
  5588. cimType = CIM_STRING;
  5589. status = TRUE ;
  5590. }
  5591. else if ( typeid ( *propertyValue ) == typeid ( SnmpOpaqueType ) )
  5592. {
  5593. SnmpOpaqueType *opaque = ( SnmpOpaqueType * ) propertyValue ;
  5594. if ( opaque->IsNull () )
  5595. {
  5596. variant.vt = VT_NULL ;
  5597. }
  5598. else
  5599. {
  5600. variant.vt = VT_BSTR ;
  5601. wchar_t *value = opaque->GetStringValue () ;
  5602. variant.bstrVal = SysAllocString ( value ) ;
  5603. delete [] value ;
  5604. }
  5605. cimType = CIM_STRING;
  5606. status = TRUE ;
  5607. }
  5608. else if ( typeid ( *propertyValue ) == typeid ( SnmpNetworkAddressType ) )
  5609. {
  5610. SnmpNetworkAddressType *networkAddress = ( SnmpNetworkAddressType * ) propertyValue ;
  5611. if ( networkAddress->IsNull () )
  5612. {
  5613. variant.vt = VT_NULL ;
  5614. }
  5615. else
  5616. {
  5617. variant.vt = VT_BSTR ;
  5618. wchar_t *value = networkAddress->GetStringValue () ;
  5619. variant.bstrVal = SysAllocString ( value ) ;
  5620. delete [] value ;
  5621. }
  5622. cimType = CIM_STRING;
  5623. status = TRUE ;
  5624. }
  5625. else if ( typeid ( *propertyValue ) == typeid ( SnmpFixedLengthDisplayStringType ) )
  5626. {
  5627. SnmpFixedLengthDisplayStringType *displayString = ( SnmpFixedLengthDisplayStringType * ) propertyValue ;
  5628. if ( displayString->IsNull () )
  5629. {
  5630. variant.vt = VT_NULL ;
  5631. }
  5632. else
  5633. {
  5634. variant.vt = VT_BSTR ;
  5635. wchar_t *value = displayString->GetStringValue () ;
  5636. variant.bstrVal = SysAllocString ( value ) ;
  5637. delete [] value ;
  5638. }
  5639. cimType = CIM_STRING;
  5640. status = TRUE ;
  5641. }
  5642. else if ( typeid ( *propertyValue ) == typeid ( SnmpDisplayStringType ) )
  5643. {
  5644. SnmpDisplayStringType *displayString = ( SnmpDisplayStringType * ) propertyValue ;
  5645. if ( displayString->IsNull () )
  5646. {
  5647. variant.vt = VT_NULL ;
  5648. }
  5649. else
  5650. {
  5651. variant.vt = VT_BSTR ;
  5652. wchar_t *value = displayString->GetStringValue () ;
  5653. variant.bstrVal = SysAllocString ( value ) ;
  5654. delete [] value ;
  5655. }
  5656. cimType = CIM_STRING;
  5657. status = TRUE ;
  5658. }
  5659. else if ( typeid ( *propertyValue ) == typeid ( SnmpMacAddressType ) )
  5660. {
  5661. SnmpMacAddressType *macAddress = ( SnmpMacAddressType * ) propertyValue ;
  5662. if ( macAddress->IsNull () )
  5663. {
  5664. variant.vt = VT_NULL ;
  5665. }
  5666. else
  5667. {
  5668. variant.vt = VT_BSTR ;
  5669. wchar_t *value = macAddress->GetStringValue () ;
  5670. variant.bstrVal = SysAllocString ( value ) ;
  5671. delete [] value ;
  5672. }
  5673. cimType = CIM_STRING;
  5674. status = TRUE ;
  5675. }
  5676. else if ( typeid ( *propertyValue ) == typeid ( SnmpPhysAddressType ) )
  5677. {
  5678. SnmpPhysAddressType *physAddress = ( SnmpPhysAddressType * ) propertyValue ;
  5679. if ( physAddress->IsNull () )
  5680. {
  5681. variant.vt = VT_NULL ;
  5682. }
  5683. else
  5684. {
  5685. variant.vt = VT_BSTR ;
  5686. wchar_t *value = physAddress->GetStringValue () ;
  5687. variant.bstrVal = SysAllocString ( value ) ;
  5688. delete [] value ;
  5689. }
  5690. cimType = CIM_STRING;
  5691. status = TRUE ;
  5692. }
  5693. else if ( typeid ( *propertyValue ) == typeid ( SnmpEnumeratedType ) )
  5694. {
  5695. SnmpEnumeratedType *enumeration = ( SnmpEnumeratedType * ) propertyValue ;
  5696. if ( enumeration->IsNull () )
  5697. {
  5698. variant.vt = VT_NULL ;
  5699. }
  5700. else
  5701. {
  5702. variant.vt = VT_BSTR ;
  5703. wchar_t *value = enumeration->GetStringValue () ;
  5704. variant.bstrVal = SysAllocString ( value ) ;
  5705. delete [] value ;
  5706. }
  5707. cimType = CIM_STRING;
  5708. status = TRUE ;
  5709. }
  5710. else if ( typeid ( *propertyValue ) == typeid ( SnmpBitStringType ) )
  5711. {
  5712. SnmpBitStringType *bitString = ( SnmpBitStringType * ) propertyValue ;
  5713. if ( bitString->IsNull () )
  5714. {
  5715. variant.vt = VT_NULL ;
  5716. }
  5717. else
  5718. {
  5719. wchar_t **array ;
  5720. LONG count = bitString->GetValue ( array ) ;
  5721. SAFEARRAY *safeArray ;
  5722. SAFEARRAYBOUND safeArrayBounds [ 1 ] ;
  5723. safeArrayBounds[0].lLbound = 0 ;
  5724. safeArrayBounds[0].cElements = count ;
  5725. safeArray = SafeArrayCreate ( VT_BSTR , 1 , safeArrayBounds ) ;
  5726. for ( LONG index = 0 ; index < count ; index ++ )
  5727. {
  5728. BSTR element = SysAllocString ( array [ index ] ) ;
  5729. SafeArrayPutElement ( safeArray , & index , element ) ;
  5730. SysFreeString ( element ) ;
  5731. delete [] ( array [ index ] ) ;
  5732. }
  5733. delete [] array ;
  5734. variant.vt = VT_ARRAY | VT_BSTR ;
  5735. variant.parray = safeArray ;
  5736. }
  5737. cimType = CIM_STRING | CIM_FLAG_ARRAY;
  5738. status = TRUE ;
  5739. }
  5740. else if ( typeid ( *propertyValue ) == typeid ( SnmpDateTimeType ) )
  5741. {
  5742. SnmpDateTimeType *dateTime = ( SnmpDateTimeType * ) propertyValue ;
  5743. if ( dateTime->IsNull () )
  5744. {
  5745. variant.vt = VT_NULL ;
  5746. }
  5747. else
  5748. {
  5749. variant.vt = VT_BSTR ;
  5750. wchar_t *value = dateTime->GetStringValue () ;
  5751. variant.bstrVal = SysAllocString ( value ) ;
  5752. delete [] value ;
  5753. }
  5754. cimType = CIM_STRING;
  5755. status = TRUE ;
  5756. }
  5757. else if ( typeid ( *propertyValue ) == typeid ( SnmpOSIAddressType ) )
  5758. {
  5759. SnmpOSIAddressType *osiAddress = ( SnmpOSIAddressType * ) propertyValue ;
  5760. if ( osiAddress->IsNull () )
  5761. {
  5762. variant.vt = VT_NULL ;
  5763. }
  5764. else
  5765. {
  5766. variant.vt = VT_BSTR ;
  5767. wchar_t *value = osiAddress->GetStringValue () ;
  5768. variant.bstrVal = SysAllocString ( value ) ;
  5769. delete [] value ;
  5770. }
  5771. cimType = CIM_STRING;
  5772. status = TRUE ;
  5773. }
  5774. else if ( typeid ( *propertyValue ) == typeid ( SnmpUDPAddressType ) )
  5775. {
  5776. SnmpUDPAddressType *udpAddress = ( SnmpUDPAddressType * ) propertyValue ;
  5777. if ( udpAddress->IsNull () )
  5778. {
  5779. variant.vt = VT_NULL ;
  5780. }
  5781. else
  5782. {
  5783. variant.vt = VT_BSTR ;
  5784. wchar_t *value = udpAddress->GetStringValue () ;
  5785. variant.bstrVal = SysAllocString ( value ) ;
  5786. delete [] value ;
  5787. }
  5788. cimType = CIM_STRING;
  5789. status = TRUE ;
  5790. }
  5791. else if ( typeid ( *propertyValue ) == typeid ( SnmpIPXAddressType ) )
  5792. {
  5793. SnmpIPXAddressType *ipxAddress = ( SnmpIPXAddressType * ) propertyValue ;
  5794. if ( ipxAddress->IsNull () )
  5795. {
  5796. variant.vt = VT_NULL ;
  5797. }
  5798. else
  5799. {
  5800. variant.vt = VT_BSTR ;
  5801. wchar_t *value = ipxAddress->GetStringValue () ;
  5802. variant.bstrVal = SysAllocString ( value ) ;
  5803. delete [] value ;
  5804. }
  5805. cimType = CIM_STRING;
  5806. status = TRUE ;
  5807. }
  5808. else if ( typeid ( *propertyValue ) == typeid ( SnmpRowStatusType ) )
  5809. {
  5810. SnmpRowStatusType *rowStatus = ( SnmpRowStatusType * ) propertyValue ;
  5811. if ( rowStatus->IsNull () )
  5812. {
  5813. variant.vt = VT_NULL ;
  5814. }
  5815. else
  5816. {
  5817. variant.vt = VT_BSTR ;
  5818. wchar_t *value = rowStatus->GetStringValue () ;
  5819. variant.bstrVal = SysAllocString ( value ) ;
  5820. delete [] value ;
  5821. }
  5822. cimType = CIM_STRING;
  5823. status = TRUE ;
  5824. }
  5825. }
  5826. return status ;
  5827. }
  5828. VARTYPE WbemSnmpProperty :: GetValueVariantType () const
  5829. {
  5830. VARTYPE varType = VT_NULL ;
  5831. if ( propertyValue && ! ( propertyValue->IsNull () ) )
  5832. {
  5833. varType = GetValueVariantEncodedType () ;
  5834. }
  5835. else
  5836. {
  5837. VT_NULL ;
  5838. }
  5839. return varType ;
  5840. }
  5841. VARTYPE WbemSnmpProperty :: GetValueVariantEncodedType () const
  5842. {
  5843. VARTYPE varType = VT_NULL ;
  5844. WbemSnmpQualifier *qualifier = FindQualifier ( WBEM_QUALIFIER_TEXTUAL_CONVENTION ) ;
  5845. if ( qualifier )
  5846. {
  5847. SnmpDisplayStringType *displayString = ( SnmpDisplayStringType * ) qualifier->GetValue () ;
  5848. wchar_t *textualConvention = displayString->GetValue () ;
  5849. if ( textualConvention )
  5850. {
  5851. if ( _wcsicmp ( textualConvention , WBEM_TYPE_INTEGER ) == 0 )
  5852. {
  5853. varType = VT_I4 ;
  5854. }
  5855. else if ( _wcsicmp ( textualConvention , WBEM_TYPE_INTEGER32 ) == 0 )
  5856. {
  5857. varType = VT_UI4 ;
  5858. }
  5859. else if ( _wcsicmp ( textualConvention , WBEM_TYPE_COUNTER ) == 0 )
  5860. {
  5861. varType = VT_UI4 ;
  5862. }
  5863. else if ( _wcsicmp ( textualConvention , WBEM_TYPE_COUNTER32 ) == 0 )
  5864. {
  5865. varType = VT_UI4 ;
  5866. }
  5867. else if ( _wcsicmp ( textualConvention , WBEM_TYPE_COUNTER64 ) == 0 )
  5868. {
  5869. varType = VT_BSTR ;
  5870. }
  5871. else if ( _wcsicmp ( textualConvention , WBEM_TYPE_GAUGE ) == 0 )
  5872. {
  5873. varType = VT_UI4 ;
  5874. }
  5875. else if ( _wcsicmp ( textualConvention , WBEM_TYPE_GAUGE32 ) == 0 )
  5876. {
  5877. varType = VT_UI4 ;
  5878. }
  5879. else if ( _wcsicmp ( textualConvention , WBEM_TYPE_UNSIGNED32 ) == 0 )
  5880. {
  5881. varType = VT_UI4 ;
  5882. }
  5883. else if ( _wcsicmp ( textualConvention , WBEM_TYPE_OCTETSTRING ) == 0 )
  5884. {
  5885. varType = VT_BSTR ;
  5886. }
  5887. else if ( _wcsicmp ( textualConvention , WBEM_TYPE_OBJECTIDENTIFIER ) == 0 )
  5888. {
  5889. varType = VT_BSTR ;
  5890. }
  5891. else if ( _wcsicmp ( textualConvention , WBEM_TYPE_NULL ) == 0 )
  5892. {
  5893. varType = VT_NULL ;
  5894. }
  5895. else if ( _wcsicmp ( textualConvention , WBEM_TYPE_IPADDRESS ) == 0 )
  5896. {
  5897. varType = VT_BSTR ;
  5898. }
  5899. else if ( _wcsicmp ( textualConvention , WBEM_TYPE_TIMETICKS ) == 0 )
  5900. {
  5901. varType = VT_UI4 ;
  5902. }
  5903. else if ( _wcsicmp ( textualConvention , WBEM_TYPE_OPAQUE ) == 0 )
  5904. {
  5905. varType = VT_BSTR ;
  5906. }
  5907. else if ( _wcsicmp ( textualConvention , WBEM_TYPE_NETWORKADDRESS ) == 0 )
  5908. {
  5909. varType = VT_BSTR ;
  5910. }
  5911. else if ( _wcsicmp ( textualConvention , WBEM_TYPE_DISPLAYSTRING ) == 0 )
  5912. {
  5913. varType = VT_BSTR ;
  5914. }
  5915. else if ( _wcsicmp ( textualConvention , WBEM_TYPE_MACADDRESS ) == 0 )
  5916. {
  5917. varType = VT_BSTR ;
  5918. }
  5919. else if ( _wcsicmp ( textualConvention , WBEM_TYPE_PHYSADDRESS ) == 0 )
  5920. {
  5921. varType = VT_BSTR ;
  5922. }
  5923. else if ( _wcsicmp ( textualConvention , WBEM_TYPE_ENUMERATEDINTEGER ) == 0 )
  5924. {
  5925. varType = VT_BSTR ;
  5926. }
  5927. else if ( _wcsicmp ( textualConvention , WBEM_TYPE_BITS ) == 0 )
  5928. {
  5929. varType = VT_BSTR | VT_ARRAY ;
  5930. }
  5931. else if ( _wcsicmp ( textualConvention , WBEM_TYPE_DATETIME ) == 0 )
  5932. {
  5933. varType = VT_BSTR ;
  5934. }
  5935. else if ( _wcsicmp ( textualConvention , WBEM_TYPE_SNMPOSIADDRESS ) == 0 )
  5936. {
  5937. varType = VT_BSTR ;
  5938. }
  5939. else if ( _wcsicmp ( textualConvention , WBEM_TYPE_SNMPIPXADDRESS ) == 0 )
  5940. {
  5941. varType = VT_BSTR ;
  5942. }
  5943. else if ( _wcsicmp ( textualConvention , WBEM_TYPE_SNMPUDPADDRESS ) == 0 )
  5944. {
  5945. varType = VT_BSTR ;
  5946. }
  5947. else if ( _wcsicmp ( textualConvention , WBEM_TYPE_ROWSTATUS ) == 0 )
  5948. {
  5949. varType = VT_BSTR ;
  5950. }
  5951. else
  5952. {
  5953. WbemSnmpQualifier *qualifier = FindQualifier ( WBEM_QUALIFIER_ENCODING ) ;
  5954. if ( qualifier )
  5955. {
  5956. SnmpDisplayStringType *displayString = ( SnmpDisplayStringType * ) qualifier->GetValue () ;
  5957. wchar_t *encoding = displayString->GetValue () ;
  5958. if ( encoding )
  5959. {
  5960. if ( _wcsicmp ( encoding , WBEM_TYPE_INTEGER ) == 0 )
  5961. {
  5962. varType = VT_I4 ;
  5963. }
  5964. else if ( _wcsicmp ( encoding , WBEM_TYPE_INTEGER32 ) == 0 )
  5965. {
  5966. varType = VT_UI4 ;
  5967. }
  5968. else if ( _wcsicmp ( encoding , WBEM_TYPE_COUNTER ) == 0 )
  5969. {
  5970. varType = VT_UI4 ;
  5971. }
  5972. else if ( _wcsicmp ( encoding , WBEM_TYPE_COUNTER32 ) == 0 )
  5973. {
  5974. varType = VT_UI4 ;
  5975. }
  5976. else if ( _wcsicmp ( encoding , WBEM_TYPE_COUNTER64 ) == 0 )
  5977. {
  5978. varType = VT_BSTR ;
  5979. }
  5980. else if ( _wcsicmp ( encoding , WBEM_TYPE_GAUGE ) == 0 )
  5981. {
  5982. varType = VT_UI4 ;
  5983. }
  5984. else if ( _wcsicmp ( encoding , WBEM_TYPE_GAUGE ) == 0 )
  5985. {
  5986. varType = VT_UI4 ;
  5987. }
  5988. else if ( _wcsicmp ( encoding , WBEM_TYPE_UNSIGNED32 ) == 0 )
  5989. {
  5990. varType = VT_UI4 ;
  5991. }
  5992. else if ( _wcsicmp ( encoding , WBEM_TYPE_OCTETSTRING ) == 0 )
  5993. {
  5994. varType = VT_BSTR ;
  5995. }
  5996. else if ( _wcsicmp ( encoding , WBEM_TYPE_OBJECTIDENTIFIER ) == 0 )
  5997. {
  5998. varType = VT_BSTR ;
  5999. }
  6000. else if ( _wcsicmp ( encoding , WBEM_TYPE_NULL ) == 0 )
  6001. {
  6002. varType = VT_NULL ;
  6003. }
  6004. else if ( _wcsicmp ( encoding , WBEM_TYPE_IPADDRESS ) == 0 )
  6005. {
  6006. varType = VT_BSTR ;
  6007. }
  6008. else if ( _wcsicmp ( encoding , WBEM_TYPE_TIMETICKS ) == 0 )
  6009. {
  6010. varType = VT_UI4 ;
  6011. }
  6012. else if ( _wcsicmp ( encoding , WBEM_TYPE_OPAQUE ) == 0 )
  6013. {
  6014. varType = VT_BSTR ;
  6015. }
  6016. else if ( _wcsicmp ( encoding , WBEM_TYPE_NETWORKADDRESS ) == 0 )
  6017. {
  6018. varType = VT_BSTR ;
  6019. }
  6020. }
  6021. delete [] encoding ;
  6022. }
  6023. }
  6024. delete [] textualConvention ;
  6025. }
  6026. }
  6027. return varType ;
  6028. }
  6029. BOOL WbemSnmpProperty :: Check ( WbemSnmpErrorObject &a_errorObject )
  6030. {
  6031. return FALSE ;
  6032. }
  6033. BOOL WbemSnmpProperty :: AddQualifier ( WbemSnmpQualifier *a_qualifier )
  6034. {
  6035. DebugMacro7(
  6036. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  6037. __FILE__,__LINE__,
  6038. L"WbemSnmpProperty :: AddQualifier ( (%s) )" ,
  6039. a_qualifier->GetName ()
  6040. ) ;
  6041. )
  6042. BOOL status = TRUE ;
  6043. ULONG stringItem ;
  6044. if ( validQualifierMap.Lookup ( a_qualifier->GetName () , stringItem ) )
  6045. {
  6046. qualifierPosition = NULL ;
  6047. WbemSnmpQualifier *qualifier ;
  6048. if ( qualifierMap.Lookup ( a_qualifier->GetName () , qualifier ) )
  6049. {
  6050. delete a_qualifier;
  6051. }
  6052. else
  6053. {
  6054. qualifierMap [ a_qualifier->GetName () ] = a_qualifier ;
  6055. }
  6056. }
  6057. else
  6058. {
  6059. delete a_qualifier;
  6060. status = FALSE ;
  6061. }
  6062. return status ;
  6063. }
  6064. BOOL WbemSnmpProperty :: AddQualifier ( wchar_t *qualifierName )
  6065. {
  6066. DebugMacro7(
  6067. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  6068. __FILE__,__LINE__,
  6069. L"WbemSnmpProperty :: AddQualifier ( (%s) )" ,
  6070. qualifierName
  6071. ) ;
  6072. )
  6073. BOOL status = TRUE ;
  6074. ULONG stringItem ;
  6075. if ( validQualifierMap.Lookup ( qualifierName , stringItem ) )
  6076. {
  6077. qualifierPosition = NULL ;
  6078. WbemSnmpQualifier *qualifier ;
  6079. if ( qualifierMap.Lookup ( qualifierName , qualifier ) )
  6080. {
  6081. }
  6082. else
  6083. {
  6084. qualifier = new WbemSnmpQualifier ( qualifierName , NULL ) ;
  6085. qualifierMap [ qualifier->GetName () ] = qualifier ;
  6086. }
  6087. }
  6088. else
  6089. {
  6090. status = FALSE ;
  6091. }
  6092. return status ;
  6093. }
  6094. ULONG WbemSnmpProperty :: GetQualifierCount ()
  6095. {
  6096. DebugMacro7( SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine ( __FILE__,__LINE__,L"WbemSnmpProperty :: GetQualifierCount" ) )
  6097. return qualifierMap.GetCount () ;
  6098. }
  6099. void WbemSnmpProperty :: ResetQualifier ()
  6100. {
  6101. DebugMacro7( SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine ( __FILE__,__LINE__,L"WbemSnmpProperty :: ResetQualifier" ) )
  6102. qualifierPosition = qualifierMap.GetStartPosition () ;
  6103. }
  6104. WbemSnmpQualifier *WbemSnmpProperty :: NextQualifier ()
  6105. {
  6106. DebugMacro7( SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine ( __FILE__,__LINE__,L"WbemSnmpProperty :: NextQualifier" ) )
  6107. wchar_t *qualifierKey ;
  6108. WbemSnmpQualifier *qualifier = NULL ;
  6109. if ( qualifierPosition )
  6110. {
  6111. qualifierMap.GetNextAssoc ( qualifierPosition , qualifierKey , qualifier ) ;
  6112. }
  6113. return qualifier ;
  6114. }
  6115. WbemSnmpQualifier *WbemSnmpProperty :: FindQualifier ( wchar_t *qualifierName ) const
  6116. {
  6117. DebugMacro7(
  6118. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  6119. __FILE__,__LINE__,
  6120. L"WbemSnmpProperty :: FindQualifier (%s)" ,
  6121. qualifierName
  6122. )
  6123. )
  6124. WbemSnmpQualifier *qualifier = NULL ;
  6125. if ( qualifierMap.Lookup ( qualifierName , qualifier ) )
  6126. {
  6127. }
  6128. return qualifier ;
  6129. }
  6130. WbemSnmpClassObject :: WbemSnmpClassObject (
  6131. const wchar_t *classNameArg ,
  6132. const BOOL isClass
  6133. ) : className ( NULL ),
  6134. qualifierPosition ( NULL ) ,
  6135. propertyPosition ( NULL ) ,
  6136. keyedPropertyPosition ( 1 ) ,
  6137. m_isClass ( isClass ) ,
  6138. m_isKeyed ( FALSE ) ,
  6139. m_isSingleton ( FALSE ) ,
  6140. m_isVirtual ( FALSE ) ,
  6141. m_isReadable ( FALSE ) ,
  6142. m_isWritable ( FALSE ) ,
  6143. m_numberOfAccessible ( 0 )
  6144. {
  6145. DebugMacro7( SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine ( __FILE__,__LINE__,L"WbemSnmpClassObject :: WbemSnmpClassObject" ) )
  6146. className = new wchar_t [ wcslen ( classNameArg ) + 1 ] ;
  6147. wcscpy ( className , classNameArg ) ;
  6148. }
  6149. WbemSnmpClassObject :: WbemSnmpClassObject () : className ( NULL ) ,
  6150. qualifierPosition ( NULL ) ,
  6151. propertyPosition ( NULL ) ,
  6152. keyedPropertyPosition ( 1 ) ,
  6153. m_isClass ( TRUE ) ,
  6154. m_isKeyed ( FALSE ) ,
  6155. m_isSingleton ( FALSE ) ,
  6156. m_isVirtual ( FALSE ) ,
  6157. m_isReadable ( FALSE ) ,
  6158. m_isWritable ( FALSE ) ,
  6159. m_numberOfAccessible ( 0 )
  6160. {
  6161. DebugMacro7( SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine ( __FILE__,__LINE__,L"WbemSnmpClassObject :: WbemSnmpClassObject" ) )
  6162. }
  6163. WbemSnmpClassObject :: WbemSnmpClassObject (
  6164. const WbemSnmpClassObject & copy
  6165. ) : className ( NULL ) ,
  6166. qualifierPosition ( NULL ) ,
  6167. propertyPosition ( NULL ) ,
  6168. keyedPropertyPosition ( 1 ) ,
  6169. m_isClass ( copy.m_isClass ) ,
  6170. m_isKeyed ( copy.m_isKeyed ) ,
  6171. m_isSingleton ( copy.m_isSingleton ) ,
  6172. m_isVirtual ( copy.m_isVirtual ) ,
  6173. m_isReadable ( copy.m_isReadable ) ,
  6174. m_isWritable ( copy.m_isWritable ) ,
  6175. m_numberOfAccessible ( copy.m_numberOfAccessible )
  6176. {
  6177. DebugMacro7( SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine ( __FILE__,__LINE__,L"WbemSnmpClassObject :: WbemSnmpClassObject" ) )
  6178. if ( copy.className )
  6179. {
  6180. className = new wchar_t [ wcslen ( copy.className ) + 1 ] ;
  6181. wcscpy ( className , copy.className ) ;
  6182. }
  6183. POSITION position = copy.propertyMap.GetStartPosition () ;
  6184. while ( position )
  6185. {
  6186. wchar_t *propertyName ;
  6187. WbemSnmpProperty *property ;
  6188. copy.propertyMap.GetNextAssoc ( position , propertyName , property ) ;
  6189. WbemSnmpProperty *copyProperty = new WbemSnmpProperty ( *property ) ;
  6190. propertyMap [ copyProperty->GetName () ] = copyProperty ;
  6191. }
  6192. position = copy.qualifierMap.GetStartPosition () ;
  6193. while ( position )
  6194. {
  6195. wchar_t *qualifierName ;
  6196. WbemSnmpQualifier *qualifier ;
  6197. copy.qualifierMap.GetNextAssoc ( position , qualifierName , qualifier ) ;
  6198. WbemSnmpQualifier *copyQualifier = new WbemSnmpQualifier ( *qualifier ) ;
  6199. qualifierMap [ copyQualifier->GetName () ] = copyQualifier ;
  6200. }
  6201. position = copy.keyedPropertyList.GetHeadPosition () ;
  6202. while ( position )
  6203. {
  6204. WbemSnmpProperty *keyProperty = copy.keyedPropertyList.GetNext ( position ) ;
  6205. WbemSnmpProperty *property ;
  6206. if ( propertyMap.Lookup ( keyProperty->GetName () , property ) )
  6207. {
  6208. keyedPropertyList.AddTail ( property ) ;
  6209. }
  6210. }
  6211. }
  6212. WbemSnmpClassObject :: ~WbemSnmpClassObject ()
  6213. {
  6214. DebugMacro7( SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine ( __FILE__,__LINE__,L"WbemSnmpClassObject :: ~WbemSnmpClassObject ()" ) )
  6215. delete [] className ;
  6216. keyedPropertyList.RemoveAll () ;
  6217. POSITION position = propertyMap.GetStartPosition () ;
  6218. while ( position )
  6219. {
  6220. wchar_t *propertyName ;
  6221. WbemSnmpProperty *property ;
  6222. propertyMap.GetNextAssoc ( position , propertyName , property ) ;
  6223. delete property ;
  6224. }
  6225. propertyMap.RemoveAll () ;
  6226. position = qualifierMap.GetStartPosition () ;
  6227. while ( position )
  6228. {
  6229. wchar_t *qualifierName ;
  6230. WbemSnmpQualifier *qualifier ;
  6231. qualifierMap.GetNextAssoc ( position , qualifierName , qualifier ) ;
  6232. delete qualifier ;
  6233. }
  6234. qualifierMap.RemoveAll () ;
  6235. }
  6236. void WbemSnmpClassObject :: SetKeyed ( BOOL a_isKeyed )
  6237. {
  6238. m_isKeyed = a_isKeyed ;
  6239. }
  6240. BOOL WbemSnmpClassObject :: IsKeyed ()
  6241. {
  6242. return m_isKeyed ;
  6243. }
  6244. void WbemSnmpClassObject :: SetSingleton ( BOOL a_isSingleton )
  6245. {
  6246. m_isSingleton = a_isSingleton ;
  6247. }
  6248. BOOL WbemSnmpClassObject :: IsSingleton ()
  6249. {
  6250. return m_isSingleton ;
  6251. }
  6252. void WbemSnmpClassObject :: SetVirtual ( BOOL a_isVirtual )
  6253. {
  6254. m_isVirtual = a_isVirtual ;
  6255. }
  6256. BOOL WbemSnmpClassObject :: IsVirtual ()
  6257. {
  6258. return m_isVirtual ;
  6259. }
  6260. BOOL WbemSnmpClassObject :: IsWritable ()
  6261. {
  6262. return m_isWritable ;
  6263. }
  6264. BOOL WbemSnmpClassObject :: IsReadable ()
  6265. {
  6266. return m_isReadable ;
  6267. }
  6268. ULONG WbemSnmpClassObject :: GetNumberOfAccessible ()
  6269. {
  6270. return m_numberOfAccessible ;
  6271. }
  6272. void WbemSnmpClassObject :: SetWritable ( BOOL a_isWritable )
  6273. {
  6274. m_isWritable = a_isWritable ;
  6275. }
  6276. void WbemSnmpClassObject :: SetReadable ( BOOL a_isReadable )
  6277. {
  6278. m_isReadable = a_isReadable ;
  6279. }
  6280. void WbemSnmpClassObject :: SetNumberOfAccessible ( ULONG a_numberOfAccessible )
  6281. {
  6282. m_numberOfAccessible = a_numberOfAccessible ;
  6283. }
  6284. wchar_t *WbemSnmpClassObject :: GetClassName () const
  6285. {
  6286. return className ;
  6287. }
  6288. BOOL WbemSnmpClassObject :: Check ( WbemSnmpErrorObject &a_errorObject )
  6289. {
  6290. return FALSE ;
  6291. }
  6292. void WbemSnmpClassObject :: AddKeyedProperty ( WbemSnmpProperty *snmpProperty )
  6293. {
  6294. DebugMacro7(
  6295. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  6296. __FILE__,__LINE__,
  6297. L"WbemSnmpClassObject :: AddKeyedProperty ( (%s) )" ,
  6298. snmpProperty->GetName ()
  6299. ) ;
  6300. )
  6301. WbemSnmpProperty *t_snmpProperty = FindProperty ( snmpProperty->GetName () ) ;
  6302. if ( t_snmpProperty )
  6303. {
  6304. keyedPropertyList.AddTail ( snmpProperty ) ;
  6305. }
  6306. }
  6307. BOOL WbemSnmpClassObject :: AddKeyedProperty ( wchar_t *propertyName )
  6308. {
  6309. DebugMacro7(
  6310. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  6311. __FILE__,__LINE__,
  6312. L"WbemSnmpClassObject :: AddKeyedProperty ( (%s) )" ,
  6313. propertyName
  6314. ) ;
  6315. )
  6316. WbemSnmpProperty *snmpProperty = FindProperty ( propertyName ) ;
  6317. if ( snmpProperty )
  6318. {
  6319. AddKeyedProperty ( snmpProperty ) ;
  6320. }
  6321. return snmpProperty ? TRUE : FALSE ;
  6322. }
  6323. ULONG WbemSnmpClassObject :: GetKeyPropertyCount ()
  6324. {
  6325. DebugMacro7( SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine ( __FILE__,__LINE__,L"WbemSnmpClassObject :: GetKeyPropertyCount" ) )
  6326. return keyedPropertyList.GetCount () ;
  6327. }
  6328. void WbemSnmpClassObject :: ResetKeyProperty ()
  6329. {
  6330. DebugMacro7( SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine ( __FILE__,__LINE__,L"WbemSnmpClassObject :: ResetKeyProperty" ) )
  6331. keyedPropertyPosition = 1 ;
  6332. }
  6333. WbemSnmpProperty *WbemSnmpClassObject :: NextKeyProperty ()
  6334. {
  6335. DebugMacro7( SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine ( __FILE__,__LINE__,L"WbemSnmpClassObject :: NextKeyProperty" ) )
  6336. WbemSnmpProperty *property = NULL ;
  6337. POSITION position = keyedPropertyList.GetHeadPosition () ;
  6338. while ( position )
  6339. {
  6340. WbemSnmpProperty *value = keyedPropertyList.GetNext ( position ) ;
  6341. WbemSnmpQualifier *qualifier ;
  6342. if ( qualifier = value->FindQualifier ( WBEM_QUALIFIER_KEY_ORDER ) )
  6343. {
  6344. SnmpInstanceType *typeValue = qualifier->GetValue () ;
  6345. if ( typeid ( *typeValue ) == typeid ( SnmpIntegerType ) )
  6346. {
  6347. SnmpIntegerType *integer = ( SnmpIntegerType * ) qualifier->GetValue () ;
  6348. if ( integer->GetValue () == keyedPropertyPosition )
  6349. {
  6350. property = value ;
  6351. break ;
  6352. }
  6353. }
  6354. else
  6355. {
  6356. // Problem Here
  6357. }
  6358. }
  6359. else
  6360. {
  6361. // Problem Here
  6362. }
  6363. }
  6364. keyedPropertyPosition ++ ;
  6365. return property ;
  6366. }
  6367. WbemSnmpProperty *WbemSnmpClassObject :: FindKeyProperty ( wchar_t *propertyName ) const
  6368. {
  6369. DebugMacro7(
  6370. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  6371. __FILE__,__LINE__,
  6372. L"WbemSnmpClassObject :: FindKeyProperty ( (%s)" ,
  6373. propertyName
  6374. ) ;
  6375. )
  6376. WbemSnmpProperty *property = NULL ;
  6377. POSITION position = keyedPropertyList.GetHeadPosition () ;
  6378. while ( position )
  6379. {
  6380. WbemSnmpProperty *value = keyedPropertyList.GetNext ( position ) ;
  6381. if ( _wcsicmp ( value->GetName () , propertyName ) == 0 )
  6382. {
  6383. property = value ;
  6384. break ;
  6385. }
  6386. }
  6387. return property ;
  6388. }
  6389. ULONG WbemSnmpClassObject :: GetPropertyCount ()
  6390. {
  6391. return propertyMap.GetCount () ;
  6392. }
  6393. BOOL WbemSnmpClassObject :: AddProperty ( WbemSnmpProperty *property )
  6394. {
  6395. DebugMacro7(
  6396. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  6397. __FILE__,__LINE__,
  6398. L"WbemSnmpClassObject :: AddProperty ( (%s) )" ,
  6399. property->GetName ()
  6400. ) ;
  6401. )
  6402. propertyPosition = NULL ;
  6403. WbemSnmpProperty *propertyValue ;
  6404. if ( propertyMap.Lookup ( property->GetName () , propertyValue ) )
  6405. {
  6406. delete property;
  6407. }
  6408. else
  6409. {
  6410. propertyMap [ property->GetName () ] = property ;
  6411. }
  6412. return TRUE ;
  6413. }
  6414. BOOL WbemSnmpClassObject :: AddProperty ( wchar_t *propertyName )
  6415. {
  6416. DebugMacro7(
  6417. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  6418. __FILE__,__LINE__,
  6419. L"WbemSnmpClassObject :: AddProperty ( (%s) )" ,
  6420. propertyName
  6421. ) ;
  6422. )
  6423. propertyPosition = NULL ;
  6424. WbemSnmpProperty *property ;
  6425. if ( propertyMap.Lookup ( propertyName , property ) )
  6426. {
  6427. }
  6428. else
  6429. {
  6430. property = new WbemSnmpProperty ( propertyName ) ;
  6431. propertyMap [ property->GetName () ] = property ;
  6432. }
  6433. return TRUE ;
  6434. }
  6435. void WbemSnmpClassObject :: DeleteProperty ( wchar_t *propertyName )
  6436. {
  6437. DebugMacro7(
  6438. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  6439. __FILE__,__LINE__,L"WbemSnmpClassObject :: DeleteProperty ( (%s) )" ,
  6440. propertyName
  6441. ) ;
  6442. )
  6443. propertyPosition = NULL ;
  6444. WbemSnmpProperty *property ;
  6445. if ( propertyMap.Lookup ( propertyName , property ) )
  6446. {
  6447. propertyMap.RemoveKey ( propertyName ) ;
  6448. POSITION keyPosition = keyedPropertyList.Find ( property ) ;
  6449. if ( keyPosition )
  6450. {
  6451. keyedPropertyList.RemoveAt ( keyPosition ) ;
  6452. }
  6453. else
  6454. {
  6455. // Problem Here
  6456. }
  6457. delete property ;
  6458. }
  6459. }
  6460. void WbemSnmpClassObject :: ResetProperty ()
  6461. {
  6462. DebugMacro7( SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine ( __FILE__,__LINE__,L"WbemSnmpClassObject :: ResetProperty ()" ) )
  6463. propertyPosition = propertyMap.GetStartPosition () ;
  6464. }
  6465. WbemSnmpProperty *WbemSnmpClassObject :: NextProperty ()
  6466. {
  6467. DebugMacro7( SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine ( __FILE__,__LINE__,L"WbemSnmpClassObject :: NextProperty ()" ) )
  6468. wchar_t *propertyKey ;
  6469. WbemSnmpProperty *property = NULL ;
  6470. if ( propertyPosition )
  6471. {
  6472. propertyMap.GetNextAssoc ( propertyPosition , propertyKey , property ) ;
  6473. }
  6474. return property ;
  6475. }
  6476. WbemSnmpProperty *WbemSnmpClassObject :: GetCurrentProperty ()
  6477. {
  6478. wchar_t *propertyKey ;
  6479. WbemSnmpProperty *property = NULL ;
  6480. if ( propertyPosition )
  6481. {
  6482. propertyMap.GetCurrentAssoc ( propertyPosition , propertyKey , property ) ;
  6483. }
  6484. return property ;
  6485. }
  6486. BOOL WbemSnmpClassObject :: GotoProperty ( WbemSnmpProperty *property )
  6487. {
  6488. DebugMacro7( SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine ( __FILE__,__LINE__,L"WbemSnmpClassObject :: NextProperty ()" ) )
  6489. ResetProperty () ;
  6490. WbemSnmpProperty *t_Property ;
  6491. while ( t_Property = NextProperty () )
  6492. {
  6493. if ( t_Property == property )
  6494. {
  6495. return TRUE ;
  6496. }
  6497. }
  6498. return FALSE ;
  6499. }
  6500. WbemSnmpProperty *WbemSnmpClassObject :: FindProperty ( wchar_t *propertyName ) const
  6501. {
  6502. DebugMacro7(
  6503. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  6504. __FILE__,__LINE__,L"WbemSnmpClassObject :: FindProperty (%s) " ,
  6505. propertyName
  6506. ) ;
  6507. )
  6508. WbemSnmpProperty *property = NULL ;
  6509. if ( propertyMap.Lookup ( propertyName , property ) )
  6510. {
  6511. }
  6512. return property ;
  6513. }
  6514. ULONG WbemSnmpClassObject :: GetQualifierCount ()
  6515. {
  6516. DebugMacro7( SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine ( __FILE__,__LINE__,L"WbemSnmpClassObject :: GetQualifierCount ()" ) )
  6517. return qualifierMap.GetCount () ;
  6518. }
  6519. BOOL WbemSnmpClassObject :: AddQualifier ( WbemSnmpQualifier *a_qualifier )
  6520. {
  6521. DebugMacro7(
  6522. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  6523. __FILE__,__LINE__,
  6524. L"WbemSnmpClassObject :: AddQualifier ( (%s) )" ,
  6525. a_qualifier->GetName ()
  6526. ) ;
  6527. )
  6528. BOOL status = TRUE ;
  6529. ULONG stringItem ;
  6530. if ( validQualifierMap.Lookup ( a_qualifier->GetName () , stringItem ) )
  6531. {
  6532. qualifierPosition = NULL ;
  6533. WbemSnmpQualifier *qualifier ;
  6534. if ( qualifierMap.Lookup ( a_qualifier->GetName () , qualifier ) )
  6535. {
  6536. delete a_qualifier;
  6537. }
  6538. else
  6539. {
  6540. qualifierMap [ a_qualifier->GetName () ] = a_qualifier ;
  6541. }
  6542. }
  6543. else
  6544. {
  6545. delete a_qualifier;
  6546. status = FALSE ;
  6547. }
  6548. return status ;
  6549. }
  6550. BOOL WbemSnmpClassObject :: AddQualifier ( wchar_t *qualifierName )
  6551. {
  6552. DebugMacro7(
  6553. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  6554. __FILE__,__LINE__,
  6555. L"WbemSnmpClassObject :: AddQualifier ( (%s) )" ,
  6556. qualifierName
  6557. ) ;
  6558. )
  6559. BOOL status = TRUE ;
  6560. ULONG stringItem ;
  6561. if ( validQualifierMap.Lookup ( qualifierName , stringItem ) )
  6562. {
  6563. qualifierPosition = NULL ;
  6564. WbemSnmpQualifier *qualifier ;
  6565. if ( qualifierMap.Lookup ( qualifierName , qualifier ) )
  6566. {
  6567. }
  6568. else
  6569. {
  6570. qualifier = new WbemSnmpQualifier ( qualifierName , NULL ) ;
  6571. qualifierMap [ qualifier->GetName () ] = qualifier ;
  6572. }
  6573. }
  6574. else
  6575. {
  6576. status = FALSE ;
  6577. }
  6578. return status ;
  6579. }
  6580. void WbemSnmpClassObject :: ResetQualifier ()
  6581. {
  6582. DebugMacro7( SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine ( __FILE__,__LINE__,L"WbemSnmpClassObject :: ResetQualifier" ) )
  6583. qualifierPosition = qualifierMap.GetStartPosition () ;
  6584. }
  6585. WbemSnmpQualifier *WbemSnmpClassObject :: NextQualifier ()
  6586. {
  6587. DebugMacro7( SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine ( __FILE__,__LINE__,L"WbemSnmpClassObject :: NextQualifier" ) )
  6588. wchar_t *qualifierKey ;
  6589. WbemSnmpQualifier *qualifier = NULL ;
  6590. if ( qualifierPosition )
  6591. {
  6592. qualifierMap.GetNextAssoc ( qualifierPosition , qualifierKey , qualifier ) ;
  6593. }
  6594. return qualifier ;
  6595. }
  6596. WbemSnmpQualifier *WbemSnmpClassObject :: FindQualifier ( wchar_t *qualifierName ) const
  6597. {
  6598. DebugMacro7(
  6599. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  6600. __FILE__,__LINE__,
  6601. L"WbemSnmpClassObject :: FindQualifier ( (%s) )",
  6602. qualifierName
  6603. ) ;
  6604. )
  6605. WbemSnmpQualifier *qualifier = NULL ;
  6606. if ( qualifierMap.Lookup ( qualifierName , qualifier ) )
  6607. {
  6608. }
  6609. return qualifier ;
  6610. }
  6611. BOOL WbemSnmpClassObject :: Set ( WbemSnmpErrorObject &a_errorObject , IWbemClassObject *mosClassObject , BOOL rigorous )
  6612. {
  6613. DebugMacro7(
  6614. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  6615. __FILE__,__LINE__,
  6616. L"BOOL WbemSnmpClassObject :: Set ( WbemSnmpErrorObject &a_errorObject , IWbemClassObject *mosClassObject , BOOL rigorous )"
  6617. ) ;
  6618. )
  6619. BOOL result = SetMosClassObject ( a_errorObject , mosClassObject , rigorous ) ;
  6620. return result ;
  6621. }
  6622. BOOL WbemSnmpClassObject :: SetMosClassObject ( WbemSnmpErrorObject &a_errorObject , IWbemClassObject *mosClassObject , BOOL rigorous )
  6623. {
  6624. DebugMacro7(
  6625. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  6626. __FILE__,__LINE__,
  6627. L"WbemSnmpClassObject :: SetMosClassObject ( WbemSnmpErrorObject &a_errorObject , IWbemClassObject *mosClassObject , BOOL rigorous )"
  6628. )
  6629. )
  6630. BOOL status = TRUE ;
  6631. HRESULT t_WBEM_result = WBEM_S_NO_ERROR ;
  6632. VARIANT variant ;
  6633. VariantInit ( & variant ) ;
  6634. t_WBEM_result = mosClassObject->Get ( WBEM_PROPERTY_GENUS , 0 , &variant , NULL , NULL ) ;
  6635. if ( SUCCEEDED ( t_WBEM_result ) )
  6636. {
  6637. m_isClass = ( ( variant.lVal ) == WBEM_GENUS_CLASS ) ? TRUE : FALSE ;
  6638. t_WBEM_result = mosClassObject->Get ( WBEM_PROPERTY_CLASS , 0 , &variant , NULL , NULL ) ;
  6639. if ( SUCCEEDED ( t_WBEM_result ) )
  6640. {
  6641. className = new wchar_t [ wcslen ( variant.bstrVal ) + 1 ] ;
  6642. wcscpy ( className , variant.bstrVal ) ;
  6643. IWbemQualifierSet *classQualifierObject ;
  6644. if ( SUCCEEDED ( mosClassObject->GetQualifierSet ( &classQualifierObject ) ) )
  6645. {
  6646. status = SetMosClassObjectQualifiers ( a_errorObject , classQualifierObject ) ;
  6647. if ( status )
  6648. {
  6649. status = SetMosClassObjectProperties ( a_errorObject , mosClassObject , rigorous ) ;
  6650. }
  6651. classQualifierObject->Release () ;
  6652. }
  6653. else
  6654. {
  6655. /*
  6656. * Failed to get qualifier set. WBEM error
  6657. */
  6658. status = FALSE ;
  6659. a_errorObject.SetStatus ( WBEM_SNMP_ERROR_CRITICAL_ERROR ) ;
  6660. a_errorObject.SetWbemStatus ( WBEM_ERROR_CRITICAL_ERROR ) ;
  6661. a_errorObject.SetMessage ( L"Failed to get object qualifier set" ) ;
  6662. }
  6663. }
  6664. else
  6665. {
  6666. /*
  6667. * Failed to get __Class property. WBEM error
  6668. */
  6669. status = FALSE ;
  6670. a_errorObject.SetStatus ( WBEM_SNMP_ERROR_CRITICAL_ERROR ) ;
  6671. a_errorObject.SetWbemStatus ( WBEM_ERROR_CRITICAL_ERROR ) ;
  6672. a_errorObject.SetMessage ( L"Failed to get __Class property" ) ;
  6673. }
  6674. }
  6675. else
  6676. {
  6677. /*
  6678. * Failed to get __Genus property. WBEM error
  6679. */
  6680. status = FALSE ;
  6681. a_errorObject.SetStatus ( WBEM_SNMP_ERROR_CRITICAL_ERROR ) ;
  6682. a_errorObject.SetWbemStatus ( WBEM_ERROR_CRITICAL_ERROR ) ;
  6683. a_errorObject.SetMessage ( L"Failed to get __Genus property" ) ;
  6684. }
  6685. /*
  6686. *
  6687. */
  6688. if ( status )
  6689. {
  6690. if ( IsKeyed () )
  6691. {
  6692. // Iterate through keys checking order is as expected
  6693. ULONG keyPropertyCount = 0 ;
  6694. ULONG keyOrder = 1 ;
  6695. while ( keyOrder <= GetKeyPropertyCount () )
  6696. {
  6697. WbemSnmpProperty *property ;
  6698. ResetProperty () ;
  6699. while ( status && ( property = NextProperty () ) )
  6700. {
  6701. if ( property->IsKey () )
  6702. {
  6703. if ( keyOrder != property->GetKeyOrder () )
  6704. {
  6705. }
  6706. else
  6707. {
  6708. // Key order good
  6709. keyPropertyCount ++ ;
  6710. break ;
  6711. }
  6712. }
  6713. }
  6714. keyOrder ++ ;
  6715. }
  6716. if ( keyPropertyCount != GetKeyPropertyCount () )
  6717. {
  6718. // Invalid key ordering
  6719. status = FALSE ;
  6720. a_errorObject.SetStatus ( WBEM_SNMP_E_INVALID_QUALIFIER ) ;
  6721. a_errorObject.SetWbemStatus ( WBEM_E_FAILED ) ;
  6722. a_errorObject.SetMessage ( L"Class specified invalid key ordering" ) ;
  6723. }
  6724. }
  6725. else
  6726. {
  6727. // Class has no key properties
  6728. }
  6729. }
  6730. if ( status )
  6731. {
  6732. ULONG t_numberOfVirtuals = 0 ;
  6733. if ( IsKeyed () && IsVirtual () )
  6734. {
  6735. WbemSnmpProperty *property ;
  6736. ResetProperty () ;
  6737. while ( property = NextProperty () )
  6738. {
  6739. if ( property->IsVirtualKey () )
  6740. {
  6741. t_numberOfVirtuals ++ ;
  6742. }
  6743. }
  6744. }
  6745. m_numberOfAccessible = GetPropertyCount () - t_numberOfVirtuals ;
  6746. if ( m_numberOfAccessible == 0 )
  6747. {
  6748. // All properties are keyed,virtual
  6749. status = FALSE ;
  6750. a_errorObject.SetStatus ( WBEM_SNMP_E_INVALID_OBJECT ) ;
  6751. a_errorObject.SetWbemStatus ( WBEM_E_FAILED ) ;
  6752. a_errorObject.SetMessage ( L"Class must contain atleast one property which is not a virtual key or inaccessible" ) ;
  6753. }
  6754. }
  6755. VariantClear ( & variant ) ;
  6756. return status ;
  6757. }
  6758. BOOL WbemSnmpClassObject :: SetMosClassObjectQualifiers ( WbemSnmpErrorObject &a_errorObject , IWbemQualifierSet *classQualifierObject )
  6759. {
  6760. DebugMacro7(
  6761. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  6762. __FILE__,__LINE__,L"WbemSnmpClassObject :: SetMosClassObjectProperties ( WbemSnmpErrorObject &a_errorObject , IWbemQualifierSet *classQualifierObject )"
  6763. ) ;
  6764. )
  6765. BOOL status = TRUE ;
  6766. WBEMSTATUS t_WBEM_result = WBEM_S_NO_ERROR ;
  6767. VARIANT variant ;
  6768. VariantInit ( & variant ) ;
  6769. BSTR qualifierName = NULL ;
  6770. LONG qualifierFlavour = 0 ;
  6771. classQualifierObject->BeginEnumeration ( 0 ) ;
  6772. while ( classQualifierObject->Next ( 0 , & qualifierName , & variant , & qualifierFlavour ) == WBEM_NO_ERROR )
  6773. {
  6774. AddQualifier ( qualifierName ) ;
  6775. WbemSnmpQualifier *qualifier = FindQualifier ( qualifierName ) ;
  6776. if ( qualifier )
  6777. {
  6778. if ( qualifier->SetValue ( variant ) )
  6779. {
  6780. }
  6781. else
  6782. {
  6783. /*
  6784. * Qualifier Expected Type and Qualifier Value Type were not the same
  6785. */
  6786. status = FALSE ;
  6787. a_errorObject.SetStatus ( WBEM_SNMP_E_TYPE_MISMATCH ) ;
  6788. a_errorObject.SetWbemStatus ( WBEM_E_FAILED ) ;
  6789. wchar_t *temp = UnicodeStringDuplicate ( L"Type Mismatch for class qualifier: " ) ;
  6790. wchar_t *stringBuffer = UnicodeStringAppend ( temp , qualifierName ) ;
  6791. delete [] temp ;
  6792. a_errorObject.SetMessage ( stringBuffer ) ;
  6793. delete [] stringBuffer ;
  6794. }
  6795. if ( qualifier = FindQualifier ( WBEM_QUALIFIER_SINGLETON ) )
  6796. {
  6797. SnmpInstanceType *value = qualifier->GetValue () ;
  6798. if ( typeid ( *value ) == typeid ( SnmpIntegerType ) )
  6799. {
  6800. SnmpIntegerType *integer = ( SnmpIntegerType * ) value ;
  6801. SetSingleton ( integer->GetValue () ) ;
  6802. }
  6803. else
  6804. {
  6805. status = FALSE ;
  6806. a_errorObject.SetStatus ( WBEM_SNMP_E_TYPE_MISMATCH ) ;
  6807. a_errorObject.SetWbemStatus ( WBEM_E_FAILED ) ;
  6808. a_errorObject.SetMessage ( L"Type mismatch for class qualifier: singleton" ) ;
  6809. }
  6810. }
  6811. }
  6812. else
  6813. {
  6814. // Problem Here
  6815. }
  6816. SysFreeString ( qualifierName ) ;
  6817. VariantClear ( & variant ) ;
  6818. }
  6819. classQualifierObject->EndEnumeration () ;
  6820. return status ;
  6821. }
  6822. BOOL WbemSnmpClassObject :: SetMosClassObjectProperties ( WbemSnmpErrorObject &a_errorObject , IWbemClassObject *mosClassObject , BOOL rigorous )
  6823. {
  6824. DebugMacro7(
  6825. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  6826. __FILE__,__LINE__,
  6827. L"WbemSnmpClassObject :: SetMosClassObjectProperties ( WbemSnmpErrorObject &a_errorObject , IWbemClassObject *mosClassObject , BOOL rigorous )"
  6828. ) ;
  6829. )
  6830. BOOL status = TRUE ;
  6831. HRESULT t_WBEM_result = WBEM_S_NO_ERROR ;
  6832. VARIANT variant ;
  6833. VariantInit ( & variant ) ;
  6834. BSTR propertyName = NULL ;
  6835. CIMTYPE cimType;
  6836. mosClassObject->BeginEnumeration ( WBEM_FLAG_NONSYSTEM_ONLY ) ;
  6837. while ( status && ( mosClassObject->Next ( 0 , &propertyName , &variant , &cimType , NULL ) == WBEM_NO_ERROR ) )
  6838. {
  6839. IWbemQualifierSet *propertyQualifierSet ;
  6840. if ( ( t_WBEM_result = mosClassObject->GetPropertyQualifierSet ( propertyName , &propertyQualifierSet ) ) == WBEM_NO_ERROR )
  6841. {
  6842. VARIANT textualConventionVariant ;
  6843. VariantInit ( &textualConventionVariant ) ;
  6844. LONG flag;
  6845. if ( SUCCEEDED ( propertyQualifierSet->Get ( WBEM_QUALIFIER_TEXTUAL_CONVENTION , 0 , &textualConventionVariant , &flag ) ) )
  6846. {
  6847. AddProperty ( propertyName ) ;
  6848. WbemSnmpProperty *property = FindProperty ( propertyName ) ;
  6849. if ( property )
  6850. {
  6851. status = SetMosClassObjectPropertyQualifiers ( a_errorObject , property , propertyQualifierSet ) ;
  6852. if ( status )
  6853. {
  6854. WbemSnmpQualifier *qualifier ;
  6855. if ( qualifier = property->FindQualifier ( WBEM_QUALIFIER_KEY ) )
  6856. {
  6857. SnmpInstanceType *value = qualifier->GetValue () ;
  6858. if ( typeid ( *value ) == typeid ( SnmpIntegerType ) )
  6859. {
  6860. SnmpIntegerType *integer = ( SnmpIntegerType * ) value ;
  6861. if ( integer->GetValue () )
  6862. {
  6863. AddKeyedProperty ( propertyName ) ;
  6864. property->SetKey () ;
  6865. SetKeyed () ;
  6866. if ( qualifier = property->FindQualifier ( WBEM_QUALIFIER_KEY_ORDER ) )
  6867. {
  6868. SnmpInstanceType *value = qualifier->GetValue () ;
  6869. if ( typeid ( *value ) == typeid ( SnmpIntegerType ) )
  6870. {
  6871. SnmpIntegerType *integer = ( SnmpIntegerType * ) value ;
  6872. property->SetKeyOrder ( integer->GetValue () ) ;
  6873. }
  6874. else
  6875. {
  6876. wchar_t *prefix = UnicodeStringAppend ( L"Property \'" , propertyName ) ;
  6877. wchar_t *stringBuffer = UnicodeStringAppend ( prefix , L"\' has type mismatch for qualifier: key_order") ;
  6878. delete [] prefix ;
  6879. a_errorObject.SetMessage ( stringBuffer ) ;
  6880. delete [] stringBuffer ;
  6881. status = FALSE ;
  6882. a_errorObject.SetStatus ( WBEM_SNMP_E_TYPE_MISMATCH ) ;
  6883. a_errorObject.SetWbemStatus ( WBEM_E_FAILED ) ;
  6884. }
  6885. }
  6886. else
  6887. {
  6888. // Keyed property contains no key order
  6889. wchar_t *prefix = UnicodeStringAppend ( L"Property \'" , propertyName ) ;
  6890. wchar_t *stringBuffer = UnicodeStringAppend ( prefix , L"\' is defined as a key but contains no key_order qualifier") ;
  6891. delete [] prefix ;
  6892. a_errorObject.SetMessage ( stringBuffer ) ;
  6893. delete [] stringBuffer ;
  6894. status = FALSE ;
  6895. a_errorObject.SetStatus ( WBEM_SNMP_E_INVALID_PROPERTY ) ;
  6896. a_errorObject.SetWbemStatus ( WBEM_E_FAILED ) ;
  6897. }
  6898. }
  6899. if ( qualifier = property->FindQualifier ( WBEM_QUALIFIER_VIRTUAL_KEY ) )
  6900. {
  6901. SnmpInstanceType *value = qualifier->GetValue () ;
  6902. if ( typeid ( *value ) == typeid ( SnmpIntegerType ) )
  6903. {
  6904. SnmpIntegerType *integer = ( SnmpIntegerType * ) value ;
  6905. if ( integer->GetValue () )
  6906. {
  6907. property->SetVirtualKey () ;
  6908. SetVirtual () ;
  6909. }
  6910. }
  6911. else
  6912. {
  6913. wchar_t *prefix = UnicodeStringAppend ( L"Property \'" , propertyName ) ;
  6914. wchar_t *stringBuffer = UnicodeStringAppend ( prefix , L"\' has type mismatch for qualifier: virtual_key") ;
  6915. delete [] prefix ;
  6916. a_errorObject.SetMessage ( stringBuffer ) ;
  6917. delete [] stringBuffer ;
  6918. status = FALSE ;
  6919. a_errorObject.SetStatus ( WBEM_SNMP_E_TYPE_MISMATCH ) ;
  6920. a_errorObject.SetWbemStatus ( WBEM_E_FAILED ) ;
  6921. }
  6922. }
  6923. }
  6924. else
  6925. {
  6926. wchar_t *prefix = UnicodeStringAppend ( L"Property \'" , propertyName ) ;
  6927. wchar_t *stringBuffer = UnicodeStringAppend ( prefix , L"\' has type mismatch for qualifier: key") ;
  6928. delete [] prefix ;
  6929. a_errorObject.SetMessage ( stringBuffer ) ;
  6930. delete [] stringBuffer ;
  6931. status = FALSE ;
  6932. a_errorObject.SetStatus ( WBEM_SNMP_E_TYPE_MISMATCH ) ;
  6933. a_errorObject.SetWbemStatus ( WBEM_E_FAILED ) ;
  6934. }
  6935. }
  6936. if ( qualifier = property->FindQualifier ( WBEM_QUALIFIER_READ ) )
  6937. {
  6938. SnmpInstanceType *value = qualifier->GetValue () ;
  6939. if ( typeid ( *value ) == typeid ( SnmpIntegerType ) )
  6940. {
  6941. SnmpIntegerType *integer = ( SnmpIntegerType * ) value ;
  6942. if ( integer->GetValue () )
  6943. {
  6944. property->SetReadable () ;
  6945. SetReadable () ;
  6946. }
  6947. }
  6948. else
  6949. {
  6950. wchar_t *prefix = UnicodeStringAppend ( L"Property \'" , propertyName ) ;
  6951. wchar_t *stringBuffer = UnicodeStringAppend ( prefix , L"\' has type mismatch for qualifier: read") ;
  6952. delete [] prefix ;
  6953. a_errorObject.SetMessage ( stringBuffer ) ;
  6954. delete [] stringBuffer ;
  6955. status = FALSE ;
  6956. a_errorObject.SetStatus ( WBEM_SNMP_E_TYPE_MISMATCH ) ;
  6957. a_errorObject.SetWbemStatus ( WBEM_E_FAILED ) ;
  6958. }
  6959. }
  6960. if ( qualifier = property->FindQualifier ( WBEM_QUALIFIER_WRITE ) )
  6961. {
  6962. SnmpInstanceType *value = qualifier->GetValue () ;
  6963. if ( typeid ( *value ) == typeid ( SnmpIntegerType ) )
  6964. {
  6965. SnmpIntegerType *integer = ( SnmpIntegerType * ) value ;
  6966. if ( integer->GetValue () )
  6967. {
  6968. property->SetWritable () ;
  6969. SetWritable () ;
  6970. }
  6971. }
  6972. else
  6973. {
  6974. wchar_t *prefix = UnicodeStringAppend ( L"Property \'" , propertyName ) ;
  6975. wchar_t *stringBuffer = UnicodeStringAppend ( prefix , L"\' has type mismatch for qualifier: write") ;
  6976. delete [] prefix ;
  6977. a_errorObject.SetMessage ( stringBuffer ) ;
  6978. delete [] stringBuffer ;
  6979. status = FALSE ;
  6980. a_errorObject.SetStatus ( WBEM_SNMP_E_TYPE_MISMATCH ) ;
  6981. a_errorObject.SetWbemStatus ( WBEM_E_FAILED ) ;
  6982. }
  6983. }
  6984. if ( ! property->IsVirtualKey () )
  6985. {
  6986. // Check Object Identifier Present
  6987. if ( qualifier = property->FindQualifier ( WBEM_QUALIFIER_OBJECT_IDENTIFIER ) )
  6988. {
  6989. SnmpInstanceType *value = qualifier->GetValue () ;
  6990. if ( typeid ( *value ) == typeid ( SnmpObjectIdentifierType ) )
  6991. {
  6992. }
  6993. else
  6994. {
  6995. // Problem Here
  6996. wchar_t *prefix = UnicodeStringAppend ( L"Property \'" , propertyName ) ;
  6997. wchar_t *stringBuffer = UnicodeStringAppend ( prefix , L"\' has type mismatch for qualifier: object_identifier") ;
  6998. delete [] prefix ;
  6999. a_errorObject.SetMessage ( stringBuffer ) ;
  7000. delete [] stringBuffer ;
  7001. status = FALSE ;
  7002. a_errorObject.SetStatus ( WBEM_SNMP_E_TYPE_MISMATCH ) ;
  7003. a_errorObject.SetWbemStatus ( WBEM_E_FAILED ) ;
  7004. }
  7005. }
  7006. else
  7007. {
  7008. // No Object Identifier present
  7009. wchar_t *prefix = UnicodeStringAppend ( L"Property \'" , propertyName ) ;
  7010. wchar_t *stringBuffer = UnicodeStringAppend ( prefix , L"\' must specify valid qualifier for: object_identifier" ) ;
  7011. delete [] prefix ;
  7012. a_errorObject.SetMessage ( stringBuffer ) ;
  7013. delete [] stringBuffer ;
  7014. status = FALSE ;
  7015. a_errorObject.SetStatus ( WBEM_SNMP_E_INVALID_PROPERTY ) ;
  7016. a_errorObject.SetWbemStatus ( WBEM_E_FAILED ) ;
  7017. }
  7018. }
  7019. if ( qualifier = property->FindQualifier ( WBEM_QUALIFIER_TEXTUAL_CONVENTION ) )
  7020. {
  7021. SnmpInstanceType *value = qualifier->GetValue () ;
  7022. if ( typeid ( *value ) == typeid ( SnmpDisplayStringType ) )
  7023. {
  7024. SnmpDisplayStringType *displayString = ( SnmpDisplayStringType * ) value ;
  7025. wchar_t *string = displayString->GetValue () ;
  7026. ULONG stringItem ;
  7027. if ( textualConventionMap.Lookup ( string , stringItem ) )
  7028. {
  7029. property->SetTextualConvention ( stringItem ) ;
  7030. }
  7031. delete [] string ;
  7032. }
  7033. }
  7034. if ( rigorous )
  7035. {
  7036. if ( property->SetValue ( variant , cimType , SetValueIfCheckOk ) )
  7037. {
  7038. IWbemObjectAccess *t_Access = NULL ;
  7039. HRESULT result = mosClassObject->QueryInterface (
  7040. IID_IWbemObjectAccess ,
  7041. (void**)&t_Access
  7042. ) ;
  7043. if ( SUCCEEDED ( result ) )
  7044. {
  7045. long t_Handle ;
  7046. HRESULT result = t_Access->GetPropertyHandle (
  7047. propertyName ,
  7048. NULL ,
  7049. & t_Handle
  7050. );
  7051. if ( SUCCEEDED ( result ) )
  7052. {
  7053. property->SetHandle ( t_Handle ) ;
  7054. }
  7055. t_Access->Release () ;
  7056. }
  7057. }
  7058. else
  7059. {
  7060. /*
  7061. * Property Expected Type and property Value Type were not the same
  7062. */
  7063. status = FALSE ;
  7064. a_errorObject.SetStatus ( WBEM_SNMP_E_TYPE_MISMATCH ) ;
  7065. a_errorObject.SetWbemStatus ( WBEM_E_FAILED ) ;
  7066. wchar_t *temp = UnicodeStringDuplicate ( L"Type Mismatch for property: " ) ;
  7067. wchar_t *stringBuffer = UnicodeStringAppend ( temp , propertyName ) ;
  7068. delete [] temp ;
  7069. a_errorObject.SetMessage ( stringBuffer ) ;
  7070. delete [] stringBuffer ;
  7071. }
  7072. }
  7073. else
  7074. {
  7075. if ( property->SetValue ( variant , cimType , SetValueRegardlessDontReturnCheck ) )
  7076. {
  7077. }
  7078. else
  7079. {
  7080. /*
  7081. * Property Expected Type and property Value Type were not the same. Should not happen.
  7082. */
  7083. wchar_t *prefix = UnicodeStringAppend ( L"Property \'" , propertyName ) ;
  7084. wchar_t *stringBuffer = UnicodeStringAppend ( prefix , L"\' has type mismatch for property value" ) ;
  7085. delete [] prefix ;
  7086. a_errorObject.SetMessage ( stringBuffer ) ;
  7087. delete [] stringBuffer ;
  7088. status = FALSE ;
  7089. a_errorObject.SetStatus ( WBEM_SNMP_E_TYPE_MISMATCH ) ;
  7090. a_errorObject.SetWbemStatus ( WBEM_ERROR_CRITICAL_ERROR ) ;
  7091. }
  7092. }
  7093. }
  7094. }
  7095. else
  7096. {
  7097. }
  7098. }
  7099. VariantClear ( & textualConventionVariant ) ;
  7100. propertyQualifierSet->Release () ;
  7101. }
  7102. else
  7103. {
  7104. /*
  7105. * Failed to get qualifier set . WBEM error
  7106. */
  7107. status = FALSE ;
  7108. a_errorObject.SetStatus ( WBEM_SNMP_ERROR_CRITICAL_ERROR ) ;
  7109. a_errorObject.SetWbemStatus ( WBEM_ERROR_CRITICAL_ERROR ) ;
  7110. wchar_t *temp = UnicodeStringDuplicate ( L"Failed to get qualifier set for: " ) ;
  7111. wchar_t *stringBuffer = UnicodeStringAppend ( temp , propertyName ) ;
  7112. delete [] temp ;
  7113. a_errorObject.SetMessage ( stringBuffer ) ;
  7114. delete [] stringBuffer ;
  7115. }
  7116. SysFreeString ( propertyName ) ;
  7117. VariantClear ( & variant ) ;
  7118. }
  7119. mosClassObject->EndEnumeration () ;
  7120. return status ;
  7121. }
  7122. BOOL WbemSnmpClassObject :: SetMosClassObjectPropertyQualifiers ( WbemSnmpErrorObject &a_errorObject , WbemSnmpProperty *snmpProperty , IWbemQualifierSet *propertyQualifierSet )
  7123. {
  7124. DebugMacro7( SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  7125. __FILE__,__LINE__,
  7126. L"WbemSnmpClassObject :: SetMosClassObjectPropertyQualifiers (WbemSnmpErrorObject &a_errorObject , WbemSnmpProperty *snmpProperty , IWbemQualifierSet *propertyQualifierSet )"
  7127. ) ;
  7128. )
  7129. BOOL status = TRUE ;
  7130. WBEMSTATUS t_WBEM_result = WBEM_S_NO_ERROR ;
  7131. VARIANT variant ;
  7132. VariantInit ( & variant ) ;
  7133. BSTR qualifierName = NULL ;
  7134. LONG qualifierFlavour = 0 ;
  7135. propertyQualifierSet->BeginEnumeration ( 0 ) ;
  7136. while ( status && ( propertyQualifierSet->Next ( 0 , & qualifierName , & variant , & qualifierFlavour ) == WBEM_NO_ERROR ) )
  7137. {
  7138. snmpProperty->AddQualifier ( qualifierName ) ;
  7139. WbemSnmpQualifier *qualifier = snmpProperty->FindQualifier ( qualifierName ) ;
  7140. if ( qualifier )
  7141. {
  7142. if ( qualifier->SetValue ( variant ) )
  7143. {
  7144. }
  7145. else
  7146. {
  7147. /*
  7148. * Qualifier Expected Type and Qualifier Value Type were not the same
  7149. */
  7150. status = FALSE ;
  7151. a_errorObject.SetStatus ( WBEM_SNMP_E_TYPE_MISMATCH ) ;
  7152. a_errorObject.SetWbemStatus ( WBEM_E_FAILED ) ;
  7153. wchar_t *prefix = UnicodeStringAppend ( L"Property \'" , snmpProperty->GetName () ) ;
  7154. wchar_t *suffix = UnicodeStringAppend ( prefix , L"\' has type mismatch for qualifier: ") ;
  7155. delete [] prefix ;
  7156. wchar_t *stringBuffer = UnicodeStringAppend ( suffix , qualifierName ) ;
  7157. delete [] suffix ;
  7158. a_errorObject.SetMessage ( stringBuffer ) ;
  7159. delete [] stringBuffer ;
  7160. }
  7161. }
  7162. else
  7163. {
  7164. // Problem Here
  7165. }
  7166. SysFreeString ( qualifierName ) ;
  7167. VariantClear ( & variant ) ;
  7168. }
  7169. propertyQualifierSet->EndEnumeration () ;
  7170. return status ;
  7171. }
  7172. BOOL WbemSnmpClassObject :: Merge ( WbemSnmpErrorObject &a_errorObject , IWbemClassObject *mosClassObject , BOOL rigorous )
  7173. {
  7174. DebugMacro7(
  7175. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  7176. __FILE__,__LINE__,
  7177. L"WbemSnmpClassObject :: Merge ( WbemSnmpErrorObject &a_errorObject , IWbemClassObject *mosClassObject , BOOL rigorous )"
  7178. ) ;
  7179. )
  7180. BOOL result = MergeMosClassObject ( a_errorObject , mosClassObject , rigorous ) ;
  7181. return result ;
  7182. }
  7183. BOOL WbemSnmpClassObject :: MergeMosClassObject ( WbemSnmpErrorObject &a_errorObject , IWbemClassObject *mosClassObject , BOOL rigorous )
  7184. {
  7185. DebugMacro7(
  7186. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  7187. __FILE__,__LINE__,
  7188. L"WbemSnmpClassObject :: MergeMosClassObject (WbemSnmpErrorObject &a_errorObject , IWbemClassObject *mosClassObject , BOOL rigorous )"
  7189. ) ;
  7190. )
  7191. BOOL status = TRUE ;
  7192. HRESULT t_WBEM_result = WBEM_S_NO_ERROR ;
  7193. IWbemQualifierSet *classQualifierObject ;
  7194. if ( SUCCEEDED ( mosClassObject->GetQualifierSet ( &classQualifierObject ) ) )
  7195. {
  7196. status = MergeMosClassObjectQualifiers ( a_errorObject , classQualifierObject ) ;
  7197. if ( status )
  7198. {
  7199. status = MergeMosClassObjectProperties ( a_errorObject , mosClassObject , rigorous ) ;
  7200. }
  7201. classQualifierObject->Release () ;
  7202. }
  7203. else
  7204. {
  7205. /*
  7206. * Failed to get qualifier set. WBEM error
  7207. */
  7208. status = FALSE ;
  7209. a_errorObject.SetStatus ( WBEM_SNMP_ERROR_CRITICAL_ERROR ) ;
  7210. a_errorObject.SetWbemStatus ( WBEM_ERROR_CRITICAL_ERROR ) ;
  7211. a_errorObject.SetMessage ( L"Failed to get object qualifier set" ) ;
  7212. }
  7213. /*
  7214. *
  7215. */
  7216. if ( status )
  7217. {
  7218. if ( IsKeyed () )
  7219. {
  7220. // Iterate through keys checking order is as expected
  7221. ULONG keyPropertyCount = 0 ;
  7222. ULONG keyOrder = 1 ;
  7223. while ( keyOrder <= GetKeyPropertyCount () )
  7224. {
  7225. WbemSnmpProperty *property ;
  7226. ResetProperty () ;
  7227. while ( status && ( property = NextProperty () ) )
  7228. {
  7229. if ( property->IsKey () )
  7230. {
  7231. if ( keyOrder != property->GetKeyOrder () )
  7232. {
  7233. }
  7234. else
  7235. {
  7236. // Key order good
  7237. keyPropertyCount ++ ;
  7238. break ;
  7239. }
  7240. }
  7241. }
  7242. keyOrder ++ ;
  7243. }
  7244. if ( keyPropertyCount != GetKeyPropertyCount () )
  7245. {
  7246. // Invalid key ordering
  7247. status = FALSE ;
  7248. a_errorObject.SetStatus ( WBEM_SNMP_E_INVALID_QUALIFIER ) ;
  7249. a_errorObject.SetWbemStatus ( WBEM_E_FAILED ) ;
  7250. a_errorObject.SetMessage ( L"Class specified invalid key ordering" ) ;
  7251. }
  7252. }
  7253. else
  7254. {
  7255. // Class has no key properties
  7256. }
  7257. }
  7258. if ( status )
  7259. {
  7260. ULONG t_numberOfVirtuals = 0 ;
  7261. if ( IsKeyed () && IsVirtual () )
  7262. {
  7263. WbemSnmpProperty *property ;
  7264. ResetProperty () ;
  7265. while ( property = NextProperty () )
  7266. {
  7267. if ( property->IsVirtualKey () )
  7268. {
  7269. t_numberOfVirtuals ++ ;
  7270. }
  7271. }
  7272. }
  7273. m_numberOfAccessible = GetPropertyCount () - t_numberOfVirtuals ;
  7274. if ( m_numberOfAccessible == 0 )
  7275. {
  7276. // All properties are keyed,virtual
  7277. status = FALSE ;
  7278. a_errorObject.SetStatus ( WBEM_SNMP_E_INVALID_OBJECT ) ;
  7279. a_errorObject.SetWbemStatus ( WBEM_E_FAILED ) ;
  7280. a_errorObject.SetMessage ( L"Class must contain atleast one property which is not a virtual key or inaccessible" ) ;
  7281. }
  7282. }
  7283. return status ;
  7284. }
  7285. BOOL WbemSnmpClassObject :: MergeMosClassObjectQualifiers ( WbemSnmpErrorObject &a_errorObject , IWbemQualifierSet *classQualifierObject )
  7286. {
  7287. DebugMacro7(
  7288. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  7289. __FILE__,__LINE__,
  7290. L"WbemSnmpClassObject :: MergeMosClassObjectProperties (WbemSnmpErrorObject &a_errorObject , IWbemQualifierSet *classQualifierObject )"
  7291. ) ;
  7292. )
  7293. BOOL status = TRUE ;
  7294. WBEMSTATUS t_WBEM_result = WBEM_S_NO_ERROR ;
  7295. VARIANT variant ;
  7296. VariantInit ( & variant ) ;
  7297. BSTR qualifierName = NULL ;
  7298. LONG qualifierFlavour = 0 ;
  7299. classQualifierObject->BeginEnumeration ( 0 ) ;
  7300. while ( classQualifierObject->Next ( 0 , & qualifierName , & variant , & qualifierFlavour) == WBEM_NO_ERROR )
  7301. {
  7302. AddQualifier ( qualifierName ) ;
  7303. WbemSnmpQualifier *qualifier = FindQualifier ( qualifierName ) ;
  7304. if ( qualifier )
  7305. {
  7306. if ( qualifier->SetValue ( variant ) )
  7307. {
  7308. }
  7309. else
  7310. {
  7311. /*
  7312. * Qualifier Expected Type and Qualifier Value Type were not the same
  7313. */
  7314. status = FALSE ;
  7315. a_errorObject.SetStatus ( WBEM_SNMP_E_TYPE_MISMATCH ) ;
  7316. a_errorObject.SetWbemStatus ( WBEM_E_FAILED ) ;
  7317. wchar_t *temp = UnicodeStringDuplicate ( L"Type Mismatch for class qualifier: " ) ;
  7318. wchar_t *stringBuffer = UnicodeStringAppend ( temp , qualifierName ) ;
  7319. delete [] temp ;
  7320. a_errorObject.SetMessage ( stringBuffer ) ;
  7321. delete [] stringBuffer ;
  7322. }
  7323. }
  7324. else
  7325. {
  7326. // Problem Here
  7327. }
  7328. SysFreeString ( qualifierName ) ;
  7329. VariantClear ( & variant ) ;
  7330. }
  7331. classQualifierObject->EndEnumeration () ;
  7332. return status ;
  7333. }
  7334. BOOL WbemSnmpClassObject :: MergeMosClassObjectProperties ( WbemSnmpErrorObject &a_errorObject , IWbemClassObject *mosClassObject , BOOL rigorous )
  7335. {
  7336. DebugMacro7(
  7337. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  7338. __FILE__,__LINE__,
  7339. L"WbemSnmpClassObject :: MergeMosClassObjectProperties"
  7340. ) ;
  7341. )
  7342. BOOL status = TRUE ;
  7343. HRESULT t_WBEM_result = WBEM_S_NO_ERROR ;
  7344. VARIANT variant ;
  7345. VariantInit ( & variant ) ;
  7346. BSTR propertyName = NULL ;
  7347. CIMTYPE cimType ;
  7348. mosClassObject->BeginEnumeration ( WBEM_FLAG_NONSYSTEM_ONLY ) ;
  7349. while ( status && ( mosClassObject->Next ( 0 , &propertyName , &variant , &cimType , NULL ) == WBEM_NO_ERROR ) )
  7350. {
  7351. IWbemQualifierSet *propertyQualifierSet ;
  7352. if ( ( t_WBEM_result = mosClassObject->GetPropertyQualifierSet ( propertyName , &propertyQualifierSet ) ) == WBEM_NO_ERROR )
  7353. {
  7354. WbemSnmpProperty *property = FindProperty ( propertyName ) ;
  7355. if ( property )
  7356. {
  7357. status = MergeMosClassObjectPropertyQualifiers ( a_errorObject , property , propertyQualifierSet ) ;
  7358. if ( status )
  7359. {
  7360. WbemSnmpQualifier *qualifier ;
  7361. if ( qualifier = property->FindQualifier ( WBEM_QUALIFIER_KEY ) )
  7362. {
  7363. SnmpInstanceType *value = qualifier->GetValue () ;
  7364. if ( typeid ( *value ) == typeid ( SnmpIntegerType ) )
  7365. {
  7366. SnmpIntegerType *integer = ( SnmpIntegerType * ) value ;
  7367. if ( integer->GetValue () )
  7368. {
  7369. if ( ! FindKeyProperty ( propertyName ) )
  7370. {
  7371. AddKeyedProperty ( propertyName ) ;
  7372. }
  7373. property->SetKey () ;
  7374. SetKeyed () ;
  7375. if ( qualifier = property->FindQualifier ( WBEM_QUALIFIER_KEY_ORDER ) )
  7376. {
  7377. SnmpInstanceType *value = qualifier->GetValue () ;
  7378. if ( typeid ( *value ) == typeid ( SnmpIntegerType ) )
  7379. {
  7380. SnmpIntegerType *integer = ( SnmpIntegerType * ) value ;
  7381. property->SetKeyOrder ( integer->GetValue () ) ;
  7382. }
  7383. else
  7384. {
  7385. status = FALSE ;
  7386. a_errorObject.SetStatus ( WBEM_SNMP_E_TYPE_MISMATCH ) ;
  7387. a_errorObject.SetWbemStatus ( WBEM_E_FAILED ) ;
  7388. a_errorObject.SetMessage ( L"Type mismatch for qualifier: key_order" ) ;
  7389. }
  7390. }
  7391. else
  7392. {
  7393. // Keyed property contains no key order
  7394. status = FALSE ;
  7395. a_errorObject.SetStatus ( WBEM_SNMP_E_INVALID_PROPERTY ) ;
  7396. a_errorObject.SetWbemStatus ( WBEM_E_FAILED ) ;
  7397. a_errorObject.SetMessage ( L"Property is defined as a key but contains no key_order qualifier" ) ;
  7398. }
  7399. }
  7400. if ( qualifier = property->FindQualifier ( WBEM_QUALIFIER_VIRTUAL_KEY ) )
  7401. {
  7402. SnmpInstanceType *value = qualifier->GetValue () ;
  7403. if ( typeid ( *value ) == typeid ( SnmpIntegerType ) )
  7404. {
  7405. SnmpIntegerType *integer = ( SnmpIntegerType * ) value ;
  7406. if ( integer->GetValue () )
  7407. {
  7408. property->SetVirtualKey () ;
  7409. SetVirtual () ;
  7410. }
  7411. }
  7412. else
  7413. {
  7414. status = FALSE ;
  7415. a_errorObject.SetStatus ( WBEM_SNMP_E_TYPE_MISMATCH ) ;
  7416. a_errorObject.SetWbemStatus ( WBEM_E_FAILED ) ;
  7417. a_errorObject.SetMessage ( L"Type mismatch for qualifier: virtual_key" ) ;
  7418. }
  7419. }
  7420. }
  7421. else
  7422. {
  7423. status = FALSE ;
  7424. a_errorObject.SetStatus ( WBEM_SNMP_E_TYPE_MISMATCH ) ;
  7425. a_errorObject.SetWbemStatus ( WBEM_E_FAILED ) ;
  7426. a_errorObject.SetMessage ( L"Type mismatch for qualifier: key" ) ;
  7427. }
  7428. }
  7429. if ( qualifier = property->FindQualifier ( WBEM_QUALIFIER_READ ) )
  7430. {
  7431. SnmpInstanceType *value = qualifier->GetValue () ;
  7432. if ( typeid ( *value ) == typeid ( SnmpIntegerType ) )
  7433. {
  7434. SnmpIntegerType *integer = ( SnmpIntegerType * ) value ;
  7435. if ( integer->GetValue () )
  7436. {
  7437. property->SetReadable () ;
  7438. SetReadable () ;
  7439. }
  7440. }
  7441. else
  7442. {
  7443. status = FALSE ;
  7444. a_errorObject.SetStatus ( WBEM_SNMP_E_TYPE_MISMATCH ) ;
  7445. a_errorObject.SetWbemStatus ( WBEM_E_FAILED ) ;
  7446. a_errorObject.SetMessage ( L"Type mismatch for qualifier: read" ) ;
  7447. }
  7448. }
  7449. if ( qualifier = property->FindQualifier ( WBEM_QUALIFIER_WRITE ) )
  7450. {
  7451. SnmpInstanceType *value = qualifier->GetValue () ;
  7452. if ( typeid ( *value ) == typeid ( SnmpIntegerType ) )
  7453. {
  7454. SnmpIntegerType *integer = ( SnmpIntegerType * ) value ;
  7455. if ( integer->GetValue () )
  7456. {
  7457. property->SetWritable () ;
  7458. SetWritable () ;
  7459. }
  7460. }
  7461. else
  7462. {
  7463. status = FALSE ;
  7464. a_errorObject.SetStatus ( WBEM_SNMP_E_TYPE_MISMATCH ) ;
  7465. a_errorObject.SetWbemStatus ( WBEM_E_FAILED ) ;
  7466. a_errorObject.SetMessage ( L"Type mismatch for qualifier: write" ) ;
  7467. }
  7468. }
  7469. if ( qualifier = property->FindQualifier ( WBEM_QUALIFIER_SINGLETON ) )
  7470. {
  7471. SnmpInstanceType *value = qualifier->GetValue () ;
  7472. if ( typeid ( *value ) == typeid ( SnmpIntegerType ) )
  7473. {
  7474. SnmpIntegerType *integer = ( SnmpIntegerType * ) value ;
  7475. SetSingleton ( integer->GetValue () ) ;
  7476. }
  7477. else
  7478. {
  7479. status = FALSE ;
  7480. a_errorObject.SetStatus ( WBEM_SNMP_E_TYPE_MISMATCH ) ;
  7481. a_errorObject.SetWbemStatus ( WBEM_E_FAILED ) ;
  7482. a_errorObject.SetMessage ( L"Type mismatch for qualifier: singleton" ) ;
  7483. }
  7484. }
  7485. if ( ! property->IsVirtualKey () )
  7486. {
  7487. // Check Object Identifier Present
  7488. if ( qualifier = property->FindQualifier ( WBEM_QUALIFIER_OBJECT_IDENTIFIER ) )
  7489. {
  7490. SnmpInstanceType *value = qualifier->GetValue () ;
  7491. if ( typeid ( *value ) == typeid ( SnmpObjectIdentifierType ) )
  7492. {
  7493. }
  7494. else
  7495. {
  7496. // Problem Here
  7497. status = FALSE ;
  7498. a_errorObject.SetStatus ( WBEM_SNMP_E_TYPE_MISMATCH ) ;
  7499. a_errorObject.SetWbemStatus ( WBEM_E_FAILED ) ;
  7500. a_errorObject.SetMessage ( L"Type mismatch for qualifier: object_identifier" ) ;
  7501. }
  7502. }
  7503. else
  7504. {
  7505. // No Object Identifier present
  7506. status = FALSE ;
  7507. a_errorObject.SetStatus ( WBEM_SNMP_E_INVALID_PROPERTY ) ;
  7508. a_errorObject.SetWbemStatus ( WBEM_E_FAILED ) ;
  7509. a_errorObject.SetMessage ( L"Property must specify valid qualifier for: object_identifier" ) ;
  7510. }
  7511. }
  7512. if ( rigorous )
  7513. {
  7514. if ( property->SetValue ( variant , cimType , SetValueIfCheckOk ) )
  7515. {
  7516. }
  7517. else
  7518. {
  7519. /*
  7520. * Property Expected Type and property Value Type were not the same
  7521. */
  7522. status = FALSE ;
  7523. a_errorObject.SetStatus ( WBEM_SNMP_E_TYPE_MISMATCH ) ;
  7524. a_errorObject.SetWbemStatus ( WBEM_E_FAILED ) ;
  7525. wchar_t *temp = UnicodeStringDuplicate ( L"Type Mismatch for property: " ) ;
  7526. wchar_t *stringBuffer = UnicodeStringAppend ( temp , propertyName ) ;
  7527. delete [] temp ;
  7528. a_errorObject.SetMessage ( stringBuffer ) ;
  7529. delete [] stringBuffer ;
  7530. }
  7531. }
  7532. else
  7533. {
  7534. if ( property->SetValue ( variant , cimType , SetValueRegardlessDontReturnCheck ) )
  7535. {
  7536. }
  7537. else
  7538. {
  7539. /*
  7540. * Property Expected Type and property Value Type were not the same. Should not happen.
  7541. */
  7542. wchar_t *prefix = UnicodeStringAppend ( L"Property \'" , propertyName ) ;
  7543. wchar_t *stringBuffer = UnicodeStringAppend ( prefix , L"\' has type mismatch for property value" ) ;
  7544. delete [] prefix ;
  7545. a_errorObject.SetMessage ( stringBuffer ) ;
  7546. delete [] stringBuffer ;
  7547. status = FALSE ;
  7548. a_errorObject.SetStatus ( WBEM_SNMP_E_TYPE_MISMATCH ) ;
  7549. a_errorObject.SetWbemStatus ( WBEM_ERROR_CRITICAL_ERROR ) ;
  7550. }
  7551. }
  7552. }
  7553. }
  7554. else
  7555. {
  7556. }
  7557. propertyQualifierSet->Release () ;
  7558. }
  7559. else
  7560. {
  7561. /*
  7562. * Failed to get qualifier set . WBEM error
  7563. */
  7564. status = FALSE ;
  7565. a_errorObject.SetStatus ( WBEM_SNMP_ERROR_CRITICAL_ERROR ) ;
  7566. a_errorObject.SetWbemStatus ( WBEM_ERROR_CRITICAL_ERROR ) ;
  7567. wchar_t *temp = UnicodeStringDuplicate ( L"Failed to get qualifier set for: " ) ;
  7568. wchar_t *stringBuffer = UnicodeStringAppend ( temp , propertyName ) ;
  7569. delete [] temp ;
  7570. a_errorObject.SetMessage ( stringBuffer ) ;
  7571. delete [] stringBuffer ;
  7572. }
  7573. SysFreeString ( propertyName ) ;
  7574. VariantClear ( & variant ) ;
  7575. }
  7576. mosClassObject->EndEnumeration () ;
  7577. return status ;
  7578. }
  7579. BOOL WbemSnmpClassObject :: MergeMosClassObjectPropertyQualifiers ( WbemSnmpErrorObject &a_errorObject , WbemSnmpProperty *snmpProperty , IWbemQualifierSet *propertyQualifierSet )
  7580. {
  7581. DebugMacro7(
  7582. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  7583. __FILE__,__LINE__,
  7584. L"WbemSnmpClassObject :: MergeMosClassObjectPropertyQualifiers ( WbemSnmpErrorObject &a_errorObject , WbemSnmpProperty *snmpProperty , IWbemQualifierSet *propertyQualifierSet )"
  7585. ) ;
  7586. )
  7587. BOOL status = TRUE ;
  7588. WBEMSTATUS t_WBEM_result = WBEM_S_NO_ERROR ;
  7589. VARIANT variant ;
  7590. VariantInit ( & variant ) ;
  7591. BSTR qualifierName = NULL ;
  7592. LONG qualifierFlavour = 0 ;
  7593. propertyQualifierSet->BeginEnumeration ( 0 ) ;
  7594. while ( status && ( propertyQualifierSet->Next ( 0 , & qualifierName , & variant , & qualifierFlavour ) == WBEM_NO_ERROR ) )
  7595. {
  7596. if (_wcsicmp(qualifierName, WBEM_QUALIFIER_TYPE_MISMATCH) == 0)
  7597. {
  7598. continue;
  7599. }
  7600. snmpProperty->AddQualifier ( qualifierName ) ;
  7601. WbemSnmpQualifier *qualifier = snmpProperty->FindQualifier ( qualifierName ) ;
  7602. if ( qualifier )
  7603. {
  7604. if ( qualifier->SetValue ( variant ) )
  7605. {
  7606. }
  7607. else
  7608. {
  7609. /*
  7610. * Qualifier Expected Type and Qualifier Value Type were not the same
  7611. */
  7612. status = FALSE ;
  7613. a_errorObject.SetStatus ( WBEM_SNMP_E_TYPE_MISMATCH ) ;
  7614. a_errorObject.SetWbemStatus ( WBEM_E_FAILED ) ;
  7615. wchar_t *prefix = UnicodeStringAppend ( L"Property \'" , snmpProperty->GetName () ) ;
  7616. wchar_t *suffix = UnicodeStringAppend ( prefix , L"\' has type mismatch for qualifier: ") ;
  7617. delete [] prefix ;
  7618. wchar_t *stringBuffer = UnicodeStringAppend ( suffix , qualifierName ) ;
  7619. delete [] suffix ;
  7620. a_errorObject.SetMessage ( stringBuffer ) ;
  7621. delete [] stringBuffer ;
  7622. }
  7623. }
  7624. else
  7625. {
  7626. // Problem Here
  7627. }
  7628. SysFreeString ( qualifierName ) ;
  7629. VariantClear ( & variant ) ;
  7630. }
  7631. propertyQualifierSet->EndEnumeration () ;
  7632. return status ;
  7633. }
  7634. BOOL WbemSnmpClassObject :: Get ( WbemSnmpErrorObject &a_errorObject , IWbemClassObject *mosClassObject )
  7635. {
  7636. DebugMacro7( SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine ( __FILE__,__LINE__,L"WbemSnmpClassObject :: Get" ) )
  7637. BOOL status = GetMosClassObject ( a_errorObject , mosClassObject ) ;
  7638. return status ;
  7639. }
  7640. BOOL WbemSnmpClassObject :: GetMosClassObject ( WbemSnmpErrorObject &a_errorObject , IWbemClassObject *mosClassObject )
  7641. {
  7642. DebugMacro7( SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine ( __FILE__,__LINE__,L"WbemSnmpClassObject :: GetMosClassObject" ) )
  7643. BOOL status = TRUE ;
  7644. WBEMSTATUS t_WBEM_result = WBEM_S_NO_ERROR ;
  7645. IWbemQualifierSet *classQualifierObject ;
  7646. if ( SUCCEEDED ( mosClassObject->GetQualifierSet ( &classQualifierObject ) ) )
  7647. {
  7648. status = GetMosClassObjectQualifiers ( a_errorObject , classQualifierObject ) ;
  7649. if ( status )
  7650. {
  7651. status = GetMosClassObjectProperties ( a_errorObject , mosClassObject ) ;
  7652. }
  7653. else
  7654. {
  7655. }
  7656. classQualifierObject->Release () ;
  7657. }
  7658. else
  7659. {
  7660. /*
  7661. * Couldn't get object qualifier set.
  7662. */
  7663. status = FALSE ;
  7664. a_errorObject.SetStatus ( WBEM_SNMP_ERROR_CRITICAL_ERROR ) ;
  7665. a_errorObject.SetWbemStatus ( WBEM_ERROR_CRITICAL_ERROR ) ;
  7666. a_errorObject.SetMessage ( L"Failed to get object qualifier set" ) ;
  7667. }
  7668. return status ;
  7669. }
  7670. BOOL WbemSnmpClassObject :: GetMosClassObjectQualifiers ( WbemSnmpErrorObject &a_errorObject , IWbemQualifierSet *classQualifierObject )
  7671. {
  7672. DebugMacro7( SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine ( __FILE__,__LINE__,L"WbemSnmpClassObject :: GetMosClassObjectQualifiers" ) )
  7673. BOOL status = TRUE ;
  7674. HRESULT t_WBEM_result = WBEM_S_NO_ERROR ;
  7675. VARIANT variant ;
  7676. VariantInit ( & variant ) ;
  7677. WbemSnmpQualifier *qualifier ;
  7678. ResetQualifier () ;
  7679. while ( status && ( qualifier = NextQualifier () ) )
  7680. {
  7681. if ( qualifier->IsPropagatable () )
  7682. {
  7683. wchar_t *qualifierName = qualifier->GetName () ;
  7684. if ( qualifier->GetValue ( variant ) )
  7685. {
  7686. t_WBEM_result = classQualifierObject->Put ( qualifierName , &variant , WBEM_CLASS_PROPAGATION ) ;
  7687. if ( SUCCEEDED ( t_WBEM_result ) )
  7688. {
  7689. }
  7690. else
  7691. {
  7692. /*
  7693. * Failed to set qualifier value. Should not happen.
  7694. */
  7695. status = FALSE ;
  7696. a_errorObject.SetStatus ( WBEM_SNMP_ERROR_CRITICAL_ERROR ) ;
  7697. a_errorObject.SetWbemStatus ( WBEM_ERROR_CRITICAL_ERROR ) ;
  7698. a_errorObject.SetMessage ( L"Failed to set class qualifier value" ) ;
  7699. }
  7700. }
  7701. else
  7702. {
  7703. /*
  7704. * Failed to get qualifier value. Should not happen.
  7705. */
  7706. status = FALSE ;
  7707. a_errorObject.SetStatus ( WBEM_SNMP_ERROR_CRITICAL_ERROR ) ;
  7708. a_errorObject.SetWbemStatus ( WBEM_ERROR_CRITICAL_ERROR ) ;
  7709. a_errorObject.SetMessage ( L"Failed to get class qualifier value" ) ;
  7710. }
  7711. VariantClear ( & variant ) ;
  7712. }
  7713. }
  7714. return status ;
  7715. }
  7716. BOOL WbemSnmpClassObject :: GetMosClassObjectProperties ( WbemSnmpErrorObject &a_errorObject , IWbemClassObject *mosClassObject )
  7717. {
  7718. DebugMacro7( SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine ( __FILE__,__LINE__,L"WbemSnmpClassObject :: GetMosClassObjectProperties" ) )
  7719. BOOL status = TRUE ;
  7720. HRESULT t_WBEM_result = WBEM_S_NO_ERROR ;
  7721. VARIANT variant ;
  7722. VariantInit ( & variant ) ;
  7723. WbemSnmpProperty *property ;
  7724. ResetProperty () ;
  7725. while ( status && ( property = NextProperty () ) )
  7726. {
  7727. wchar_t *propertyName = property->GetName () ;
  7728. IWbemQualifierSet *propertyQualifierObject ;
  7729. if ( SUCCEEDED ( mosClassObject->GetPropertyQualifierSet ( propertyName , &propertyQualifierObject ) ) )
  7730. {
  7731. status = GetMosClassObjectPropertyQualifiers ( a_errorObject , property , propertyQualifierObject ) ;
  7732. if ( status )
  7733. {
  7734. CIMTYPE cimType ;
  7735. if ( property->GetValue ( variant , cimType ) )
  7736. {
  7737. if ( IsClass () )
  7738. {
  7739. if ( property->IsNull () )
  7740. {
  7741. t_WBEM_result = mosClassObject->Put ( propertyName , 0 , &variant , cimType ) ;
  7742. }
  7743. else
  7744. {
  7745. t_WBEM_result = mosClassObject->Put ( propertyName , 0 , &variant , 0 ) ;
  7746. }
  7747. }
  7748. else
  7749. {
  7750. t_WBEM_result = mosClassObject->Put ( propertyName , 0 , &variant , 0 ) ;
  7751. }
  7752. if ( SUCCEEDED ( t_WBEM_result ) )
  7753. {
  7754. }
  7755. else
  7756. {
  7757. /*
  7758. * Failed to set property value. Should not happen.
  7759. */
  7760. wchar_t *prefix = UnicodeStringAppend ( L"Failed to set property value for property \'" , propertyName ) ;
  7761. wchar_t *stringBuffer = UnicodeStringAppend ( prefix , L"\'" ) ;
  7762. delete [] prefix ;
  7763. a_errorObject.SetMessage ( stringBuffer ) ;
  7764. delete [] stringBuffer ;
  7765. status = FALSE ;
  7766. a_errorObject.SetStatus ( WBEM_SNMP_ERROR_CRITICAL_ERROR ) ;
  7767. a_errorObject.SetWbemStatus ( WBEM_ERROR_CRITICAL_ERROR ) ;
  7768. }
  7769. }
  7770. else
  7771. {
  7772. /*
  7773. * Failed to get property value. Should not happen.
  7774. */
  7775. status = FALSE ;
  7776. a_errorObject.SetStatus ( WBEM_SNMP_ERROR_CRITICAL_ERROR ) ;
  7777. a_errorObject.SetWbemStatus ( WBEM_ERROR_CRITICAL_ERROR ) ;
  7778. wchar_t *prefix = UnicodeStringAppend ( L"Failed to get property value for property \'" , propertyName ) ;
  7779. wchar_t *stringBuffer = UnicodeStringAppend ( prefix , L"\'" ) ;
  7780. delete [] prefix ;
  7781. a_errorObject.SetMessage ( stringBuffer ) ;
  7782. delete [] stringBuffer ;
  7783. }
  7784. VariantClear ( & variant ) ;
  7785. }
  7786. propertyQualifierObject->Release () ;
  7787. }
  7788. }
  7789. return status ;
  7790. }
  7791. BOOL WbemSnmpClassObject :: GetMosClassObjectPropertyQualifiers ( WbemSnmpErrorObject &a_errorObject , WbemSnmpProperty *snmpProperty , IWbemQualifierSet *propertyQualifierSet )
  7792. {
  7793. DebugMacro7( SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine ( __FILE__,__LINE__,L"WbemSnmpClassObject :: GetMosClassObjectPropertyQualifiers" ) )
  7794. BOOL status = TRUE ;
  7795. WBEMSTATUS t_WBEM_result = WBEM_S_NO_ERROR ;
  7796. VARIANT variant ;
  7797. VariantInit ( & variant ) ;
  7798. WbemSnmpQualifier *qualifier ;
  7799. snmpProperty->ResetQualifier () ;
  7800. while ( status && ( qualifier = snmpProperty->NextQualifier () ) )
  7801. {
  7802. if ( qualifier->IsPropagatable () )
  7803. {
  7804. wchar_t *qualifierName = qualifier->GetName () ;
  7805. if ( qualifier->GetValue ( variant ) )
  7806. {
  7807. t_WBEM_result = ( WBEMSTATUS ) propertyQualifierSet->Put ( qualifierName , &variant , WBEM_CLASS_PROPAGATION ) ;
  7808. if ( SUCCEEDED ( t_WBEM_result ) )
  7809. {
  7810. }
  7811. else
  7812. {
  7813. wchar_t *prefix = UnicodeStringAppend ( L"Failed to set property qualifier \'" , qualifierName ) ;
  7814. wchar_t *middle = UnicodeStringAppend ( prefix , L"\' for property \'" ) ;
  7815. delete [] prefix ;
  7816. wchar_t *suffix = UnicodeStringAppend ( middle , snmpProperty->GetName () ) ;
  7817. delete [] middle ;
  7818. wchar_t *stringBuffer = UnicodeStringAppend ( suffix , L"\'" ) ;
  7819. delete [] suffix ;
  7820. a_errorObject.SetMessage ( stringBuffer ) ;
  7821. delete [] stringBuffer ;
  7822. status = FALSE ;
  7823. a_errorObject.SetStatus ( WBEM_SNMP_ERROR_CRITICAL_ERROR ) ;
  7824. a_errorObject.SetWbemStatus ( WBEM_ERROR_CRITICAL_ERROR ) ;
  7825. }
  7826. }
  7827. else
  7828. {
  7829. wchar_t *prefix = UnicodeStringAppend ( L"Failed to get property qualifier \'" , qualifierName ) ;
  7830. wchar_t *middle = UnicodeStringAppend ( prefix , L"\' for property \'" ) ;
  7831. delete [] prefix ;
  7832. wchar_t *suffix = UnicodeStringAppend ( middle , snmpProperty->GetName () ) ;
  7833. delete [] middle ;
  7834. wchar_t *stringBuffer = UnicodeStringAppend ( suffix , L"\'" ) ;
  7835. delete [] suffix ;
  7836. a_errorObject.SetMessage ( stringBuffer ) ;
  7837. delete [] stringBuffer ;
  7838. status = FALSE ;
  7839. a_errorObject.SetStatus ( WBEM_SNMP_ERROR_CRITICAL_ERROR ) ;
  7840. a_errorObject.SetWbemStatus ( WBEM_ERROR_CRITICAL_ERROR ) ;
  7841. }
  7842. VariantClear ( & variant ) ;
  7843. }
  7844. }
  7845. return status ;
  7846. }