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.

118 lines
2.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. /*--------------------------------------------------
  13. Filename: sec.hpp
  14. Author: B.Rajeev
  15. Purpose: Provides declarations for the SnmpSecurity class
  16. --------------------------------------------------*/
  17. #ifndef __SECURITY__
  18. #define __SECURITY__
  19. #include "forward.h"
  20. #include "error.h"
  21. #define SnmpV1Security SnmpCommunityBasedSecurity
  22. // provides the security context under which snmp pdus are transmitted
  23. class DllImportExport SnmpSecurity
  24. {
  25. private:
  26. // the "=" operator and the copy constructor have been made
  27. // private to prevent copies of the SnmpSecurity instance from
  28. // being made
  29. SnmpSecurity &operator=(IN const SnmpSecurity &security)
  30. {
  31. return *this;
  32. }
  33. SnmpSecurity(IN const SnmpSecurity &snmp_security) {}
  34. protected:
  35. SnmpSecurity() {}
  36. public:
  37. virtual ~SnmpSecurity(){}
  38. virtual SnmpErrorReport Secure (
  39. IN SnmpEncodeDecode &snmpEncodeDecode,
  40. IN OUT SnmpPdu &snmpPdu
  41. ) = 0;
  42. virtual SnmpSecurity *Copy() const = 0;
  43. virtual void * operator()(void) const = 0;
  44. virtual operator void *() const = 0;
  45. };
  46. class DllImportExport SnmpCommunityBasedSecurity: public SnmpSecurity
  47. {
  48. protected:
  49. char *community_name;
  50. BOOL is_valid;
  51. void Initialize();
  52. public:
  53. SnmpCommunityBasedSecurity ( IN const SnmpCommunityBasedSecurity &a_SnmpCommunityBasedSecurity ) ;
  54. SnmpCommunityBasedSecurity ( IN const char *a_CommunityName = "public" ) ;
  55. SnmpCommunityBasedSecurity ( IN const SnmpOctetString &a_OctetString ) ;
  56. ~SnmpCommunityBasedSecurity () ;
  57. SnmpErrorReport Secure (
  58. IN SnmpEncodeDecode &snmpEncodeDecode,
  59. IN OUT SnmpPdu &snmpPdu
  60. ) ;
  61. SnmpSecurity *Copy() const;
  62. SnmpCommunityBasedSecurity &operator=(IN const SnmpCommunityBasedSecurity &to_copy) ;
  63. void * operator()(void) const
  64. {
  65. return ( is_valid?(void *)this:NULL );
  66. }
  67. operator void *() const
  68. {
  69. return SnmpCommunityBasedSecurity::operator()();
  70. }
  71. void SetCommunityName ( IN const SnmpOctetString &a_OctetString ) ;
  72. void SetCommunityName ( IN const char *a_CommunityName ) ;
  73. void GetCommunityName ( SnmpOctetString &a_SnmpOctetString ) const ;
  74. const char *GetCommunityName() const;
  75. };
  76. #endif // __SECURITY__