Source code of Windows XP (NT5)
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.

149 lines
2.8 KiB

  1. /*++
  2. Copyright (c) 1995-1996 Microsoft Corporation
  3. Module Name:
  4. ipaccess.hxx
  5. Abstract:
  6. This module provides definitions of the IPAccess check object
  7. Author:
  8. Murali R. Krishnan ( MuraliK ) 18-March-1996
  9. Environment:
  10. User-Mode - Win32
  11. Project:
  12. Internet Server DLL
  13. Revision History:
  14. --*/
  15. # ifndef _IPACCESS_HXX_
  16. # define _IPACCESS_HXX_
  17. /************************************************************
  18. * Include Headers
  19. ************************************************************/
  20. # include "tsres.hxx"
  21. #define SIZEOF_INETA_IP_SEC_LIST( IPList ) \
  22. ( sizeof(INET_INFO_IP_SEC_LIST) + \
  23. (IPList)->cEntries * \
  24. sizeof(INET_INFO_IP_SEC_ENTRY) \
  25. )
  26. /************************************************************
  27. * Type Definitions
  28. ************************************************************/
  29. class IPAccessList {
  30. public:
  31. dllexp
  32. IPAccessList(VOID)
  33. : m_pIPList ( NULL),
  34. m_cReadLocks ( 0),
  35. m_tsLock ()
  36. { }
  37. dllexp
  38. ~IPAccessList(VOID)
  39. { Cleanup(); }
  40. dllexp VOID
  41. Cleanup(VOID);
  42. //
  43. // Data access protection methods
  44. //
  45. dllexp VOID
  46. LockThisForRead( VOID )
  47. {
  48. m_tsLock.Lock( TSRES_LOCK_READ );
  49. ASSERT( InterlockedIncrement( &m_cReadLocks ) > 0);
  50. }
  51. dllexp VOID
  52. LockThisForWrite( VOID )
  53. {
  54. m_tsLock.Lock( TSRES_LOCK_WRITE );
  55. ASSERT( m_cReadLocks == 0);
  56. }
  57. dllexp VOID
  58. UnlockThis( VOID )
  59. {
  60. #if DBG
  61. if ( m_cReadLocks ) // If non-zero, then this is a read unlock
  62. InterlockedDecrement( &m_cReadLocks );
  63. #endif
  64. m_tsLock.Unlock();
  65. }
  66. dllexp BOOL
  67. IsEmpty(VOID) const
  68. { return ( m_pIPList == NULL); }
  69. dllexp BOOL
  70. ReadIPList(IN LPCSTR pszRegKey);
  71. dllexp BOOL
  72. IsPresent(IN LPSOCKADDR_IN psockAddr);
  73. dllexp DWORD
  74. QueryIPListSize(VOID) const
  75. { return ( (m_pIPList != NULL) ?
  76. SIZEOF_INETA_IP_SEC_LIST( m_pIPList)
  77. : 0);
  78. }
  79. dllexp VOID
  80. CopyIPList(OUT LPINETA_IP_SEC_LIST pList)
  81. {
  82. LockThisForRead();
  83. if ( m_pIPList != NULL) {
  84. memcpy( pList, m_pIPList, SIZEOF_INETA_IP_SEC_LIST(m_pIPList));
  85. }
  86. UnlockThis();
  87. }
  88. # if DBG
  89. dllexp VOID
  90. Print( IN LPCSTR pszListName) const;
  91. # endif // DBG
  92. private:
  93. TS_RESOURCE m_tsLock; // Resource lock for IP access check
  94. LONG m_cReadLocks; // # of readers
  95. INETA_IP_SEC_LIST * m_pIPList; // security list
  96. }; // class IPAccessList
  97. # endif // _IPACCESS_HXX_
  98. /************************ End of File ***********************/