NOSEQCON.H 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. /*
  2. ** Command & Conquer Red Alert(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\noseqcon.h_v 1.13 01 Mar 1996 17:32:42 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 : NOSEQCON.H *
  26. * *
  27. * Programmer : Bill Randolph *
  28. * *
  29. * Start Date : December 19, 1994 *
  30. * *
  31. * Last Update : April 9, 1995 [BR] *
  32. * *
  33. *-------------------------------------------------------------------------*
  34. * *
  35. * This class provides a "Non-Sequenced" ACK/Retry approach to packet *
  36. * transmission. It sends out as many packets as are in the queue, whose *
  37. * resend delta times have expired; and it ACK's any packets its received *
  38. * who haven't been ACK'd yet. Thus, order of delivery is NOT guaranteed; *
  39. * however, the performance is better than the Sequenced approach. *
  40. * *
  41. * A derived class must provide: *
  42. * - Init: Initialization of any hardware-specific values. *
  43. * - Send: a hardware-dependent send routine. *
  44. * *
  45. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  46. #ifndef NONSEQCONN_H
  47. #define NONSEQCONN_H
  48. /*
  49. ********************************* Includes **********************************
  50. */
  51. #include "connect.h"
  52. #include "combuf.h"
  53. /*
  54. ***************************** Class Declaration *****************************
  55. */
  56. class NonSequencedConnClass : public ConnectionClass
  57. {
  58. /*
  59. ---------------------------- Public Interface ----------------------------
  60. */
  61. public:
  62. /*.....................................................................
  63. Constructor/destructor.
  64. .....................................................................*/
  65. NonSequencedConnClass (int numsend, int numrecieve, int maxlen,
  66. unsigned short magicnum, unsigned long retry_delta,
  67. unsigned long max_retries, unsigned long timeout);
  68. virtual ~NonSequencedConnClass ();
  69. /*.....................................................................
  70. Initialization.
  71. .....................................................................*/
  72. virtual void Init (void);
  73. /*.....................................................................
  74. Send/Receive routines.
  75. .....................................................................*/
  76. virtual int Send_Packet (void * buf, int buflen, int ack_req);
  77. virtual int Receive_Packet (void * buf, int buflen);
  78. virtual int Get_Packet (void * buf, int *buflen);
  79. /*.....................................................................
  80. The packet "queue"; this non-sequenced version isn't really much of
  81. a queue, but more of a repository.
  82. .....................................................................*/
  83. CommBufferClass *Queue;
  84. /*
  85. -------------------------- Protected Interface ---------------------------
  86. */
  87. protected:
  88. /*.....................................................................
  89. Routines to service the Send & Receive queues.
  90. .....................................................................*/
  91. virtual int Service_Send_Queue (void);
  92. virtual int Service_Receive_Queue (void);
  93. /*.....................................................................
  94. Running totals of # of packets we send & receive which require an ACK,
  95. and those that don't.
  96. .....................................................................*/
  97. unsigned long NumRecNoAck;
  98. unsigned long NumRecAck;
  99. unsigned long NumSendNoAck;
  100. unsigned long NumSendAck;
  101. /*.....................................................................
  102. This is the ID of the last consecutively-received packet; anything older
  103. than this, we know is a resend. Anything newer than this MUST be lying
  104. around in the Queue for us to detect it as a resend.
  105. .....................................................................*/
  106. unsigned long LastSeqID;
  107. /*.....................................................................
  108. This is the ID of the PACKET_DATA_ACK packet we read last; it ensures
  109. that the application reads that type of packet in order.
  110. .....................................................................*/
  111. unsigned long LastReadID;
  112. };
  113. #endif