NULLCONN.H 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. /*
  2. ** Command & Conquer(tm)
  3. ** Copyright 2025 Electronic Arts Inc.
  4. **
  5. ** This program is free software: you can redistribute it and/or modify
  6. ** it under the terms of the GNU General Public License as published by
  7. ** the Free Software Foundation, either version 3 of the License, or
  8. ** (at your option) any later version.
  9. **
  10. ** This program is distributed in the hope that it will be useful,
  11. ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. ** GNU General Public License for more details.
  14. **
  15. ** You should have received a copy of the GNU General Public License
  16. ** along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. /* $Header: F:\projects\c&c\vcs\code\nullconn.h_v 1.12 16 Oct 1995 16:45:54 JOE_BOSTIC $ */
  19. /***************************************************************************
  20. ** 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 **
  21. ***************************************************************************
  22. * *
  23. * Project Name : Command & Conquer *
  24. * *
  25. * File Name : NULLCONN.H *
  26. * *
  27. * Programmer : Bill Randolph *
  28. * *
  29. * Start Date : December 19, 1994 *
  30. * *
  31. * Last Update : April 3, 1995 [BR] *
  32. * *
  33. *-------------------------------------------------------------------------*
  34. * *
  35. * This is the Connection Class for a NULL-Modem connection. It inherits *
  36. * a Queue, PacketBuf, timeout variables from ConnectionClass. It *
  37. * inherits its Send_/Receive_/Get_Packet functions, and the non-sequenced *
  38. * ACK/Retry logic in Service_Send_Queue & Service_Recieve_Queue from *
  39. * NonSequencedConnClass. *
  40. * *
  41. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  42. #ifndef NULLCONN_H
  43. #define NULLCONN_H
  44. /*
  45. ********************************* Includes **********************************
  46. */
  47. #include "noseqcon.h"
  48. #include "commlib.h"
  49. /*
  50. ********************************** Defines **********************************
  51. */
  52. #define PACKET_SERIAL_START 0xDABD
  53. #define PACKET_SERIAL_VERIFY 0xDEAF
  54. #define PACKET_SERIAL_OVERHEAD_SIZE (sizeof( SerialHeaderType ) + sizeof( SerialCRCType ))
  55. typedef struct {
  56. unsigned short MagicNumber;
  57. unsigned short Length;
  58. unsigned short MagicNumber2;
  59. } SerialHeaderType;
  60. typedef struct {
  61. int SerialCRC;
  62. } SerialCRCType;
  63. /*
  64. ***************************** Class Declaration *****************************
  65. */
  66. class NullModemConnClass : public NonSequencedConnClass
  67. {
  68. /*
  69. ---------------------------- Public Interface ----------------------------
  70. */
  71. public:
  72. /*.....................................................................
  73. Constructor/destructor.
  74. .....................................................................*/
  75. NullModemConnClass (int numsend, int numrecieve, int maxlen,
  76. unsigned short magicnum);
  77. virtual ~NullModemConnClass ();
  78. /*.....................................................................
  79. Initialization.
  80. .....................................................................*/
  81. void Init (HANDLE port_handle);
  82. /*.....................................................................
  83. Utility routines.
  84. .....................................................................*/
  85. unsigned long Actual_Max_Packet (void) { return (MaxPacketLen + (sizeof(SerialHeaderType)) + sizeof(int) + sizeof (char)); }
  86. /*.....................................................................
  87. This routine computes a CRC value for the given buffer.
  88. .....................................................................*/
  89. static int Compute_CRC(char *buf, int buflen);
  90. /*.....................................................................
  91. This routine returns the number of bytes extra added the packet
  92. for communication.
  93. .....................................................................*/
  94. static int Packet_Overhead_Size( void );
  95. /*
  96. --------------------------- Private Interface ----------------------------
  97. */
  98. protected:
  99. /*.....................................................................
  100. This routine actually performs a hardware-dependent data send.
  101. .....................................................................*/
  102. int Send (char *buf, int buflen);
  103. /*.....................................................................
  104. This is the PORT value used by the GreenLeaf calls.
  105. .....................................................................*/
  106. HANDLE PortHandle;
  107. PORT *Port;
  108. /*.....................................................................
  109. This buffer is a staging area for data sent out; it includes the
  110. packet sent by the parent class (which includes the application's
  111. packet, plus the CommHeaderType header), plus:
  112. - 2-byte buffer start ID
  113. - 2-byte length
  114. - 4-byte CRC value (at the end of the buffer)
  115. This is the actual packet that gets sent across the serial line.
  116. .....................................................................*/
  117. char *SendBuf;
  118. };
  119. #endif
  120. /************************** end of nullconn.h ******************************/