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.

272 lines
5.7 KiB

  1. #ifndef __ICQ_CLIENT_HEADER_
  2. #define __ICQ_CLIENT_HEADER_
  3. #define ICQ99_SERVER_PORT 0xA00F
  4. #define ICQ99_HACK_PORT 0xA00F
  5. #define ICQ2K_SERVER_PORT 0x0000
  6. #define ICQ2K_HACK_PORT 0x0001
  7. #define ICQ_BUFFER_SIZE 576
  8. #define ICQ_CLIENT_TIMEOUT 360
  9. //
  10. // SERVER MESSAGES are PortRedirect'ed to port
  11. // Here it is dispatched accordingly.. It serves as just an envoy.
  12. typedef class _ICQ_PEER : public GENERIC_NODE
  13. {
  14. friend
  15. VOID
  16. IcqPeerConnectionCompletionRoutine
  17. (
  18. ULONG ErrorCode,
  19. ULONG BytesTransferred,
  20. PNH_BUFFER Bufferp
  21. );
  22. friend
  23. VOID
  24. IcqPeerReadCompletionRoutine
  25. (
  26. ULONG ErrorCode,
  27. ULONG BytesTransferred,
  28. PNH_BUFFER Bufferp
  29. );
  30. // friend class _ICQ_PEER;
  31. public:
  32. _ICQ_PEER();
  33. ~_ICQ_PEER();
  34. virtual void ComponentCleanUpRoutine(void);
  35. virtual void StopSync(void);
  36. virtual PCHAR GetObjectName() { return ObjectNamep; }
  37. virtual ULONG ProcessOutgoingPeerMessage(PUCHAR buf, ULONG len);
  38. virtual ULONG InitiatePeerConnection(PDispatchReply DispatchReplyp);
  39. virtual ULONG EndPeerSessionForClient(PCNhSock ClosedSocketp);
  40. virtual ULONG CreateShadowMappingPriorToConnection(PDispatchReply DispatchReplyp);
  41. // member variables section
  42. PCNhSock ToClientSocketp;
  43. PCNhSock ToPeerSocketp;
  44. ULONG PeerUIN;
  45. ULONG PeerVer;
  46. ULONG PeerIp;
  47. USHORT PeerPort;
  48. BOOLEAN bActivated;
  49. BOOLEAN bShadowMappingExists;
  50. ICQ_DIRECTION_FLAGS MappingDirection;
  51. IPendingProxyConnection* ShadowRedirectp;
  52. ISecondaryControlChannel* OutgoingPeerControlRedirectp;
  53. IDataChannel * IncomingDataRedirectp;
  54. // HANDLE hIncomingDataRedirectHandle;
  55. static const PCHAR ObjectNamep;
  56. } ICQ_PEER, * PICQ_PEER;
  57. //
  58. //
  59. //
  60. typedef class _ICQ_CLIENT : public virtual DISPATCHEE
  61. {
  62. friend _ICQ_CLIENT* ScanTheListForLocalPeer(
  63. PULONG PeerIp,
  64. PUSHORT PeerPort,
  65. ULONG IcqUIN
  66. );
  67. public:
  68. _ICQ_CLIENT();
  69. ~_ICQ_CLIENT();
  70. virtual void ComponentCleanUpRoutine(void);
  71. virtual void StopSync(void);
  72. virtual PCHAR GetObjectName() { return ObjectNamep;}
  73. ULONG DispatchCompletionRoutine
  74. (
  75. PDispatchReply DispatchReplyp
  76. );
  77. // ** Initialize **
  78. // The first packet to any server is initialized here..
  79. // This creates a new UDP Server socket (if there isn't one.)
  80. // Initializes the Server Address, creates a more specific
  81. // Redirection between the Client ~ Proxy
  82. // (if there is one already deletes that )
  83. // Modifies the packet if necessary and forwards it to
  84. // the designated destination.
  85. // Creates secondary Mappings and such
  86. // NOTE: This function is called from the Context Of
  87. // IcqReadCompletion Routine which dispatches the inits.
  88. //
  89. ULONG Initialize(
  90. PNH_BUFFER Bufferp,
  91. ULONG clientIp,
  92. USHORT clientPort,
  93. ULONG serverIp,
  94. USHORT serverPort,
  95. PCNhSock localClientSocketp
  96. );
  97. // ** ServerRead **
  98. // This will keep track of Peer Online Messages and such..
  99. // will create sockets for each peer that is online and will
  100. // create mappings which will redirect the outgoing packets
  101. // to the peers to the appropriate Handler.. Which in turn
  102. // will change the appropriate packets and then create
  103. // Redirects if necessary.
  104. ULONG ServerRead(
  105. PNH_BUFFER Bufferp,
  106. ULONG serverIp,
  107. USHORT serverPort
  108. );
  109. ULONG ClientRead(
  110. PNH_BUFFER Bufferp,
  111. ULONG serverIp,
  112. USHORT serverPort
  113. );
  114. ISecondaryControlChannel*
  115. PeerRedirection(
  116. ULONG dstIp,
  117. USHORT dstPort,
  118. ULONG srcIp OPTIONAL,
  119. USHORT srcPort OPTIONAL,
  120. ICQ_DIRECTION_FLAGS DirectionContext
  121. );
  122. // Do we need this?
  123. // ServerWrite();
  124. // PeerWrite();
  125. VOID ReportExistingPeers(VOID);
  126. //protected:
  127. ULONG IcqServerToClientUdp(
  128. PUCHAR mcp,
  129. ULONG mcplen
  130. );
  131. ULONG IcqClientToServerUdp(
  132. PUCHAR buf,
  133. ULONG size
  134. );
  135. ULONG DeleteTimer(TIMER_DELETION bHow);
  136. ULONG ResetTimer(VOID);
  137. // member - ServerSocket
  138. PCNhSock ServerSocketp; // when writing and reading to server
  139. //
  140. // NAT ENGINE RELATED
  141. IPendingProxyConnection * ShadowRedirectp;
  142. ISecondaryControlChannel* IncomingPeerControlRedirectionp;
  143. // this socket is shared among all the clients
  144. PCNhSock ClientSocketp; // when writing to the client back +
  145. ULONG ClientIp;
  146. USHORT ClientToServerPort; // UDP
  147. USHORT ClientToPeerPort; // TCP
  148. USHORT ImitatedPeerPort;
  149. ULONG UIN;
  150. ULONG ClientVer;
  151. ULONG ServerIp;
  152. USHORT ServerPort;
  153. CLIST IcqPeerList;
  154. PTIMER_CONTEXT TimerContextp;
  155. static const PCHAR ObjectNamep;
  156. } ICQ_CLIENT, *PICQ_CLIENT;
  157. //
  158. // Function Definitions
  159. //
  160. VOID NTAPI IcqClientTimeoutHandler(
  161. PVOID Parameterp,
  162. BOOLEAN TimerOrWaitFired
  163. );
  164. #endif