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.

2400 lines
55 KiB

  1. //***************************************************************************
  2. //
  3. // MINISERV.CPP
  4. //
  5. // Module: OLE MS SNMP Property Provider
  6. //
  7. // Purpose: Implementation for the SnmpSetEventObject class.
  8. //
  9. // Copyright (c) 1996-2001 Microsoft Corporation, All Rights Reserved
  10. //
  11. //***************************************************************************
  12. #include "precomp.h"
  13. #include <provexpt.h>
  14. #include <snmptempl.h>
  15. #include <snmpmt.h>
  16. #include <typeinfo.h>
  17. #include <process.h>
  18. #include <objbase.h>
  19. #include <stdio.h>
  20. #include <wbemidl.h>
  21. #include "classfac.h"
  22. #include "guids.h"
  23. #include <snmpcont.h>
  24. #include <snmpevt.h>
  25. #include <snmpthrd.h>
  26. #include <snmplog.h>
  27. #include <snmpcl.h>
  28. #include <instpath.h>
  29. #include <snmptype.h>
  30. #include <snmpauto.h>
  31. #include <snmpobj.h>
  32. #include <genlex.h>
  33. #include <sql_1.h>
  34. #include <objpath.h>
  35. #include "propprov.h"
  36. #include "propsnmp.h"
  37. #include "propget.h"
  38. #include "propset.h"
  39. #include "snmpget.h"
  40. #include "snmpset.h"
  41. #include "snmpqset.h"
  42. SnmpSetClassObject :: SnmpSetClassObject ( SnmpResponseEventObject *parentOperation ) :
  43. SnmpClassObject ( parentOperation ) ,
  44. m_WritableSetCount ( 0 ) ,
  45. m_WritableSet ( NULL ) ,
  46. m_RowStatusSpecified ( FALSE ) ,
  47. m_RowStatusPresent ( FALSE )
  48. {
  49. }
  50. SnmpSetClassObject :: ~SnmpSetClassObject ()
  51. {
  52. if ( m_WritableSetCount )
  53. {
  54. for ( DWORD t_Index = 0 ; t_Index < m_WritableSetCount ; t_Index ++ )
  55. {
  56. delete [] (m_WritableSet[t_Index]) ;
  57. m_WritableSet[t_Index] = NULL ;
  58. }
  59. delete [] m_WritableSet ;
  60. m_WritableSet = NULL ;
  61. m_WritableSetCount = 0 ;
  62. }
  63. }
  64. void SnmpSetClassObject :: SetWritableSet (
  65. wchar_t **a_WritableSet ,
  66. ULONG a_WritableSetCount
  67. )
  68. {
  69. if ( m_WritableSetCount )
  70. {
  71. for ( DWORD t_Index = 0 ; t_Index < m_WritableSetCount ; t_Index ++ )
  72. {
  73. delete [] (m_WritableSet[t_Index]) ;
  74. m_WritableSet[t_Index] = NULL ;
  75. }
  76. delete [] m_WritableSet;
  77. m_WritableSet = NULL ;
  78. m_WritableSetCount = 0 ;
  79. }
  80. m_WritableSet = a_WritableSet ;
  81. m_WritableSetCount = a_WritableSetCount ;
  82. }
  83. BOOL SnmpSetClassObject :: IsWritable ( WbemSnmpProperty *a_Property )
  84. {
  85. if ( a_Property )
  86. {
  87. if ( ! a_Property->GetTag () )
  88. {
  89. BOOL t_Status = ( GetSnmpVersion () == 1 ) && ( a_Property->IsSNMPV1Type () ) ;
  90. t_Status = t_Status || ( ( GetSnmpVersion () == 2 ) && ( a_Property->IsSNMPV2CType () ) ) ;
  91. if ( t_Status )
  92. {
  93. if ( a_Property->IsVirtualKey () == FALSE )
  94. {
  95. if ( a_Property->IsWritable () )
  96. {
  97. if ( m_WritableSetCount )
  98. {
  99. for ( DWORD t_Index = 0 ; t_Index < m_WritableSetCount; t_Index ++ )
  100. {
  101. if ( _wcsicmp ( a_Property->GetName () , m_WritableSet [ t_Index ] ) == 0 )
  102. {
  103. return TRUE ;
  104. }
  105. }
  106. }
  107. else
  108. {
  109. return TRUE ;
  110. }
  111. }
  112. }
  113. }
  114. }
  115. }
  116. return FALSE ;
  117. }
  118. ULONG SnmpSetClassObject :: NumberOfWritable ()
  119. {
  120. WbemSnmpProperty *t_CurrentProperty = GetCurrentProperty () ;
  121. ULONG t_NumberOfWritable = 0 ;
  122. WbemSnmpProperty *property ;
  123. ResetProperty () ;
  124. while ( property = NextProperty () )
  125. {
  126. if ( ! property->GetTag () )
  127. {
  128. BOOL t_Status = ( GetSnmpVersion () == 1 ) && ( property->IsSNMPV1Type () ) ;
  129. t_Status = t_Status || ( ( GetSnmpVersion () == 2 ) && ( property->IsSNMPV2CType () ) ) ;
  130. if ( t_Status )
  131. {
  132. if ( property->IsVirtualKey () == FALSE )
  133. {
  134. if ( property->IsWritable () )
  135. {
  136. if ( m_WritableSetCount )
  137. {
  138. for ( DWORD t_Index = 0 ; t_Index < m_WritableSetCount; t_Index ++ )
  139. {
  140. if ( _wcsicmp ( property->GetName () , m_WritableSet [ t_Index ] ) == 0 )
  141. {
  142. t_NumberOfWritable ++ ;
  143. break ;
  144. }
  145. }
  146. }
  147. else
  148. {
  149. t_NumberOfWritable ++ ;
  150. }
  151. }
  152. }
  153. }
  154. }
  155. }
  156. GotoProperty ( t_CurrentProperty ) ;
  157. return t_NumberOfWritable ;
  158. }
  159. BOOL SnmpSetClassObject :: Check ( WbemSnmpErrorObject &a_errorObject )
  160. {
  161. // Check Class Object, used in a Get Request, for validity
  162. BOOL status = TRUE ;
  163. snmpVersion = m_parentOperation->SetAgentVersion ( a_errorObject ) ;
  164. if ( snmpVersion == 0 )
  165. {
  166. status = FALSE ;
  167. }
  168. #if 0
  169. WbemSnmpQualifier *qualifier = FindQualifier ( WBEM_QUALIFIER_ROWSTATUS ) ;
  170. if ( qualifier )
  171. {
  172. SnmpInstanceType *value = qualifier->GetValue () ;
  173. if ( typeid ( *value ) == typeid ( SnmpIntegerType ) )
  174. {
  175. SnmpIntegerType *integerType = ( SnmpIntegerType * ) value ;
  176. m_RowStatusSpecified = integerType->GetValue () ;
  177. }
  178. else
  179. {
  180. // Problem Here
  181. status = FALSE ;
  182. a_errorObject.SetStatus ( WBEM_SNMP_E_TYPE_MISMATCH ) ;
  183. a_errorObject.SetWbemStatus ( WBEM_E_FAILED ) ;
  184. a_errorObject.SetMessage ( L"Type mismatch for qualifier: RowStatus" ) ;
  185. }
  186. }
  187. #endif
  188. // Check all Properties for validity
  189. WbemSnmpProperty *property ;
  190. ResetProperty () ;
  191. while ( status && ( property = NextProperty () ) )
  192. {
  193. status = CheckProperty ( a_errorObject , property ) ;
  194. }
  195. if ( ! m_accessible )
  196. {
  197. status = FALSE ;
  198. a_errorObject.SetStatus ( WBEM_SNMP_E_NOWRITABLEPROPERTIES ) ;
  199. a_errorObject.SetWbemStatus ( WBEM_E_FAILED ) ;
  200. a_errorObject.SetMessage ( L"Class must contain at least one property which is accessible" ) ;
  201. }
  202. if ( m_RowStatusSpecified && ! m_RowStatusPresent )
  203. {
  204. status = FALSE ;
  205. a_errorObject.SetStatus ( WBEM_SNMP_E_INVALID_CLASS ) ;
  206. a_errorObject.SetWbemStatus ( WBEM_E_FAILED ) ;
  207. a_errorObject.SetMessage ( L"Class must contain at least one property which is of type RowStatus" ) ;
  208. }
  209. return status ;
  210. }
  211. BOOL SnmpSetClassObject :: CheckProperty ( WbemSnmpErrorObject &a_errorObject , WbemSnmpProperty *property )
  212. {
  213. // Check property validity
  214. BOOL status = TRUE ;
  215. if ( typeid ( *property->GetValue () ) == typeid ( SnmpObjectIdentifierType ) )
  216. {
  217. SnmpObjectIdentifierType *t_ObjectIdentifier = ( SnmpObjectIdentifierType * ) property->GetValue () ;
  218. if ( t_ObjectIdentifier->GetValueLength () < 2 )
  219. {
  220. status = FALSE ;
  221. a_errorObject.SetStatus ( WBEM_SNMP_E_TYPE_MISMATCH ) ;
  222. a_errorObject.SetWbemStatus ( WBEM_E_FAILED ) ;
  223. wchar_t *temp = UnicodeStringDuplicate ( L"Type Mismatch for property: " ) ;
  224. wchar_t *stringBuffer = UnicodeStringAppend ( temp , property->GetName () ) ;
  225. delete [] temp ;
  226. a_errorObject.SetMessage ( stringBuffer ) ;
  227. delete [] stringBuffer ;
  228. }
  229. }
  230. if ( typeid ( *property->GetValue () ) == typeid ( SnmpRowStatusType ) )
  231. {
  232. if ( m_RowStatusPresent )
  233. {
  234. status = FALSE ;
  235. a_errorObject.SetStatus ( WBEM_SNMP_E_INVALID_CLASS ) ;
  236. a_errorObject.SetWbemStatus ( WBEM_E_FAILED ) ;
  237. a_errorObject.SetMessage ( L"Class contains more than one property with RowStatus type definition" ) ;
  238. }
  239. else
  240. {
  241. m_RowStatusPresent = TRUE ;
  242. }
  243. }
  244. if ( ( snmpVersion == 1 ) && property->IsSNMPV1Type () && IsWritable ( property ) )
  245. {
  246. m_accessible = TRUE ;
  247. }
  248. else if ( ( snmpVersion == 2 ) && property->IsSNMPV2CType () && IsWritable ( property ) )
  249. {
  250. m_accessible = TRUE ;
  251. }
  252. return status ;
  253. }
  254. SnmpSetResponseEventObject :: SnmpSetResponseEventObject (
  255. CImpPropProv *providerArg ,
  256. IWbemClassObject *classObjectArg ,
  257. IWbemContext *a_Context ,
  258. long lflags
  259. ) : SnmpResponseEventObject ( providerArg , a_Context ) ,
  260. classObject ( NULL ) ,
  261. session ( NULL ) ,
  262. operation ( NULL ) ,
  263. processComplete ( FALSE ) ,
  264. m_lflags ( lflags ) ,
  265. state ( 0 ) ,
  266. m_SnmpTooBig ( FALSE ) ,
  267. m_VarBindsLeftBeforeTooBig ( 0 ) ,
  268. #pragma warning (disable:4355)
  269. snmpObject ( this )
  270. #pragma warning (default:4355)
  271. {
  272. if ( classObjectArg )
  273. {
  274. classObject = classObjectArg;
  275. classObject->AddRef () ;
  276. }
  277. if ( a_Context )
  278. {
  279. VARIANT t_Variant ;
  280. VariantInit ( & t_Variant ) ;
  281. HRESULT t_Result = a_Context->GetValue ( L"__PUT_EXTENSIONS" , 0 , & t_Variant ) ;
  282. if ( SUCCEEDED ( t_Result ) )
  283. {
  284. if ( t_Variant.vt == VT_BOOL && t_Variant.boolVal == VARIANT_TRUE )
  285. {
  286. VARIANT t_ArrayVariant ;
  287. VariantInit ( & t_ArrayVariant ) ;
  288. HRESULT t_Result = a_Context->GetValue ( L"__PUT_EXT_PROPERTIES" , 0 , & t_ArrayVariant ) ;
  289. if ( SUCCEEDED ( t_Result ) )
  290. {
  291. if ( t_ArrayVariant.vt == ( VT_ARRAY | VT_BSTR ) )
  292. {
  293. if ( SafeArrayGetDim ( t_ArrayVariant.parray ) == 1 )
  294. {
  295. LONG t_Dimension = 1 ;
  296. LONG t_Lower ;
  297. SafeArrayGetLBound ( t_ArrayVariant.parray , t_Dimension , & t_Lower ) ;
  298. LONG t_Upper ;
  299. SafeArrayGetUBound ( t_ArrayVariant.parray , t_Dimension , & t_Upper ) ;
  300. LONG t_Count = ( t_Upper - t_Lower ) + 1 ;
  301. DWORD t_WritableSetCount = t_Count ;
  302. wchar_t **t_WritableSet = new wchar_t * [ t_Count ] ;
  303. for ( LONG t_ElementIndex = t_Lower ; t_ElementIndex <= t_Upper ; t_ElementIndex ++ )
  304. {
  305. BSTR t_Element ;
  306. SafeArrayGetElement ( t_ArrayVariant.parray , &t_ElementIndex , & t_Element ) ;
  307. wchar_t *t_String = new wchar_t [ wcslen ( t_Element ) + 1 ] ;
  308. wcscpy ( t_String , t_Element ) ;
  309. t_WritableSet [ t_ElementIndex - t_Lower ] = t_String ;
  310. }
  311. snmpObject.SetWritableSet ( t_WritableSet , t_WritableSetCount ) ;
  312. }
  313. }
  314. VariantClear ( & t_ArrayVariant ) ;
  315. }
  316. }
  317. VariantClear ( & t_Variant ) ;
  318. }
  319. }
  320. }
  321. SnmpSetResponseEventObject :: ~SnmpSetResponseEventObject ()
  322. {
  323. if ( classObject )
  324. classObject->Release () ;
  325. }
  326. BOOL SnmpSetResponseEventObject :: SendSnmp ( WbemSnmpErrorObject &a_errorObject , const ULONG &a_NumberToSend )
  327. {
  328. m_SnmpTooBig = FALSE ;
  329. BOOL status = TRUE ;
  330. IWbemQualifierSet *classQualifierObject ;
  331. HRESULT result = m_namespaceObject->GetQualifierSet ( &classQualifierObject ) ;
  332. if ( SUCCEEDED ( result ) )
  333. {
  334. wchar_t *agentAddress = NULL ;
  335. wchar_t *agentTransport = NULL ;
  336. wchar_t *agentWriteCommunityName = NULL ;
  337. ULONG agentRetryCount ;
  338. ULONG agentRetryTimeout ;
  339. ULONG agentMaxVarBindsPerPdu ;
  340. ULONG agentFlowControlWindowSize ;
  341. status = SetAgentVersion ( m_errorObject ) ;
  342. if ( status ) status = GetAgentAddress ( m_errorObject , classQualifierObject , agentAddress ) ;
  343. if ( status ) status = GetAgentTransport ( m_errorObject , classQualifierObject , agentTransport ) ;
  344. if ( status ) status = GetAgentWriteCommunityName ( m_errorObject , classQualifierObject , agentWriteCommunityName ) ;
  345. if ( status ) status = GetAgentRetryCount ( m_errorObject , classQualifierObject , agentRetryCount ) ;
  346. if ( status ) status = GetAgentRetryTimeout ( m_errorObject , classQualifierObject , agentRetryTimeout ) ;
  347. if ( status ) status = GetAgentMaxVarBindsPerPdu ( m_errorObject , classQualifierObject , agentMaxVarBindsPerPdu ) ;
  348. if ( status ) status = GetAgentFlowControlWindowSize ( m_errorObject , classQualifierObject , agentFlowControlWindowSize ) ;
  349. if ( status )
  350. {
  351. char *dbcsAgentAddress = UnicodeToDbcsString ( agentAddress ) ;
  352. if ( dbcsAgentAddress )
  353. {
  354. char *dbcsagentWriteCommunityName = UnicodeToDbcsString ( agentWriteCommunityName ) ;
  355. if ( dbcsagentWriteCommunityName )
  356. {
  357. if ( _wcsicmp ( agentTransport , WBEM_AGENTIPTRANSPORT ) == 0 )
  358. {
  359. char *t_Address ;
  360. if ( provider->GetIpAddressString () && provider->GetIpAddressValue () && _stricmp ( provider->GetIpAddressString () , dbcsAgentAddress ) == 0 )
  361. {
  362. t_Address = provider->GetIpAddressValue () ;
  363. }
  364. else
  365. {
  366. if ( SnmpTransportIpAddress :: ValidateAddress ( dbcsAgentAddress , SNMP_ADDRESS_RESOLVE_VALUE ) )
  367. {
  368. t_Address = dbcsAgentAddress ;
  369. }
  370. else
  371. {
  372. if ( SnmpTransportIpAddress :: ValidateAddress ( dbcsAgentAddress , SNMP_ADDRESS_RESOLVE_NAME ) )
  373. {
  374. t_Address = dbcsAgentAddress ;
  375. }
  376. else
  377. {
  378. status = FALSE ;
  379. a_errorObject.SetStatus ( WBEM_SNMP_E_INVALID_TRANSPORTCONTEXT ) ;
  380. a_errorObject.SetWbemStatus ( WBEM_E_FAILED ) ;
  381. a_errorObject.SetMessage ( L"Illegal IP address value or unresolvable name for AgentAddress" ) ;
  382. }
  383. }
  384. }
  385. if ( status )
  386. {
  387. if ( m_agentVersion == 1 )
  388. {
  389. session = new SnmpV1OverIp (
  390. t_Address ,
  391. SNMP_ADDRESS_RESOLVE_NAME | SNMP_ADDRESS_RESOLVE_VALUE ,
  392. dbcsagentWriteCommunityName ,
  393. agentRetryCount ,
  394. agentRetryTimeout ,
  395. agentMaxVarBindsPerPdu ,
  396. agentFlowControlWindowSize
  397. );
  398. if ( ! (*session)() )
  399. {
  400. DebugMacro3(
  401. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  402. __FILE__,__LINE__,
  403. L"SNMPCL Session could not be created"
  404. ) ;
  405. )
  406. delete session ;
  407. session = NULL ;
  408. status = FALSE ;
  409. a_errorObject.SetStatus ( WBEM_SNMP_E_TRANSPORT_ERROR ) ;
  410. a_errorObject.SetWbemStatus ( WBEM_E_FAILED ) ;
  411. a_errorObject.SetMessage ( L"Failed to get transport resources" ) ;
  412. }
  413. }
  414. else if ( m_agentVersion == 2 )
  415. {
  416. session = new SnmpV2COverIp (
  417. t_Address ,
  418. SNMP_ADDRESS_RESOLVE_NAME | SNMP_ADDRESS_RESOLVE_VALUE ,
  419. dbcsagentWriteCommunityName ,
  420. agentRetryCount ,
  421. agentRetryTimeout ,
  422. agentMaxVarBindsPerPdu ,
  423. agentFlowControlWindowSize
  424. );
  425. if ( ! (*session)() )
  426. {
  427. DebugMacro3(
  428. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  429. __FILE__,__LINE__,
  430. L"SNMPCL Session could not be created"
  431. ) ;
  432. )
  433. delete session ;
  434. session = NULL ;
  435. status = FALSE ;
  436. a_errorObject.SetStatus ( WBEM_SNMP_E_TRANSPORT_ERROR ) ;
  437. a_errorObject.SetWbemStatus ( WBEM_E_FAILED ) ;
  438. a_errorObject.SetMessage ( L"Failed to get transport resources" ) ;
  439. }
  440. }
  441. else
  442. {
  443. status = FALSE ;
  444. a_errorObject.SetStatus ( WBEM_SNMP_E_INVALID_TRANSPORTCONTEXT ) ;
  445. a_errorObject.SetWbemStatus ( WBEM_E_FAILED ) ;
  446. a_errorObject.SetMessage ( L"Illegal value for qualifier: AgentSnmpVersion" ) ;
  447. }
  448. }
  449. }
  450. else if ( _wcsicmp ( agentTransport , WBEM_AGENTIPXTRANSPORT ) == 0 )
  451. {
  452. if ( m_agentVersion == 1 )
  453. {
  454. session = new SnmpV1OverIpx (
  455. dbcsAgentAddress ,
  456. dbcsagentWriteCommunityName ,
  457. agentRetryCount ,
  458. agentRetryTimeout ,
  459. agentMaxVarBindsPerPdu ,
  460. agentFlowControlWindowSize
  461. );
  462. if ( ! (*session)() )
  463. {
  464. DebugMacro3(
  465. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  466. __FILE__,__LINE__,
  467. L"SNMPCL Session could not be created"
  468. ) ;
  469. )
  470. delete session ;
  471. session = NULL ;
  472. status = FALSE ;
  473. a_errorObject.SetStatus ( WBEM_SNMP_E_TRANSPORT_ERROR ) ;
  474. a_errorObject.SetWbemStatus ( WBEM_E_FAILED ) ;
  475. a_errorObject.SetMessage ( L"Failed to get transport resources" ) ;
  476. }
  477. }
  478. else if ( m_agentVersion == 2 )
  479. {
  480. session = new SnmpV2COverIpx (
  481. dbcsAgentAddress ,
  482. dbcsagentWriteCommunityName ,
  483. agentRetryCount ,
  484. agentRetryTimeout ,
  485. agentMaxVarBindsPerPdu ,
  486. agentFlowControlWindowSize
  487. );
  488. if ( ! (*session)() )
  489. {
  490. DebugMacro3(
  491. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  492. __FILE__,__LINE__,
  493. L"SNMPCL Session could not be created"
  494. ) ;
  495. )
  496. delete session ;
  497. session = NULL ;
  498. status = FALSE ;
  499. a_errorObject.SetStatus ( WBEM_SNMP_E_TRANSPORT_ERROR ) ;
  500. a_errorObject.SetWbemStatus ( WBEM_E_FAILED ) ;
  501. a_errorObject.SetMessage ( L"Failed to get transport resources" ) ;
  502. }
  503. }
  504. else
  505. {
  506. status = FALSE ;
  507. a_errorObject.SetStatus ( WBEM_SNMP_E_INVALID_TRANSPORTCONTEXT ) ;
  508. a_errorObject.SetWbemStatus ( WBEM_E_FAILED ) ;
  509. a_errorObject.SetMessage ( L"Illegal value for qualifier: AgentSnmpVersion" ) ;
  510. }
  511. }
  512. else
  513. {
  514. status = FALSE ;
  515. a_errorObject.SetStatus ( WBEM_SNMP_E_INVALID_TRANSPORTCONTEXT ) ;
  516. a_errorObject.SetWbemStatus ( WBEM_E_FAILED ) ;
  517. a_errorObject.SetMessage ( L"Illegal value for qualifier: AgentTransport" ) ;
  518. }
  519. delete [] dbcsagentWriteCommunityName ;
  520. }
  521. else
  522. {
  523. status = FALSE ;
  524. a_errorObject.SetStatus ( WBEM_SNMP_E_INVALID_TRANSPORTCONTEXT ) ;
  525. a_errorObject.SetWbemStatus ( WBEM_E_FAILED ) ;
  526. a_errorObject.SetMessage ( L"Illegal value for qualifier: agentWriteCommunityName" ) ;
  527. }
  528. delete [] dbcsAgentAddress ;
  529. if ( status )
  530. {
  531. operation = new SetOperation(*session,this);
  532. operation->Send ( a_NumberToSend ) ;
  533. }
  534. }
  535. else
  536. {
  537. status = FALSE ;
  538. a_errorObject.SetStatus ( WBEM_SNMP_E_INVALID_TRANSPORTCONTEXT ) ;
  539. a_errorObject.SetWbemStatus ( WBEM_E_FAILED ) ;
  540. a_errorObject.SetMessage ( L"Illegal value for qualifier: AgentAddress" ) ;
  541. }
  542. }
  543. else
  544. {
  545. DebugMacro1(
  546. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  547. __FILE__,__LINE__,
  548. L" TransportInformation settings invalid"
  549. ) ;
  550. )
  551. }
  552. delete [] agentTransport ;
  553. delete [] agentAddress ;
  554. delete [] agentWriteCommunityName ;
  555. classQualifierObject->Release () ;
  556. }
  557. else
  558. {
  559. status = FALSE ;
  560. a_errorObject.SetStatus ( WBEM_SNMP_ERROR_CRITICAL_ERROR ) ;
  561. a_errorObject.SetWbemStatus ( WBEM_ERROR_CRITICAL_ERROR ) ;
  562. a_errorObject.SetMessage ( L"Failed to get class qualifier set" ) ;
  563. }
  564. return status ;
  565. }
  566. SnmpUpdateEventObject :: SnmpUpdateEventObject (
  567. CImpPropProv *providerArg ,
  568. IWbemClassObject *classObject ,
  569. IWbemContext *a_Context ,
  570. long lflags
  571. ) : SnmpSetResponseEventObject ( providerArg , classObject , a_Context , lflags )
  572. {
  573. }
  574. SnmpUpdateEventObject :: ~SnmpUpdateEventObject ()
  575. {
  576. }
  577. BOOL SnmpUpdateEventObject :: CheckForRowExistence ( WbemSnmpErrorObject &a_errorObject )
  578. {
  579. DebugMacro3(
  580. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  581. __FILE__,__LINE__,
  582. L"SnmpUpdateEventObject :: CheckForRowExistence ( WbemSnmpErrorObject &a_errorObject )"
  583. ) ;
  584. )
  585. BOOL status = TRUE ;
  586. IWbemQualifierSet *classQualifierObject ;
  587. HRESULT result = m_namespaceObject->GetQualifierSet ( &classQualifierObject ) ;
  588. if ( SUCCEEDED ( result ) )
  589. {
  590. wchar_t *agentAddress = NULL ;
  591. wchar_t *agentTransport = NULL ;
  592. wchar_t *agentWriteCommunityName = NULL ;
  593. ULONG agentRetryCount ;
  594. ULONG agentRetryTimeout ;
  595. ULONG agentMaxVarBindsPerPdu ;
  596. ULONG agentFlowControlWindowSize ;
  597. status = SetAgentVersion ( m_errorObject ) ;
  598. if ( status ) status = GetAgentAddress ( m_errorObject , classQualifierObject , agentAddress ) ;
  599. if ( status ) status = GetAgentTransport ( m_errorObject , classQualifierObject , agentTransport ) ;
  600. if ( status ) status = GetAgentWriteCommunityName ( m_errorObject , classQualifierObject , agentWriteCommunityName ) ;
  601. if ( status ) status = GetAgentRetryCount ( m_errorObject , classQualifierObject , agentRetryCount ) ;
  602. if ( status ) status = GetAgentRetryTimeout ( m_errorObject , classQualifierObject , agentRetryTimeout ) ;
  603. if ( status ) status = GetAgentMaxVarBindsPerPdu ( m_errorObject , classQualifierObject , agentMaxVarBindsPerPdu ) ;
  604. if ( status ) status = GetAgentFlowControlWindowSize ( m_errorObject , classQualifierObject , agentFlowControlWindowSize ) ;
  605. if ( status )
  606. {
  607. char *dbcsAgentAddress = UnicodeToDbcsString ( agentAddress ) ;
  608. if ( dbcsAgentAddress )
  609. {
  610. char *dbcsagentWriteCommunityName = UnicodeToDbcsString ( agentWriteCommunityName ) ;
  611. if ( dbcsagentWriteCommunityName )
  612. {
  613. if ( _wcsicmp ( agentTransport , WBEM_AGENTIPTRANSPORT ) == 0 )
  614. {
  615. char *t_Address ;
  616. if ( provider->GetIpAddressString () && provider->GetIpAddressValue () && _stricmp ( provider->GetIpAddressString () , dbcsAgentAddress ) == 0 )
  617. {
  618. t_Address = provider->GetIpAddressValue () ;
  619. }
  620. else
  621. {
  622. t_Address = dbcsAgentAddress ;
  623. }
  624. if ( m_agentVersion == 1 )
  625. {
  626. session = new SnmpV1OverIp (
  627. t_Address ,
  628. SNMP_ADDRESS_RESOLVE_NAME | SNMP_ADDRESS_RESOLVE_VALUE ,
  629. dbcsagentWriteCommunityName ,
  630. agentRetryCount ,
  631. agentRetryTimeout ,
  632. agentFlowControlWindowSize ,
  633. agentMaxVarBindsPerPdu
  634. );
  635. if ( ! (*session)() )
  636. {
  637. DebugMacro3(
  638. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  639. __FILE__,__LINE__,
  640. L"SNMPCL Session could not be created"
  641. ) ;
  642. )
  643. delete session ;
  644. session = NULL ;
  645. status = FALSE ;
  646. a_errorObject.SetStatus ( WBEM_SNMP_E_TRANSPORT_ERROR ) ;
  647. a_errorObject.SetWbemStatus ( WBEM_E_FAILED ) ;
  648. a_errorObject.SetMessage ( L"Failed to get transport resources" ) ;
  649. }
  650. }
  651. else if ( m_agentVersion == 2 )
  652. {
  653. session = new SnmpV2COverIp (
  654. t_Address ,
  655. SNMP_ADDRESS_RESOLVE_NAME | SNMP_ADDRESS_RESOLVE_VALUE ,
  656. dbcsagentWriteCommunityName ,
  657. agentRetryCount ,
  658. agentRetryTimeout ,
  659. agentFlowControlWindowSize ,
  660. agentMaxVarBindsPerPdu
  661. );
  662. if ( ! (*session)() )
  663. {
  664. DebugMacro3(
  665. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  666. __FILE__,__LINE__,
  667. L"SNMPCL Session could not be created"
  668. ) ;
  669. )
  670. delete session ;
  671. session = NULL ;
  672. status = FALSE ;
  673. a_errorObject.SetStatus ( WBEM_SNMP_E_TRANSPORT_ERROR ) ;
  674. a_errorObject.SetWbemStatus ( WBEM_E_FAILED ) ;
  675. a_errorObject.SetMessage ( L"Failed to get transport resources" ) ;
  676. }
  677. }
  678. else
  679. {
  680. status = FALSE ;
  681. a_errorObject.SetStatus ( WBEM_SNMP_E_INVALID_TRANSPORTCONTEXT ) ;
  682. a_errorObject.SetWbemStatus ( WBEM_E_FAILED ) ;
  683. a_errorObject.SetMessage ( L"Illegal value for qualifier: AgentSnmpVersion" ) ;
  684. }
  685. }
  686. else if ( _wcsicmp ( agentTransport , WBEM_AGENTIPXTRANSPORT ) == 0 )
  687. {
  688. if ( m_agentVersion == 1 )
  689. {
  690. session = new SnmpV1OverIpx (
  691. dbcsAgentAddress ,
  692. dbcsagentWriteCommunityName ,
  693. agentRetryCount ,
  694. agentRetryTimeout ,
  695. agentFlowControlWindowSize ,
  696. agentMaxVarBindsPerPdu
  697. );
  698. if ( ! (*session)() )
  699. {
  700. DebugMacro3(
  701. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  702. __FILE__,__LINE__,
  703. L"SNMPCL Session could not be created"
  704. ) ;
  705. )
  706. delete session ;
  707. session = NULL ;
  708. status = FALSE ;
  709. a_errorObject.SetStatus ( WBEM_SNMP_E_TRANSPORT_ERROR ) ;
  710. a_errorObject.SetWbemStatus ( WBEM_E_FAILED ) ;
  711. a_errorObject.SetMessage ( L"Failed to get transport resources" ) ;
  712. }
  713. }
  714. else if ( m_agentVersion == 2 )
  715. {
  716. session = new SnmpV2COverIpx (
  717. dbcsAgentAddress ,
  718. dbcsagentWriteCommunityName ,
  719. agentRetryCount ,
  720. agentRetryTimeout ,
  721. agentFlowControlWindowSize ,
  722. agentMaxVarBindsPerPdu
  723. );
  724. if ( ! (*session)() )
  725. {
  726. DebugMacro3(
  727. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  728. __FILE__,__LINE__,
  729. L"SNMPCL Session could not be created"
  730. ) ;
  731. )
  732. delete session ;
  733. session = NULL ;
  734. status = FALSE ;
  735. a_errorObject.SetStatus ( WBEM_SNMP_E_TRANSPORT_ERROR ) ;
  736. a_errorObject.SetWbemStatus ( WBEM_E_FAILED ) ;
  737. a_errorObject.SetMessage ( L"Failed to get transport resources" ) ;
  738. }
  739. }
  740. else
  741. {
  742. status = FALSE ;
  743. a_errorObject.SetStatus ( WBEM_SNMP_E_INVALID_TRANSPORTCONTEXT ) ;
  744. a_errorObject.SetWbemStatus ( WBEM_E_FAILED ) ;
  745. a_errorObject.SetMessage ( L"Illegal value for qualifier: AgentSnmpVersion" ) ;
  746. }
  747. }
  748. else
  749. {
  750. status = FALSE ;
  751. a_errorObject.SetStatus ( WBEM_SNMP_E_INVALID_TRANSPORTCONTEXT ) ;
  752. a_errorObject.SetWbemStatus ( WBEM_E_FAILED ) ;
  753. a_errorObject.SetMessage ( L"Illegal value for qualifier: AgentTransport" ) ;
  754. }
  755. delete [] dbcsagentWriteCommunityName ;
  756. }
  757. else
  758. {
  759. status = FALSE ;
  760. a_errorObject.SetStatus ( WBEM_SNMP_E_INVALID_TRANSPORTCONTEXT ) ;
  761. a_errorObject.SetWbemStatus ( WBEM_E_FAILED ) ;
  762. a_errorObject.SetMessage ( L"Illegal value for qualifier: agentWriteCommunityName" ) ;
  763. }
  764. delete [] dbcsAgentAddress ;
  765. if ( status )
  766. {
  767. m_QueryOperation = new SetQueryOperation(*session,this);
  768. m_QueryOperation->Send () ;
  769. }
  770. }
  771. else
  772. {
  773. status = FALSE ;
  774. a_errorObject.SetStatus ( WBEM_SNMP_E_INVALID_TRANSPORTCONTEXT ) ;
  775. a_errorObject.SetWbemStatus ( WBEM_E_FAILED ) ;
  776. a_errorObject.SetMessage ( L"Illegal value for qualifier: AgentAddress" ) ;
  777. }
  778. }
  779. else
  780. {
  781. DebugMacro1(
  782. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  783. __FILE__,__LINE__,
  784. L" TransportInformation settings invalid"
  785. ) ;
  786. )
  787. }
  788. delete [] agentTransport ;
  789. delete [] agentAddress ;
  790. delete [] agentWriteCommunityName ;
  791. classQualifierObject->Release () ;
  792. }
  793. else
  794. {
  795. status = FALSE ;
  796. a_errorObject.SetStatus ( WBEM_SNMP_ERROR_CRITICAL_ERROR ) ;
  797. a_errorObject.SetWbemStatus ( WBEM_ERROR_CRITICAL_ERROR ) ;
  798. a_errorObject.SetMessage ( L"Failed to get class qualifier set" ) ;
  799. }
  800. return status ;
  801. }
  802. BOOL SnmpUpdateEventObject :: Update ( WbemSnmpErrorObject &a_errorObject )
  803. {
  804. DebugMacro3(
  805. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  806. __FILE__,__LINE__,
  807. L"SnmpUpdateEventObject :: Update ( WbemSnmpErrorObject &a_errorObject )"
  808. ) ;
  809. )
  810. BOOL status = TRUE ;
  811. HRESULT t_WBEM_result = WBEM_S_NO_ERROR ;
  812. IWbemClassObject *t_ClassObject = NULL ;
  813. VARIANT variant ;
  814. VariantInit ( & variant ) ;
  815. t_WBEM_result = classObject->Get ( WBEM_PROPERTY_CLASS , 0 , &variant , NULL , NULL ) ;
  816. if ( SUCCEEDED ( t_WBEM_result ) )
  817. {
  818. IWbemServices *t_Serv = provider->GetServer();
  819. HRESULT result = WBEM_E_FAILED;
  820. if (t_Serv)
  821. {
  822. result = t_Serv->GetObject (
  823. variant.bstrVal ,
  824. 0 ,
  825. m_Context ,
  826. & t_ClassObject ,
  827. NULL
  828. ) ;
  829. t_Serv->Release();
  830. }
  831. VariantClear ( & variant ) ;
  832. if ( SUCCEEDED ( result ) )
  833. {
  834. if ( status = GetNamespaceObject ( a_errorObject ) )
  835. {
  836. status = snmpObject.Set ( a_errorObject , t_ClassObject , FALSE ) ;
  837. if ( status )
  838. {
  839. status = snmpObject.Merge ( a_errorObject , GetClassObject () ) ;
  840. if ( status )
  841. {
  842. status = snmpObject.Check ( a_errorObject ) ;
  843. if ( status )
  844. {
  845. status = HandleSnmpVersion ( a_errorObject ) ;
  846. }
  847. else
  848. {
  849. DebugMacro3(
  850. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  851. __FILE__,__LINE__,
  852. L"Failed During Check : Class definition did not conform to mapping"
  853. ) ;
  854. )
  855. }
  856. }
  857. else
  858. {
  859. DebugMacro3(
  860. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  861. __FILE__,__LINE__,
  862. L"Failed During Merge : Class definition did not conform to mapping"
  863. ) ;
  864. )
  865. }
  866. }
  867. else
  868. {
  869. DebugMacro3(
  870. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  871. __FILE__,__LINE__,
  872. L"Failed During Set : Class definition did not conform to mapping"
  873. ) ;
  874. )
  875. }
  876. }
  877. t_ClassObject->Release () ;
  878. }
  879. }
  880. DebugMacro3(
  881. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  882. __FILE__,__LINE__,
  883. L"Returning from SnmpUpdateEventObject :: Update ( WbemSnmpErrorObject &a_errorObject ) with Result (%lx)" ,
  884. a_errorObject.GetWbemStatus ()
  885. ) ;
  886. )
  887. return status ;
  888. }
  889. SnmpUpdateAsyncEventObject :: SnmpUpdateAsyncEventObject (
  890. CImpPropProv *providerArg ,
  891. IWbemClassObject *classObject ,
  892. IWbemObjectSink *notify ,
  893. IWbemContext *a_Context ,
  894. long lflags
  895. ) : SnmpUpdateEventObject ( providerArg , classObject , a_Context , lflags ) , notificationHandler ( notify )
  896. {
  897. DebugMacro3(
  898. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  899. __FILE__,__LINE__,
  900. L"SnmpUpdateAsyncEventObject :: SnmpUpdateAsyncEventObject ()"
  901. ) ;
  902. )
  903. notify->AddRef () ;
  904. }
  905. SnmpUpdateAsyncEventObject :: ~SnmpUpdateAsyncEventObject ()
  906. {
  907. DebugMacro3(
  908. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  909. __FILE__,__LINE__,
  910. L"SnmpUpdateAsyncEventObject :: ~SnmpUpdateAsyncEventObject ()"
  911. ) ;
  912. )
  913. if ( FAILED ( m_errorObject.GetWbemStatus () ) )
  914. {
  915. // Get Status object
  916. IWbemClassObject *notifyStatus ;
  917. BOOL status = GetSnmpNotifyStatusObject ( &notifyStatus ) ;
  918. if ( status )
  919. {
  920. DebugMacro3(
  921. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  922. __FILE__,__LINE__,
  923. L"Sending Status"
  924. ) ;
  925. )
  926. HRESULT result = notificationHandler->SetStatus ( 0 , m_errorObject.GetWbemStatus () , NULL , notifyStatus ) ;
  927. notifyStatus->Release () ;
  928. }
  929. else
  930. {
  931. HRESULT result = notificationHandler->SetStatus ( 0 , m_errorObject.GetWbemStatus () , NULL , NULL ) ;
  932. }
  933. }
  934. else
  935. {
  936. HRESULT result = notificationHandler->SetStatus ( 0 , m_errorObject.GetWbemStatus () , NULL , NULL ) ;
  937. }
  938. notificationHandler->Release () ;
  939. DebugMacro3(
  940. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  941. __FILE__,__LINE__,
  942. L"Returning from SnmpUpdateAsyncEventObject :: ~SnmpUpdateAsyncEventObject ()"
  943. ) ;
  944. )
  945. }
  946. void SnmpUpdateAsyncEventObject :: SetComplete ()
  947. {
  948. DebugMacro3(
  949. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  950. __FILE__,__LINE__,
  951. L"SnmpUpdateAsyncEventObject :: SetComplete ()"
  952. ) ;
  953. )
  954. if ( SUCCEEDED ( m_errorObject.GetWbemStatus () ) )
  955. {
  956. DebugMacro3(
  957. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  958. __FILE__,__LINE__,
  959. L"Update Succeeded"
  960. ) ;
  961. )
  962. WbemSnmpErrorObject errorObject ;
  963. IWbemClassObject *classObject = GetClassObject () ;
  964. BOOL status = snmpObject.Get ( errorObject , classObject ) ;
  965. if ( status )
  966. {
  967. if ( notificationHandler )
  968. {
  969. DebugMacro3(
  970. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  971. __FILE__,__LINE__,
  972. L"Sending Object"
  973. ) ;
  974. )
  975. notificationHandler->Indicate ( 1 , & classObject ) ;
  976. }
  977. }
  978. else
  979. {
  980. }
  981. }
  982. else
  983. {
  984. }
  985. /*
  986. * Remove worker object from worker thread container
  987. */
  988. DebugMacro3(
  989. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  990. __FILE__,__LINE__,
  991. L"Reaping Task"
  992. ) ;
  993. )
  994. SetOperation *t_operation = operation ;
  995. DebugMacro3(
  996. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  997. __FILE__,__LINE__,
  998. L"Deleting (this)"
  999. ) ;
  1000. )
  1001. Complete () ;
  1002. DebugMacro3(
  1003. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  1004. __FILE__,__LINE__,
  1005. L"Destroying SNMPCL operation"
  1006. ) ;
  1007. )
  1008. if ( t_operation )
  1009. t_operation->DestroyOperation () ;
  1010. DebugMacro3(
  1011. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  1012. __FILE__,__LINE__,
  1013. L"Returning from SnmpUpdateAsyncEventObject :: SetComplete ()"
  1014. ) ;
  1015. )
  1016. }
  1017. void SnmpUpdateAsyncEventObject :: Process ()
  1018. {
  1019. DebugMacro3(
  1020. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  1021. __FILE__,__LINE__,
  1022. L"SnmpUpdateAsyncEventObject :: Process ()"
  1023. ) ;
  1024. )
  1025. switch ( state )
  1026. {
  1027. case 0:
  1028. {
  1029. BOOL status = Update ( m_errorObject ) ;
  1030. if ( status )
  1031. {
  1032. }
  1033. else
  1034. {
  1035. ReceiveComplete () ;
  1036. }
  1037. }
  1038. break ;
  1039. default:
  1040. {
  1041. }
  1042. break ;
  1043. }
  1044. DebugMacro3(
  1045. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  1046. __FILE__,__LINE__,
  1047. L"Returning from SnmpUpdateAsyncEventObject :: Process ()"
  1048. ) ;
  1049. )
  1050. }
  1051. BOOL SnmpUpdateEventObject :: HandleSnmpVersion ( WbemSnmpErrorObject &a_ErrorObject )
  1052. {
  1053. DebugMacro3(
  1054. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  1055. __FILE__,__LINE__,
  1056. L"SnmpUpdateEventObject :: HandleSnmpVersion ( WbemSnmpErrorObject &a_ErrorObject )"
  1057. ) ;
  1058. )
  1059. BOOL t_Status = FALSE ;
  1060. if ( snmpObject.RowStatusSpecified () )
  1061. {
  1062. if ( snmpObject.GetSnmpVersion () == 1 )
  1063. {
  1064. if ( WBEM_FLAG_CREATE_OR_UPDATE == ( m_lflags & WBEM_FLAG_CREATE_OR_UPDATE ) )
  1065. {
  1066. t_Status = Create_Or_Update () ;
  1067. }
  1068. else if ( WBEM_FLAG_CREATE_ONLY == ( m_lflags & WBEM_FLAG_CREATE_ONLY ) )
  1069. {
  1070. t_Status = Create_Only () ;
  1071. }
  1072. else if ( WBEM_FLAG_UPDATE_ONLY == ( m_lflags & WBEM_FLAG_UPDATE_ONLY ) )
  1073. {
  1074. t_Status = Update_Only () ;
  1075. }
  1076. else
  1077. {
  1078. t_Status = FALSE ;
  1079. }
  1080. }
  1081. else
  1082. {
  1083. if ( WBEM_FLAG_CREATE_OR_UPDATE == ( m_lflags & WBEM_FLAG_CREATE_OR_UPDATE ) )
  1084. {
  1085. t_Status = Create_Or_Update () ;
  1086. }
  1087. else if ( WBEM_FLAG_CREATE_ONLY == ( m_lflags & WBEM_FLAG_CREATE_ONLY ) )
  1088. {
  1089. t_Status = Create_Only () ;
  1090. }
  1091. else if ( WBEM_FLAG_UPDATE_ONLY == ( m_lflags & WBEM_FLAG_UPDATE_ONLY ) )
  1092. {
  1093. t_Status = Update_Only () ;
  1094. }
  1095. else
  1096. {
  1097. t_Status = FALSE ;
  1098. }
  1099. }
  1100. }
  1101. else
  1102. {
  1103. if ( WBEM_FLAG_CREATE_OR_UPDATE == ( m_lflags & WBEM_FLAG_CREATE_OR_UPDATE ) )
  1104. {
  1105. state = 0 ;
  1106. t_Status = SendSnmp ( a_ErrorObject ) ;
  1107. }
  1108. else if ( WBEM_FLAG_CREATE_ONLY == ( m_lflags & WBEM_FLAG_CREATE_ONLY ) )
  1109. {
  1110. state = 1 ;
  1111. t_Status = CheckForRowExistence ( a_ErrorObject ) ;
  1112. }
  1113. else if ( WBEM_FLAG_UPDATE_ONLY == ( m_lflags & WBEM_FLAG_UPDATE_ONLY ) )
  1114. {
  1115. state = 2 ;
  1116. t_Status = CheckForRowExistence ( a_ErrorObject ) ;
  1117. }
  1118. else
  1119. {
  1120. t_Status = FALSE ;
  1121. }
  1122. }
  1123. return t_Status ;
  1124. }
  1125. void SnmpUpdateAsyncEventObject :: ReceiveComplete ()
  1126. {
  1127. DebugMacro3(
  1128. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  1129. __FILE__,__LINE__,
  1130. L"SnmpUpdateAsyncEventObject :: ReceiveComplete ()"
  1131. ) ;
  1132. )
  1133. BOOL t_Status = TRUE ;
  1134. switch ( state )
  1135. {
  1136. case 0:
  1137. {
  1138. /*
  1139. * V1 SMI - CREATE_OR_UPDATE
  1140. */
  1141. if ( m_SnmpTooBig )
  1142. {
  1143. m_errorObject.SetStatus ( WBEM_SNMP_E_TRANSPORT_ERROR ) ;
  1144. m_errorObject.SetWbemStatus ( WBEM_E_FAILED ) ;
  1145. m_errorObject.SetMessage ( L"Agent could not process Set Request because SNMP PDU was too big" ) ;
  1146. }
  1147. SetComplete () ;
  1148. return ;
  1149. }
  1150. break ;
  1151. case 1:
  1152. {
  1153. /*
  1154. * V1 SMI - CREATE_ONLY
  1155. */
  1156. if ( ! SUCCEEDED ( m_errorObject.GetStatus () ) )
  1157. {
  1158. SetComplete () ;
  1159. return ;
  1160. }
  1161. state = 3 ;
  1162. if ( m_QueryOperation->GetRowReceived () == 0 )
  1163. {
  1164. t_Status = SendSnmp ( m_errorObject ) ;
  1165. }
  1166. else
  1167. {
  1168. m_errorObject.SetStatus ( WBEM_SNMP_E_ALREADY_EXISTS ) ;
  1169. m_errorObject.SetWbemStatus ( WBEM_E_ALREADY_EXISTS ) ;
  1170. m_errorObject.SetMessage ( L"Instance already exists" ) ;
  1171. t_Status = FALSE ;
  1172. }
  1173. if ( m_QueryOperation )
  1174. m_QueryOperation->DestroyOperation () ;
  1175. }
  1176. break ;
  1177. case 2:
  1178. {
  1179. /*
  1180. * V1 SMI - UPDATE_ONLY
  1181. */
  1182. if ( ! SUCCEEDED ( m_errorObject.GetStatus () ) )
  1183. {
  1184. SetComplete () ;
  1185. return ;
  1186. }
  1187. state = 3 ;
  1188. if ( m_QueryOperation->GetRowReceived () )
  1189. {
  1190. t_Status = SendSnmp ( m_errorObject ) ;
  1191. }
  1192. else
  1193. {
  1194. m_errorObject.SetStatus ( WBEM_SNMP_E_NOT_FOUND ) ;
  1195. m_errorObject.SetWbemStatus ( WBEM_E_NOT_FOUND ) ;
  1196. m_errorObject.SetMessage ( L"Instance does not exist" ) ;
  1197. t_Status = FALSE ;
  1198. }
  1199. if ( m_QueryOperation )
  1200. m_QueryOperation->DestroyOperation () ;
  1201. }
  1202. break ;
  1203. case 3:
  1204. {
  1205. if ( m_SnmpTooBig )
  1206. {
  1207. m_errorObject.SetStatus ( WBEM_SNMP_E_TRANSPORT_ERROR ) ;
  1208. m_errorObject.SetWbemStatus ( WBEM_E_FAILED ) ;
  1209. m_errorObject.SetMessage ( L"Agent could not process Set Request because SNMP PDU was too big" ) ;
  1210. }
  1211. t_Status = FALSE ;
  1212. }
  1213. break ;
  1214. case 4:
  1215. {
  1216. /*
  1217. * V2C SMI ROWSTATUS - CREATE_OR_UPDATE
  1218. */
  1219. m_errorObject.SetStatus ( WBEM_SNMP_E_PROVIDER_FAILURE ) ;
  1220. m_errorObject.SetWbemStatus ( WBEM_E_FAILED ) ;
  1221. m_errorObject.SetMessage ( L"UNKNOWN STATE TRANSITION" ) ;
  1222. t_Status = FALSE ;
  1223. }
  1224. break ;
  1225. case 10:
  1226. {
  1227. /*
  1228. * V2C SMI ROWSTATUS - CREATE_ONLY
  1229. */
  1230. WbemSnmpProperty *t_Property ;
  1231. snmpObject.ResetProperty () ;
  1232. while ( t_Property = snmpObject.NextProperty () )
  1233. {
  1234. t_Property->SetTag ( FALSE ) ;
  1235. }
  1236. ULONG t_VarBindsPerPdu = 0 ;
  1237. IWbemQualifierSet *classQualifierObject ;
  1238. HRESULT result = m_namespaceObject->GetQualifierSet ( &classQualifierObject ) ;
  1239. if ( SUCCEEDED ( result ) )
  1240. {
  1241. t_Status = GetAgentMaxVarBindsPerPdu ( m_errorObject , classQualifierObject , t_VarBindsPerPdu ) ;
  1242. classQualifierObject->Release () ;
  1243. if ( t_Status )
  1244. {
  1245. m_VarBindsLeftBeforeTooBig = t_VarBindsPerPdu ;
  1246. ULONG t_NumberOfWritable = snmpObject.NumberOfWritable () ;
  1247. /*
  1248. * Check to see if we can fit all vbs in to one pdu
  1249. */
  1250. if ( t_NumberOfWritable < t_VarBindsPerPdu )
  1251. {
  1252. // Does fit
  1253. t_Status = Send_Variable_Binding_List (
  1254. snmpObject ,
  1255. t_NumberOfWritable ,
  1256. SnmpRowStatusType :: SnmpRowStatusEnum :: createAndGo
  1257. ) ;
  1258. state = 11 ;
  1259. }
  1260. else
  1261. {
  1262. // Does not fit, therefore decompose
  1263. t_Status = Send_Variable_Binding_List (
  1264. snmpObject ,
  1265. m_VarBindsLeftBeforeTooBig ,
  1266. SnmpRowStatusType :: SnmpRowStatusEnum :: createAndWait
  1267. ) ;
  1268. state = 12 ;
  1269. }
  1270. }
  1271. else
  1272. {
  1273. m_errorObject.SetStatus ( WBEM_SNMP_E_TRANSPORT_ERROR ) ;
  1274. m_errorObject.SetWbemStatus ( WBEM_E_FAILED ) ;
  1275. m_errorObject.SetMessage ( L"Internal Error" ) ;
  1276. t_Status = FALSE ;
  1277. }
  1278. }
  1279. else
  1280. {
  1281. m_errorObject.SetStatus ( WBEM_SNMP_E_TRANSPORT_ERROR ) ;
  1282. m_errorObject.SetWbemStatus ( WBEM_E_FAILED ) ;
  1283. m_errorObject.SetMessage ( L"Internal Error" ) ;
  1284. t_Status = FALSE ;
  1285. }
  1286. }
  1287. break ;
  1288. case 11:
  1289. {
  1290. /*
  1291. * check to see if we fitted everything into one pdu
  1292. */
  1293. if ( m_SnmpTooBig )
  1294. {
  1295. /*
  1296. * PDU TOO BIG
  1297. */
  1298. /*
  1299. * Decrement the number of variable bindings so that we can avoid an SNMP TOO BIG response
  1300. */
  1301. m_VarBindsLeftBeforeTooBig -- ;
  1302. /*
  1303. * Resend
  1304. */
  1305. t_Status = Send_Variable_Binding_List (
  1306. snmpObject ,
  1307. m_VarBindsLeftBeforeTooBig ,
  1308. SnmpRowStatusType :: SnmpRowStatusEnum :: createAndWait
  1309. ) ;
  1310. state = 12 ;
  1311. }
  1312. else
  1313. {
  1314. /*
  1315. * We've either succeeded or totally failed.
  1316. */
  1317. if ( t_Status = SUCCEEDED ( m_errorObject.GetWbemStatus () ) )
  1318. {
  1319. }
  1320. else
  1321. {
  1322. }
  1323. }
  1324. }
  1325. break ;
  1326. case 12:
  1327. {
  1328. /*
  1329. * check to see if we fitted everything into one pdu
  1330. */
  1331. if ( m_SnmpTooBig )
  1332. {
  1333. /*
  1334. * PDU TOO BIG
  1335. */
  1336. if ( m_VarBindsLeftBeforeTooBig == 0 )
  1337. {
  1338. /*
  1339. * Set Error object for TooBig because we only sent one vb
  1340. */
  1341. t_Status = FALSE ;
  1342. }
  1343. else
  1344. {
  1345. /*
  1346. * Decrement the number of variable bindings so that we can avoid an SNMP TOO BIG response
  1347. */
  1348. m_VarBindsLeftBeforeTooBig -- ;
  1349. /*
  1350. * Resend
  1351. */
  1352. t_Status = Send_Variable_Binding_List (
  1353. snmpObject ,
  1354. m_VarBindsLeftBeforeTooBig ,
  1355. SnmpRowStatusType :: SnmpRowStatusEnum :: createAndWait
  1356. ) ;
  1357. state = 12 ;
  1358. }
  1359. }
  1360. else
  1361. {
  1362. /*
  1363. * We've either succeeded or totally failed to set the row as createAndWait
  1364. */
  1365. if ( t_Status = SUCCEEDED ( m_errorObject.GetWbemStatus () ) )
  1366. {
  1367. /*
  1368. * Now send a non row status variable binding list
  1369. */
  1370. ULONG t_VarBindsPerPdu = 0 ;
  1371. IWbemQualifierSet *classQualifierObject ;
  1372. HRESULT result = m_namespaceObject->GetQualifierSet ( &classQualifierObject ) ;
  1373. if ( SUCCEEDED ( result ) )
  1374. {
  1375. t_Status = GetAgentMaxVarBindsPerPdu ( m_errorObject , classQualifierObject , t_VarBindsPerPdu ) ;
  1376. classQualifierObject->Release () ;
  1377. if ( t_Status )
  1378. {
  1379. m_VarBindsLeftBeforeTooBig = t_VarBindsPerPdu ;
  1380. t_Status = Send_Variable_Binding_List (
  1381. snmpObject ,
  1382. m_VarBindsLeftBeforeTooBig
  1383. ) ;
  1384. state = 13 ;
  1385. }
  1386. else
  1387. {
  1388. m_errorObject.SetStatus ( WBEM_SNMP_E_TRANSPORT_ERROR ) ;
  1389. m_errorObject.SetWbemStatus ( WBEM_E_FAILED ) ;
  1390. m_errorObject.SetMessage ( L"Internal Error" ) ;
  1391. t_Status = FALSE ;
  1392. }
  1393. }
  1394. else
  1395. {
  1396. m_errorObject.SetStatus ( WBEM_SNMP_E_TRANSPORT_ERROR ) ;
  1397. m_errorObject.SetWbemStatus ( WBEM_E_FAILED ) ;
  1398. m_errorObject.SetMessage ( L"Internal Error" ) ;
  1399. t_Status = FALSE ;
  1400. }
  1401. }
  1402. else
  1403. {
  1404. }
  1405. }
  1406. }
  1407. break ;
  1408. case 13:
  1409. {
  1410. /*
  1411. * check to see if we succeeded in sending a non row status variable binding list
  1412. */
  1413. if ( m_SnmpTooBig )
  1414. {
  1415. if ( m_VarBindsLeftBeforeTooBig == 0 )
  1416. {
  1417. /*
  1418. * Set Error object for TooBig because we only sent one vb
  1419. */
  1420. t_Status = FALSE ;
  1421. }
  1422. else
  1423. {
  1424. m_VarBindsLeftBeforeTooBig -- ;
  1425. t_Status = Send_Variable_Binding_List (
  1426. snmpObject ,
  1427. m_VarBindsLeftBeforeTooBig ,
  1428. SnmpRowStatusType :: SnmpRowStatusEnum :: createAndWait
  1429. ) ;
  1430. state = 13 ;
  1431. }
  1432. }
  1433. else
  1434. {
  1435. if ( snmpObject.NumberOfWritable () == 0 )
  1436. {
  1437. t_Status = Send_Variable_Binding_List (
  1438. snmpObject ,
  1439. 0 ,
  1440. SnmpRowStatusType :: SnmpRowStatusEnum :: active
  1441. ) ;
  1442. state = 14 ;
  1443. }
  1444. else
  1445. {
  1446. ULONG t_VarBindsPerPdu = 0 ;
  1447. IWbemQualifierSet *classQualifierObject ;
  1448. HRESULT result = m_namespaceObject->GetQualifierSet ( &classQualifierObject ) ;
  1449. if ( SUCCEEDED ( result ) )
  1450. {
  1451. t_Status = GetAgentMaxVarBindsPerPdu ( m_errorObject , classQualifierObject , t_VarBindsPerPdu ) ;
  1452. classQualifierObject->Release () ;
  1453. if ( t_Status )
  1454. {
  1455. m_VarBindsLeftBeforeTooBig = t_VarBindsPerPdu ;
  1456. t_Status = Send_Variable_Binding_List (
  1457. snmpObject ,
  1458. m_VarBindsLeftBeforeTooBig
  1459. ) ;
  1460. state = 13 ;
  1461. }
  1462. else
  1463. {
  1464. m_errorObject.SetStatus ( WBEM_SNMP_E_TRANSPORT_ERROR ) ;
  1465. m_errorObject.SetWbemStatus ( WBEM_E_FAILED ) ;
  1466. m_errorObject.SetMessage ( L"Internal Error" ) ;
  1467. t_Status = FALSE ;
  1468. }
  1469. }
  1470. else
  1471. {
  1472. m_errorObject.SetStatus ( WBEM_SNMP_E_TRANSPORT_ERROR ) ;
  1473. m_errorObject.SetWbemStatus ( WBEM_E_FAILED ) ;
  1474. m_errorObject.SetMessage ( L"Internal Error" ) ;
  1475. t_Status = FALSE ;
  1476. }
  1477. }
  1478. }
  1479. }
  1480. break ;
  1481. case 14:
  1482. {
  1483. if ( m_SnmpTooBig )
  1484. {
  1485. m_errorObject.SetStatus ( WBEM_SNMP_E_TRANSPORT_ERROR ) ;
  1486. m_errorObject.SetWbemStatus ( WBEM_E_FAILED ) ;
  1487. m_errorObject.SetMessage ( L"Agent could not process Set Request because SNMP PDU was too big" ) ;
  1488. t_Status = FALSE ;
  1489. }
  1490. else
  1491. {
  1492. SetComplete () ;
  1493. return ;
  1494. }
  1495. }
  1496. break ;
  1497. case 20:
  1498. {
  1499. /*
  1500. * V2C SMI ROWSTATUS - UPDATE_ONLY
  1501. */
  1502. WbemSnmpProperty *t_Property ;
  1503. snmpObject.ResetProperty () ;
  1504. while ( t_Property = snmpObject.NextProperty () )
  1505. {
  1506. t_Property->SetTag ( FALSE ) ;
  1507. }
  1508. ULONG t_VarBindsPerPdu = 0 ;
  1509. IWbemQualifierSet *classQualifierObject ;
  1510. HRESULT result = m_namespaceObject->GetQualifierSet ( &classQualifierObject ) ;
  1511. if ( SUCCEEDED ( result ) )
  1512. {
  1513. t_Status = GetAgentMaxVarBindsPerPdu ( m_errorObject , classQualifierObject , t_VarBindsPerPdu ) ;
  1514. classQualifierObject->Release () ;
  1515. if ( t_Status )
  1516. {
  1517. m_VarBindsLeftBeforeTooBig = t_VarBindsPerPdu ;
  1518. ULONG t_NumberOfWritable = snmpObject.NumberOfWritable () ;
  1519. /*
  1520. * Check to see if we can fit all vbs in to one pdu
  1521. */
  1522. if ( t_NumberOfWritable < t_VarBindsPerPdu )
  1523. {
  1524. // Does fit
  1525. t_Status = Send_Variable_Binding_List (
  1526. snmpObject ,
  1527. t_NumberOfWritable ,
  1528. SnmpRowStatusType :: SnmpRowStatusEnum :: active
  1529. ) ;
  1530. state = 21 ;
  1531. }
  1532. else
  1533. {
  1534. // Does not fit, therefore decompose
  1535. t_Status = Send_Variable_Binding_List (
  1536. snmpObject ,
  1537. m_VarBindsLeftBeforeTooBig ,
  1538. SnmpRowStatusType :: SnmpRowStatusEnum :: notInService
  1539. ) ;
  1540. state = 22 ;
  1541. }
  1542. }
  1543. else
  1544. {
  1545. m_errorObject.SetStatus ( WBEM_SNMP_E_TRANSPORT_ERROR ) ;
  1546. m_errorObject.SetWbemStatus ( WBEM_E_FAILED ) ;
  1547. m_errorObject.SetMessage ( L"Internal Error" ) ;
  1548. t_Status = FALSE ;
  1549. }
  1550. }
  1551. else
  1552. {
  1553. m_errorObject.SetStatus ( WBEM_SNMP_E_TRANSPORT_ERROR ) ;
  1554. m_errorObject.SetWbemStatus ( WBEM_E_FAILED ) ;
  1555. m_errorObject.SetMessage ( L"Internal Error" ) ;
  1556. t_Status = FALSE ;
  1557. }
  1558. }
  1559. break ;
  1560. case 21:
  1561. {
  1562. /*
  1563. * check to see if we fitted everything into one pdu
  1564. */
  1565. if ( m_SnmpTooBig )
  1566. {
  1567. /*
  1568. * PDU TOO BIG
  1569. */
  1570. /*
  1571. * Decrement the number of variable bindings so that we can avoid an SNMP TOO BIG response
  1572. */
  1573. m_VarBindsLeftBeforeTooBig -- ;
  1574. /*
  1575. * Resend
  1576. */
  1577. t_Status = Send_Variable_Binding_List (
  1578. snmpObject ,
  1579. m_VarBindsLeftBeforeTooBig ,
  1580. SnmpRowStatusType :: SnmpRowStatusEnum :: notInService
  1581. ) ;
  1582. state = 22 ;
  1583. }
  1584. else
  1585. {
  1586. /*
  1587. * We've either succeeded or totally failed.
  1588. */
  1589. if ( t_Status = SUCCEEDED ( m_errorObject.GetWbemStatus () ) )
  1590. {
  1591. }
  1592. else
  1593. {
  1594. }
  1595. }
  1596. }
  1597. break ;
  1598. case 22:
  1599. {
  1600. /*
  1601. * check to see if we fitted everything into one pdu
  1602. */
  1603. if ( m_SnmpTooBig )
  1604. {
  1605. /*
  1606. * PDU TOO BIG
  1607. */
  1608. if ( m_VarBindsLeftBeforeTooBig == 0 )
  1609. {
  1610. /*
  1611. * Set Error object for TooBig because we only sent one vb
  1612. */
  1613. t_Status = FALSE ;
  1614. }
  1615. else
  1616. {
  1617. /*
  1618. * Decrement the number of variable bindings so that we can avoid an SNMP TOO BIG response
  1619. */
  1620. m_VarBindsLeftBeforeTooBig -- ;
  1621. /*
  1622. * Resend
  1623. */
  1624. t_Status = Send_Variable_Binding_List (
  1625. snmpObject ,
  1626. m_VarBindsLeftBeforeTooBig ,
  1627. SnmpRowStatusType :: SnmpRowStatusEnum :: notInService
  1628. ) ;
  1629. state = 22 ;
  1630. }
  1631. }
  1632. else
  1633. {
  1634. /*
  1635. * We've either succeeded or totally failed to set the row as notInService
  1636. */
  1637. if ( t_Status = SUCCEEDED ( m_errorObject.GetWbemStatus () ) )
  1638. {
  1639. /*
  1640. * Now send a non row status variable binding list
  1641. */
  1642. ULONG t_VarBindsPerPdu = 0 ;
  1643. IWbemQualifierSet *classQualifierObject ;
  1644. HRESULT result = m_namespaceObject->GetQualifierSet ( &classQualifierObject ) ;
  1645. if ( SUCCEEDED ( result ) )
  1646. {
  1647. t_Status = GetAgentMaxVarBindsPerPdu ( m_errorObject , classQualifierObject , t_VarBindsPerPdu ) ;
  1648. classQualifierObject->Release () ;
  1649. if ( t_Status )
  1650. {
  1651. m_VarBindsLeftBeforeTooBig = t_VarBindsPerPdu ;
  1652. t_Status = Send_Variable_Binding_List (
  1653. snmpObject ,
  1654. m_VarBindsLeftBeforeTooBig
  1655. ) ;
  1656. state = 23 ;
  1657. }
  1658. else
  1659. {
  1660. m_errorObject.SetStatus ( WBEM_SNMP_E_TRANSPORT_ERROR ) ;
  1661. m_errorObject.SetWbemStatus ( WBEM_E_FAILED ) ;
  1662. m_errorObject.SetMessage ( L"Internal Error" ) ;
  1663. t_Status = FALSE ;
  1664. }
  1665. }
  1666. else
  1667. {
  1668. m_errorObject.SetStatus ( WBEM_SNMP_E_TRANSPORT_ERROR ) ;
  1669. m_errorObject.SetWbemStatus ( WBEM_E_FAILED ) ;
  1670. m_errorObject.SetMessage ( L"Internal Error" ) ;
  1671. t_Status = FALSE ;
  1672. }
  1673. }
  1674. else
  1675. {
  1676. }
  1677. }
  1678. }
  1679. break ;
  1680. case 23:
  1681. {
  1682. /*
  1683. * check to see if we succeeded in sending a non row status variable binding list
  1684. */
  1685. if ( m_SnmpTooBig )
  1686. {
  1687. if ( m_VarBindsLeftBeforeTooBig == 0 )
  1688. {
  1689. /*
  1690. * Set Error object for TooBig because we only sent one vb
  1691. */
  1692. t_Status = FALSE ;
  1693. }
  1694. else
  1695. {
  1696. m_VarBindsLeftBeforeTooBig -- ;
  1697. t_Status = Send_Variable_Binding_List (
  1698. snmpObject ,
  1699. m_VarBindsLeftBeforeTooBig ,
  1700. SnmpRowStatusType :: SnmpRowStatusEnum :: notInService
  1701. ) ;
  1702. state = 23 ;
  1703. }
  1704. }
  1705. else
  1706. {
  1707. ULONG t_VarBindsPerPdu = 0 ;
  1708. if ( snmpObject.NumberOfWritable () == 0 )
  1709. {
  1710. t_Status = Send_Variable_Binding_List (
  1711. snmpObject ,
  1712. 0 ,
  1713. SnmpRowStatusType :: SnmpRowStatusEnum :: active
  1714. ) ;
  1715. state = 24 ;
  1716. }
  1717. else
  1718. {
  1719. ULONG t_VarBindsPerPdu = 0 ;
  1720. IWbemQualifierSet *classQualifierObject ;
  1721. HRESULT result = m_namespaceObject->GetQualifierSet ( &classQualifierObject ) ;
  1722. if ( SUCCEEDED ( result ) )
  1723. {
  1724. t_Status = GetAgentMaxVarBindsPerPdu ( m_errorObject , classQualifierObject , t_VarBindsPerPdu ) ;
  1725. classQualifierObject->Release () ;
  1726. if ( t_Status )
  1727. {
  1728. m_VarBindsLeftBeforeTooBig = t_VarBindsPerPdu ;
  1729. t_Status = Send_Variable_Binding_List (
  1730. snmpObject ,
  1731. m_VarBindsLeftBeforeTooBig
  1732. ) ;
  1733. state = 23 ;
  1734. }
  1735. else
  1736. {
  1737. m_errorObject.SetStatus ( WBEM_SNMP_E_TRANSPORT_ERROR ) ;
  1738. m_errorObject.SetWbemStatus ( WBEM_E_FAILED ) ;
  1739. m_errorObject.SetMessage ( L"Internal Error" ) ;
  1740. t_Status = FALSE ;
  1741. }
  1742. }
  1743. else
  1744. {
  1745. m_errorObject.SetStatus ( WBEM_SNMP_E_TRANSPORT_ERROR ) ;
  1746. m_errorObject.SetWbemStatus ( WBEM_E_FAILED ) ;
  1747. m_errorObject.SetMessage ( L"Internal Error" ) ;
  1748. t_Status = FALSE ;
  1749. }
  1750. }
  1751. }
  1752. }
  1753. break ;
  1754. case 24:
  1755. {
  1756. if ( m_SnmpTooBig )
  1757. {
  1758. m_errorObject.SetStatus ( WBEM_SNMP_E_TRANSPORT_ERROR ) ;
  1759. m_errorObject.SetWbemStatus ( WBEM_E_FAILED ) ;
  1760. m_errorObject.SetMessage ( L"Agent could not process Set Request because SNMP PDU was too big" ) ;
  1761. t_Status = FALSE ;
  1762. }
  1763. else
  1764. {
  1765. SetComplete () ;
  1766. return ;
  1767. }
  1768. }
  1769. break ;
  1770. case 30:
  1771. {
  1772. if ( ! SUCCEEDED ( m_errorObject.GetStatus () ) )
  1773. {
  1774. SetComplete () ;
  1775. return ;
  1776. }
  1777. if ( m_QueryOperation->GetRowReceived () == 0 )
  1778. {
  1779. t_Status = Update_Only () ;
  1780. }
  1781. else
  1782. {
  1783. t_Status = Create_Only () ;
  1784. }
  1785. }
  1786. break ;
  1787. default:
  1788. {
  1789. m_errorObject.SetStatus ( WBEM_SNMP_E_PROVIDER_FAILURE ) ;
  1790. m_errorObject.SetWbemStatus ( WBEM_E_FAILED ) ;
  1791. m_errorObject.SetMessage ( L"UNKNOWN STATE TRANSITION" ) ;
  1792. t_Status = FALSE ;
  1793. }
  1794. break ;
  1795. }
  1796. if ( t_Status == FALSE )
  1797. {
  1798. SetComplete () ;
  1799. }
  1800. DebugMacro3(
  1801. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  1802. __FILE__,__LINE__,
  1803. L"Returning from SnmpUpdateAsyncEventObject :: ReceiveComplete ()"
  1804. ) ;
  1805. )
  1806. }
  1807. void SnmpUpdateAsyncEventObject :: SnmpTooBig ()
  1808. {
  1809. DebugMacro3(
  1810. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  1811. __FILE__,__LINE__,
  1812. L"SnmpUpdateAsyncEventObject :: SnmpTooBig ()"
  1813. ) ;
  1814. )
  1815. m_SnmpTooBig = TRUE ;
  1816. DebugMacro3(
  1817. SnmpDebugLog :: s_SnmpDebugLog->WriteFileAndLine (
  1818. __FILE__,__LINE__,
  1819. L"Returning from SnmpUpdateAsyncEventObject :: SnmpTooBig ()"
  1820. ) ;
  1821. )
  1822. }
  1823. BOOL SnmpUpdateEventObject :: Create_Only ()
  1824. {
  1825. BOOL t_Status = TRUE ;
  1826. /*
  1827. * V2C SMI ROWSTATUS - CREATE_ONLY
  1828. */
  1829. WbemSnmpProperty *t_Property ;
  1830. snmpObject.ResetProperty () ;
  1831. while ( t_Property = snmpObject.NextProperty () )
  1832. {
  1833. t_Property->SetTag ( FALSE ) ;
  1834. }
  1835. ULONG t_VarBindsPerPdu = 0 ;
  1836. IWbemQualifierSet *classQualifierObject ;
  1837. HRESULT result = m_namespaceObject->GetQualifierSet ( &classQualifierObject ) ;
  1838. if ( SUCCEEDED ( result ) )
  1839. {
  1840. t_Status = GetAgentMaxVarBindsPerPdu ( m_errorObject , classQualifierObject , t_VarBindsPerPdu ) ;
  1841. classQualifierObject->Release () ;
  1842. if ( t_Status )
  1843. {
  1844. m_VarBindsLeftBeforeTooBig = t_VarBindsPerPdu ;
  1845. ULONG t_NumberOfWritable = snmpObject.NumberOfWritable () ;
  1846. /*
  1847. * Check to see if we can fit all vbs in to one pdu
  1848. */
  1849. if ( t_NumberOfWritable < t_VarBindsPerPdu )
  1850. {
  1851. // Does fit
  1852. t_Status = Send_Variable_Binding_List (
  1853. snmpObject ,
  1854. t_NumberOfWritable ,
  1855. SnmpRowStatusType :: SnmpRowStatusEnum :: createAndGo
  1856. ) ;
  1857. state = 7 ;
  1858. }
  1859. else
  1860. {
  1861. // Does not fit, therefore decompose
  1862. t_Status = Send_Variable_Binding_List (
  1863. snmpObject ,
  1864. m_VarBindsLeftBeforeTooBig ,
  1865. SnmpRowStatusType :: SnmpRowStatusEnum :: createAndWait
  1866. ) ;
  1867. state = 8 ;
  1868. }
  1869. }
  1870. else
  1871. {
  1872. m_errorObject.SetStatus ( WBEM_SNMP_E_TRANSPORT_ERROR ) ;
  1873. m_errorObject.SetWbemStatus ( WBEM_E_FAILED ) ;
  1874. m_errorObject.SetMessage ( L"Internal Error" ) ;
  1875. t_Status = FALSE ;
  1876. }
  1877. }
  1878. else
  1879. {
  1880. m_errorObject.SetStatus ( WBEM_SNMP_E_TRANSPORT_ERROR ) ;
  1881. m_errorObject.SetWbemStatus ( WBEM_E_FAILED ) ;
  1882. m_errorObject.SetMessage ( L"Internal Error" ) ;
  1883. t_Status = FALSE ;
  1884. }
  1885. return t_Status ;
  1886. }
  1887. BOOL SnmpUpdateEventObject :: Update_Only ()
  1888. {
  1889. BOOL t_Status = TRUE ;
  1890. /*
  1891. * V2C SMI ROWSTATUS - UPDATE_ONLY
  1892. */
  1893. WbemSnmpProperty *t_Property ;
  1894. snmpObject.ResetProperty () ;
  1895. while ( t_Property = snmpObject.NextProperty () )
  1896. {
  1897. t_Property->SetTag ( FALSE ) ;
  1898. }
  1899. ULONG t_VarBindsPerPdu = 0 ;
  1900. IWbemQualifierSet *classQualifierObject ;
  1901. HRESULT result = m_namespaceObject->GetQualifierSet ( &classQualifierObject ) ;
  1902. if ( SUCCEEDED ( result ) )
  1903. {
  1904. t_Status = GetAgentMaxVarBindsPerPdu ( m_errorObject , classQualifierObject , t_VarBindsPerPdu ) ;
  1905. classQualifierObject->Release () ;
  1906. if ( t_Status )
  1907. {
  1908. m_VarBindsLeftBeforeTooBig = t_VarBindsPerPdu ;
  1909. ULONG t_NumberOfWritable = snmpObject.NumberOfWritable () ;
  1910. /*
  1911. * Check to see if we can fit all vbs in to one pdu
  1912. */
  1913. if ( t_NumberOfWritable < t_VarBindsPerPdu )
  1914. {
  1915. // Does fit
  1916. t_Status = Send_Variable_Binding_List (
  1917. snmpObject ,
  1918. t_NumberOfWritable ,
  1919. SnmpRowStatusType :: SnmpRowStatusEnum :: active
  1920. ) ;
  1921. state = 7 ;
  1922. }
  1923. else
  1924. {
  1925. // Does not fit, therefore decompose
  1926. t_Status = Send_Variable_Binding_List (
  1927. snmpObject ,
  1928. m_VarBindsLeftBeforeTooBig ,
  1929. SnmpRowStatusType :: SnmpRowStatusEnum :: notInService
  1930. ) ;
  1931. state = 8 ;
  1932. }
  1933. }
  1934. else
  1935. {
  1936. m_errorObject.SetStatus ( WBEM_SNMP_E_TRANSPORT_ERROR ) ;
  1937. m_errorObject.SetWbemStatus ( WBEM_E_FAILED ) ;
  1938. m_errorObject.SetMessage ( L"Internal Error" ) ;
  1939. t_Status = FALSE ;
  1940. }
  1941. }
  1942. else
  1943. {
  1944. m_errorObject.SetStatus ( WBEM_SNMP_E_TRANSPORT_ERROR ) ;
  1945. m_errorObject.SetWbemStatus ( WBEM_E_FAILED ) ;
  1946. m_errorObject.SetMessage ( L"Internal Error" ) ;
  1947. t_Status = FALSE ;
  1948. }
  1949. return t_Status ;
  1950. }
  1951. BOOL SnmpUpdateEventObject :: Create_Or_Update ()
  1952. {
  1953. BOOL t_Status = FALSE ;
  1954. state = 30 ;
  1955. t_Status = CheckForRowExistence ( m_errorObject ) ;
  1956. return t_Status ;
  1957. }
  1958. BOOL SnmpUpdateEventObject :: Send_Variable_Binding_List (
  1959. SnmpSetClassObject &a_SnmpSetClassObject ,
  1960. ULONG a_NumberToSend
  1961. )
  1962. {
  1963. /*
  1964. * Find Property of RowStatus type and make sure we don't send in request
  1965. */
  1966. BOOL t_Status = FALSE ;
  1967. WbemSnmpProperty *t_Property ;
  1968. a_SnmpSetClassObject.ResetProperty () ;
  1969. while ( t_Property = a_SnmpSetClassObject.NextProperty () )
  1970. {
  1971. if ( typeid ( *t_Property->GetValue () ) == typeid ( SnmpRowStatusType ) )
  1972. {
  1973. t_Property->SetTag ( TRUE ) ;
  1974. }
  1975. }
  1976. t_Status = SendSnmp ( m_errorObject , a_NumberToSend ) ;
  1977. return t_Status ;
  1978. }
  1979. BOOL SnmpUpdateEventObject :: Send_Variable_Binding_List (
  1980. SnmpSetClassObject &a_SnmpSetClassObject ,
  1981. ULONG a_NumberToSend ,
  1982. SnmpRowStatusType :: SnmpRowStatusEnum a_SnmpRowStatusEnum
  1983. )
  1984. {
  1985. BOOL t_Status = FALSE ;
  1986. WbemSnmpProperty *t_Property ;
  1987. a_SnmpSetClassObject.ResetProperty () ;
  1988. while ( t_Property = a_SnmpSetClassObject.NextProperty () )
  1989. {
  1990. if ( typeid ( *t_Property->GetValue () ) == typeid ( SnmpRowStatusType ) )
  1991. {
  1992. t_Property->SetTag ( FALSE ) ;
  1993. SnmpRowStatusType *t_RowStatus = new SnmpRowStatusType ( a_SnmpRowStatusEnum ) ;
  1994. t_Property->SetValue ( t_RowStatus ) ;
  1995. }
  1996. }
  1997. t_Status = SendSnmp ( m_errorObject , a_NumberToSend ) ;
  1998. return t_Status ;
  1999. }