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