libnx  v4.8.0
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 typedef enum {
14  LdnServiceType_User = 0, ///< Initializes ldn:u.
15  LdnServiceType_System = 1, ///< Initializes ldn:s.
17 
18 /// State loaded by \ref ldnmGetStateForMonitor / \ref ldnGetState.
19 typedef enum {
20  LdnState_None = 0, ///< None
21  LdnState_Initialized = 1, ///< Initialized
22  LdnState_AccessPointOpened = 2, ///< AccessPointOpened (\ref ldnOpenAccessPoint)
23  LdnState_AccessPointCreated = 3, ///< AccessPointCreated (\ref ldnCreateNetwork / \ref ldnCreateNetworkPrivate)
24  LdnState_StationOpened = 4, ///< StationOpened (\ref ldnOpenStation)
25  LdnState_StationConnected = 5, ///< StationConnected (\ref ldnConnect / \ref ldnConnectPrivate)
26  LdnState_Error = 6, ///< Error
27 } LdnState;
28 
29 /// DisconnectReason loaded by \ref ldnGetDisconnectReason.
30 typedef enum {
31  LdnDisconnectReason_None = 0, ///< None
32  LdnDisconnectReason_User = 1, ///< User
33  LdnDisconnectReason_SystemRequest = 2, ///< SystemRequest
34  LdnDisconnectReason_DestroyedByAdmin = 3, ///< DestroyedByAdmin
35  LdnDisconnectReason_DestroyedBySystemRequest = 4, ///< DestroyedBySystemRequest
36  LdnDisconnectReason_Admin = 5, ///< Admin
37  LdnDisconnectReason_SignalLost = 6, ///< SignalLost
39 
40 /// ScanFilterFlags
41 typedef enum {
42  LdnScanFilterFlags_LocalCommunicationId = BIT(0), ///< When set, enables using LdnScanFilter::local_communication_id.
43  LdnScanFilterFlags_NetworkId = BIT(1), ///< When set, enables using LdnScanFilter::network_id.
44  LdnScanFilterFlags_Unknown2 = BIT(2), ///< When set, enables using LdnScanFilter::unk_x20.
45  LdnScanFilterFlags_MacAddr = BIT(3), ///< When set, enables using LdnScanFilter::mac_addr. Only available with \ref ldnScanPrivate.
46  LdnScanFilterFlags_Ssid = BIT(4), ///< When set, enables using the LdnScanFilter::ssid.
47  LdnScanFilterFlags_UserData = BIT(5), ///< When set, enables using LdnScanFilter::userdata_filter.
49 
50 /// AcceptPolicy
51 typedef enum {
52  LdnAcceptPolicy_AllowAll = 0, ///< Allow all.
53  LdnAcceptPolicy_DenyAll = 1, ///< Deny all.
54  LdnAcceptPolicy_Blacklist = 2, ///< Blacklist, addresses in the list (\ref ldnAddAcceptFilterEntry) are not allowed.
55  LdnAcceptPolicy_Whitelist = 3, ///< Whitelist, only addresses in the list (\ref ldnAddAcceptFilterEntry) are allowed.
57 
58 /// OperationMode
59 typedef enum {
60  LdnOperationMode_Unknown0 = 0, ///< Unknown
61  LdnOperationMode_Unknown1 = 1, ///< Unknown
63 
64 /// WirelessControllerRestriction
65 typedef enum {
69 
70 /// Ipv4Address. This is essentially the same as struct in_addr - hence this can be used with standard sockets (byteswap required).
71 typedef struct {
72  u32 addr; ///< Address
74 
75 /// SubnetMask. This is essentially the same as struct in_addr - hence this can be used with standard sockets (byteswap required).
76 typedef struct {
77  u32 mask; ///< Mask
79 
80 /// MacAddress
81 typedef struct {
82  u8 addr[6]; ///< Address
84 
85 /// Ssid
86 typedef struct {
87  u8 len; ///< Length excluding NUL-terminator, must be 0x1-0x20.
88  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).
89 } LdnSsid;
90 
91 /// NodeLatestUpdate
92 typedef struct {
93  u8 val; ///< The field in state is reset to zero by \ref ldnGetNetworkInfoLatestUpdate after loading it.
94  u8 reserved[0x7]; ///< Not initialized with \ref ldnGetNetworkInfoLatestUpdate.
96 
97 /// AddressEntry
98 typedef struct {
99  LdnIpv4Address ip_addr; ///< \ref LdnIpv4Address
100  LdnMacAddress mac_addr; ///< \ref LdnMacAddress
101  u8 pad[0x2]; ///< Padding
103 
104 /// NodeInfo
105 typedef struct {
106  LdnIpv4Address ip_addr; ///< \ref LdnIpv4Address
107  LdnMacAddress mac_addr; ///< \ref LdnMacAddress
108  s8 id; ///< ID / index
109  u8 is_connected; ///< IsConnected flag
110  char nickname[0x20]; ///< LdnUserConfig::nickname
111  u8 reserved_x2C[0x2]; ///< Reserved
112  s16 local_communication_version; ///< LocalCommunicationVersion
113  u8 reserved_x30[0x10]; ///< Reserved
114 } LdnNodeInfo;
115 
116 /// UserConfig. The input struct is copied to a tmp struct, which is then used with the cmd.
117 typedef struct {
118  char nickname[0x20]; ///< NUL-terminated string for the user nickname.
119  u8 reserved[0x10]; ///< Cleared to zero for the tmp struct.
120 } LdnUserConfig;
121 
122 /// NetworkInfo
123 typedef struct {
124  u64 local_communication_id; ///< LocalCommunicationId
125  u8 reserved_x8[0x2]; ///< Reserved
126  u16 userdata_filter; ///< Arbitrary user data which can be used for filtering with \ref LdnScanFilter.
127  u8 reserved_xC[0x4]; ///< Reserved
128  u8 network_id[0x10]; ///< LdnSecurityParameter::network_id. NetworkId which is used to generate/overwrite the ssid. With \ref ldnScan / \ref ldnScanPrivate, this is only done after filtering when unk_x4B is value 0x2.
129  LdnMacAddress mac_addr; ///< \ref LdnMacAddress
130  LdnSsid ssid; ///< \ref LdnSsid
131  s16 network_channel; ///< NetworkChannel
132  s8 link_level; ///< LinkLevel
133  u8 unk_x4B; ///< Unknown. Set to hard-coded value 0x2 with output structs, except with \ref ldnScan / \ref ldnScanPrivate which can also set value 0x1 in certain cases.
134  u8 pad_x4C[0x4]; ///< Padding
135  u8 sec_param_data[0x10]; ///< LdnSecurityParameter::data
136  u16 sec_type; ///< LdnSecurityConfig::type
137  u8 accept_policy; ///< \ref LdnAcceptPolicy
138  u8 unk_x63; ///< Only set with \ref ldnScan / \ref ldnScanPrivate, when unk_x4B is value 0x2.
139  u8 pad_x64[0x2]; ///< Padding
140  s8 participant_max; ///< Maximum participants, for nodes.
141  u8 participant_num; ///< ParticipantNum, number of set entries in nodes. If unk_x4B is not 0x2, ParticipantNum should be handled as if it's 0.
142  LdnNodeInfo nodes[8]; ///< Array of \ref LdnNodeInfo, starting with the AccessPoint node.
143  u8 reserved_x268[0x2]; ///< Reserved
144  u16 advertise_data_size; ///< AdvertiseData size (\ref ldnSetAdvertiseData)
145  u8 advertise_data[0x180]; ///< AdvertiseData (\ref ldnSetAdvertiseData)
146  u8 reserved_x3EC[0x8C]; ///< Reserved
147  u64 auth_id; ///< Random AuthenticationId.
149 
150 /// ScanFilter. The input struct is copied to a tmp struct, which is then used with the cmd (\ref ldnScan and \ref ldnScanPrivate).
151 typedef struct {
152  s64 local_communication_id; ///< See ::LdnScanFilterFlags_LocalCommunicationId. When enabled, this will be overwritten if it's -1 (written data is from the user-process control.nacp, with value 0 used instead if loading fails). During filtering if enabled, LdnNetworkInfo::unk_x4B must match 0x2, and this ScanFilter field must match LdnNetworkInfo::local_communication_id.
153  u8 pad_x8[0x2]; ///< Padding
154  u16 userdata_filter; ///< See ::LdnScanFilterFlags_UserData. During filtering if enabled, LdnNetworkInfo::unk_x4B must match 0x2, and this ScanFilter field must match LdnNetworkInfo::userdata_filter.
155  u8 pad_xC[0x4]; ///< Padding
156  u8 network_id[0x10]; ///< See ::LdnScanFilterFlags_NetworkId. During filtering if enabled, LdnNetworkInfo::unk_x4B must match 0x2, and this ScanFilter data must match LdnNetworkInfo::network_id.
157  u32 unk_x20; ///< See ::LdnScanFilterFlags_Unknown2. When enabled, this must be <=0x3, and during filtering must match LdnNetworkInfo::unk_x4B.
158  LdnMacAddress mac_addr; ///< \ref LdnMacAddress (::LdnScanFilterFlags_MacAddr, during filtering if enabled this must match LdnNetworkInfo::mac_addr)
159  LdnSsid ssid; ///< \ref LdnSsid (::LdnScanFilterFlags_Ssid, during filtering if enabled this must match LdnNetworkInfo::ssid)
160  u8 reserved[0x10]; ///< Cleared to zero for the tmp struct.
161  u32 flags; ///< Bitmask for \ref LdnScanFilterFlags. Masked with value 0x37 for \ref ldnScan, with \ref ldnScanPrivate this is masked with 0x3F.
162 } LdnScanFilter;
163 
164 /// SecurityConfig
165 typedef struct {
166  u16 type; ///< Type, a default of value 0x1 can be used here. Overwritten by \ref ldnCreateNetwork, \ref ldnCreateNetworkPrivate, \ref ldnConnect, \ref ldnConnectPrivate.
167  u16 data_size; ///< Data size. Must be 0x10-0x40.
168  u8 data[0x40]; ///< Data, used with key derivation.
170 
171 /// SecurityParameter. The struct used by \ref ldnCreateNetwork internally is randomly-generated.
172 typedef struct {
173  u8 data[0x10]; ///< Data, used with the same key derivation as \ref LdnSecurityConfig.
174  u8 network_id[0x10]; ///< LdnNetworkInfo::network_id
176 
177 /// NetworkConfig. The input struct is copied to a tmp struct, which is then used with the cmd (\ref ldnCreateNetwork, \ref ldnCreateNetworkPrivate, \ref ldnConnectPrivate).
178 typedef struct {
179  s64 local_communication_id; ///< LdnNetworkInfo::local_communication_id. \ref ldnCreateNetwork, \ref ldnCreateNetworkPrivate, \ref ldnConnect, \ref ldnConnectPrivate: When -1, this is overwritten with the first LocalCommunicationId from the user-process control.nacp, if loading fails value 0 is written instead. Otherwise when not -1, if control.nacp loading is successful, this field must match one of the LocalCommunicationIds from there.
180  u8 reserved_x8[2]; ///< Cleared to zero for the tmp struct.
181  u16 userdata_filter; ///< LdnNetworkInfo::userdata_filter
182  u8 reserved_xC[4]; ///< Cleared to zero for the tmp struct.
183  s16 network_channel; ///< LdnNetworkInfo::network_channel. Channel, can be zero. Overwritten internally by \ref ldnCreateNetwork.
184  s8 participant_max; ///< LdnNetworkInfo::participant_max. \ref ldnCreateNetwork / \ref ldnCreateNetworkPrivate: Must be 0x1-0x8.
185  u8 reserved_x13; ///< Cleared to zero for the tmp struct.
186  s16 local_communication_version; ///< LdnNodeInfo::local_communication_version, for the first entry in LdnNetworkInfo::nodes. Must not be negative.
187  u8 reserved_x16[0xA]; ///< Cleared to zero for the tmp struct.
189 
190 ///@name ldn:m
191 ///@{
192 
193 /// Initialize ldn:m.
195 
196 /// Exit ldn:m.
197 void ldnmExit(void);
198 
199 /// Gets the Service object for IMonitorService.
201 
202 /**
203  * @brief GetStateForMonitor
204  * @param[out] out \ref LdnState
205  */
207 
208 /**
209  * @brief GetNetworkInfoForMonitor
210  * @param[out] out \ref LdnNetworkInfo
211  */
213 
214 /**
215  * @brief GetIpv4AddressForMonitor
216  * @param[out] addr \ref LdnIpv4Address
217  * @param[out] mask \ref LdnSubnetMask
218  */
220 
221 /**
222  * @brief GetSecurityParameterForMonitor
223  * @note Not exposed by official sw.
224  * @param[out] out \ref LdnSecurityParameter
225  */
227 
228 /**
229  * @brief GetNetworkConfigForMonitor
230  * @note Not exposed by official sw.
231  * @param[out] out \ref LdnNetworkConfig
232  */
234 
235 ///@}
236 
237 ///@name ldn
238 ///@{
239 
240 /// Initialize ldn.
242 
243 /// Exit ldn.
244 void ldnExit(void);
245 
246 /// Gets the Service object for IUserLocalCommunicationService/ISystemLocalCommunicationService.
248 
249 /**
250  * @brief GetState
251  * @param[out] out \ref LdnState
252  */
254 
255 /**
256  * @brief GetNetworkInfo
257  * @param[out] out \ref LdnNetworkInfo
258  */
260 
261 /**
262  * @brief GetIpv4Address
263  * @param[out] addr \ref LdnIpv4Address
264  * @param[out] mask \ref LdnSubnetMask
265  */
267 
268 /**
269  * @brief GetDisconnectReason
270  * @param[out] out \ref LdnDisconnectReason
271  */
273 
274 /**
275  * @brief GetSecurityParameter
276  * @param[out] out \ref LdnSecurityParameter
277  */
279 
280 /**
281  * @brief GetNetworkConfig
282  * @param[out] out \ref LdnNetworkConfig
283  */
285 
286 /**
287  * @brief AttachStateChangeEvent
288  * @note The Event must be closed by the user once finished with it.
289  * @note This is signaled when the data returned by \ref ldnGetNetworkInfo / \ref ldnGetNetworkInfoLatestUpdate is updated.
290  * @param[out] out_event Output Event with autoclear=true.
291  */
293 
294 /**
295  * @brief GetNetworkInfoLatestUpdate
296  * @param[out] network_info \ref LdnNetworkInfo
297  * @param[out] nodes Output array of \ref LdnNodeLatestUpdate.
298  * @param[in] count Size of the nodes array in entries, must be 8.
299  */
301 
302 /**
303  * @brief Scan
304  * @note \ref LdnState must be ::LdnState_AccessPointCreated, ::LdnState_StationOpened, or ::LdnState_StationConnected.
305  * @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.
306  * @param[in] channel Channel, value 0 can be used for this.
307  * @param[in] filter \ref LdnScanFilter
308  * @param[out] network_info Output array of \ref LdnNetworkInfo.
309  * @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.
310  * @param[out] total_out Total output entries.
311  */
312 Result ldnScan(s32 channel, const LdnScanFilter *filter, LdnNetworkInfo *network_info, s32 count, s32 *total_out);
313 
314 /**
315  * @brief ScanPrivate
316  * @note \ref LdnState must be ::LdnState_AccessPointCreated, ::LdnState_StationOpened, or ::LdnState_StationConnected.
317  * @note See \ref ldnScan.
318  * @param[in] channel Channel, value 0 can be used for this.
319  * @param[in] filter \ref LdnScanFilter
320  * @param[out] network_info Output array of \ref LdnNetworkInfo.
321  * @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.
322  * @param[out] total_out Total output entries.
323  */
324 Result ldnScanPrivate(s32 channel, const LdnScanFilter *filter, LdnNetworkInfo *network_info, s32 count, s32 *total_out);
325 
326 /**
327  * @brief SetWirelessControllerRestriction
328  * @note Only available on [5.0.0+].
329  * @note \ref LdnState must be ::LdnState_Initialized.
330  * @param[in] restriction \ref LdnWirelessControllerRestriction
331  */
333 
334 /**
335  * @brief OpenAccessPoint
336  * @note \ref LdnState must be ::LdnState_Initialized, this eventually sets the State to ::LdnState_AccessPointOpened.
337  */
339 
340 /**
341  * @brief CloseAccessPoint
342  * @note \ref LdnState must be ::LdnState_AccessPointOpened or ::LdnState_AccessPointCreated, this eventually sets the State to ::LdnState_Initialized.
343  * @note Used automatically internally by \ref ldnExit if needed.
344  */
346 
347 /**
348  * @brief CreateNetwork
349  * @note \ref LdnState must be ::LdnState_AccessPointOpened, this eventually sets the State to ::LdnState_AccessPointCreated.
350  * @param[in] sec_config \ref LdnSecurityConfig
351  * @param[in] user_config \ref LdnUserConfig
352  * @param[in] network_config \ref LdnNetworkConfig
353  */
354 Result ldnCreateNetwork(const LdnSecurityConfig *sec_config, const LdnUserConfig *user_config, const LdnNetworkConfig *network_config);
355 
356 /**
357  * @brief CreateNetworkPrivate
358  * @note \ref LdnState must be ::LdnState_AccessPointOpened, this eventually sets the State to ::LdnState_AccessPointCreated.
359  * @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).
360  * @param[in] sec_config \ref LdnSecurityConfig
361  * @param[in] sec_param \ref LdnSecurityParameter
362  * @param[in] user_config \ref LdnUserConfig
363  * @param[in] network_config \ref LdnNetworkConfig
364  * @param[in] addrs Input array of \ref LdnAddressEntry. This can be NULL.
365  * @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.
366  */
367 Result ldnCreateNetworkPrivate(const LdnSecurityConfig *sec_config, const LdnSecurityParameter *sec_param, const LdnUserConfig *user_config, const LdnNetworkConfig *network_config, const LdnAddressEntry *addrs, s32 count);
368 
369 /**
370  * @brief DestroyNetwork
371  * @note \ref LdnState must be ::LdnState_AccessPointCreated, this eventually sets the State to ::LdnState_AccessPointOpened.
372  */
374 
375 /**
376  * @brief Reject
377  * @note \ref LdnState must be ::LdnState_AccessPointCreated.
378  * @param[in] addr \ref LdnIpv4Address
379  */
381 
382 /**
383  * @brief SetAdvertiseData
384  * @note An empty buffer (buffer=NULL/size=0) can be used to reset the AdvertiseData size in state to zero.
385  * @note \ref LdnState must be ::LdnState_AccessPointOpened or ::LdnState_AccessPointCreated.
386  * @param[in] buffer Input buffer containing arbitrary user data.
387  * @param[in] size Input buffer size, must be <=0x180. If this isn't enough space, you can for example also periodically use this cmd with different regions of your data with some sequence_number field (or use sockets while connected to the network).
388  */
389 Result ldnSetAdvertiseData(const void* buffer, size_t size);
390 
391 /**
392  * @brief SetStationAcceptPolicy
393  * @note \ref LdnState must be ::LdnState_AccessPointOpened or ::LdnState_AccessPointCreated.
394  * @param[in] policy \ref LdnAcceptPolicy
395  */
397 
398 /**
399  * @brief AddAcceptFilterEntry
400  * @note \ref LdnState must be ::LdnState_AccessPointOpened or ::LdnState_AccessPointCreated.
401  * @note See \ref LdnAcceptPolicy.
402  * @param[in] addr \ref LdnMacAddress. If you want, you can also pass LdnNodeInfo::mac_addr for this.
403  */
405 
406 /**
407  * @brief ClearAcceptFilter
408  * @note \ref LdnState must be ::LdnState_AccessPointOpened or ::LdnState_AccessPointCreated.
409  */
411 
412 /**
413  * @brief OpenStation
414  * @note \ref LdnState must be ::LdnState_Initialized, this eventually sets the State to ::LdnState_StationOpened.
415  */
417 
418 /**
419  * @brief CloseStation
420  * @note \ref LdnState must be ::LdnState_StationOpened or ::LdnState_StationConnected, this eventually sets the State to ::LdnState_Initialized.
421  * @note Used automatically internally by \ref ldnExit if needed.
422  */
424 
425 /**
426  * @brief Connect
427  * @note \ref LdnState must be ::LdnState_StationOpened, this eventually sets the State to ::LdnState_StationConnected.
428  * @note This is identical to \ref ldnConnectPrivate besides the used params, the code overwriting LdnSecurityConfig::type also differs.
429  * @param[in] sec_config \ref LdnSecurityConfig
430  * @param[in] user_config \ref LdnUserConfig
431  * @param[in] version LocalCommunicationVersion, this must be 0x0-0x7FFF.
432  * @param[in] option ConnectOption bitmask, must be <=0x1. You can use value 0 for example here.
433  * @param[in] network_info \ref LdnNetworkInfo
434  */
435 Result ldnConnect(const LdnSecurityConfig *sec_config, const LdnUserConfig *user_config, s32 version, u32 option, const LdnNetworkInfo *network_info);
436 
437 /**
438  * @brief ConnectPrivate
439  * @note \ref LdnState must be ::LdnState_StationOpened, this eventually sets the State to ::LdnState_StationConnected.
440  * @note See \ref ldnConnect.
441  * @param[in] sec_config \ref LdnSecurityConfig
442  * @param[in] sec_param \ref LdnSecurityParameter
443  * @param[in] user_config \ref LdnUserConfig
444  * @param[in] version LocalCommunicationVersion, this must be 0x0-0x7FFF.
445  * @param[in] option ConnectOption bitmask, must be <=0x1. You can use value 0 for example here.
446  * @param[in] network_config \ref LdnNetworkConfig
447  */
448 Result ldnConnectPrivate(const LdnSecurityConfig *sec_config, const LdnSecurityParameter *sec_param, const LdnUserConfig *user_config, s32 version, u32 option, const LdnNetworkConfig *network_config);
449 
450 /**
451  * @brief Disconnect
452  * @note \ref LdnState must be ::LdnState_StationConnected, this eventually sets the State to ::LdnState_StationOpened.
453  */
455 
456 /**
457  * @brief SetOperationMode
458  * @note Only available on [4.0.0+].
459  * @note Only available with ::LdnServiceType_System.
460  * @note \ref LdnState must be ::LdnState_Initialized.
461  * @param[in] mode \ref LdnOperationMode
462  */
464 
465 ///@}
466 
Service * ldnGetServiceSession_LocalCommunicationService(void)
Gets the Service object for IUserLocalCommunicationService/ISystemLocalCommunicationService.
Result ldnmGetSecurityParameterForMonitor(LdnSecurityParameter *out)
GetSecurityParameterForMonitor.
Result ldnAttachStateChangeEvent(Event *out_event)
AttachStateChangeEvent.
Result ldnDestroyNetwork(void)
DestroyNetwork.
Result ldnSetWirelessControllerRestriction(LdnWirelessControllerRestriction restriction)
SetWirelessControllerRestriction.
Result ldnCreateNetwork(const LdnSecurityConfig *sec_config, const LdnUserConfig *user_config, const LdnNetworkConfig *network_config)
CreateNetwork.
LdnServiceType
Definition: ldn.h:13
@ LdnServiceType_User
Initializes ldn:u.
Definition: ldn.h:14
@ LdnServiceType_System
Initializes ldn:s.
Definition: ldn.h:15
LdnWirelessControllerRestriction
WirelessControllerRestriction.
Definition: ldn.h:65
@ LdnWirelessControllerRestriction_Unknown0
Unknown.
Definition: ldn.h:66
@ LdnWirelessControllerRestriction_Unknown1
Unknown.
Definition: ldn.h:67
Result ldnSetStationAcceptPolicy(LdnAcceptPolicy policy)
SetStationAcceptPolicy.
Result ldnOpenAccessPoint(void)
OpenAccessPoint.
Result ldnGetSecurityParameter(LdnSecurityParameter *out)
GetSecurityParameter.
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:19
@ LdnState_Error
Error.
Definition: ldn.h:26
@ LdnState_AccessPointOpened
AccessPointOpened (ldnOpenAccessPoint)
Definition: ldn.h:22
@ LdnState_StationOpened
StationOpened (ldnOpenStation)
Definition: ldn.h:24
@ LdnState_Initialized
Initialized.
Definition: ldn.h:21
@ LdnState_StationConnected
StationConnected (ldnConnect / ldnConnectPrivate)
Definition: ldn.h:25
@ LdnState_None
None.
Definition: ldn.h:20
@ LdnState_AccessPointCreated
AccessPointCreated (ldnCreateNetwork / ldnCreateNetworkPrivate)
Definition: ldn.h:23
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 ldnmGetIpv4AddressForMonitor(LdnIpv4Address *addr, LdnSubnetMask *mask)
GetIpv4AddressForMonitor.
Result ldnCloseAccessPoint(void)
CloseAccessPoint.
Result ldnGetState(LdnState *out)
GetState.
Result ldnGetNetworkInfoLatestUpdate(LdnNetworkInfo *network_info, LdnNodeLatestUpdate *nodes, s32 count)
GetNetworkInfoLatestUpdate.
void ldnExit(void)
Exit ldn.
Result ldnmInitialize(void)
Initialize ldn:m.
LdnScanFilterFlags
ScanFilterFlags.
Definition: ldn.h:41
@ LdnScanFilterFlags_NetworkId
When set, enables using LdnScanFilter::network_id.
Definition: ldn.h:43
@ LdnScanFilterFlags_LocalCommunicationId
When set, enables using LdnScanFilter::local_communication_id.
Definition: ldn.h:42
@ LdnScanFilterFlags_Unknown2
When set, enables using LdnScanFilter::unk_x20.
Definition: ldn.h:44
@ LdnScanFilterFlags_Ssid
When set, enables using the LdnScanFilter::ssid.
Definition: ldn.h:46
@ LdnScanFilterFlags_MacAddr
When set, enables using LdnScanFilter::mac_addr. Only available with ldnScanPrivate.
Definition: ldn.h:45
@ LdnScanFilterFlags_UserData
When set, enables using LdnScanFilter::userdata_filter.
Definition: ldn.h:47
Result ldnmGetNetworkInfoForMonitor(LdnNetworkInfo *out)
GetNetworkInfoForMonitor.
LdnDisconnectReason
DisconnectReason loaded by ldnGetDisconnectReason.
Definition: ldn.h:30
@ LdnDisconnectReason_Admin
Admin.
Definition: ldn.h:36
@ LdnDisconnectReason_SystemRequest
SystemRequest.
Definition: ldn.h:33
@ LdnDisconnectReason_None
None.
Definition: ldn.h:31
@ LdnDisconnectReason_SignalLost
SignalLost.
Definition: ldn.h:37
@ LdnDisconnectReason_DestroyedByAdmin
DestroyedByAdmin.
Definition: ldn.h:34
@ LdnDisconnectReason_User
User.
Definition: ldn.h:32
@ LdnDisconnectReason_DestroyedBySystemRequest
DestroyedBySystemRequest.
Definition: ldn.h:35
LdnAcceptPolicy
AcceptPolicy.
Definition: ldn.h:51
@ LdnAcceptPolicy_DenyAll
Deny all.
Definition: ldn.h:53
@ LdnAcceptPolicy_AllowAll
Allow all.
Definition: ldn.h:52
@ LdnAcceptPolicy_Blacklist
Blacklist, addresses in the list (ldnAddAcceptFilterEntry) are not allowed.
Definition: ldn.h:54
@ LdnAcceptPolicy_Whitelist
Whitelist, only addresses in the list (ldnAddAcceptFilterEntry) are allowed.
Definition: ldn.h:55
Result ldnGetNetworkInfo(LdnNetworkInfo *out)
GetNetworkInfo.
Result ldnmGetStateForMonitor(LdnState *out)
GetStateForMonitor.
Result ldnClearAcceptFilter(void)
ClearAcceptFilter.
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 ldnAddAcceptFilterEntry(LdnMacAddress addr)
AddAcceptFilterEntry.
Result ldnCloseStation(void)
CloseStation.
Result ldnReject(LdnIpv4Address addr)
Reject.
Result ldnSetOperationMode(LdnOperationMode mode)
SetOperationMode.
Result ldnOpenStation(void)
OpenStation.
Result ldnmGetNetworkConfigForMonitor(LdnNetworkConfig *out)
GetNetworkConfigForMonitor.
Result ldnGetDisconnectReason(LdnDisconnectReason *out)
GetDisconnectReason.
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.
LdnOperationMode
OperationMode.
Definition: ldn.h:59
@ LdnOperationMode_Unknown1
Unknown.
Definition: ldn.h:61
@ LdnOperationMode_Unknown0
Unknown.
Definition: ldn.h:60
Service * ldnmGetServiceSession_MonitorService(void)
Gets the Service object for IMonitorService.
Kernel-mode event structure.
Definition: event.h:13
AddressEntry.
Definition: ldn.h:98
LdnIpv4Address ip_addr
LdnIpv4Address
Definition: ldn.h:99
LdnMacAddress mac_addr
LdnMacAddress
Definition: ldn.h:100
Ipv4Address. This is essentially the same as struct in_addr - hence this can be used with standard so...
Definition: ldn.h:71
u32 addr
Address.
Definition: ldn.h:72
MacAddress.
Definition: ldn.h:81
NetworkConfig. The input struct is copied to a tmp struct, which is then used with the cmd (ldnCreate...
Definition: ldn.h:178
u8 reserved_x13
Cleared to zero for the tmp struct.
Definition: ldn.h:185
s64 local_communication_id
LdnNetworkInfo::local_communication_id. ldnCreateNetwork, ldnCreateNetworkPrivate,...
Definition: ldn.h:179
s8 participant_max
LdnNetworkInfo::participant_max. ldnCreateNetwork / ldnCreateNetworkPrivate: Must be 0x1-0x8.
Definition: ldn.h:184
u16 userdata_filter
LdnNetworkInfo::userdata_filter.
Definition: ldn.h:181
s16 network_channel
LdnNetworkInfo::network_channel. Channel, can be zero. Overwritten internally by ldnCreateNetwork.
Definition: ldn.h:183
s16 local_communication_version
LdnNodeInfo::local_communication_version, for the first entry in LdnNetworkInfo::nodes....
Definition: ldn.h:186
NetworkInfo.
Definition: ldn.h:123
u64 local_communication_id
LocalCommunicationId.
Definition: ldn.h:124
u16 sec_type
LdnSecurityConfig::type.
Definition: ldn.h:136
u8 unk_x4B
Unknown. Set to hard-coded value 0x2 with output structs, except with ldnScan / ldnScanPrivate which ...
Definition: ldn.h:133
u64 auth_id
Random AuthenticationId.
Definition: ldn.h:147
u16 advertise_data_size
AdvertiseData size (ldnSetAdvertiseData)
Definition: ldn.h:144
s8 participant_max
Maximum participants, for nodes.
Definition: ldn.h:140
s8 link_level
LinkLevel.
Definition: ldn.h:132
u8 accept_policy
LdnAcceptPolicy
Definition: ldn.h:137
u16 userdata_filter
Arbitrary user data which can be used for filtering with LdnScanFilter.
Definition: ldn.h:126
u8 unk_x63
Only set with ldnScan / ldnScanPrivate, when unk_x4B is value 0x2.
Definition: ldn.h:138
LdnMacAddress mac_addr
LdnMacAddress
Definition: ldn.h:129
LdnSsid ssid
LdnSsid
Definition: ldn.h:130
u8 participant_num
ParticipantNum, number of set entries in nodes. If unk_x4B is not 0x2, ParticipantNum should be handl...
Definition: ldn.h:141
s16 network_channel
NetworkChannel.
Definition: ldn.h:131
NodeInfo.
Definition: ldn.h:105
LdnMacAddress mac_addr
LdnMacAddress
Definition: ldn.h:107
LdnIpv4Address ip_addr
LdnIpv4Address
Definition: ldn.h:106
s8 id
ID / index.
Definition: ldn.h:108
u8 is_connected
IsConnected flag.
Definition: ldn.h:109
s16 local_communication_version
LocalCommunicationVersion.
Definition: ldn.h:112
NodeLatestUpdate.
Definition: ldn.h:92
u8 val
The field in state is reset to zero by ldnGetNetworkInfoLatestUpdate after loading it.
Definition: ldn.h:93
ScanFilter. The input struct is copied to a tmp struct, which is then used with the cmd (ldnScan and ...
Definition: ldn.h:151
u16 userdata_filter
See LdnScanFilterFlags_UserData. During filtering if enabled, LdnNetworkInfo::unk_x4B must match 0x2,...
Definition: ldn.h:154
u32 flags
Bitmask for LdnScanFilterFlags. Masked with value 0x37 for ldnScan, with ldnScanPrivate this is maske...
Definition: ldn.h:161
u32 unk_x20
See LdnScanFilterFlags_Unknown2. When enabled, this must be <=0x3, and during filtering must match Ld...
Definition: ldn.h:157
LdnMacAddress mac_addr
LdnMacAddress (LdnScanFilterFlags_MacAddr, during filtering if enabled this must match LdnNetworkInfo...
Definition: ldn.h:158
LdnSsid ssid
LdnSsid (LdnScanFilterFlags_Ssid, during filtering if enabled this must match LdnNetworkInfo::ssid)
Definition: ldn.h:159
s64 local_communication_id
See LdnScanFilterFlags_LocalCommunicationId. When enabled, this will be overwritten if it's -1 (writt...
Definition: ldn.h:152
SecurityConfig.
Definition: ldn.h:165
u16 data_size
Data size. Must be 0x10-0x40.
Definition: ldn.h:167
u16 type
Type, a default of value 0x1 can be used here. Overwritten by ldnCreateNetwork, ldnCreateNetworkPriva...
Definition: ldn.h:166
SecurityParameter. The struct used by ldnCreateNetwork internally is randomly-generated.
Definition: ldn.h:172
Ssid.
Definition: ldn.h:86
u8 len
Length excluding NUL-terminator, must be 0x1-0x20.
Definition: ldn.h:87
SubnetMask. This is essentially the same as struct in_addr - hence this can be used with standard soc...
Definition: ldn.h:76
u32 mask
Mask.
Definition: ldn.h:77
UserConfig. The input struct is copied to a tmp struct, which is then used with the cmd.
Definition: ldn.h:117
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