NOSEQCON.H 5.8 KB

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