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.

250 lines
4.6 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. /*-------------------------------------------------------
  13. filename: encdec.hpp
  14. author: B.Rajeev
  15. purpose: Provides declarations for the class PseudoSession.
  16. -------------------------------------------------------*/
  17. #ifndef __ENCODE_DECODE__
  18. #define __ENCODE_DECODE__
  19. #include "forward.h"
  20. #include "error.h"
  21. #define IP_ADDR_LEN 4
  22. #define ILLEGAL_REQUEST_ID 0
  23. typedef long RequestId;
  24. class DllImportExport SnmpEncodeDecode
  25. {
  26. friend VBList;
  27. friend SnmpImpTransport;
  28. friend SnmpImpSession;
  29. friend SnmpCommunityBasedSecurity;
  30. friend SnmpClassLibrary;
  31. friend TransportWindow;
  32. protected:
  33. BOOL m_IsValid;
  34. void *m_Session;
  35. void *m_Window ;
  36. static CriticalSection s_CriticalSection;
  37. void *GetWinSnmpSession () { return m_Session ; }
  38. virtual void SetTranslateMode () = 0 ;
  39. static BOOL DestroyStaticComponents () ;
  40. static BOOL InitializeStaticComponents () ;
  41. public:
  42. enum PduType {GET, GETNEXT, SET, GETBULK, RESPONSE, TRAP, V1TRAP, INFORM, UNKNOWN };
  43. SnmpEncodeDecode ();
  44. virtual BOOL EncodeFrame (
  45. OUT SnmpPdu &a_SnmpPdu ,
  46. IN RequestId a_RequestId,
  47. IN PduType a_PduType,
  48. IN SnmpErrorReport &a_SnmpErrorReport ,
  49. IN SnmpVarBindList &a_SnmpVarBindList,
  50. IN SnmpCommunityBasedSecurity *&a_SnmpCommunityBasedSecuity ,
  51. IN SnmpTransportAddress *&a_SrcTransportAddress ,
  52. IN SnmpTransportAddress *&a_DstTransportAddress
  53. ) ;
  54. virtual BOOL EncodeFrame (
  55. IN SnmpPdu &a_SnmpPdu ,
  56. OUT void *a_ImplementationEncoding
  57. ) ;
  58. virtual BOOL SetVarBindList (
  59. IN SnmpPdu &a_SnmpPdu ,
  60. OUT SnmpVarBindList &a_SnmpVarBindList
  61. ) ;
  62. virtual BOOL SetCommunityName (
  63. IN SnmpPdu &a_SnmpPdu ,
  64. IN SnmpCommunityBasedSecurity &a_SnmpCommunityBasedSecurity
  65. ) ;
  66. virtual BOOL SetErrorReport (
  67. IN SnmpPdu &a_SnmpPdu ,
  68. OUT SnmpErrorReport &a_SnmpErrorReport
  69. ) ;
  70. virtual BOOL SetPduType (
  71. IN SnmpPdu &a_SnmpPdu ,
  72. OUT PduType a_PduType
  73. ) ;
  74. virtual BOOL SetSourceAddress (
  75. IN OUT SnmpPdu &a_SnmpPdu ,
  76. IN SnmpTransportAddress &a_TransportAddress
  77. ) ;
  78. virtual BOOL SetDestinationAddress (
  79. IN OUT SnmpPdu &a_SnmpPdu ,
  80. IN SnmpTransportAddress &a_TransportAddress
  81. ) ;
  82. virtual BOOL SetRequestId (
  83. IN OUT SnmpPdu &a_SnmpPdu ,
  84. IN RequestId request_id
  85. ) ;
  86. virtual BOOL DecodeFrame (
  87. IN SnmpPdu &a_SnmpPdu ,
  88. OUT RequestId a_RequestId,
  89. OUT PduType a_PduType ,
  90. OUT SnmpErrorReport &a_SnmpErrorReport ,
  91. OUT SnmpVarBindList *&a_SnmpVarBindList ,
  92. OUT SnmpCommunityBasedSecurity *&a_SnmpCommunityBasedSecurity ,
  93. OUT SnmpTransportAddress *&a_SrcTransportAddress ,
  94. OUT SnmpTransportAddress *&a_DstTransportAddress
  95. ) ;
  96. virtual BOOL DecodeFrame (
  97. IN void *a_ImplementationEncoding ,
  98. OUT SnmpPdu &a_SnmpPdu
  99. ) ;
  100. virtual BOOL GetPduType (
  101. IN SnmpPdu &a_SnmpPdu ,
  102. OUT PduType &a_PduType
  103. ) ;
  104. virtual BOOL GetRequestId (
  105. IN SnmpPdu &a_SnmpPdu ,
  106. RequestId &a_RequestId
  107. ) ;
  108. virtual BOOL GetErrorReport (
  109. IN SnmpPdu &a_SnmpPdu ,
  110. OUT SnmpErrorReport &a_SnmpErrorReport
  111. ) ;
  112. virtual BOOL GetCommunityName (
  113. IN SnmpPdu &a_SnmpPdu ,
  114. OUT SnmpCommunityBasedSecurity &a_SnmpCommunityBasedSecurity
  115. ) ;
  116. virtual BOOL GetVarbindList (
  117. IN SnmpPdu &a_SnmpPdu ,
  118. OUT SnmpVarBindList &a_SnmpVarBindList
  119. ) ;
  120. virtual BOOL GetSourceAddress (
  121. IN SnmpPdu &a_SnmpPdu ,
  122. SnmpTransportAddress *&a_TransportAddress
  123. ) ;
  124. virtual BOOL GetDestinationAddress (
  125. IN SnmpPdu &a_SnmpPdu ,
  126. SnmpTransportAddress *&a_TransportAddress
  127. ) ;
  128. virtual void *operator()() const
  129. {
  130. return ( m_IsValid ? (void *) this: NULL );
  131. }
  132. virtual ~SnmpEncodeDecode ();
  133. };
  134. class DllImportExport SnmpV1EncodeDecode : public SnmpEncodeDecode
  135. {
  136. friend VBList;
  137. friend SnmpImpTransport;
  138. friend SnmpImpSession;
  139. friend SnmpCommunityBasedSecurity;
  140. private:
  141. void InitializeVariables();
  142. protected:
  143. void SetTranslateMode () ;
  144. public:
  145. SnmpV1EncodeDecode () ;
  146. ~SnmpV1EncodeDecode ();
  147. };
  148. class DllImportExport SnmpV2CEncodeDecode : public SnmpEncodeDecode
  149. {
  150. private:
  151. // initializes the pdu
  152. void InitializeVariables();
  153. protected:
  154. void SetTranslateMode () ;
  155. public:
  156. SnmpV2CEncodeDecode () ;
  157. ~SnmpV2CEncodeDecode ();
  158. };
  159. #endif // __ENCODE_DECODE__