1 /*--------------------------------------------------------------------------
2 Project: HorizonSDK
3 File: rdt_Header.cpp
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 #include "rdt_Header.h"
21
22 #include <string.h>
23
24 #include "rdt_Utility.h"
25
26 namespace
27 {
28
29 } // end of anonymous namespace
30
31 namespace nn { namespace rdt { namespace CTR {
32
33 ///< コンストラクタ
Header(void)34 Header::Header(void)
35 {
36 Clear();
37 }
38
39
Clear(void)40 void Header::Clear(void)
41 {
42 magicNum = MAGIC_NUMBER;
43
44 // マジックナンバーを除き、ゼロクリア。
45 memset(&magicNum + 1, 0, sizeof(Header)-sizeof(magicNum));
46 }
47
48
PrintDebugInfo(void) const49 void Header::PrintDebugInfo(void) const
50 {
51 ASSERTMSG(magicNum==MAGIC_NUMBER, "Wrong magic number.");
52 ASSERTMSG(reserved==0, "Don't use reserved. Keep it as zero.");
53
54 char buf[256] = "";
55 #ifdef _WIN32
56 controlBit & BIT_ACK ? strcat_s(buf, "[ACK]") : strcat_s(buf, "[---]");
57 controlBit & BIT_SYN ? strcat_s(buf, "[SYN]") : strcat_s(buf, "[---]");
58 controlBit & BIT_FIN ? strcat_s(buf, "[FIN]") : strcat_s(buf, "[---]");
59 controlBit & BIT_RST ? strcat_s(buf, "[RST]") : strcat_s(buf, "[---]");
60 #else
61 controlBit & BIT_ACK ? strcat(buf, "[ACK]") : strcat(buf, "[---]");
62 controlBit & BIT_SYN ? strcat(buf, "[SYN]") : strcat(buf, "[---]");
63 controlBit & BIT_FIN ? strcat(buf, "[FIN]") : strcat(buf, "[---]");
64 controlBit & BIT_RST ? strcat(buf, "[RST]") : strcat(buf, "[---]");
65 #endif
66 LOG("Control bit: %s\n", buf);
67 LOG("SEQ: %u, ACK: %u, dataOffset: %u, dataLength: %u\n", seqNum, ackNum, dataOffset, dataLength);
68 LOG("WindowSize: %u, checksum: %u\n", windowSize, checkSum);
69 }
70
71
72 }}} // namespace nn::rdt::CTR
73