1 /*---------------------------------------------------------------------------*
2 Project: Horizon
3 File: rdt_Header.cpp
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 #include "rdt_Header.h"
19
20 #include <string.h>
21
22 #include "rdt_Utility.h"
23
24 namespace
25 {
26
27 } // End of anonymous namespace
28
29 namespace nn { namespace rdt { namespace CTR {
30
31 //
Header(void)32 Header::Header(void)
33 {
34 Clear();
35 }
36
37
Clear(void)38 void Header::Clear(void)
39 {
40 magicNum = MAGIC_NUMBER;
41
42 // Clear to zero except for the magic number.
43 memset(&magicNum + 1, 0, sizeof(Header)-sizeof(magicNum));
44 }
45
46
PrintDebugInfo(void) const47 void Header::PrintDebugInfo(void) const
48 {
49 ASSERTMSG(magicNum==MAGIC_NUMBER, "Wrong magic number.");
50 ASSERTMSG(reserved==0, "Don't use reserved. Keep it as zero.");
51
52 char buf[256] = "";
53 #ifdef _WIN32
54 controlBit & BIT_ACK ? strcat_s(buf, "[ACK]") : strcat_s(buf, "[---]");
55 controlBit & BIT_SYN ? strcat_s(buf, "[SYN]") : strcat_s(buf, "[---]");
56 controlBit & BIT_FIN ? strcat_s(buf, "[FIN]") : strcat_s(buf, "[---]");
57 controlBit & BIT_RST ? strcat_s(buf, "[RST]") : strcat_s(buf, "[---]");
58 #else
59 controlBit & BIT_ACK ? strcat(buf, "[ACK]") : strcat(buf, "[---]");
60 controlBit & BIT_SYN ? strcat(buf, "[SYN]") : strcat(buf, "[---]");
61 controlBit & BIT_FIN ? strcat(buf, "[FIN]") : strcat(buf, "[---]");
62 controlBit & BIT_RST ? strcat(buf, "[RST]") : strcat(buf, "[---]");
63 #endif
64 LOG("Control bit: %s\n", buf);
65 LOG("SEQ: %u, ACK: %u, dataOffset: %u, dataLength: %u\n", seqNum, ackNum, dataOffset, dataLength);
66 LOG("WindowSize: %u, checksum: %u\n", windowSize, checkSum);
67 }
68
69
70 }}} // namespace nn::rdt::CTR
71