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.

234 lines
6.5 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.cpv $
  13. * *
  14. * $Revision: 1.9 $
  15. * $Date: 19 Feb 1997 13:57:36 $
  16. * *
  17. * $Author: CHULME $
  18. * *
  19. * $Log: S:\sturgeon\src\gki\vcs\gatekpr.cpv $
  20. //
  21. // Rev 1.9 19 Feb 1997 13:57:36 CHULME
  22. // Modified DeleteCachedAddress to write all registry settings
  23. //
  24. // Rev 1.8 14 Feb 1997 16:41:16 CHULME
  25. // Changed registry key to GKIDLL\2.0 to match GKI version
  26. //
  27. // Rev 1.7 17 Jan 1997 12:53:00 CHULME
  28. // Removed UNICODE dependent code
  29. //
  30. // Rev 1.6 17 Jan 1997 09:01:58 CHULME
  31. // No change.
  32. //
  33. // Rev 1.5 13 Jan 1997 17:01:38 CHULME
  34. // Fixed debug messages for registry cached addresses
  35. //
  36. // Rev 1.4 10 Jan 1997 16:14:22 CHULME
  37. // Removed MFC dependency
  38. //
  39. // Rev 1.3 20 Dec 1996 16:37:42 CHULME
  40. // Fixed access synchronization with Gatekeeper lock
  41. //
  42. // Rev 1.2 19 Dec 1996 19:27:32 CHULME
  43. // Retry count and interval only read/written to registry on DEBUG
  44. //
  45. // Rev 1.1 22 Nov 1996 15:24:28 CHULME
  46. // Added VCS log to the header
  47. *************************************************************************/
  48. // gatekeeper.cpp : Provides the implementation for the CGatekeeper class
  49. //
  50. #include "precomp.h"
  51. #include "dspider.h"
  52. #include "dgkilit.h"
  53. #include "GATEKPR.H"
  54. #ifdef _DEBUG
  55. #undef THIS_FILE
  56. static char THIS_FILE[] = __FILE__;
  57. #endif
  58. /////////////////////////////////////////////////////////////////////////////
  59. // CGatekeeper construction
  60. CGatekeeper::CGatekeeper()
  61. :m_dwMCastTTL(1),
  62. m_fRejectReceived(FALSE),
  63. m_dwLockingThread(0)
  64. {
  65. SetIPAddress("");
  66. m_GKSockAddr.sin_addr.S_un.S_addr = INADDR_ANY;
  67. InitializeCriticalSection(&m_CriticalSection);
  68. }
  69. /////////////////////////////////////////////////////////////////////////////
  70. // CGatekeeper destruction
  71. CGatekeeper::~CGatekeeper()
  72. {
  73. if (m_dwLockingThread)
  74. Unlock();
  75. DeleteCriticalSection(&m_CriticalSection);
  76. }
  77. void
  78. CGatekeeper::Read(void)
  79. {
  80. // ABSTRACT: This member function will read the gatekeeper addresses and the
  81. // multicast flag from the Registry and load the member variables
  82. // AUTHOR: Colin Hulme
  83. HKEY hKey;
  84. DWORD dwDisposition;
  85. DWORD dwType;
  86. DWORD dwLen;
  87. LONG lRet;
  88. #ifdef _DEBUG
  89. char szGKDebug[80];
  90. #endif
  91. SPIDER_TRACE(SP_FUNC, "CGatekeeper::Read()\n", 0);
  92. dwType = REG_SZ;
  93. lRet = RegCreateKeyEx(HKEY_LOCAL_MACHINE, TEXT("SOFTWARE\\Microsoft\\Conferencing\\GatekeeperDLL"),
  94. 0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS,
  95. NULL, &hKey, &dwDisposition);
  96. dwLen =IPADDR_SZ + 1;
  97. #if(0) // don't do the registry hack now that setting the address is exposed
  98. lRet = RegQueryValueEx(hKey, TEXT("GKIPAddress"), NULL, &dwType,
  99. (LPBYTE)m_GKIPAddress, &dwLen);
  100. SPIDER_DEBUGS(m_GKIPAddress);
  101. if(m_GKIPAddress[0] != 0)
  102. {
  103. m_GKSockAddr.sin_addr.s_addr = inet_addr(m_GKIPAddress);
  104. }
  105. #endif // if(0)
  106. dwType = REG_DWORD;
  107. dwLen = sizeof(DWORD);
  108. RegQueryValueEx(hKey, TEXT("GKMCastTTL"), NULL, &dwType,
  109. (LPBYTE)&m_dwMCastTTL, &dwLen);
  110. SPIDER_DEBUG(m_dwMCastTTL);
  111. #if(0)
  112. #ifdef _DEBUG
  113. RegQueryValueEx(hKey, TEXT("GKRetryMS"), NULL, &dwType,
  114. (LPBYTE)&m_dwRetryMS, &dwLen);
  115. if (m_dwRetryMS == 0)
  116. m_dwRetryMS = DEFAULT_RETRY_MS;
  117. SPIDER_DEBUG(m_dwRetryMS);
  118. RegQueryValueEx(hKey, TEXT("GKMaxRetries"), NULL, &dwType,
  119. (LPBYTE)&m_dwMaxRetries, &dwLen);
  120. if (m_dwMaxRetries == 0)
  121. m_dwMaxRetries = DEFAULT_MAX_RETRIES;
  122. SPIDER_DEBUG(m_dwMaxRetries);
  123. #else
  124. m_dwRetryMS = DEFAULT_RETRY_MS;
  125. m_dwMaxRetries = DEFAULT_MAX_RETRIES;
  126. #endif //_DEBUG
  127. #endif // if(0)
  128. RegCloseKey(hKey);
  129. }
  130. void
  131. CGatekeeper::Write(void)
  132. {
  133. // ABSTRACT: This member function will write the gatekeeper addresses and the
  134. // multicast flag to the Registry.
  135. // AUTHOR: Colin Hulme
  136. HKEY hKey;
  137. DWORD dwDisposition;
  138. #ifdef _DEBUG
  139. char szGKDebug[80];
  140. #endif
  141. SPIDER_TRACE(SP_FUNC, "CGatekeeper::Write()\n", 0);
  142. RegCreateKeyEx(HKEY_LOCAL_MACHINE, TEXT("SOFTWARE\\Intel\\GKIDLL\\2.0"),
  143. 0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS,
  144. NULL, &hKey, &dwDisposition);
  145. RegSetValueEx(hKey, TEXT("GKIPAddress"), NULL, REG_SZ,
  146. (LPBYTE)m_GKIPAddress, lstrlenA(m_GKIPAddress));
  147. #if(0)
  148. #ifdef _DEBUG
  149. RegSetValueEx(hKey, TEXT("GKMCastTTL"), NULL, REG_DWORD,
  150. (LPBYTE)&m_dwMCastTTL, sizeof(DWORD));
  151. RegSetValueEx(hKey, TEXT("GKRetryMS"), NULL, REG_DWORD,
  152. (LPBYTE)&m_dwRetryMS, sizeof(DWORD));
  153. RegSetValueEx(hKey, TEXT("GKMaxRetries"), NULL, REG_DWORD,
  154. (LPBYTE)&m_dwMaxRetries, sizeof(DWORD));
  155. #endif //_DEBUG
  156. #endif // if(0)
  157. RegCloseKey(hKey);
  158. }
  159. #ifdef BROADCAST_DISCOVERY
  160. void
  161. CGatekeeper::DeleteCachedAddresses(void)
  162. {
  163. // ABSTRACT: This memeber function will delete the cached gatekeeper
  164. // addresses from the Registry
  165. //AUTHOR: Colin Hulme
  166. HKEY hKey;
  167. DWORD dwDisposition;
  168. #ifdef _DEBUG
  169. char szGKDebug[80];
  170. #endif
  171. SPIDER_TRACE(SP_FUNC, "CGatekeeper::DeleteCachedAddresses()\n", 0);
  172. RegCreateKeyEx(HKEY_LOCAL_MACHINE, TEXT("SOFTWARE\\Intel\\GKIDLL\\2.0"),
  173. 0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS,
  174. NULL, &hKey, &dwDisposition);
  175. RegDeleteValue(hKey, "GKIPAddress");
  176. RegDeleteValue(hKey, "GKIPXAddress");
  177. #ifdef _DEBUG
  178. RegSetValueEx(hKey, TEXT("GKMCastTTL"), NULL, REG_DWORD,
  179. (LPBYTE)&m_dwMCastTTL, sizeof(DWORD));
  180. RegSetValueEx(hKey, TEXT("GKRetryMS"), NULL, REG_DWORD,
  181. (LPBYTE)&m_dwRetryMS, sizeof(DWORD));
  182. RegSetValueEx(hKey, TEXT("GKMaxRetries"), NULL, REG_DWORD,
  183. (LPBYTE)&m_dwMaxRetries, sizeof(DWORD));
  184. #endif
  185. RegCloseKey(hKey);
  186. }
  187. #endif //#ifdef BROADCAST_DISCOVERY
  188. void
  189. CGatekeeper::Lock(void)
  190. {
  191. EnterCriticalSection(&m_CriticalSection);
  192. m_dwLockingThread = GetCurrentThreadId();
  193. }
  194. void
  195. CGatekeeper::Unlock(void)
  196. {
  197. // Assert that the unlock is done by the
  198. // thread that holds the lock
  199. ASSERT(m_dwLockingThread == GetCurrentThreadId());
  200. m_dwLockingThread = 0;
  201. LeaveCriticalSection(&m_CriticalSection);
  202. }