1 /*-------------------------------------------------------------------------- 2 Project: HorizonSDK 3 File: rdt_Header.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-04-30#$ 14 $Rev: 15289 $ 15 $Author: hiratsu_daisuke $ 16 *-------------------------------------------------------------------------*/ 17 18 #include "stdafx.h" 19 20 #ifndef NN_RDT_HEADER_H_ 21 #define NN_RDT_HEADER_H_ 22 23 24 namespace nn { namespace rdt { namespace CTR { 25 26 /*! 27 @brief これはRDTのセグメントヘッダを表現する構造体です。 28 */ 29 struct Header{ 30 public: 31 static const u32 MAGIC_NUMBER = 'N' << 24 | 'N' << 16 | 'R' << 8 | 'P' << 0; 32 33 // コントロールビット群。 34 static const u16 BIT_ACK = 0x0001; 35 static const u16 BIT_RST = 0x0002; 36 static const u16 BIT_SYN = 0x0008; 37 static const u16 BIT_FIN = 0x0010; 38 static const u16 BIT_SRV = 0x0100; 39 static const u16 BIT_CLI = 0x0200; 40 41 /*! 42 @brief 初期化します。 43 */ 44 Header(void); 45 46 /*! 47 @brief ヘッダの内容をクリアします。 48 ただし、マジックナンバーだけはクリアされません。 49 */ 50 void Clear(void); 51 52 /*! 53 @brief デバッグ用。内容をプリント。 54 */ 55 void PrintDebugInfo(void) const; 56 57 u32 magicNum; // マジックナンバー(構造体の先頭に置くこと!) 58 u32 seqNum; // シーケンス番号 59 u32 ackNum; // ACK番号 60 u8 dataOffset; // データオフセット。データ部分がどこから始まるか。(=ヘッダ長さ) 61 u8 reserved; // 未使用(パディングの役割もあったりして) 62 u16 controlBit; // コントロールビット 63 u32 dataLength; // 実データサイズ。たぶん不要になりそう。 64 u16 windowSize; // ウィンドウサイズ。受信側から送信側に通知するときに使う。 65 u16 checkSum; // チェックサム 66 }; 67 68 }}} // namespace nn::rdt::CTR 69 70 #endif // end of NN_RDT_HEADER_H_ 71