CTR Pia  4.11.3
Game Communication Engine
local_UdsNetworkSetting.h
1 /*---------------------------------------------------------------------------*
2  Project: Pia
3  File: local_UdsNetworkSetting.h
4 
5  Copyright 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 
14 
15 #pragma once
16 
17 #include <pia/definitions.h>
18 
19 #include <pia/local/local_LocalNetworkSetting.h>
20 
21 namespace nn
22 {
23 namespace pia
24 {
25 namespace local
26 {
27 
28 static const u32 UDS_RECEIVE_BUFFER_SIZE_MIN = 4 * 4096; //!< Defines the minimum receive buffer size.
29 static const u32 UDS_SCAN_BUFFER_SIZE_MIN = 1 * 1024; //!< Minimum size of the scan buffer.
30 
31 static const size_t UDS_PASSPHRASE_LENGTH_MIN = nn::uds::UDS_PASSPHRASE_LENGTH_MIN; //!< Minimum size of the passphrase for generating the encrypted key used in communication.
32 static const size_t UDS_PASSPHRASE_LENGTH_MAX = nn::uds::UDS_PASSPHRASE_LENGTH_MAX; //!< Maximum size of the passphrase for generating the encryption key used in communication.
33 static const size_t UDS_APPLICATION_DATA_SIZE_MAX = nn::uds::NET_DESC_APPDATA_SIZE_MAX; //!< Maximum size of the application data that can be set for the beacon. The size available for the application to use will be less than this amount because the size includes a region for system use.
34 
35 /*!
36  @brief Class for configuring networks that use the UDS library.
37 
38  @date 2014-03-03 Initial version.
39 */
41 {
42 public:
46  m_pReceiveBuffer(NULL),
48  m_SendOption(nn::uds::NO_WAIT),
49  m_ReceiveOption(nn::uds::NO_WAIT),
50  m_pUserName(NULL)
51  {
52  }
53 
54 /*!
55  @cond PRIVATE
56 */
57  virtual LocalNetworkType GetLocalNetworkType() const
58  {
59  return LOCAL_NETWORK_TYPE_UDS;
60  }
61  //! @endcond
62 
63  size_t m_ReceiveBufferSize; //!< Specifies the receive buffer size. The size must be at least <tt>@ref local::UDS_RECEIVE_BUFFER_SIZE_MIN</tt> and a multiple of 4096.
64  void* m_pReceiveBuffer; //!< Specifies the receive buffer size. This value should be specified if you want to allocate the buffer from within the application. It must be 4096-byte aligned. If left unspecified, a buffer is allocated within the Pia library as usual.
65  size_t m_ScanBufferSize; //!< Specifies the scan buffer size. The size must be at least <tt>@ref local::UDS_SCAN_BUFFER_SIZE_MIN</tt>.
66  u8 m_SendOption; //!< Specifies UDS send options. Available options include <tt>nn::uds::NO_WAIT</tt> and <tt>nn::uds::FORCE_DIRECT_BC</tt>. Use the OR operator to set multiple options.
67  u8 m_ReceiveOption; //!< Specifies UDS receive options. Always set <tt>nn::uds::NO_WAIT</tt> to on. Use the OR operator to set multiple options.
68  nn::cfg::CTR::UserName* m_pUserName; //!< Returns the user name.
69 };
70 
71 /*!
72  @brief Class for configuring the creation of networks that use the UDS library.
73 
74  @date 2014-03-03 Initial version.
75 */
77 {
78 public:
79 /*!
80  @brief The default constructor.
81 */
84  m_SubId(0),
85  m_MaxEntry(0),
86  m_LocalCommunicationId(0),
87  m_PassphraseLength(0),
88  m_Channel(0),
89  m_ApplicationDataSize(0)
90  {
91  memset(m_Passphrase, 0, sizeof(m_Passphrase));
92  memset(m_ApplicationData, 0, sizeof(m_ApplicationData));
93  }
94 
95  u8 m_SubId; //!< Specifies an ID for identifying the communication mode. Set this parameter to a value between <tt>0x00</tt> and <tt>0xFE</tt>.
96  u8 m_MaxEntry; //!< Maximum number of stations that can connect to the network.
97  u32 m_LocalCommunicationId; //!< Specifies the local communication ID. Specify the value generated by <tt>@ref LocalNetwork::CreateLocalCommunicationId</tt>.
98  char m_Passphrase[UDS_PASSPHRASE_LENGTH_MAX]; //!< Specifies the passphrase used to encrypt the wireless layer. The size must be at least <tt>@ref UDS_PASSPHRASE_LENGTH_MIN</tt> but no greater than <tt>@ref UDS_PASSPHRASE_LENGTH_MAX</tt>.
99  size_t m_PassphraseLength; //!< Specifies the size of the passphrase used to encrypt the wireless layer. Must be at least <tt>@ref UDS_PASSPHRASE_LENGTH_MIN</tt> but no greater than <tt>@ref UDS_PASSPHRASE_LENGTH_MAX</tt>.
100  u8 m_Channel; //!< Specifies the channel to use for communication. Specify channel <tt>0</tt> (automatic), <tt>1</tt>, <tt>6</tt>, or <tt>11</tt>. When this function runs on production devices, the channel is always selected automatically.
101  u8 m_ApplicationData[UDS_APPLICATION_DATA_SIZE_MAX]; //!< The optional data to set for the beacon. The size must be no greater than the value that can be obtained with <tt>@ref LocalNetwork::GetBeaconApplicationDataSizeMax</tt>.
102  size_t m_ApplicationDataSize; //!< Size of the optional data to set for the beacon. The size must be no greater than the value that can be obtained using <tt>@ref LocalNetwork::GetBeaconApplicationDataSizeMax</tt>.
103 };
104 
105 /*!
106  @brief Class that holds information about networks that use the UDS library.
107 
108  @date 2014-03-03 Initial version.
109 */
111 {
112 public:
113 /*!
114  @brief The default constructor.
115 */
118  {
119  }
120 
121 /*!
122  @brief Gets the number of stations currently participating in the network.
123 
124  @details The number of stations that can be obtained is the number at the point when the network is scanned.
125 
126  @return Returns the number of stations participating in the network.
127 */
128  virtual u32 GetCurrentParticipants() const
129  {
130  return m_NetworkDescription.GetNowEntry();
131  }
132 
133 /*!
134  @brief Gets the maximum number of stations that can participate in the network.
135 
136  @return Returns the maximum number of stations that can participate in the network.
137 */
138  virtual u32 GetMaxParticipants() const
139  {
140  return m_NetworkDescription.GetMaxEntry();
141  }
142 
143 /*!
144  @brief Gets whether the network allows participation.
145 
146  @details The state that can be obtained is the state at the point when the network is scanned.
147 
148  @return Returns whether the network allows participation.
149 
150  @see LocalNetwork::DisallowParticipating, LocalNetwork::AllowParticipating
151 */
152  virtual bool IsOpened() const
153  {
154  return m_NetworkDescription.CanConnectAsClient();
155  }
156 
157  virtual u32 GetLocalCommunicationId() const
158  {
159  return m_NetworkDescription.GetLocalCommunicationId();
160  }
161 
162 /*!
163  @brief Gets the ID for identifying the communication mode.
164 
165  @return Returns the ID for identifying the communication mode.
166 */
167  virtual u8 GetSubId() const
168  {
169  return m_NetworkDescription.GetSubId();
170  }
171 
172 /*!
173  @brief Gets the channel being used for the communication.
174 
175  @details There is normally no need to reference this.
176 
177  @return Returns the channel being used for communication.
178 */
179  virtual u16 GetChannel() const
180  {
181  return m_NetworkDescription.GetChannel();
182  }
183 
184 /*!
185  @brief Gets the BSSID (the host's MAC address).
186 
187  @details The size of the BSSID is <tt>nn::uds::MAC_ADDRESS_SIZE</tt> bytes. Set a buffer of this size in the parameter.
188 
189  @param[out] pBssidBuffer Buffer that stores the BSSID. The size must be <tt>nn::uds::MAC_ADDRESS_SIZE</tt> bytes.
190 */
191  virtual void GetBssid(bit8* pBssidBuffer) const
192  {
193  if (!PIA_IS_VALID_POINTER(pBssidBuffer))
194  {
195  return;
196  }
197  memcpy(pBssidBuffer, m_NetworkDescription.GetBssid(), nn::uds::MAC_ADDRESS_SIZE);
198  }
199 
200 /*!
201  @cond PRIVATE
202 */
203  const nn::uds::NetworkDescription& GetNetworkDescription() const
204  {
205  return m_NetworkDescription;
206  }
207  //! @endcond
208 
209 /*!
210  @cond PRIVATE
211 */
212  nn::uds::NetworkDescription& GetNetworkDescription()
213  {
214  return m_NetworkDescription;
215  }
216  //! @endcond
217 
218 /*!
219  @cond PRIVATE
220 */
221  void SetNetworkDescription(const nn::uds::NetworkDescription& networkDescription)
222  {
223  m_NetworkDescription = networkDescription;
224  }
225  //! @endcond
226 
227  // n2908: Copy <tt>NetworkDescription</tt>.
228  virtual void Copy(const LocalNetworkDescription* description)
229  {
230  const UdsNetworkDescription* pUdsDesc = static_cast<const UdsNetworkDescription*>(description);
231  m_NetworkDescription = pUdsDesc->m_NetworkDescription;
232  }
233 
234 private:
235  nn::uds::NetworkDescription m_NetworkDescription; //!< Network information.
236 };
237 
238 /*!
239  @brief Class for configuring connections to networks that use the UDS library.
240 
241  @date 2014-03-03 Initial version.
242 */
244 {
245 public:
248  m_PassphraseLength(0)
249  {
250  memset(m_Passphrase, 0, sizeof(m_Passphrase));
251  }
252 
253  char m_Passphrase[UDS_PASSPHRASE_LENGTH_MAX]; //!< Specifies the passphrase used to encrypt the wireless layer. The size must be at least <tt>@ref UDS_PASSPHRASE_LENGTH_MIN</tt> but no greater than <tt>@ref UDS_PASSPHRASE_LENGTH_MAX</tt>.
254  u8 m_PassphraseLength; //!< Specifies the size of the passphrase used to encrypt the wireless layer. Must be at least <tt>@ref UDS_PASSPHRASE_LENGTH_MIN</tt> but no greater than <tt>@ref UDS_PASSPHRASE_LENGTH_MAX</tt>.
255 };
256 
257 
258 /*!
259 @cond PRIVATE
260 The following declarations are for internal use by the library.
261 */
262 class UdsScanNetworkSetting : public LocalScanNetworkSetting
263 {
264 public:
265  UdsScanNetworkSetting()
266  : LocalScanNetworkSetting(),
267  m_SubId(0),
268  m_LocalCommunicationId(0),
269  m_pScanBuffer(NULL),
271  {
272  }
273 
274  u8 m_SubId;
275  u32 m_LocalCommunicationId;
276 
277  void* m_pScanBuffer; // Same as for <tt>UdsNetworkSetting</tt>.
278  u32 m_ScanBufferSize; // Same as for <tt>UdsNetworkSetting</tt>.
279 };
280 
281 class UdsNetworkConnectionStatus : public LocalConnectionStatus
282 {
283 public:
284  UdsNetworkConnectionStatus()
285  : LocalConnectionStatus()
286  {
287  }
288 
289  virtual u8 GetParticipantNum() const
290  {
291  return m_ConnectionStatus.nowEntry;
292  }
293 
294  nn::uds::ConnectionStatus m_ConnectionStatus;
295 };
296 
297 class UdsBeaconSystemData : public LocalBeaconSystemData
298 {
299 public:
300  UdsBeaconSystemData()
301  : LocalBeaconSystemData()
302  {
303  }
304 };
305 
306 class UdsBeaconSystemDataHostMigration : public LocalBeaconSystemData
307 {
308 public:
309  UdsBeaconSystemDataHostMigration()
310  {
311  memset(m_MacAddress, 0, sizeof(m_MacAddress));
312  memset(m_ReservedUdsHostMigration, 0, sizeof(m_ReservedUdsHostMigration));
313  }
314 
315  bit8 m_MacAddress[nn::uds::MAC_ADDRESS_SIZE]; //!< For determining the network to connect to after host migration.
316  u8 m_ReservedUdsHostMigration[6];
317 };
318 
319 /*!
320 Internal library declarations end here.
321 @endcond
322 */
323 
324 
325 /*!
326  @brief Class that holds information about stations that are connected to a network that uses the UDS library.
327 
328  @date 2014-03-03 Initial version.
329 */
331 {
332 public:
334  {
335  }
336 
337  nn::uds::ScrambledLocalFriendCode m_ScrambledLocalFriendCode; //!< Information that can be converted into a local friend code.
338  nn::cfg::UserName m_UserName; //!< The user name.
339 };
340 
341 
342 /*!
343  @brief Class that holds information about a network discovered via the nearby network search feature, using the UDS library.
344 
345  @date 2015-02-10 Initial version.
346 */
348 {
349 public:
352  {
353  }
354 
355  UdsNetworkDescription m_NetworkDescription; //!< Information about the network.
356  UdsStationInfo m_NodeInformation[STATION_MAX_ENTRY]; //!< Information about the stations connected to the network.
357 };
358 
359 }
360 }
361 } // End of namespace nn::pia::local.
Class that holds information about a network discovered via the nearby network search feature...
Definition: local_UdsNetworkSetting.h:347
u32 m_LocalCommunicationId
Specifies the local communication ID. Specify the value generated by LocalNetwork::CreateLocalCommuni...
Definition: local_UdsNetworkSetting.h:97
UdsCreateNetworkSetting()
The default constructor.
Definition: local_UdsNetworkSetting.h:82
Class for configuring the creation of networks that use the UDS library.
Definition: local_UdsNetworkSetting.h:76
static const size_t UDS_PASSPHRASE_LENGTH_MAX
Maximum size of the passphrase for generating the encryption key used in communication.
Definition: local_UdsNetworkSetting.h:32
Class for configuring connections to networks that use the UDS library.
Definition: local_UdsNetworkSetting.h:243
size_t m_ApplicationDataSize
Size of the optional data to set for the beacon. The size must be no greater than the value that can ...
Definition: local_UdsNetworkSetting.h:102
static const u8 STATION_MAX_ENTRY
The maximum number of nodes that can connect. The local network host is included in the number of con...
Definition: local_LocalNetworkSetting.h:33
u8 m_SubId
Specifies an ID for identifying the communication mode. Set this parameter to a value between 0x00 an...
Definition: local_UdsNetworkSetting.h:95
Definition: assert.h:115
u8 m_MaxEntry
Maximum number of stations that can connect to the network.
Definition: local_UdsNetworkSetting.h:96
virtual bool IsOpened() const
Gets whether the network allows participation.
Definition: local_UdsNetworkSetting.h:152
Class for configuring a local network.
Definition: local_LocalNetworkSetting.h:73
Class that holds information about the network discovered using nearby network search.
Definition: local_LocalNetworkSetting.h:262
static const u32 UDS_RECEIVE_BUFFER_SIZE_MIN
Defines the minimum receive buffer size.
Definition: local_UdsNetworkSetting.h:28
nn::uds::ScrambledLocalFriendCode m_ScrambledLocalFriendCode
Information that can be converted into a local friend code.
Definition: local_UdsNetworkSetting.h:337
static const u32 UDS_SCAN_BUFFER_SIZE_MIN
Minimum size of the scan buffer.
Definition: local_UdsNetworkSetting.h:29
size_t m_PassphraseLength
Specifies the size of the passphrase used to encrypt the wireless layer. Must be at least UDS_PASSPHR...
Definition: local_UdsNetworkSetting.h:99
u8 m_ReceiveOption
Specifies UDS receive options. Always set nn::uds::NO_WAIT to on. Use the OR operator to set multiple...
Definition: local_UdsNetworkSetting.h:67
UdsNetworkDescription()
The default constructor.
Definition: local_UdsNetworkSetting.h:116
Class that holds information about stations that are connected to a network that uses the UDS library...
Definition: local_UdsNetworkSetting.h:330
size_t m_ReceiveBufferSize
Specifies the receive buffer size. The size must be at least local::UDS_RECEIVE_BUFFER_SIZE_MIN and a...
Definition: local_UdsNetworkSetting.h:63
void * m_pReceiveBuffer
Specifies the receive buffer size. This value should be specified if you want to allocate the buffer ...
Definition: local_UdsNetworkSetting.h:64
u8 m_PassphraseLength
Specifies the size of the passphrase used to encrypt the wireless layer. Must be at least UDS_PASSPHR...
Definition: local_UdsNetworkSetting.h:254
nn::cfg::CTR::UserName * m_pUserName
Returns the user name.
Definition: local_UdsNetworkSetting.h:68
Class for configuring the creation of a local network.
Definition: local_LocalNetworkSetting.h:102
virtual u16 GetChannel() const
Gets the channel being used for the communication.
Definition: local_UdsNetworkSetting.h:179
u8 m_SendOption
Specifies UDS send options. Available options include nn::uds::NO_WAIT and nn::uds::FORCE_DIRECT_BC. Use the OR operator to set multiple options.
Definition: local_UdsNetworkSetting.h:66
Class that holds information about networks that use the UDS library.
Definition: local_UdsNetworkSetting.h:110
Class that holds information about a local network.
Definition: local_LocalNetworkSetting.h:121
virtual u8 GetSubId() const
Gets the ID for identifying the communication mode.
Definition: local_UdsNetworkSetting.h:167
virtual void GetBssid(bit8 *pBssidBuffer) const
Gets the BSSID (the host&#39;s MAC address).
Definition: local_UdsNetworkSetting.h:191
static const size_t UDS_PASSPHRASE_LENGTH_MIN
Minimum size of the passphrase for generating the encrypted key used in communication.
Definition: local_UdsNetworkSetting.h:31
UdsNetworkDescription m_NetworkDescription
Information about the network.
Definition: local_UdsNetworkSetting.h:355
size_t m_ScanBufferSize
Specifies the scan buffer size. The size must be at least local::UDS_SCAN_BUFFER_SIZE_MIN.
Definition: local_UdsNetworkSetting.h:65
virtual u32 GetCurrentParticipants() const
Gets the number of stations currently participating in the network.
Definition: local_UdsNetworkSetting.h:128
nn::cfg::UserName m_UserName
The user name.
Definition: local_UdsNetworkSetting.h:338
u8 m_Channel
Specifies the channel to use for communication. Specify channel 0 (automatic), 1, 6...
Definition: local_UdsNetworkSetting.h:100
virtual u32 GetMaxParticipants() const
Gets the maximum number of stations that can participate in the network.
Definition: local_UdsNetworkSetting.h:138
static const size_t UDS_APPLICATION_DATA_SIZE_MAX
Maximum size of the application data that can be set for the beacon. The size available for the appli...
Definition: local_UdsNetworkSetting.h:33
Class for configuring networks that use the UDS library.
Definition: local_UdsNetworkSetting.h:40
Class for configuring a connection to a local network.
Definition: local_LocalNetworkSetting.h:152
Class that holds information about stations connected to a local network.
Definition: local_LocalNetworkSetting.h:230