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.

132 lines
3.2 KiB

  1. /************************************************************************
  2. * *
  3. * INTEL CORPORATION PROPRIETARY INFORMATION *
  4. * *
  5. * This software is supplied under the terms of a license *
  6. * agreement or non-disclosure agreement with Intel Corporation *
  7. * and may not be copied or disclosed except in accordance *
  8. * with the terms of that agreement. *
  9. * *
  10. * Copyright (C) 1997 Intel Corp. All Rights Reserved *
  11. * *
  12. * $Archive: S:\sturgeon\src\gki\vcs\gatekpr.h_v $
  13. * *
  14. * $Revision: 1.5 $
  15. * $Date: 12 Feb 1997 01:10:56 $
  16. * *
  17. * $Author: CHULME $
  18. * *
  19. * $Log: S:\sturgeon\src\gki\vcs\gatekpr.h_v $
  20. *
  21. * Rev 1.5 12 Feb 1997 01:10:56 CHULME
  22. * Redid thread synchronization to use Gatekeeper.Lock
  23. *
  24. * Rev 1.4 17 Jan 1997 12:52:46 CHULME
  25. * Removed UNICODE dependent code
  26. *
  27. * Rev 1.3 10 Jan 1997 16:14:26 CHULME
  28. * Removed MFC dependency
  29. *
  30. * Rev 1.2 20 Dec 1996 16:38:30 CHULME
  31. * Fixed access synchronization with Gatekeeper lock
  32. *
  33. * Rev 1.1 22 Nov 1996 15:24:22 CHULME
  34. * Added VCS log to the header
  35. *************************************************************************/
  36. // GATEKPR.H : interface of the CGatekeeper class
  37. // See gatekeeper.cpp for the implementation of this class
  38. /////////////////////////////////////////////////////////////////////////////
  39. #ifndef GATEKEEPER_H
  40. #define GATEKEEPER_H
  41. class CGatekeeper
  42. {
  43. private:
  44. char m_GKIPAddress[IPADDR_SZ + 1];
  45. SOCKADDR_IN m_GKSockAddr;
  46. DWORD m_dwMCastTTL;
  47. BOOL m_fRejectReceived;
  48. CRITICAL_SECTION m_CriticalSection;
  49. DWORD m_dwLockingThread;
  50. public:
  51. CGatekeeper();
  52. ~CGatekeeper();
  53. void Read(void);
  54. void Write(void);
  55. #ifdef BROADCAST_DISCOVERY
  56. void DeleteCachedAddresses(void);
  57. #endif // #ifdef BROADCAST_DISCOVERY
  58. PSOCKADDR_IN GetSockAddr(void)
  59. {
  60. if(m_GKSockAddr.sin_addr.S_un.S_addr != INADDR_ANY)
  61. {
  62. return(&m_GKSockAddr);
  63. }
  64. else return NULL;
  65. }
  66. char *GetIPAddress(void)
  67. {
  68. return(m_GKIPAddress);
  69. }
  70. DWORD GetMCastTTL(void)
  71. {
  72. return m_dwMCastTTL;
  73. }
  74. BOOL GetRejectFlag(void)
  75. {
  76. return (m_fRejectReceived);
  77. }
  78. void SetIPAddress(char *szAddr)
  79. {
  80. if (lstrlenA(szAddr) <= IPADDR_SZ)
  81. {
  82. lstrcpyA(m_GKIPAddress, szAddr);
  83. m_GKSockAddr.sin_addr.s_addr = inet_addr(m_GKIPAddress);
  84. }
  85. }
  86. void SetSockAddr(PSOCKADDR_IN pAddr)
  87. {
  88. if(pAddr && pAddr->sin_addr.S_un.S_addr != INADDR_ANY)
  89. {
  90. m_GKSockAddr = *pAddr;
  91. lstrcpyA(m_GKIPAddress, inet_ntoa(m_GKSockAddr.sin_addr));
  92. }
  93. }
  94. void SetMCastTTL(DWORD dwttl)
  95. {
  96. m_dwMCastTTL = dwttl;
  97. }
  98. void SetRejectFlag(BOOL fReject)
  99. {
  100. m_fRejectReceived = fReject;
  101. }
  102. void Lock(void);
  103. void Unlock(void);
  104. };
  105. class CGatekeeperLock
  106. {
  107. private:
  108. CGatekeeper* m_pGK;
  109. public:
  110. CGatekeeperLock(CGatekeeper *pGK)
  111. {
  112. ASSERT(pGK);
  113. m_pGK = pGK;
  114. pGK->Lock();
  115. }
  116. ~CGatekeeperLock()
  117. {
  118. m_pGK->Unlock();
  119. }
  120. };
  121. #endif // GATEKEEPER_H
  122. /////////////////////////////////////////////////////////////////////////////