1 /*---------------------------------------------------------------------------* 2 Project: Horizon 3 File: rdt_HostBase.h 4 5 Copyright (C)2009-2012 Nintendo Co., Ltd. All rights reserved. 6 7 These coded instructions, statements, and computer programs contain 8 proprietary information of Nintendo of America Inc. and/or Nintendo 9 Company Ltd., and are protected by Federal copyright law. They may 10 not be disclosed to third parties or copied or duplicated in any form, 11 in whole or in part, without the prior written consent of Nintendo. 12 13 $Rev: 46347 $ 14 *---------------------------------------------------------------------------*/ 15 16 #include "stdafx.h" 17 18 #ifndef NN_RDT_HOSTBASE_H_ 19 #define NN_RDT_HOSTBASE_H_ 20 21 22 #include "rdt_Transceiver.h" 23 24 namespace nn { namespace rdt { namespace CTR { 25 26 /* Please see man pages for details 27 28 29 */ 30 class HostBase{ 31 public: 32 33 /* Please see man pages for details 34 35 */ 36 HostBase(void); 37 38 /* Please see man pages for details 39 40 */ 41 virtual ~HostBase(void); 42 43 /* Please see man pages for details 44 45 */ 46 #ifdef _WIN32 47 nn::Result Initialize(SOCKET &sock); 48 #elif defined(NN_PLATFORM_CTR) 49 nn::Result Initialize(u16 nodeId, u8 port); // Sender node ID and port number 50 #else 51 #error no platform selected 52 #endif 53 54 /* Please see man pages for details 55 56 */ 57 void Finalize(void); 58 59 /* Please see man pages for details 60 61 62 */ 63 void SetPacketLossRatio(int per); 64 65 /* Please see man pages for details 66 67 */ GetErrorCode(void)68 nn::Result GetErrorCode(void) const { return m_resultCode; } 69 70 /* Please see man pages for details 71 72 */ 73 static void PrintProperty(void); 74 75 76 protected: 77 // Sends segment. To perform resend process, do so outside of this function. 78 // Depending on the packet loss rate, the send fails (no send is performed) 79 void putSegment(const Segment &seg); 80 81 // Receive segment. 82 nn::Result pullSegment(Segment *pSeg); 83 84 // Sends segment that includes the RST control bit. 85 // This segment is not a target for resending. 86 void sendRstSegment(u32 seq); 87 88 // Sends segment that includes the RST and ACK control bit. 89 // This segment is not a target for resending. 90 void sendRstAckSegment(u32 seq, u32 ack); 91 92 // Records error information. Call this function if a state where an error occurs happens. 93 void errorHandling(Result resultCode); 94 95 96 private: 97 /* Please see man pages for details 98 99 */ 100 HostBase (const HostBase&); 101 102 /* Please see man pages for details 103 104 */ 105 HostBase& operator=(const HostBase&); 106 107 Transceiver m_transceiver; // Send/receive object 108 109 int m_packetLossRatio; // Packet loss rate. Zero or higher, 100 or lower. 110 111 Result m_resultCode; // Record most recent result code here 112 113 bool m_initialized; 114 u8 m_padding[3]; 115 }; 116 117 118 }}} // namespace nn::rdt::CTR 119 120 #endif // end of NN_RDT_HOSTBASE_H_ 121