NULLCONN.H 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. //
  2. // Copyright 2020 Electronic Arts Inc.
  3. //
  4. // TiberianDawn.DLL and RedAlert.dll and corresponding source code is free
  5. // software: you can redistribute it and/or modify it under the terms of
  6. // the GNU General Public License as published by the Free Software Foundation,
  7. // either version 3 of the License, or (at your option) any later version.
  8. // TiberianDawn.DLL and RedAlert.dll and corresponding source code is distributed
  9. // in the hope that it will be useful, but with permitted additional restrictions
  10. // under Section 7 of the GPL. See the GNU General Public License in LICENSE.TXT
  11. // distributed with this program. You should have received a copy of the
  12. // GNU General Public License along with permitted additional restrictions
  13. // with this program. If not, see https://github.com/electronicarts/CnC_Remastered_Collection
  14. /* $Header: /CounterStrike/NULLCONN.H 1 3/03/97 10:25a Joe_bostic $ */
  15. /***************************************************************************
  16. ** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S **
  17. ***************************************************************************
  18. * *
  19. * Project Name : Command & Conquer *
  20. * *
  21. * File Name : NULLCONN.H *
  22. * *
  23. * Programmer : Bill Randolph *
  24. * *
  25. * Start Date : December 19, 1994 *
  26. * *
  27. * Last Update : April 3, 1995 [BR] *
  28. * *
  29. *-------------------------------------------------------------------------*
  30. * *
  31. * This is the Connection Class for a NULL-Modem connection. It inherits *
  32. * a Queue, PacketBuf, timeout variables from ConnectionClass. It *
  33. * inherits its Send_/Receive_/Get_Packet functions, and the non-sequenced *
  34. * ACK/Retry logic in Service_Send_Queue & Service_Receive_Queue from *
  35. * ConnectionClass. *
  36. * *
  37. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  38. #ifndef NULLCONN_H
  39. #define NULLCONN_H
  40. /*
  41. ********************************* Includes **********************************
  42. */
  43. #include "connect.h"
  44. //#include "commlib.h"
  45. /*
  46. ********************************** Defines **********************************
  47. */
  48. #define PACKET_SERIAL_START 0xDABD
  49. #define PACKET_SERIAL_VERIFY 0xDEAF
  50. #define PACKET_SERIAL_OVERHEAD_SIZE (sizeof( SerialHeaderType ) + sizeof( SerialCRCType ))
  51. typedef struct {
  52. unsigned short MagicNumber;
  53. unsigned short Length;
  54. unsigned short MagicNumber2;
  55. } SerialHeaderType;
  56. typedef struct {
  57. int SerialCRC;
  58. } SerialCRCType;
  59. /*
  60. ***************************** Class Declaration *****************************
  61. */
  62. class NullModemConnClass : public ConnectionClass
  63. {
  64. /*
  65. ---------------------------- Public Interface ----------------------------
  66. */
  67. public:
  68. /*.....................................................................
  69. Constructor/destructor.
  70. .....................................................................*/
  71. NullModemConnClass (int numsend, int numrecieve, int maxlen,
  72. unsigned short magicnum);
  73. virtual ~NullModemConnClass ();
  74. /*.....................................................................
  75. Initialization.
  76. .....................................................................*/
  77. #ifdef WIN32
  78. void Init (HANDLE port_handle);
  79. #else //WIN32
  80. void Init (PORT *port);
  81. #endif //WIN32
  82. /*.....................................................................
  83. Utility routines.
  84. .....................................................................*/
  85. unsigned long Actual_Max_Packet (void) { return (MaxPacketLen +
  86. (sizeof(SerialHeaderType)) + sizeof(int) + sizeof (char)); }
  87. /*.....................................................................
  88. This routine computes a CRC value for the given buffer.
  89. .....................................................................*/
  90. static int Compute_CRC(char *buf, int buflen);
  91. /*.....................................................................
  92. This routine returns the number of bytes extra added the packet
  93. for communication.
  94. .....................................................................*/
  95. static int Packet_Overhead_Size( void );
  96. /*
  97. --------------------------- Private Interface ----------------------------
  98. */
  99. protected:
  100. /*.....................................................................
  101. This routine actually performs a hardware-dependent data send.
  102. .....................................................................*/
  103. virtual int Send (char *buf, int buflen, void *extrabuf, int extralen);
  104. #ifdef WIN32
  105. /*
  106. ** This is the winsoze port handle
  107. */
  108. HANDLE PortHandle;
  109. #else //WIN32
  110. /*.....................................................................
  111. This is the PORT value used by the GreenLeaf calls.
  112. .....................................................................*/
  113. PORT *Port;
  114. #endif //WIN32
  115. /*.....................................................................
  116. This buffer is a staging area for data sent out; it includes the
  117. packet sent by the parent class (which includes the application's
  118. packet, plus the CommHeaderType header), plus:
  119. - 2-byte buffer start ID
  120. - 2-byte length
  121. - 4-byte CRC value (at the end of the buffer)
  122. This is the actual packet that gets sent across the serial line.
  123. .....................................................................*/
  124. char *SendBuf;
  125. };
  126. #endif
  127. /************************** end of nullconn.h ******************************/