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.

277 lines
7.1 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\gkreg.h_v $
  13. * *
  14. * $Revision: 1.2 $
  15. * $Date: 12 Feb 1997 01:12:04 $
  16. * *
  17. * $Author: CHULME $
  18. * *
  19. * $Log: S:\sturgeon\src\gki\vcs\gkreg.h_v $
  20. *
  21. * Rev 1.2 12 Feb 1997 01:12:04 CHULME
  22. * Redid thread synchronization to use Gatekeeper.Lock
  23. *
  24. * Rev 1.1 08 Feb 1997 12:17:00 CHULME
  25. * Changed from using unsigned long to using HANDLE for threads
  26. * Added semphore to registration class
  27. *
  28. * Rev 1.0 17 Jan 1997 08:48:32 CHULME
  29. * Initial revision.
  30. *
  31. * Rev 1.3 10 Jan 1997 16:16:02 CHULME
  32. * Removed MFC dependency
  33. *
  34. * Rev 1.2 02 Dec 1996 23:50:34 CHULME
  35. * Added premptive synchronization code
  36. *
  37. * Rev 1.1 22 Nov 1996 15:21:16 CHULME
  38. * Added VCS log to the header
  39. *************************************************************************/
  40. // Registration.h : interface of the CRegistration class
  41. // See Registration.cpp for the implementation of this class
  42. /////////////////////////////////////////////////////////////////////////////
  43. #ifndef REGISTRATION_H
  44. #define REGISTRATION_H
  45. #include "dcall.h"
  46. extern "C" HRESULT CopyVendorInfo(PCC_VENDORINFO *ppDest, PCC_VENDORINFO pSource);
  47. extern "C" HRESULT FreeVendorInfo(PCC_VENDORINFO pVendorInfo);
  48. typedef void * POS;
  49. template <class T> struct TItem
  50. {
  51. TItem *pNext;
  52. TItem *pPrev;
  53. T Value;
  54. TItem (const T& NewValue) : Value(NewValue) {}
  55. };
  56. // Here we implement a circularly linked list
  57. template <class T> class CLinkedList
  58. {
  59. public:
  60. CLinkedList();
  61. ~CLinkedList();
  62. void AddTail (const T& NewItem);
  63. BOOL IsEmpty (void);
  64. POS GetFirstPos (void);
  65. T GetNext (POS &Position);
  66. POS Find (const T& Item);
  67. BOOL RemoveAt (POS &Position);
  68. T GetAt(const POS Position);
  69. void RemoveAll(void);
  70. int GetCount(void);
  71. private:
  72. TItem<T> *pTail;
  73. int iCount;
  74. void AddTailPriv(TItem<T> *pNewItem);
  75. };
  76. typedef CLinkedList < CCall* > CCallList;
  77. class CRegistration
  78. {
  79. private:
  80. SeqTransportAddr *m_pCallSignalAddress;
  81. EndpointType m_terminalType;
  82. SeqAliasAddr *m_pRgstrtnRqst_trmnlAls;
  83. HWND m_hWnd;
  84. WORD m_wBaseMessage;
  85. unsigned short m_usRegistrationTransport;
  86. SeqAliasAddr *m_pLocationInfo;
  87. TransportAddress m_Location[2];
  88. PCC_VENDORINFO m_pVendorInfo;
  89. GatekeeperIdentifier m_RCm_gtkprIdntfr;
  90. EndpointIdentifier m_endpointID;
  91. RequestSeqNum m_requestSeqNum;
  92. SeqTransportAddr *m_pRASAddress;
  93. CCallList m_Calls;
  94. RasMessage *m_pRasMessage;
  95. HANDLE m_hRcvThread;
  96. UINT_PTR m_uTimer;
  97. UINT m_uRetryResetCount;
  98. UINT m_uRetryCountdown;
  99. UINT m_uMaxRetryCount;
  100. CRITICAL_SECTION m_SocketCRS;
  101. // HANDLE m_hRetryThread;
  102. #ifdef BROADCAST_DISCOVERY
  103. HANDLE m_hDiscThread;
  104. #endif
  105. unsigned short m_usCallReferenceValue;
  106. unsigned short m_usRetryCount;
  107. // CRITICAL_SECTION m_CriticalSection;
  108. // DWORD m_dwLockingThread;
  109. public:
  110. // volatile HANDLE m_hRetrySemaphore;
  111. enum {
  112. GK_UNREGISTERED,
  113. GK_REG_PENDING,
  114. GK_REGISTERED,
  115. GK_UNREG_PENDING,
  116. GK_LOC_PENDING
  117. } m_State;
  118. CGKSocket *m_pSocket;
  119. CRegistration();
  120. ~CRegistration();
  121. HRESULT AddVendorInfo(PCC_VENDORINFO pVendorInfo);
  122. HRESULT AddCallSignalAddr(TransportAddress& rvalue);
  123. HRESULT AddRASAddr(TransportAddress& rvalue, unsigned short usPort);
  124. void SetTerminalType(EndpointType *pTerminalType)
  125. {
  126. m_terminalType = *pTerminalType;
  127. }
  128. HRESULT AddAliasAddr(AliasAddress& rvalue);
  129. HRESULT AddLocationInfo(AliasAddress& rvalue);
  130. void SetHWnd(HWND hWnd)
  131. {
  132. m_hWnd = hWnd;
  133. }
  134. void SetBaseMessage(WORD wBaseMessage)
  135. {
  136. m_wBaseMessage = wBaseMessage;
  137. }
  138. void SetRegistrationTransport(unsigned short usRegistrationTransport)
  139. {
  140. m_usRegistrationTransport = usRegistrationTransport;
  141. }
  142. void SetRcvThread(HANDLE hThread)
  143. {
  144. m_hRcvThread = hThread;
  145. }
  146. HANDLE GetRcvThread(void)
  147. {
  148. return m_hRcvThread;
  149. }
  150. void LockSocket() { EnterCriticalSection(&m_SocketCRS); }
  151. void UnlockSocket() { LeaveCriticalSection(&m_SocketCRS); }
  152. UINT_PTR StartRetryTimer(void);
  153. // void SetRetryThread(HANDLE hThread)
  154. // {
  155. // m_hRetryThread = hThread;
  156. // }
  157. #ifdef BROADCAST_DISCOVERY
  158. void SetDiscThread(HANDLE hThread)
  159. {
  160. m_hDiscThread = hThread;
  161. }
  162. HANDLE GetDiscThread(void)
  163. {
  164. return m_hDiscThread;
  165. }
  166. #endif
  167. HWND GetHWnd(void)
  168. {
  169. return (m_hWnd);
  170. }
  171. WORD GetBaseMessage(void)
  172. {
  173. return (m_wBaseMessage);
  174. }
  175. unsigned short GetRegistrationTransport(void)
  176. {
  177. return (m_usRegistrationTransport);
  178. }
  179. unsigned short GetNextCRV(void)
  180. {
  181. return (++m_usCallReferenceValue);
  182. }
  183. TransportAddress *GetTransportAddress(unsigned short usCallTransport);
  184. RequestSeqNum GetNextSeqNum(void)
  185. {
  186. return (++m_requestSeqNum);
  187. }
  188. EndpointIdentifier GetEndpointIdentifier(void)
  189. {
  190. return (m_endpointID);
  191. }
  192. SeqAliasAddr *GetAlias(void)
  193. {
  194. return (m_pRgstrtnRqst_trmnlAls);
  195. }
  196. RasMessage *GetRasMessage(void)
  197. {
  198. return (m_pRasMessage);
  199. }
  200. int GetState(void)
  201. {
  202. return (m_State);
  203. }
  204. HRESULT RegistrationRequest(BOOL fDiscovery);
  205. HRESULT UnregistrationRequest(void);
  206. HRESULT GatekeeperRequest(void);
  207. HRESULT LocationRequest(void);
  208. HRESULT PDUHandler(RasMessage *pRasMessage);
  209. HRESULT RegistrationConfirm(RasMessage *pRasMessage);
  210. HRESULT RegistrationReject(RasMessage *pRasMessage);
  211. HRESULT UnregistrationConfirm(RasMessage *pRasMessage);
  212. HRESULT UnregistrationReject(RasMessage *pRasMessage);
  213. HRESULT LocationConfirm(RasMessage *pRasMessage);
  214. HRESULT LocationReject(RasMessage *pRasMessage);
  215. HRESULT UnknownMessage(RasMessage *pRasMessage);
  216. HRESULT GatekeeperConfirm(RasMessage *pRasMessage);
  217. HRESULT GatekeeperReject(RasMessage *pRasMessage);
  218. HRESULT SendUnregistrationConfirm(RasMessage *pRasMessage);
  219. HRESULT Retry(void);
  220. HRESULT SendInfoRequestResponse(CallInfoStruct *pCallInfo, RasMessage *pRasMessage);
  221. CCall *FindCallBySeqNum(RequestSeqNum seqNum);
  222. CCall *FindCallByCRV(CallReferenceValue crv);
  223. void DeleteCall(CCall *pCall);
  224. void AddCall(CCall *pCall);
  225. CCall *GetNextCall(CCall *pCall);
  226. // void Lock(void);
  227. // void Unlock(void);
  228. };
  229. #if 0
  230. class CRegistrationLock
  231. {
  232. private:
  233. CRegistration* m_pReg;
  234. public:
  235. CRegistrationLock(CRegistration *g_pReg)
  236. {
  237. _ASSERT(g_pReg);
  238. m_pReg = g_pReg;
  239. g_pReg->Lock();
  240. }
  241. ~CRegistrationLock()
  242. {
  243. m_pReg->Unlock();
  244. }
  245. };
  246. #endif
  247. #endif // REGISTRATION_H
  248. /////////////////////////////////////////////////////////////////////////////
  249.