1 /*---------------------------------------------------------------------------* 2 Project: Horizon 3 File: uds_NetworkDescription.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: 46929 $ 14 *---------------------------------------------------------------------------*/ 15 16 /* Please see man pages for details 17 18 */ 19 20 #ifndef NN_UDS_CTR_UDS_NETWORK_DESCRIPTION_H_ 21 #define NN_UDS_CTR_UDS_NETWORK_DESCRIPTION_H_ 22 23 #include <cstring> 24 #include <nn/uds/CTR/uds_Type.h> 25 #include <nn/uds/CTR/uds_Result.h> 26 #include <nn/uds/CTR/uds_InfoElement.h> 27 28 namespace nn { 29 namespace uds { 30 namespace CTR { 31 32 /* Please see man pages for details 33 34 35 36 */ 37 class NetworkDescription 38 { 39 40 public: 41 /* Please see man pages for details 42 43 */ 44 enum CompareResult 45 { 46 SAME_NETWORK_SAME_DATA, // 47 SAME_NETWORK_DIFFERENT_DATA, // 48 DIFFERENT_NETWORK // 49 }; 50 51 /* Please see man pages for details 52 53 54 55 56 57 58 59 60 61 62 63 64 */ 65 nn::Result Initialize( u32 localId, u8 subId, u8 maxEntry, u8 channel, const void* pData, size_t dataSize ); 66 /* Please see man pages for details 67 68 69 70 71 72 73 74 75 76 77 */ 78 void Initialize( u32 localId, u8 subId, u8 maxEntry, u8 channel ); 79 /* Please see man pages for details 80 81 82 83 84 85 86 87 88 89 */ 90 void Initialize( const detail::NetworkDescriptionElement* element, u8 channel, const bit8 bssid[MAC_ADDRESS_SIZE]); 91 92 /* Please see man pages for details 93 94 95 96 97 */ Finalize()98 void Finalize() { m_IsInitialized = false; std::memset(m_Bssid, 0x00, MAC_ADDRESS_SIZE); } 99 /* Please see man pages for details 100 101 102 */ GetBssid()103 const bit8* GetBssid() const{ return m_Bssid; } 104 /* Please see man pages for details 105 106 107 */ GetGameId()108 u32 GetGameId() const {return this->GetLocalCommunicationId(); } 109 /* Please see man pages for details 110 111 112 */ GetLocalCommunicationId()113 u32 GetLocalCommunicationId() const {return m_IsInitialized? detail::UDS_BE2LE32(m_Element.gameId):0; } 114 /* Please see man pages for details 115 116 117 */ GetSubId()118 u8 GetSubId() const {return m_IsInitialized? m_Element.subId:0; } 119 /* Please see man pages for details 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 */ GetTemporaryId()149 u32 GetTemporaryId() const {return m_IsInitialized? detail::UDS_BE2LE32(m_Element.temporaryId):0; } 150 /* Please see man pages for details 151 152 153 */ GetChannel()154 u16 GetChannel() const { return m_IsInitialized? m_Channel:0; } 155 /* Please see man pages for details 156 157 158 */ GetNowEntry()159 u8 GetNowEntry() const { return m_IsInitialized? m_Element.nowEntry:0 ; } 160 /* Please see man pages for details 161 162 163 */ GetMaxEntry()164 u8 GetMaxEntry() const { return m_IsInitialized? m_Element.maxEntry:0 ; } 165 /* Please see man pages for details 166 167 168 169 170 171 */ 172 size_t GetApplicationData(bit8* buffer, const size_t bufferSize) const; 173 /* Please see man pages for details 174 175 176 177 178 */ CanConnectAsSpectator()179 bool CanConnectAsSpectator() const { return ( m_IsInitialized && !(detail::UDS_BE2LE16(m_Element.attribute) & detail::EJECT_SPECTAOTR_FLAG)); } 180 /* Please see man pages for details 181 182 183 184 185 */ CanConnectAsClient()186 bool CanConnectAsClient() const { return ( m_IsInitialized && !(detail::UDS_BE2LE16(m_Element.attribute) & detail::DISALLOW_CONNECT_FLAG)); } 187 /* Please see man pages for details 188 189 190 191 192 */ CanReconnectAsClient()193 bool CanReconnectAsClient() const { return ( m_IsInitialized && !this->CanConnectAsClient() && !(detail::UDS_BE2LE16(m_Element.attribute) & detail::DISALLOW_RECONNECT_FLAG)); }//!<Checks if reconnection is permitted for Clients. The determination of whether it is a reconnection is made when the Master actually connects, so there is no guarantee that reconnection is possible even if this value is true. 194 195 /* Please see man pages for details 196 197 198 199 200 */ 201 CompareResult CompareWith(const NetworkDescription& otherOne) const; 202 203 /* Please see man pages for details 204 205 206 207 208 209 210 */ 211 CompareResult CompareWith(bit8 bssid[MAC_ADDRESS_SIZE], detail::NetworkDescriptionElement* element) const; 212 213 /* Please see man pages for details 214 215 216 217 218 219 220 221 222 223 */ 224 nn::Result Decompose(detail::NetworkDescriptionElement* element, u8* channel, bit8 bssid[MAC_ADDRESS_SIZE]); 225 226 /* Please see man pages for details 227 228 229 230 231 232 233 */ 234 bool operator==(NetworkDescription &networkDescription); 235 /* Please see man pages for details 236 237 238 239 240 241 242 */ 243 bool operator!=(NetworkDescription &networkDescription); 244 245 private: 246 bit8 m_Bssid[MAC_ADDRESS_SIZE]; // 247 u16 m_Channel; // 248 bool m_IsInitialized; 249 NN_PADDING3; 250 detail::NetworkDescriptionElement m_Element; // 251 252 }; 253 254 typedef NetworkDescription NetworkDescription2; // Type in order to call NetworkDescription that was revised with .hid 255 256 } // end of namespace CTR 257 } // end of namespace uds 258 } // end of namespace nn 259 260 #endif /* NN_UDS_CTR_UDS_NETWORK_DESCRIPTION_H_ */ 261