CnC_Remastered_Collection

Command and Conquer: Red Alert
Log | Files | Refs | README | LICENSE

NULLCONN.H (6183B)


      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: /CounterStrike/NULLCONN.H 1     3/03/97 10:25a 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_Receive_Queue from		*
     37  * ConnectionClass.																			*
     38  *                                                                         *
     39  * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
     40 
     41 #ifndef NULLCONN_H
     42 #define NULLCONN_H
     43 
     44 
     45 /*
     46 ********************************* Includes **********************************
     47 */
     48 #include "connect.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 ConnectionClass
     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 #ifdef WIN32
     90 		void Init (HANDLE port_handle);
     91 #else	//WIN32
     92 		void Init (PORT *port);
     93 #endif	//WIN32
     94 
     95 		/*.....................................................................
     96 		Utility routines.
     97 		.....................................................................*/
     98 		unsigned long Actual_Max_Packet (void) { return (MaxPacketLen +
     99 			(sizeof(SerialHeaderType)) + sizeof(int) + sizeof (char)); }
    100 
    101 		/*.....................................................................
    102 		This routine computes a CRC value for the given buffer.
    103 		.....................................................................*/
    104 		static int Compute_CRC(char *buf, int buflen);
    105 
    106 		/*.....................................................................
    107 		This routine returns the number of bytes extra added the packet
    108 		for communication.
    109 		.....................................................................*/
    110 		static int Packet_Overhead_Size( void );
    111 
    112 	/*
    113 	--------------------------- Private Interface ----------------------------
    114 	*/
    115 	protected:
    116 		/*.....................................................................
    117 		This routine actually performs a hardware-dependent data send.
    118 		.....................................................................*/
    119 		virtual int Send (char *buf, int buflen, void *extrabuf, int extralen);
    120 #ifdef WIN32
    121 		/*
    122 		** This is the winsoze port handle
    123 		*/
    124 		HANDLE PortHandle;
    125 #else	//WIN32
    126 		/*.....................................................................
    127 		This is the PORT value used by the GreenLeaf calls.
    128 		.....................................................................*/
    129 		PORT *Port;
    130 #endif	//WIN32
    131 
    132 		/*.....................................................................
    133 		This buffer is a staging area for data sent out; it includes the
    134 		packet sent by the parent class (which includes the application's
    135 		packet, plus the CommHeaderType header), plus:
    136 		- 2-byte buffer start ID
    137 		- 2-byte length
    138 		- 4-byte CRC value (at the end of the buffer)
    139 		This is the actual packet that gets sent across the serial line.
    140 		.....................................................................*/
    141 		char *SendBuf;
    142 };
    143 
    144 #endif
    145 
    146 /************************** end of nullconn.h ******************************/
    147