1 /*---------------------------------------------------------------------------* 2 Project: Horizon 3 File: uds_NetworkDescription.h 4 5 Copyright (C)2009 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: 30958 $ 14 *---------------------------------------------------------------------------*/ 15 16 /*! @file 17 @brief UDS ネットワーク情報クラスの定義 18 */ 19 20 #ifndef LIBRARIES_UDS_CTR_UDS_NETWORK_DESCRIPTION_H_ 21 #define LIBRARIES_UDS_CTR_UDS_NETWORK_DESCRIPTION_H_ 22 23 #include <nn.h> 24 25 #include <nn/uds/CTR/uds_Type.h> 26 #include <nn/uds/CTR/uds_Result.h> 27 #include <nn/uds/CTR/uds_InfoElement.h> 28 29 namespace nn { 30 namespace uds { 31 namespace CTR { 32 33 /*! 34 :category Scan関数の結果の取り扱い 35 @class nn::uds::CTR::NetworkDescription 36 @brief @ref nn::uds::CTR::NetworkDescriptionReader から取得出来る、ネットワーク情報を示すクラスです。 37 */ 38 class NetworkDescription 39 { 40 41 public: 42 43 /*! 44 :private 45 @brief NetworkDescription の初期化を行います。 46 通常、アプリは @ref nn::uds::CTR::NetworkDescriptionReader から NetworkDescription を取得するので 47 Initialize() をする必要はありません。 48 49 @param[in] localId ローカル通信 ID です。 50 @param[in] subId アプリが自由に設定可能な通信モード識別用 ID です。 51 @param[in] maxEntry ネットワークに接続可能なノードの最大数です。 52 @param[in] channel ネットワークが存在するチャンネルです。 53 @return 54 */ 55 void Initialize( u32 localId, u8 subId, u8 maxEntry, u8 channel ); 56 57 /*! 58 :private 59 @brief NetworkDescription の初期化を行います。 60 通常、アプリは @ref nn::uds::CTR::NetworkDescriptionReader から NetworkDescription を取得するので 61 Initialize() をする必要はありません。 62 63 @param[in] element ビーコン内に含まれる NetworkDescription IE のペイロードです。 64 @param[in] channel ネットワークが存在するチャンネルです。 65 @param[in] bssid ネットワークの BSSID (Master の MAC アドレス) です。 66 @return 67 */ 68 void Initialize( const detail::NetworkDescriptionElement* element, u8 channel, const bit8 bssid[MAC_ADDRESS_SIZE]); 69 70 /*! 71 :private 72 @brief NetworkDescription の終了処理を行います。 73 不正なビーコンを検知した際に実行されます。 74 @return 75 */ Finalize()76 void Finalize() { m_IsInitialized = false; std::memset(m_Bssid, 0x00, MAC_ADDRESS_SIZE); } 77 GetBssid()78 const bit8* GetBssid() const{ return m_Bssid; } //!< BSSID (Master の MAC アドレス)を取得します。 GetGameId()79 u32 GetGameId() const {return this->GetLocalCommunicationId(); } //!< ローカル通信 ID を取得します。本関数は @ref GetLocalCommunicationId 関数と同一で互換性維持のために残されている API です。 GetLocalCommunicationId()80 u32 GetLocalCommunicationId() const {return m_IsInitialized? detail::UDS_BE2LE32(m_Element.gameId):0; } //!< ローカル通信 ID を取得します。 @ref Scan で指定した値と同一になります。 GetSubId()81 u8 GetSubId() const {return m_IsInitialized? m_Element.subId:0; } //!< SubId を取得します。 GetTemporaryId()82 u32 GetTemporaryId() const {return m_IsInitialized? detail::UDS_BE2LE32(m_Element.temporaryId):0; } //!< TemporaryId を取得します。ネットワークの識別に利用できますが、BSSID もしくは Master の NodeInformation の使用を推奨します。 GetChannel()83 u16 GetChannel() const { return m_IsInitialized? m_Channel:0; } //!< 通信に使用しているチャンネルを取得します。通常参照する必要はありません。 GetNowEntry()84 u8 GetNowEntry() const { return m_IsInitialized? m_Element.nowEntry:0 ; } //!< 現在の接続台数を取得します。 GetMaxEntry()85 u8 GetMaxEntry() const { return m_IsInitialized? m_Element.maxEntry:0 ; } //!< 最大接続台数を取得します。 86 size_t GetApplicationData(bit8* buffer, const size_t bufferSize) const; //!< SetApplicationDataToBeacon() でセットしたデータを取得します。 CanConnectAsSpectator()87 bool CanConnectAsSpectator() const { return ( m_IsInitialized && !(detail::UDS_BE2LE16(m_Element.attribute) & detail::EJECT_SPECTAOTR_FLAG)); } //!<Spectator としての接続が許可されているかをチェックします。 88 89 /*! 90 @brief NetworkDescriptionクラスのオブジェクトを比較し、同値であればtrueを返します。 91 同じネットワークでも接続台数やSetApplicationDataによりデータがセットされるとfalseになります。 92 @param[in] networkDescription 比較するNetworkDescriptionクラスのオブジェクト 93 */ 94 bool operator==(NetworkDescription networkDescription); 95 /*! 96 @brief NetworkDescriptionクラスのオブジェクトを比較し、同値でなければtrueを返します。 97 同じネットワークでも接続台数やSetApplicationDataによりデータがセットされるとtrueになります。 98 @param[in] networkDescription 比較するNetworkDescriptionクラスのオブジェクト 99 */ 100 bool operator!=(NetworkDescription networkDescription); 101 102 private: 103 bit8 m_Bssid[MAC_ADDRESS_SIZE]; //!< BSSID 104 u16 m_Channel; //!< チャンネル (0:Auto) 105 bool m_IsInitialized; 106 NN_PADDING3; 107 detail::NetworkDescriptionElement m_Element; //!< システムの都合上ネットワークバイトオーダーとなっていることに注意 108 109 }; 110 111 } // end of namespace CTR 112 } // end of namespace uds 113 } // end of namespace nn 114 115 #endif /* LIBRARIES_UDS_CTR_UDS_NETWORK_DESCRIPTION_H_ */ 116