libnx v4.10.0
Loading...
Searching...
No Matches
ldn.h
Go to the documentation of this file.
1/**
2 * @file ldn.h
3 * @brief LDN (local network communications) IPC wrapper. See also: https://switchbrew.org/wiki/LDN_services
4 * @author yellows8
5 * @copyright libnx Authors
6 */
7
8#pragma once
9#include "../types.h"
10#include "../sf/service.h"
11#include "../kernel/event.h"
12
13#define LDN_PRIORITY_SYSTEM 0x38 ///< System priority for __nx_ldn_priority.
14#define LDN_PRIORITY_USER 0x5A ///< User priority for __nx_ldn_priority.
15
16typedef enum {
17 LdnServiceType_User = 0, ///< Initializes ldn:u.
18 LdnServiceType_System = 1, ///< Initializes ldn:s.
20
21/// State loaded by \ref ldnmGetStateForMonitor / \ref ldnGetState.
22typedef enum {
23 LdnState_None = 0, ///< None
24 LdnState_Initialized = 1, ///< Initialized
25 LdnState_AccessPoint = 2, ///< AccessPoint (\ref ldnOpenAccessPoint)
26 LdnState_AccessPointCreated = 3, ///< AccessPointCreated (\ref ldnCreateNetwork / \ref ldnCreateNetworkPrivate)
27 LdnState_Station = 4, ///< Station (\ref ldnOpenStation)
28 LdnState_StationConnected = 5, ///< StationConnected (\ref ldnConnect / \ref ldnConnectPrivate)
29 LdnState_Error = 6, ///< Error
30} LdnState;
31
32/// DisconnectReason loaded by \ref ldnGetDisconnectReason.
33typedef enum {
35 LdnDisconnectReason_DisconnectedByUser = 1, ///< DisconnectedByUser
36 LdnDisconnectReason_DisconnectedBySystem = 2, ///< DisconnectedBySystem
37 LdnDisconnectReason_DestroyedByUser = 3, ///< DestroyedByUser
38 LdnDisconnectReason_DestroyedBySystem = 4, ///< DestroyedBySystem
40 LdnDisconnectReason_SignalLost = 6, ///< SignalLost
42
43/// ScanFilterFlag
44typedef enum {
45 LdnScanFilterFlag_LocalCommunicationId = BIT(0), ///< Enables using LdnScanFilter::network_id LdnIntentId::local_communication_id.
46 LdnScanFilterFlag_SessionId = BIT(1), ///< Enables using LdnScanFilter::network_id session_id.
47 LdnScanFilterFlag_NetworkType = BIT(2), ///< Enables using LdnScanFilter::network_type.
48 LdnScanFilterFlag_Bssid = BIT(3), ///< Enables using LdnScanFilter::bssid. Only available with \ref ldnScanPrivate.
49 LdnScanFilterFlag_Ssid = BIT(4), ///< Enables using LdnScanFilter::ssid.
50 LdnScanFilterFlag_SceneId = BIT(5), ///< Enables using LdnScanFilter::network_id LdnIntentId::scene_id.
51 LdnScanFilterFlag_IntentId = LdnScanFilterFlag_LocalCommunicationId | LdnScanFilterFlag_SceneId, ///< Enables using LdnScanFilter::network_id intent_id.
54
55/// AcceptPolicy
56typedef enum {
57 LdnAcceptPolicy_AlwaysAccept = 0, ///< AlwaysAccept
58 LdnAcceptPolicy_AlwaysReject = 1, ///< AlwaysReject
59 LdnAcceptPolicy_BlackList = 2, ///< BlackList, addresses in the list (\ref ldnAddAcceptFilterEntry) are not allowed.
60 LdnAcceptPolicy_WhiteList = 3, ///< WhiteList, only addresses in the list (\ref ldnAddAcceptFilterEntry) are allowed.
62
63/// SecurityMode. LdnSecurityMode_Product can be used as the default value. The ldn cmds which use an input SecurityMode normally overwrite the SecurityMode.
64typedef enum {
65 LdnSecurityMode_Any = 0, ///< Any
66 LdnSecurityMode_Product = 1, ///< Product
67 LdnSecurityMode_Debug = 2, ///< Debug
68 LdnSecurityMode_SystemDebug = 3, ///< SystemDebug
70
71/// OperationMode
72typedef enum {
73 LdnOperationMode_Stable = 0, ///< Stable
74 LdnOperationMode_HighSpeed = 1, ///< HighSpeed
76
77/// WirelessControllerRestriction
82
83/// Protocol
84typedef enum {
85 LdnProtocol_NX = 1, ///< NX (default)
86 LdnProtocol_Unknown3 = 3, ///< (NXAndOunce?)
88
89/// Ipv4Address. This is essentially the same as struct in_addr - hence this can be used with standard sockets (byteswap required).
90typedef struct {
91 u32 addr; ///< Address
93
94/// SubnetMask. This is essentially the same as struct in_addr - hence this can be used with standard sockets (byteswap required).
95typedef struct {
96 u32 mask; ///< Mask
98
99/// MacAddress
100typedef struct {
101 u8 addr[6]; ///< Address
103
104/// Ssid
105typedef struct {
106 u8 len; ///< Length excluding NUL-terminator, must be 0x1-0x20.
107 char str[0x21]; ///< SSID string including NUL-terminator, str[len_field] must be 0. The chars in this string must be be in the range of 0x20-0x7F, for when the Ssid is converted to a string (otherwise the byte written to the string will be 0).
108} LdnSsid;
109
110/// NodeLatestUpdate
111typedef struct {
112 u8 state_change; ///< StateChange. The field in state is reset to zero by \ref ldnGetNetworkInfoLatestUpdate after loading it.
113 u8 reserved[0x7]; ///< Reserved
115
116/// AddressEntry
117typedef struct {
118 LdnIpv4Address ip_addr; ///< \ref LdnIpv4Address
119 LdnMacAddress mac_addr; ///< \ref LdnMacAddress
120 u8 reserved[0x2]; ///< Reserved
122
123/// NodeInfo
124typedef struct {
125 LdnIpv4Address ip_addr; ///< \ref LdnIpv4Address
126 LdnMacAddress mac_addr; ///< \ref LdnMacAddress
127 s8 node_id; ///< NodeId
128 u8 is_connected; ///< IsConnected flag
129 char user_name[0x21]; ///< LdnUserConfig::user_name
130 u8 platform; ///< [19.0.0+] Platform? (0 = NX, 1 = Ounce)
131 s16 local_communication_version; ///< LocalCommunicationVersion
132 u8 reserved_x30[0x10]; ///< Reserved
134
135/// UserConfig. The input struct is copied to a tmp struct, which is then used with the cmd.
136typedef struct {
137 char user_name[0x21]; ///< UserName (NUL-terminated string for the user name)
138 u8 reserved[0xF]; ///< Reserved
140
141/// IntentId
142typedef struct {
143 s64 local_communication_id; ///< LocalCommunicationId. \ref ldnCreateNetwork, \ref ldnCreateNetworkPrivate, \ref ldnConnect, \ref ldnConnectPrivate (also \ref LdnScanFilter when enabled): When -1, this is overwritten with the first LocalCommunicationId from the user-process NACP, if loading fails value 0 is written instead. Otherwise when not -1, if NACP loading is successful, this field must match one of the LocalCommunicationIds from there.
144 u8 reserved_x8[0x2]; ///< Reserved
145 u16 scene_id; ///< SceneId. Arbitrary user data, this can be used for filtering with \ref LdnScanFilter (::LdnScanFilterFlag_SceneId) for example.
146 u8 reserved_xC[0x4]; ///< Reserved
148
149/// SessionId
150typedef struct {
151 u8 random[0x10]; ///< Random. Used to generate/overwrite the ssid when needed.
153
154/// NetworkId
155typedef struct {
156 LdnIntentId intent_id; ///< IntentId
157 LdnSessionId session_id; ///< SessionId
159
160/// CommonNetworkInfo
161typedef struct {
162 LdnMacAddress bssid; ///< \ref LdnMacAddress
163 LdnSsid ssid; ///< \ref LdnSsid
164 s16 channel; ///< Channel
165 s8 link_level; ///< LinkLevel
166 u8 network_type; ///< NetworkType
167 u8 reserved[0x4]; ///< Reserved
169
170/// NetworkInfo
171typedef struct {
172 LdnNetworkId network_id; ///< NetworkId
173 LdnCommonNetworkInfo common; ///< CommonNetworkInfo
174 u8 server_random[0x10]; ///< LdnSecurityParameter::server_random
175 u16 security_mode; ///< LdnSecurityConfig::security_mode
176 u8 station_accept_policy; ///< \ref LdnAcceptPolicy
177 u8 version; ///< Version
178 u8 reserved_x14[0x2]; ///< Reserved
179 s8 node_count_max; ///< NodeCountMax
180 u8 node_count; ///< NodeCount, number of set entries in nodes.
181 LdnNodeInfo nodes[8]; ///< Array of \ref LdnNodeInfo, starting with the AccessPoint node.
182 u8 reserved_x218[0x2]; ///< Reserved
183 u16 advertise_data_size; ///< AdvertiseDataSize (\ref ldnSetAdvertiseData)
184 u8 advertise_data[0x180]; ///< AdvertiseData (\ref ldnSetAdvertiseData)
185 u8 reserved_x39C[0x8C]; ///< Reserved
186 u64 reserved_x428; ///< Reserved
188
189/// ScanFilter. \ref ldnScan / \ref ldnScanPrivate will only return the \ref LdnNetworkInfo when validating the \ref LdnNetworkInfo with LdnScanFilter was sucessful, with the fields enabled by \ref LdnScanFilterFlag.
190typedef struct {
191 LdnNetworkId network_id; ///< NetworkId
192 u32 network_type; ///< NetworkType (::LdnScanFilterFlag_NetworkType)
193 LdnMacAddress bssid; ///< Bssid (::LdnScanFilterFlag_Bssid)
194 LdnSsid ssid; ///< Ssid (::LdnScanFilterFlag_Ssid)
195 u8 reserved[0x10]; ///< Reserved
196 u32 flags; ///< Bitmask for \ref LdnScanFilterFlag.
198
199/// SecurityConfig
200typedef struct {
201 u16 security_mode; ///< \ref LdnSecurityMode Overwritten by \ref ldnCreateNetwork, \ref ldnCreateNetworkPrivate, \ref ldnConnect, \ref ldnConnectPrivate.
202 u16 passphrase_size; ///< PassphraseSize. Must be 0x10-0x40.
203 u8 passphrase[0x40]; ///< Passphrase, used with key derivation.
205
206/// SecurityParameter. The struct used by \ref ldnCreateNetwork internally is randomly-generated.
207typedef struct {
208 u8 server_random[0x10]; ///< ServerRandom, used with the same key derivation as \ref LdnSecurityConfig.
209 LdnSessionId session_id; ///< SessionId
211
212/// NetworkConfig. The input struct is copied to a tmp struct, which is then used with the cmd (\ref ldnCreateNetwork, \ref ldnCreateNetworkPrivate, \ref ldnConnectPrivate).
213typedef struct {
214 LdnIntentId intent_id; ///< IntentId
215 s16 channel; ///< LdnCommonNetworkInfo::channel. Channel, can be zero. Overwritten internally by \ref ldnCreateNetwork.
216 s8 node_count_max; ///< LdnNetworkInfo::node_count_max. \ref ldnCreateNetwork / \ref ldnCreateNetworkPrivate: Must be 0x1-0x8.
217 u8 reserved_x13; ///< Cleared to zero for the tmp struct.
218 s16 local_communication_version; ///< LdnNodeInfo::local_communication_version, for the first entry in LdnNetworkInfo::nodes. Must not be negative.
219 u8 reserved_x16[0xA]; ///< Cleared to zero for the tmp struct.
221
222/// ActionFrameSettings
223typedef struct {
224 s64 local_communication_id; ///< LocalCommunicationId (Same handling as LdnIntentId::local_communication_id)
225 u8 reserved[0x34]; ///< Reserved
226 u16 security_mode; ///< \ref LdnSecurityMode (Must be ::LdnSecurityMode_Product or ::LdnSecurityMode_Debug, internally this is overriden)
227 u16 passphrase_size; ///< PassphraseSize (Must be 0x10-0x40)
228 u8 passphrase[0x40]; ///< Passphrase
230
231///@name ldn:m
232///@{
233
234/// Initialize ldn:m.
236
237/// Exit ldn:m.
238void ldnmExit(void);
239
240/// Gets the Service object for IMonitorService.
242
243/**
244 * @brief GetState
245 * @param[out] out \ref LdnState
246 */
248
249/**
250 * @brief GetNetworkInfo
251 * @param[out] out \ref LdnNetworkInfo
252 */
254
255/**
256 * @brief GetIpv4Address
257 * @param[out] addr \ref LdnIpv4Address
258 * @param[out] mask \ref LdnSubnetMask
259 */
261
262/**
263 * @brief GetSecurityParameter
264 * @note Not exposed by official sw.
265 * @param[out] out \ref LdnSecurityParameter
266 */
268
269/**
270 * @brief GetNetworkConfig
271 * @note Not exposed by official sw.
272 * @param[out] out \ref LdnNetworkConfig
273 */
275
276///@}
277
278///@name ldn
279///@{
280
281/// Initialize ldn.
282/// The priority is only used with ::LdnServiceType_System on [19.0.0+]. To optionally set this, define "s32 __nx_ldn_priority". The priority must be \ref LDN_PRIORITY_SYSTEM (default) or \ref LDN_PRIORITY_USER.
284
285/// Exit ldn.
286void ldnExit(void);
287
288/// Gets the Service object for IUserLocalCommunicationService/ISystemLocalCommunicationService.
290
291/// Gets the Service object for IClientProcessMonitor, only valid with [18.0.0+].
293
294/**
295 * @brief GetState
296 * @param[out] out \ref LdnState
297 */
299
300/**
301 * @brief GetNetworkInfo
302 * @param[out] out \ref LdnNetworkInfo
303 */
305
306/**
307 * @brief GetIpv4Address
308 * @param[out] addr \ref LdnIpv4Address
309 * @param[out] mask \ref LdnSubnetMask
310 */
312
313/**
314 * @brief GetDisconnectReason
315 * @param[out] out \ref LdnDisconnectReason
316 */
318
319/**
320 * @brief GetSecurityParameter
321 * @param[out] out \ref LdnSecurityParameter
322 */
324
325/**
326 * @brief GetNetworkConfig
327 * @param[out] out \ref LdnNetworkConfig
328 */
330
331/**
332 * @brief GetStateChangeEvent
333 * @note The Event must be closed by the user once finished with it.
334 * @note This is signaled when the data returned by \ref ldnGetNetworkInfo / \ref ldnGetNetworkInfoLatestUpdate is updated.
335 * @param[out] out_event Output Event with autoclear=true.
336 */
338
339/**
340 * @brief GetNetworkInfoAndHistory
341 * @param[out] network_info \ref LdnNetworkInfo
342 * @param[out] nodes Output array of \ref LdnNodeLatestUpdate.
343 * @param[in] count Size of the nodes array in entries, must be 8.
344 */
346
347/**
348 * @brief Scan
349 * @note \ref LdnState must be ::LdnState_AccessPointCreated, ::LdnState_Station, or ::LdnState_StationConnected.
350 * @note This is the same as \ref ldnScanPrivate (minus the masking for LdnScanFilter::flags), except this has the same channel-override functionality as \ref ldnCreateNetwork.
351 * @param[in] channel Channel, value 0 can be used for this.
352 * @param[in] filter \ref LdnScanFilter
353 * @param[out] network_info Output array of \ref LdnNetworkInfo.
354 * @param[in] count Size of the network_info array in entries. Must be at least 1, this is clamped to a maximum of 0x18 internally.
355 * @param[out] total_out Total output entries.
356 */
357Result ldnScan(s32 channel, const LdnScanFilter *filter, LdnNetworkInfo *network_info, s32 count, s32 *total_out);
358
359/**
360 * @brief ScanPrivate
361 * @note \ref LdnState must be ::LdnState_AccessPointCreated, ::LdnState_Station, or ::LdnState_StationConnected.
362 * @note See \ref ldnScan.
363 * @param[in] channel Channel, value 0 can be used for this.
364 * @param[in] filter \ref LdnScanFilter
365 * @param[out] network_info Output array of \ref LdnNetworkInfo.
366 * @param[in] count Size of the network_info array in entries. Must be at least 1, this is clamped to a maximum of 0x18 internally.
367 * @param[out] total_out Total output entries.
368 */
369Result ldnScanPrivate(s32 channel, const LdnScanFilter *filter, LdnNetworkInfo *network_info, s32 count, s32 *total_out);
370
371/**
372 * @brief SetWirelessControllerRestriction
373 * @note Only available on [5.0.0+].
374 * @note \ref LdnState must be ::LdnState_Initialized.
375 * @param[in] restriction \ref LdnWirelessControllerRestriction
376 */
378
379/**
380 * @brief SetProtocol
381 * @note This is only usable with [20.0.0+] (with [18.0.0-19-0.1] this is available but not usable).
382 * @note \ref LdnState must be ::LdnState_Initialized. If a non-default Protocol is wanted, use this after \ref ldnInitialize.
383 * @note This is used by \ref ldnInitialize with LdnProtocol_NX on [20.0.0+].
384 * @param[in] protocol \ref LdnProtocol
385 */
387
388/**
389 * @brief OpenAccessPoint
390 * @note \ref LdnState must be ::LdnState_Initialized, this eventually sets the State to ::LdnState_AccessPoint.
391 */
393
394/**
395 * @brief CloseAccessPoint
396 * @note \ref LdnState must be ::LdnState_AccessPoint or ::LdnState_AccessPointCreated, this eventually sets the State to ::LdnState_Initialized.
397 * @note Used automatically internally by \ref ldnExit if needed.
398 */
400
401/**
402 * @brief CreateNetwork
403 * @note \ref LdnState must be ::LdnState_AccessPoint, this eventually sets the State to ::LdnState_AccessPointCreated.
404 * @param[in] sec_config \ref LdnSecurityConfig
405 * @param[in] user_config \ref LdnUserConfig
406 * @param[in] network_config \ref LdnNetworkConfig
407 */
408Result ldnCreateNetwork(const LdnSecurityConfig *sec_config, const LdnUserConfig *user_config, const LdnNetworkConfig *network_config);
409
410/**
411 * @brief CreateNetworkPrivate
412 * @note \ref LdnState must be ::LdnState_AccessPoint, this eventually sets the State to ::LdnState_AccessPointCreated.
413 * @note This is the same as \ref ldnCreateNetwork besides the additional user-specified params, and with this cmd LdnNetworkConfig::channel is not overwritten (unlike \ref ldnCreateNetwork).
414 * @param[in] sec_config \ref LdnSecurityConfig
415 * @param[in] sec_param \ref LdnSecurityParameter
416 * @param[in] user_config \ref LdnUserConfig
417 * @param[in] network_config \ref LdnNetworkConfig
418 * @param[in] addrs Input array of \ref LdnAddressEntry. This can be NULL.
419 * @param[in] count Size of the addrs array in entries. This must be <=8. This can be 0, in which case the network will be non-Private like \ref ldnCreateNetwork.
420 */
421Result ldnCreateNetworkPrivate(const LdnSecurityConfig *sec_config, const LdnSecurityParameter *sec_param, const LdnUserConfig *user_config, const LdnNetworkConfig *network_config, const LdnAddressEntry *addrs, s32 count);
422
423/**
424 * @brief DestroyNetwork
425 * @note \ref LdnState must be ::LdnState_AccessPointCreated, this eventually sets the State to ::LdnState_AccessPoint.
426 */
428
429/**
430 * @brief Reject
431 * @note \ref LdnState must be ::LdnState_AccessPointCreated.
432 * @param[in] addr \ref LdnIpv4Address
433 */
435
436/**
437 * @brief SetAdvertiseData
438 * @note An empty buffer (buffer=NULL/size=0) can be used to reset the AdvertiseData size in state to zero.
439 * @note \ref LdnState must be ::LdnState_AccessPoint or ::LdnState_AccessPointCreated.
440 * @param[in] buffer Input buffer containing arbitrary user data.
441 * @param[in] size Input buffer size, must be <=0x180.
442 */
443Result ldnSetAdvertiseData(const void* buffer, size_t size);
444
445/**
446 * @brief SetStationAcceptPolicy
447 * @note \ref LdnState must be ::LdnState_AccessPoint or ::LdnState_AccessPointCreated.
448 * @param[in] policy \ref LdnAcceptPolicy
449 */
451
452/**
453 * @brief AddAcceptFilterEntry
454 * @note \ref LdnState must be ::LdnState_AccessPoint or ::LdnState_AccessPointCreated.
455 * @note See \ref LdnAcceptPolicy.
456 * @param[in] addr \ref LdnMacAddress. If you want, you can also pass LdnNodeInfo::mac_addr for this.
457 */
459
460/**
461 * @brief ClearAcceptFilter
462 * @note \ref LdnState must be ::LdnState_AccessPoint or ::LdnState_AccessPointCreated.
463 */
465
466/**
467 * @brief OpenStation
468 * @note \ref LdnState must be ::LdnState_Initialized, this eventually sets the State to ::LdnState_Station.
469 */
471
472/**
473 * @brief CloseStation
474 * @note \ref LdnState must be ::LdnState_Station or ::LdnState_StationConnected, this eventually sets the State to ::LdnState_Initialized.
475 * @note Used automatically internally by \ref ldnExit if needed.
476 */
478
479/**
480 * @brief Connect
481 * @note \ref LdnState must be ::LdnState_Station, this eventually sets the State to ::LdnState_StationConnected.
482 * @note This is identical to \ref ldnConnectPrivate besides the used params, the code overwriting LdnSecurityConfig::type also differs.
483 * @param[in] sec_config \ref LdnSecurityConfig
484 * @param[in] user_config \ref LdnUserConfig
485 * @param[in] version LocalCommunicationVersion, this must be 0x0-0x7FFF.
486 * @param[in] option ConnectOption bitmask, must be <=0x1. You can use value 0 for example here.
487 * @param[in] network_info \ref LdnNetworkInfo
488 */
489Result ldnConnect(const LdnSecurityConfig *sec_config, const LdnUserConfig *user_config, s32 version, u32 option, const LdnNetworkInfo *network_info);
490
491/**
492 * @brief ConnectPrivate
493 * @note \ref LdnState must be ::LdnState_Station, this eventually sets the State to ::LdnState_StationConnected.
494 * @note See \ref ldnConnect.
495 * @param[in] sec_config \ref LdnSecurityConfig
496 * @param[in] sec_param \ref LdnSecurityParameter
497 * @param[in] user_config \ref LdnUserConfig
498 * @param[in] version LocalCommunicationVersion, this must be 0x0-0x7FFF.
499 * @param[in] option ConnectOption bitmask, must be <=0x1. You can use value 0 for example here.
500 * @param[in] network_config \ref LdnNetworkConfig
501 */
502Result ldnConnectPrivate(const LdnSecurityConfig *sec_config, const LdnSecurityParameter *sec_param, const LdnUserConfig *user_config, s32 version, u32 option, const LdnNetworkConfig *network_config);
503
504/**
505 * @brief Disconnect
506 * @note \ref LdnState must be ::LdnState_StationConnected, this eventually sets the State to ::LdnState_Station.
507 */
509
510/**
511 * @brief SetOperationMode
512 * @note With ::LdnServiceType_System this is only available on [4.0.0+].
513 * @note With ::LdnServiceType_User this is only available on [19.0.0+].
514 * @note \ref LdnState must be ::LdnState_Initialized.
515 * @param[in] mode \ref LdnOperationMode
516 */
518
519/**
520 * @brief EnableActionFrame
521 * @note Only available on [18.0.0+].
522 * @note \ref LdnState must be ::LdnState_Initialized.
523 * @param[in] settings \ref LdnActionFrameSettings
524 */
526
527/**
528 * @brief DisableActionFrame
529 * @note Only available on [18.0.0+].
530 * @note \ref LdnState must be ::LdnState_Initialized.
531 */
533
534/**
535 * @brief SendActionFrame
536 * @note Only available on [18.0.0+].
537 * @note \ref LdnState must be ::LdnState_AccessPointCreated / ::LdnState_Station.
538 * @param[in] data Data buffer.
539 * @param[in] size Data buffer size.
540 * @param[in] destination Destination \ref LdnMacAddress.
541 * @param[in] bssid Bssid \ref LdnMacAddress.
542 * @param[in] channel Channel, must be non-zero.
543 * @param[in] flags MessageFlag bit0 clear = block until the data can be sent, set = return error when the data can't be sent.
544 */
545Result ldnSendActionFrame(const void* data, size_t size, LdnMacAddress destination, LdnMacAddress bssid, s16 channel, u32 flags);
546
547/**
548 * @brief RecvActionFrame
549 * @note Only available on [18.0.0+].
550 * @note \ref ldnEnableActionFrame must be used prior to this.
551 * @param[out] data Output data buffer.
552 * @param[in] size Max size of the data buffer.
553 * @param[out] addr0 First \ref LdnMacAddress.
554 * @param[out] addr1 Second \ref LdnMacAddress.
555 * @param[out] channel Channel
556 * @param[out] out_size Output size.
557 * @param[out] link_level LinkLevel
558 * @param[in] flags MessageFlag bit0 clear = block until data is available, set = return error when data is not available.
559 */
560Result ldnRecvActionFrame(void* data, size_t size, LdnMacAddress *addr0, LdnMacAddress *addr1, s16 *channel, u32 *out_size, s32 *link_level, u32 flags);
561
562/**
563 * @brief SetHomeChannel
564 * @note Only available on [18.0.0+].
565 * @note \ref LdnState must be ::LdnState_Station.
566 * @param[in] channel Channel, must be non-zero.
567 */
569
570/**
571 * @brief SetTxPower
572 * @note Only available on [18.0.0+].
573 * @note \ref LdnState must be ::LdnState_AccessPoint* / ::LdnState_Station*.
574 * @param[in] power Power, must be 0x0..0xFF.
575 */
577
578/**
579 * @brief ResetTxPower
580 * @note Only available on [18.0.0+].
581 * @note \ref LdnState must be ::LdnState_AccessPoint* / ::LdnState_Station*.
582 */
584
585///@}
586
Result ldnDestroyNetwork(void)
DestroyNetwork.
Result ldnSetWirelessControllerRestriction(LdnWirelessControllerRestriction restriction)
SetWirelessControllerRestriction.
Result ldnmGetNetworkInfo(LdnNetworkInfo *out)
GetNetworkInfo.
Result ldnCreateNetwork(const LdnSecurityConfig *sec_config, const LdnUserConfig *user_config, const LdnNetworkConfig *network_config)
CreateNetwork.
Result ldnSetHomeChannel(s16 channel)
SetHomeChannel.
LdnServiceType
Definition ldn.h:16
@ LdnServiceType_User
Initializes ldn:u.
Definition ldn.h:17
@ LdnServiceType_System
Initializes ldn:s.
Definition ldn.h:18
LdnWirelessControllerRestriction
WirelessControllerRestriction.
Definition ldn.h:78
@ LdnWirelessControllerRestriction_Enabled
Enabled.
Definition ldn.h:80
@ LdnWirelessControllerRestriction_Disabled
Disabled.
Definition ldn.h:79
Result ldnSetStationAcceptPolicy(LdnAcceptPolicy policy)
SetStationAcceptPolicy.
Result ldnDisableActionFrame(void)
DisableActionFrame.
Result ldnOpenAccessPoint(void)
OpenAccessPoint.
Result ldnGetSecurityParameter(LdnSecurityParameter *out)
GetSecurityParameter.
LdnSecurityMode
SecurityMode. LdnSecurityMode_Product can be used as the default value. The ldn cmds which use an inp...
Definition ldn.h:64
@ LdnSecurityMode_Product
Product.
Definition ldn.h:66
@ LdnSecurityMode_Any
Any.
Definition ldn.h:65
@ LdnSecurityMode_SystemDebug
SystemDebug.
Definition ldn.h:68
@ LdnSecurityMode_Debug
Debug.
Definition ldn.h:67
Result ldnCreateNetworkPrivate(const LdnSecurityConfig *sec_config, const LdnSecurityParameter *sec_param, const LdnUserConfig *user_config, const LdnNetworkConfig *network_config, const LdnAddressEntry *addrs, s32 count)
CreateNetworkPrivate.
Result ldnSetAdvertiseData(const void *buffer, size_t size)
SetAdvertiseData.
LdnState
State loaded by ldnmGetStateForMonitor / ldnGetState.
Definition ldn.h:22
@ LdnState_Error
Error.
Definition ldn.h:29
@ LdnState_Initialized
Initialized.
Definition ldn.h:24
@ LdnState_Station
Station (ldnOpenStation)
Definition ldn.h:27
@ LdnState_StationConnected
StationConnected (ldnConnect / ldnConnectPrivate)
Definition ldn.h:28
@ LdnState_None
None.
Definition ldn.h:23
@ LdnState_AccessPointCreated
AccessPointCreated (ldnCreateNetwork / ldnCreateNetworkPrivate)
Definition ldn.h:26
@ LdnState_AccessPoint
AccessPoint (ldnOpenAccessPoint)
Definition ldn.h:25
Result ldnmGetNetworkConfig(LdnNetworkConfig *out)
GetNetworkConfig.
void ldnmExit(void)
Exit ldn:m.
Result ldnConnectPrivate(const LdnSecurityConfig *sec_config, const LdnSecurityParameter *sec_param, const LdnUserConfig *user_config, s32 version, u32 option, const LdnNetworkConfig *network_config)
ConnectPrivate.
Result ldnSetProtocol(LdnProtocol protocol)
SetProtocol.
Result ldnSendActionFrame(const void *data, size_t size, LdnMacAddress destination, LdnMacAddress bssid, s16 channel, u32 flags)
SendActionFrame.
Result ldnCloseAccessPoint(void)
CloseAccessPoint.
Result ldnGetStateChangeEvent(Event *out_event)
GetStateChangeEvent.
Service * ldnGetServiceSession_LocalCommunicationService(void)
Gets the Service object for IUserLocalCommunicationService/ISystemLocalCommunicationService.
Result ldnmGetSecurityParameter(LdnSecurityParameter *out)
GetSecurityParameter.
Result ldnRecvActionFrame(void *data, size_t size, LdnMacAddress *addr0, LdnMacAddress *addr1, s16 *channel, u32 *out_size, s32 *link_level, u32 flags)
RecvActionFrame.
Result ldnGetState(LdnState *out)
GetState.
Result ldnmGetIpv4Address(LdnIpv4Address *addr, LdnSubnetMask *mask)
GetIpv4Address.
Result ldnSetTxPower(s16 power)
SetTxPower.
void ldnExit(void)
Exit ldn.
LdnProtocol
Protocol.
Definition ldn.h:84
@ LdnProtocol_Unknown3
(NXAndOunce?)
Definition ldn.h:86
@ LdnProtocol_NX
NX (default)
Definition ldn.h:85
Result ldnmInitialize(void)
Initialize ldn:m.
LdnDisconnectReason
DisconnectReason loaded by ldnGetDisconnectReason.
Definition ldn.h:33
@ LdnDisconnectReason_None
None.
Definition ldn.h:34
@ LdnDisconnectReason_SignalLost
SignalLost.
Definition ldn.h:40
@ LdnDisconnectReason_Rejected
Rejected.
Definition ldn.h:39
@ LdnDisconnectReason_DisconnectedByUser
DisconnectedByUser.
Definition ldn.h:35
@ LdnDisconnectReason_DestroyedByUser
DestroyedByUser.
Definition ldn.h:37
@ LdnDisconnectReason_DisconnectedBySystem
DisconnectedBySystem.
Definition ldn.h:36
@ LdnDisconnectReason_DestroyedBySystem
DestroyedBySystem.
Definition ldn.h:38
LdnAcceptPolicy
AcceptPolicy.
Definition ldn.h:56
@ LdnAcceptPolicy_BlackList
BlackList, addresses in the list (ldnAddAcceptFilterEntry) are not allowed.
Definition ldn.h:59
@ LdnAcceptPolicy_AlwaysReject
AlwaysReject.
Definition ldn.h:58
@ LdnAcceptPolicy_WhiteList
WhiteList, only addresses in the list (ldnAddAcceptFilterEntry) are allowed.
Definition ldn.h:60
@ LdnAcceptPolicy_AlwaysAccept
AlwaysAccept.
Definition ldn.h:57
Result ldnGetNetworkInfoAndHistory(LdnNetworkInfo *network_info, LdnNodeLatestUpdate *nodes, s32 count)
GetNetworkInfoAndHistory.
Result ldnGetNetworkInfo(LdnNetworkInfo *out)
GetNetworkInfo.
Result ldnEnableActionFrame(const LdnActionFrameSettings *settings)
EnableActionFrame.
Result ldnClearAcceptFilter(void)
ClearAcceptFilter.
Service * ldnmGetServiceSession_MonitorService(void)
Gets the Service object for IMonitorService.
Result ldnScanPrivate(s32 channel, const LdnScanFilter *filter, LdnNetworkInfo *network_info, s32 count, s32 *total_out)
ScanPrivate.
Result ldnDisconnect(void)
Disconnect.
Result ldnGetNetworkConfig(LdnNetworkConfig *out)
GetNetworkConfig.
Result ldnInitialize(LdnServiceType service_type)
Initialize ldn.
Result ldnmGetState(LdnState *out)
GetState.
Result ldnAddAcceptFilterEntry(LdnMacAddress addr)
AddAcceptFilterEntry.
Result ldnCloseStation(void)
CloseStation.
Result ldnReject(LdnIpv4Address addr)
Reject.
Result ldnSetOperationMode(LdnOperationMode mode)
SetOperationMode.
Result ldnOpenStation(void)
OpenStation.
Result ldnGetDisconnectReason(LdnDisconnectReason *out)
GetDisconnectReason.
LdnScanFilterFlag
ScanFilterFlag.
Definition ldn.h:44
@ LdnScanFilterFlag_Bssid
Enables using LdnScanFilter::bssid. Only available with ldnScanPrivate.
Definition ldn.h:48
@ LdnScanFilterFlag_SceneId
Enables using LdnScanFilter::network_id LdnIntentId::scene_id.
Definition ldn.h:50
@ LdnScanFilterFlag_Ssid
Enables using LdnScanFilter::ssid.
Definition ldn.h:49
@ LdnScanFilterFlag_NetworkType
Enables using LdnScanFilter::network_type.
Definition ldn.h:47
@ LdnScanFilterFlag_LocalCommunicationId
Enables using LdnScanFilter::network_id LdnIntentId::local_communication_id.
Definition ldn.h:45
@ LdnScanFilterFlag_NetworkId
Enables using LdnScanFilter::network_id.
Definition ldn.h:52
@ LdnScanFilterFlag_IntentId
Enables using LdnScanFilter::network_id intent_id.
Definition ldn.h:51
@ LdnScanFilterFlag_SessionId
Enables using LdnScanFilter::network_id session_id.
Definition ldn.h:46
Result ldnConnect(const LdnSecurityConfig *sec_config, const LdnUserConfig *user_config, s32 version, u32 option, const LdnNetworkInfo *network_info)
Connect.
Result ldnGetIpv4Address(LdnIpv4Address *addr, LdnSubnetMask *mask)
GetIpv4Address.
Result ldnScan(s32 channel, const LdnScanFilter *filter, LdnNetworkInfo *network_info, s32 count, s32 *total_out)
Scan.
Result ldnResetTxPower(void)
ResetTxPower.
LdnOperationMode
OperationMode.
Definition ldn.h:72
@ LdnOperationMode_HighSpeed
HighSpeed.
Definition ldn.h:74
@ LdnOperationMode_Stable
Stable.
Definition ldn.h:73
Service * ldnGetServiceSession_IClientProcessMonitor(void)
Gets the Service object for IClientProcessMonitor, only valid with [18.0.0+].
Kernel-mode event structure.
Definition event.h:13
ActionFrameSettings.
Definition ldn.h:223
u16 passphrase_size
PassphraseSize (Must be 0x10-0x40)
Definition ldn.h:227
u16 security_mode
LdnSecurityMode (Must be LdnSecurityMode_Product or LdnSecurityMode_Debug, internally this is overrid...
Definition ldn.h:226
s64 local_communication_id
LocalCommunicationId (Same handling as LdnIntentId::local_communication_id)
Definition ldn.h:224
AddressEntry.
Definition ldn.h:117
LdnIpv4Address ip_addr
LdnIpv4Address
Definition ldn.h:118
LdnMacAddress mac_addr
LdnMacAddress
Definition ldn.h:119
CommonNetworkInfo.
Definition ldn.h:161
s16 channel
Channel.
Definition ldn.h:164
LdnMacAddress bssid
LdnMacAddress
Definition ldn.h:162
LdnSsid ssid
LdnSsid
Definition ldn.h:163
u8 network_type
NetworkType.
Definition ldn.h:166
s8 link_level
LinkLevel.
Definition ldn.h:165
IntentId.
Definition ldn.h:142
s64 local_communication_id
LocalCommunicationId. ldnCreateNetwork, ldnCreateNetworkPrivate, ldnConnect, ldnConnectPrivate (also ...
Definition ldn.h:143
u16 scene_id
SceneId. Arbitrary user data, this can be used for filtering with LdnScanFilter (LdnScanFilterFlag_Sc...
Definition ldn.h:145
Ipv4Address. This is essentially the same as struct in_addr - hence this can be used with standard so...
Definition ldn.h:90
u32 addr
Address.
Definition ldn.h:91
MacAddress.
Definition ldn.h:100
NetworkConfig. The input struct is copied to a tmp struct, which is then used with the cmd (ldnCreate...
Definition ldn.h:213
s8 node_count_max
LdnNetworkInfo::node_count_max. ldnCreateNetwork / ldnCreateNetworkPrivate: Must be 0x1-0x8.
Definition ldn.h:216
u8 reserved_x13
Cleared to zero for the tmp struct.
Definition ldn.h:217
LdnIntentId intent_id
IntentId.
Definition ldn.h:214
s16 channel
LdnCommonNetworkInfo::channel. Channel, can be zero. Overwritten internally by ldnCreateNetwork.
Definition ldn.h:215
s16 local_communication_version
LdnNodeInfo::local_communication_version, for the first entry in LdnNetworkInfo::nodes....
Definition ldn.h:218
NetworkId.
Definition ldn.h:155
LdnSessionId session_id
SessionId.
Definition ldn.h:157
LdnIntentId intent_id
IntentId.
Definition ldn.h:156
NetworkInfo.
Definition ldn.h:171
LdnCommonNetworkInfo common
CommonNetworkInfo.
Definition ldn.h:173
u16 advertise_data_size
AdvertiseDataSize (ldnSetAdvertiseData)
Definition ldn.h:183
u16 security_mode
LdnSecurityConfig::security_mode.
Definition ldn.h:175
u64 reserved_x428
Reserved.
Definition ldn.h:186
u8 station_accept_policy
LdnAcceptPolicy
Definition ldn.h:176
LdnNetworkId network_id
NetworkId.
Definition ldn.h:172
u8 version
Version.
Definition ldn.h:177
s8 node_count_max
NodeCountMax.
Definition ldn.h:179
u8 node_count
NodeCount, number of set entries in nodes.
Definition ldn.h:180
NodeInfo.
Definition ldn.h:124
LdnMacAddress mac_addr
LdnMacAddress
Definition ldn.h:126
LdnIpv4Address ip_addr
LdnIpv4Address
Definition ldn.h:125
u8 is_connected
IsConnected flag.
Definition ldn.h:128
s8 node_id
NodeId.
Definition ldn.h:127
u8 platform
[19.0.0+] Platform? (0 = NX, 1 = Ounce)
Definition ldn.h:130
s16 local_communication_version
LocalCommunicationVersion.
Definition ldn.h:131
NodeLatestUpdate.
Definition ldn.h:111
u8 state_change
StateChange. The field in state is reset to zero by ldnGetNetworkInfoLatestUpdate after loading it.
Definition ldn.h:112
ScanFilter. ldnScan / ldnScanPrivate will only return the LdnNetworkInfo when validating the LdnNetwo...
Definition ldn.h:190
LdnNetworkId network_id
NetworkId.
Definition ldn.h:191
u32 network_type
NetworkType (LdnScanFilterFlag_NetworkType)
Definition ldn.h:192
u32 flags
Bitmask for LdnScanFilterFlag.
Definition ldn.h:196
LdnMacAddress bssid
Bssid (LdnScanFilterFlag_Bssid)
Definition ldn.h:193
LdnSsid ssid
Ssid (LdnScanFilterFlag_Ssid)
Definition ldn.h:194
SecurityConfig.
Definition ldn.h:200
u16 security_mode
LdnSecurityMode Overwritten by ldnCreateNetwork, ldnCreateNetworkPrivate, ldnConnect,...
Definition ldn.h:201
u16 passphrase_size
PassphraseSize. Must be 0x10-0x40.
Definition ldn.h:202
SecurityParameter. The struct used by ldnCreateNetwork internally is randomly-generated.
Definition ldn.h:207
LdnSessionId session_id
SessionId.
Definition ldn.h:209
SessionId.
Definition ldn.h:150
Ssid.
Definition ldn.h:105
u8 len
Length excluding NUL-terminator, must be 0x1-0x20.
Definition ldn.h:106
SubnetMask. This is essentially the same as struct in_addr - hence this can be used with standard soc...
Definition ldn.h:95
u32 mask
Mask.
Definition ldn.h:96
UserConfig. The input struct is copied to a tmp struct, which is then used with the cmd.
Definition ldn.h:136
Service object structure.
Definition service.h:14
int64_t s64
64-bit signed integer.
Definition types.h:28
#define BIT(n)
Creates a bitmask from a bit number.
Definition types.h:54
uint64_t u64
64-bit unsigned integer.
Definition types.h:22
uint8_t u8
8-bit unsigned integer.
Definition types.h:19
int8_t s8
8-bit signed integer.
Definition types.h:25
int16_t s16
16-bit signed integer.
Definition types.h:26
uint16_t u16
16-bit unsigned integer.
Definition types.h:20
u32 Result
Function error code result type.
Definition types.h:44
int32_t s32
32-bit signed integer.
Definition types.h:27
uint32_t u32
32-bit unsigned integer.
Definition types.h:21