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