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.

253 lines
5.5 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. #if _MSC_VER >= 1100
  13. template<> DllImportExport UINT AFXAPI HashKey <SnmpObjectIdentifierType&> (SnmpObjectIdentifierType &key) ;
  14. #else
  15. DllImportExport UINT HashKey (SnmpObjectIdentifierType &key) ;
  16. #endif
  17. #if _MSC_VER >= 1100
  18. template<> DllImportExport BOOL AFXAPI CompareElements <SnmpObjectIdentifierType , SnmpObjectIdentifierType >(
  19. const SnmpObjectIdentifierType* pElement1,
  20. const SnmpObjectIdentifierType* pElement2
  21. ) ;
  22. #else
  23. DllImportExport BOOL CompareElements (
  24. SnmpObjectIdentifierType* pElement1,
  25. SnmpObjectIdentifierType* pElement2
  26. ) ;
  27. #endif
  28. class VarBindObject
  29. {
  30. private:
  31. SnmpObjectIdentifier reply ;
  32. SnmpValue *value ;
  33. protected:
  34. public:
  35. VarBindObject ( const SnmpObjectIdentifier &replyArg , const SnmpValue &valueArg ) ;
  36. virtual ~VarBindObject () ;
  37. SnmpObjectIdentifier &GetObjectIdentifier () ;
  38. SnmpValue &GetValue () ;
  39. } ;
  40. class VarBindQueue
  41. {
  42. private:
  43. CList <VarBindObject *, VarBindObject *&> queue ;
  44. protected:
  45. public:
  46. VarBindQueue () ;
  47. virtual ~VarBindQueue () ;
  48. void Add ( VarBindObject *varBindObject ) ;
  49. VarBindObject *Get () ;
  50. VarBindObject *Delete () ;
  51. } ;
  52. class VarBindObjectRequest
  53. {
  54. private:
  55. BOOL repeatRequest ;
  56. VarBindQueue varBindResponseQueue ;
  57. SnmpObjectIdentifierType varBind ;
  58. SnmpObjectIdentifierType requested ;
  59. protected:
  60. public:
  61. VarBindObjectRequest ( const SnmpObjectIdentifierType &varBindArg ) ;
  62. VarBindObjectRequest (
  63. const SnmpObjectIdentifierType &varBindArg ,
  64. const SnmpObjectIdentifierType &requestedVarBindArg
  65. ) ;
  66. VarBindObjectRequest () ;
  67. virtual ~VarBindObjectRequest () ;
  68. const SnmpObjectIdentifierType &GetRequested () const ;
  69. const SnmpObjectIdentifierType &GetVarBind () const ;
  70. void AddQueuedObject ( VarBindObject *object ) ;
  71. VarBindObject *GetQueuedObject () ;
  72. VarBindObject *DeleteQueueudObject () ;
  73. void SetRequested ( const SnmpObjectIdentifierType &requestedArg ) ;
  74. void SetVarBind ( const SnmpObjectIdentifierType &varBindArg ) ;
  75. BOOL GetRepeatRequest () { return repeatRequest ; }
  76. void SetRepeatRequest ( BOOL repeatRequestArg = TRUE ) { repeatRequest = repeatRequestArg ; }
  77. } ;
  78. class GetNextOperation ;
  79. class DllImportExport SnmpAutoRetrieveOperation
  80. {
  81. friend GetNextOperation ;
  82. private:
  83. BOOL status ;
  84. GetNextOperation *operation ;
  85. protected:
  86. SnmpAutoRetrieveOperation (SnmpSession &snmp_session);
  87. virtual void ReceiveResponse() {} ;
  88. virtual void ReceiveRowResponse () {} ;
  89. virtual void ReceiveRowVarBindResponse(
  90. IN const ULONG &var_bind_index,
  91. IN const SnmpVarBind &requestVarBind ,
  92. IN const SnmpVarBind &replyVarBind ,
  93. IN const SnmpErrorReport &error) {}
  94. virtual void ReceiveVarBindResponse(
  95. IN const ULONG &var_bind_index,
  96. IN const SnmpVarBind &requestVarBind ,
  97. IN const SnmpVarBind &replyVarBind ,
  98. IN const SnmpErrorReport &error) {}
  99. virtual void ReceiveErroredVarBindResponse(
  100. IN const ULONG &var_bind_index,
  101. IN const SnmpVarBind &requestVarBind ,
  102. IN const SnmpErrorReport &error) {}
  103. virtual LONG EvaluateNextRequest (
  104. IN const ULONG &var_bind_index,
  105. IN const SnmpVarBind &requestVarBind ,
  106. IN const SnmpVarBind &replyVarBind ,
  107. IN SnmpVarBind &sendVarBind
  108. ) { return 0 ; }
  109. virtual void FrameTooBig() {}
  110. virtual void FrameOverRun() {}
  111. void DestroyOperation () ;
  112. public:
  113. virtual ~SnmpAutoRetrieveOperation() ;
  114. virtual void SendRequest (
  115. IN SnmpVarBindList &scopeVarBindList ,
  116. IN SnmpVarBindList &varBindList
  117. );
  118. virtual void SendRequest (
  119. IN SnmpVarBindList &varBindList
  120. );
  121. void CancelRequest();
  122. void ReceiveFrame(IN const SessionFrameId session_frame_id,
  123. IN const SnmpPdu &snmpPdu,
  124. IN const SnmpErrorReport &errorReport) {} ;
  125. virtual void SentFrame(IN const SessionFrameId session_frame_id,
  126. IN const SnmpErrorReport &error_report) {} ;
  127. void *operator()(void) const ;
  128. } ;
  129. class DllImportExport GetNextOperation : public SnmpGetNextOperation
  130. {
  131. private:
  132. ULONG m_RequestContainerLength ;
  133. VarBindObjectRequest **m_RequestContainer ;
  134. ULONG *m_RequestIndexContainer ;
  135. BOOL cancelledRequest ;
  136. SnmpObjectIdentifier minimumInstance ;
  137. SnmpAutoRetrieveOperation *operation ;
  138. void Cleanup () ;
  139. BOOL ProcessRow () ;
  140. void Send () ;
  141. protected:
  142. void ReceiveResponse () ;
  143. void ReceiveVarBindResponse (
  144. IN const ULONG &var_bind_index,
  145. IN const SnmpVarBind &requestVarBind ,
  146. IN const SnmpVarBind &replyVarBind ,
  147. IN const SnmpErrorReport &error
  148. ) ;
  149. void ReceiveErroredVarBindResponse(
  150. IN const ULONG &var_bind_index,
  151. IN const SnmpVarBind &requestVarBind ,
  152. IN const SnmpErrorReport &error
  153. ) ;
  154. void FrameTooBig() ;
  155. void FrameOverRun() ;
  156. void SentFrame(
  157. IN const SessionFrameId session_frame_id,
  158. IN const SnmpErrorReport &error_report
  159. );
  160. public:
  161. GetNextOperation (IN SnmpSession &session, SnmpAutoRetrieveOperation &autoRetrieveOperation ) ;
  162. ~GetNextOperation () ;
  163. void SendRequest (
  164. SnmpVarBindList &varBindList ,
  165. SnmpVarBindList &startVarBindList
  166. ) ;
  167. void SendRequest ( SnmpVarBindList &varBindList ) ;
  168. void CancelRequest () ;
  169. void DestroyOperation () ;
  170. };