libnx  v4.6.0
Data Structures | Enumerations
ldn.h File Reference

LDN (local network communications) IPC wrapper. More...

#include "../types.h"
#include "../sf/service.h"
#include "../kernel/event.h"

Go to the source code of this file.

Data Structures

struct  LdnIpv4Address
 Ipv4Address. This is essentially the same as struct in_addr - hence this can be used with standard sockets (byteswap required). More...
 
struct  LdnSubnetMask
 SubnetMask. This is essentially the same as struct in_addr - hence this can be used with standard sockets (byteswap required). More...
 
struct  LdnMacAddress
 MacAddress. More...
 
struct  LdnSsid
 Ssid. More...
 
struct  LdnNodeLatestUpdate
 NodeLatestUpdate. More...
 
struct  LdnAddressEntry
 AddressEntry. More...
 
struct  LdnNodeInfo
 NodeInfo. More...
 
struct  LdnUserConfig
 UserConfig. The input struct is copied to a tmp struct, which is then used with the cmd. More...
 
struct  LdnNetworkInfo
 NetworkInfo. More...
 
struct  LdnScanFilter
 ScanFilter. The input struct is copied to a tmp struct, which is then used with the cmd (ldnScan and ldnScanPrivate). More...
 
struct  LdnSecurityConfig
 SecurityConfig. More...
 
struct  LdnSecurityParameter
 SecurityParameter. The struct used by ldnCreateNetwork internally is randomly-generated. More...
 
struct  LdnNetworkConfig
 NetworkConfig. The input struct is copied to a tmp struct, which is then used with the cmd (ldnCreateNetwork, ldnCreateNetworkPrivate, ldnConnectPrivate). More...
 

Enumerations

enum  LdnServiceType {
  LdnServiceType_User = 0 ,
  LdnServiceType_System = 1
}
 
enum  LdnState {
  LdnState_None = 0 ,
  LdnState_Initialized = 1 ,
  LdnState_AccessPointOpened = 2 ,
  LdnState_AccessPointCreated = 3 ,
  LdnState_StationOpened = 4 ,
  LdnState_StationConnected = 5 ,
  LdnState_Error = 6
}
 State loaded by ldnmGetStateForMonitor / ldnGetState. More...
 
enum  LdnDisconnectReason {
  LdnDisconnectReason_None = 0 ,
  LdnDisconnectReason_User = 1 ,
  LdnDisconnectReason_SystemRequest = 2 ,
  LdnDisconnectReason_DestroyedByAdmin = 3 ,
  LdnDisconnectReason_DestroyedBySystemRequest = 4 ,
  LdnDisconnectReason_Admin = 5 ,
  LdnDisconnectReason_SignalLost = 6
}
 DisconnectReason loaded by ldnGetDisconnectReason. More...
 
enum  LdnScanFilterFlags {
  LdnScanFilterFlags_LocalCommunicationId = (1U<<( 0 )) ,
  LdnScanFilterFlags_NetworkId = (1U<<( 1 )) ,
  LdnScanFilterFlags_Unknown2 = (1U<<( 2 )) ,
  LdnScanFilterFlags_MacAddr = (1U<<( 3 )) ,
  LdnScanFilterFlags_Ssid = (1U<<( 4 )) ,
  LdnScanFilterFlags_UserData = (1U<<( 5 ))
}
 ScanFilterFlags. More...
 
enum  LdnAcceptPolicy {
  LdnAcceptPolicy_AllowAll = 0 ,
  LdnAcceptPolicy_DenyAll = 1 ,
  LdnAcceptPolicy_Blacklist = 2 ,
  LdnAcceptPolicy_Whitelist = 3
}
 AcceptPolicy. More...
 
enum  LdnOperationMode {
  LdnOperationMode_Unknown0 = 0 ,
  LdnOperationMode_Unknown1 = 1
}
 OperationMode. More...
 
enum  LdnWirelessControllerRestriction {
  LdnWirelessControllerRestriction_Unknown0 = 0 ,
  LdnWirelessControllerRestriction_Unknown1 = 1
}
 WirelessControllerRestriction. More...
 

Functions

ldn:m
Result ldnmInitialize (void)
 Initialize ldn:m.
 
void ldnmExit (void)
 Exit ldn:m.
 
ServiceldnmGetServiceSession_MonitorService (void)
 Gets the Service object for IMonitorService.
 
Result ldnmGetStateForMonitor (LdnState *out)
 GetStateForMonitor. More...
 
Result ldnmGetNetworkInfoForMonitor (LdnNetworkInfo *out)
 GetNetworkInfoForMonitor. More...
 
Result ldnmGetIpv4AddressForMonitor (LdnIpv4Address *addr, LdnSubnetMask *mask)
 GetIpv4AddressForMonitor. More...
 
Result ldnmGetSecurityParameterForMonitor (LdnSecurityParameter *out)
 GetSecurityParameterForMonitor. More...
 
Result ldnmGetNetworkConfigForMonitor (LdnNetworkConfig *out)
 GetNetworkConfigForMonitor. More...
 
ldn
Result ldnInitialize (LdnServiceType service_type)
 Initialize ldn.
 
void ldnExit (void)
 Exit ldn.
 
ServiceldnGetServiceSession_LocalCommunicationService (void)
 Gets the Service object for IUserLocalCommunicationService/ISystemLocalCommunicationService.
 
Result ldnGetState (LdnState *out)
 GetState. More...
 
Result ldnGetNetworkInfo (LdnNetworkInfo *out)
 GetNetworkInfo. More...
 
Result ldnGetIpv4Address (LdnIpv4Address *addr, LdnSubnetMask *mask)
 GetIpv4Address. More...
 
Result ldnGetDisconnectReason (LdnDisconnectReason *out)
 GetDisconnectReason. More...
 
Result ldnGetSecurityParameter (LdnSecurityParameter *out)
 GetSecurityParameter. More...
 
Result ldnGetNetworkConfig (LdnNetworkConfig *out)
 GetNetworkConfig. More...
 
Result ldnAttachStateChangeEvent (Event *out_event)
 AttachStateChangeEvent. More...
 
Result ldnGetNetworkInfoLatestUpdate (LdnNetworkInfo *network_info, LdnNodeLatestUpdate *nodes, s32 count)
 GetNetworkInfoLatestUpdate. More...
 
Result ldnScan (s32 channel, const LdnScanFilter *filter, LdnNetworkInfo *network_info, s32 count, s32 *total_out)
 Scan. More...
 
Result ldnScanPrivate (s32 channel, const LdnScanFilter *filter, LdnNetworkInfo *network_info, s32 count, s32 *total_out)
 ScanPrivate. More...
 
Result ldnSetWirelessControllerRestriction (LdnWirelessControllerRestriction restriction)
 SetWirelessControllerRestriction. More...
 
Result ldnOpenAccessPoint (void)
 OpenAccessPoint. More...
 
Result ldnCloseAccessPoint (void)
 CloseAccessPoint. More...
 
Result ldnCreateNetwork (const LdnSecurityConfig *sec_config, const LdnUserConfig *user_config, const LdnNetworkConfig *network_config)
 CreateNetwork. More...
 
Result ldnCreateNetworkPrivate (const LdnSecurityConfig *sec_config, const LdnSecurityParameter *sec_param, const LdnUserConfig *user_config, const LdnNetworkConfig *network_config, const LdnAddressEntry *addrs, s32 count)
 CreateNetworkPrivate. More...
 
Result ldnDestroyNetwork (void)
 DestroyNetwork. More...
 
Result ldnReject (LdnIpv4Address addr)
 Reject. More...
 
Result ldnSetAdvertiseData (const void *buffer, size_t size)
 SetAdvertiseData. More...
 
Result ldnSetStationAcceptPolicy (LdnAcceptPolicy policy)
 SetStationAcceptPolicy. More...
 
Result ldnAddAcceptFilterEntry (LdnMacAddress addr)
 AddAcceptFilterEntry. More...
 
Result ldnClearAcceptFilter (void)
 ClearAcceptFilter. More...
 
Result ldnOpenStation (void)
 OpenStation. More...
 
Result ldnCloseStation (void)
 CloseStation. More...
 
Result ldnConnect (const LdnSecurityConfig *sec_config, const LdnUserConfig *user_config, s32 version, u32 option, const LdnNetworkInfo *network_info)
 Connect. More...
 
Result ldnConnectPrivate (const LdnSecurityConfig *sec_config, const LdnSecurityParameter *sec_param, const LdnUserConfig *user_config, s32 version, u32 option, const LdnNetworkConfig *network_config)
 ConnectPrivate. More...
 
Result ldnDisconnect (void)
 Disconnect. More...
 
Result ldnSetOperationMode (LdnOperationMode mode)
 SetOperationMode. More...
 

Detailed Description

LDN (local network communications) IPC wrapper.

See also: https://switchbrew.org/wiki/LDN_services

Author
yellows8

Enumeration Type Documentation

◆ LdnAcceptPolicy

AcceptPolicy.

Enumerator
LdnAcceptPolicy_AllowAll 

Allow all.

LdnAcceptPolicy_DenyAll 

Deny all.

LdnAcceptPolicy_Blacklist 

Blacklist, addresses in the list (ldnAddAcceptFilterEntry) are not allowed.

LdnAcceptPolicy_Whitelist 

Whitelist, only addresses in the list (ldnAddAcceptFilterEntry) are allowed.

◆ LdnDisconnectReason

DisconnectReason loaded by ldnGetDisconnectReason.

Enumerator
LdnDisconnectReason_None 

None.

LdnDisconnectReason_User 

User.

LdnDisconnectReason_SystemRequest 

SystemRequest.

LdnDisconnectReason_DestroyedByAdmin 

DestroyedByAdmin.

LdnDisconnectReason_DestroyedBySystemRequest 

DestroyedBySystemRequest.

LdnDisconnectReason_Admin 

Admin.

LdnDisconnectReason_SignalLost 

SignalLost.

◆ LdnOperationMode

OperationMode.

Enumerator
LdnOperationMode_Unknown0 

Unknown.

LdnOperationMode_Unknown1 

Unknown.

◆ LdnScanFilterFlags

ScanFilterFlags.

Enumerator
LdnScanFilterFlags_LocalCommunicationId 

When set, enables using LdnScanFilter::local_communication_id.

LdnScanFilterFlags_NetworkId 

When set, enables using LdnScanFilter::network_id.

LdnScanFilterFlags_Unknown2 

When set, enables using LdnScanFilter::unk_x20.

LdnScanFilterFlags_MacAddr 

When set, enables using LdnScanFilter::mac_addr. Only available with ldnScanPrivate.

LdnScanFilterFlags_Ssid 

When set, enables using the LdnScanFilter::ssid.

LdnScanFilterFlags_UserData 

When set, enables using LdnScanFilter::userdata_filter.

◆ LdnServiceType

Enumerator
LdnServiceType_User 

Initializes ldn:u.

LdnServiceType_System 

Initializes ldn:s.

◆ LdnState

enum LdnState

State loaded by ldnmGetStateForMonitor / ldnGetState.

Enumerator
LdnState_None 

None.

LdnState_Initialized 

Initialized.

LdnState_AccessPointOpened 

AccessPointOpened (ldnOpenAccessPoint)

LdnState_AccessPointCreated 

AccessPointCreated (ldnCreateNetwork / ldnCreateNetworkPrivate)

LdnState_StationOpened 

StationOpened (ldnOpenStation)

LdnState_StationConnected 

StationConnected (ldnConnect / ldnConnectPrivate)

LdnState_Error 

Error.

◆ LdnWirelessControllerRestriction

WirelessControllerRestriction.

Enumerator
LdnWirelessControllerRestriction_Unknown0 

Unknown.

LdnWirelessControllerRestriction_Unknown1 

Unknown.

Function Documentation

◆ ldnAddAcceptFilterEntry()

Result ldnAddAcceptFilterEntry ( LdnMacAddress  addr)

AddAcceptFilterEntry.

Note
LdnState must be LdnState_AccessPointOpened or LdnState_AccessPointCreated.
See LdnAcceptPolicy.
Parameters
[in]addrLdnMacAddress. If you want, you can also pass LdnNodeInfo::mac_addr for this.

◆ ldnAttachStateChangeEvent()

Result ldnAttachStateChangeEvent ( Event out_event)

AttachStateChangeEvent.

Note
The Event must be closed by the user once finished with it.
This is signaled when the data returned by ldnGetNetworkInfo / ldnGetNetworkInfoLatestUpdate is updated.
Parameters
[out]out_eventOutput Event with autoclear=true.

◆ ldnClearAcceptFilter()

Result ldnClearAcceptFilter ( void  )

◆ ldnCloseAccessPoint()

Result ldnCloseAccessPoint ( void  )

CloseAccessPoint.

Note
LdnState must be LdnState_AccessPointOpened or LdnState_AccessPointCreated, this eventually sets the State to LdnState_Initialized.
Used automatically internally by ldnExit if needed.

◆ ldnCloseStation()

Result ldnCloseStation ( void  )

CloseStation.

Note
LdnState must be LdnState_StationOpened or LdnState_StationConnected, this eventually sets the State to LdnState_Initialized.
Used automatically internally by ldnExit if needed.

◆ ldnConnect()

Result ldnConnect ( const LdnSecurityConfig sec_config,
const LdnUserConfig user_config,
s32  version,
u32  option,
const LdnNetworkInfo network_info 
)

Connect.

Note
LdnState must be LdnState_StationOpened, this eventually sets the State to LdnState_StationConnected.
This is identical to ldnConnectPrivate besides the used params, the code overwriting LdnSecurityConfig::type also differs.
Parameters
[in]sec_configLdnSecurityConfig
[in]user_configLdnUserConfig
[in]versionLocalCommunicationVersion, this must be 0x0-0x7FFF.
[in]optionConnectOption bitmask, must be <=0x1. You can use value 0 for example here.
[in]network_infoLdnNetworkInfo

◆ ldnConnectPrivate()

Result ldnConnectPrivate ( const LdnSecurityConfig sec_config,
const LdnSecurityParameter sec_param,
const LdnUserConfig user_config,
s32  version,
u32  option,
const LdnNetworkConfig network_config 
)

ConnectPrivate.

Note
LdnState must be LdnState_StationOpened, this eventually sets the State to LdnState_StationConnected.
See ldnConnect.
Parameters
[in]sec_configLdnSecurityConfig
[in]sec_paramLdnSecurityParameter
[in]user_configLdnUserConfig
[in]versionLocalCommunicationVersion, this must be 0x0-0x7FFF.
[in]optionConnectOption bitmask, must be <=0x1. You can use value 0 for example here.
[in]network_configLdnNetworkConfig

◆ ldnCreateNetwork()

Result ldnCreateNetwork ( const LdnSecurityConfig sec_config,
const LdnUserConfig user_config,
const LdnNetworkConfig network_config 
)

CreateNetwork.

Note
LdnState must be LdnState_AccessPointOpened, this eventually sets the State to LdnState_AccessPointCreated.
Parameters
[in]sec_configLdnSecurityConfig
[in]user_configLdnUserConfig
[in]network_configLdnNetworkConfig

◆ ldnCreateNetworkPrivate()

Result ldnCreateNetworkPrivate ( const LdnSecurityConfig sec_config,
const LdnSecurityParameter sec_param,
const LdnUserConfig user_config,
const LdnNetworkConfig network_config,
const LdnAddressEntry addrs,
s32  count 
)

CreateNetworkPrivate.

Note
LdnState must be LdnState_AccessPointOpened, this eventually sets the State to LdnState_AccessPointCreated.
This is the same as ldnCreateNetwork besides the additional user-specified params, and with this cmd LdnNetworkConfig::channel is not overwritten (unlike ldnCreateNetwork).
Parameters
[in]sec_configLdnSecurityConfig
[in]sec_paramLdnSecurityParameter
[in]user_configLdnUserConfig
[in]network_configLdnNetworkConfig
[in]addrsInput array of LdnAddressEntry. This can be NULL.
[in]countSize of the addrs array in entries. This must be <=8. This can be 0, in which case the network will be non-Private like ldnCreateNetwork.

◆ ldnDestroyNetwork()

Result ldnDestroyNetwork ( void  )

DestroyNetwork.

Note
LdnState must be LdnState_AccessPointCreated, this eventually sets the State to LdnState_AccessPointOpened.

◆ ldnDisconnect()

Result ldnDisconnect ( void  )

Disconnect.

Note
LdnState must be LdnState_StationConnected, this eventually sets the State to LdnState_StationOpened.

◆ ldnGetDisconnectReason()

Result ldnGetDisconnectReason ( LdnDisconnectReason out)

GetDisconnectReason.

Parameters
[out]outLdnDisconnectReason

◆ ldnGetIpv4Address()

Result ldnGetIpv4Address ( LdnIpv4Address addr,
LdnSubnetMask mask 
)

GetIpv4Address.

Parameters
[out]addrLdnIpv4Address
[out]maskLdnSubnetMask

◆ ldnGetNetworkConfig()

Result ldnGetNetworkConfig ( LdnNetworkConfig out)

GetNetworkConfig.

Parameters
[out]outLdnNetworkConfig

◆ ldnGetNetworkInfo()

Result ldnGetNetworkInfo ( LdnNetworkInfo out)

GetNetworkInfo.

Parameters
[out]outLdnNetworkInfo

◆ ldnGetNetworkInfoLatestUpdate()

Result ldnGetNetworkInfoLatestUpdate ( LdnNetworkInfo network_info,
LdnNodeLatestUpdate nodes,
s32  count 
)

GetNetworkInfoLatestUpdate.

Parameters
[out]network_infoLdnNetworkInfo
[out]nodesOutput array of LdnNodeLatestUpdate.
[in]countSize of the nodes array in entries, must be 8.

◆ ldnGetSecurityParameter()

Result ldnGetSecurityParameter ( LdnSecurityParameter out)

GetSecurityParameter.

Parameters
[out]outLdnSecurityParameter

◆ ldnGetState()

Result ldnGetState ( LdnState out)

GetState.

Parameters
[out]outLdnState

◆ ldnmGetIpv4AddressForMonitor()

Result ldnmGetIpv4AddressForMonitor ( LdnIpv4Address addr,
LdnSubnetMask mask 
)

GetIpv4AddressForMonitor.

Parameters
[out]addrLdnIpv4Address
[out]maskLdnSubnetMask

◆ ldnmGetNetworkConfigForMonitor()

Result ldnmGetNetworkConfigForMonitor ( LdnNetworkConfig out)

GetNetworkConfigForMonitor.

Note
Not exposed by official sw.
Parameters
[out]outLdnNetworkConfig

◆ ldnmGetNetworkInfoForMonitor()

Result ldnmGetNetworkInfoForMonitor ( LdnNetworkInfo out)

GetNetworkInfoForMonitor.

Parameters
[out]outLdnNetworkInfo

◆ ldnmGetSecurityParameterForMonitor()

Result ldnmGetSecurityParameterForMonitor ( LdnSecurityParameter out)

GetSecurityParameterForMonitor.

Note
Not exposed by official sw.
Parameters
[out]outLdnSecurityParameter

◆ ldnmGetStateForMonitor()

Result ldnmGetStateForMonitor ( LdnState out)

GetStateForMonitor.

Parameters
[out]outLdnState

◆ ldnOpenAccessPoint()

Result ldnOpenAccessPoint ( void  )

OpenAccessPoint.

Note
LdnState must be LdnState_Initialized, this eventually sets the State to LdnState_AccessPointOpened.

◆ ldnOpenStation()

Result ldnOpenStation ( void  )

OpenStation.

Note
LdnState must be LdnState_Initialized, this eventually sets the State to LdnState_StationOpened.

◆ ldnReject()

Result ldnReject ( LdnIpv4Address  addr)

Reject.

Note
LdnState must be LdnState_AccessPointCreated.
Parameters
[in]addrLdnIpv4Address

◆ ldnScan()

Result ldnScan ( s32  channel,
const LdnScanFilter filter,
LdnNetworkInfo network_info,
s32  count,
s32 total_out 
)

Scan.

Note
LdnState must be LdnState_AccessPointCreated, LdnState_StationOpened, or LdnState_StationConnected.
This is the same as ldnScanPrivate (minus the masking for LdnScanFilter::flags), except this has the same channel-override functionality as ldnCreateNetwork.
Parameters
[in]channelChannel, value 0 can be used for this.
[in]filterLdnScanFilter
[out]network_infoOutput array of LdnNetworkInfo.
[in]countSize of the network_info array in entries. Must be at least 1, this is clamped to a maximum of 0x18 internally.
[out]total_outTotal output entries.

◆ ldnScanPrivate()

Result ldnScanPrivate ( s32  channel,
const LdnScanFilter filter,
LdnNetworkInfo network_info,
s32  count,
s32 total_out 
)

ScanPrivate.

Note
LdnState must be LdnState_AccessPointCreated, LdnState_StationOpened, or LdnState_StationConnected.
See ldnScan.
Parameters
[in]channelChannel, value 0 can be used for this.
[in]filterLdnScanFilter
[out]network_infoOutput array of LdnNetworkInfo.
[in]countSize of the network_info array in entries. Must be at least 1, this is clamped to a maximum of 0x18 internally.
[out]total_outTotal output entries.

◆ ldnSetAdvertiseData()

Result ldnSetAdvertiseData ( const void *  buffer,
size_t  size 
)

SetAdvertiseData.

Note
An empty buffer (buffer=NULL/size=0) can be used to reset the AdvertiseData size in state to zero.
LdnState must be LdnState_AccessPointOpened or LdnState_AccessPointCreated.
Parameters
[in]bufferInput buffer containing arbitrary user data.
[in]sizeInput 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).

◆ ldnSetOperationMode()

Result ldnSetOperationMode ( LdnOperationMode  mode)

SetOperationMode.

Note
Only available on [4.0.0+].
Only available with LdnServiceType_System.
LdnState must be LdnState_Initialized.
Parameters
[in]modeLdnOperationMode

◆ ldnSetStationAcceptPolicy()

Result ldnSetStationAcceptPolicy ( LdnAcceptPolicy  policy)

SetStationAcceptPolicy.

Note
LdnState must be LdnState_AccessPointOpened or LdnState_AccessPointCreated.
Parameters
[in]policyLdnAcceptPolicy

◆ ldnSetWirelessControllerRestriction()

Result ldnSetWirelessControllerRestriction ( LdnWirelessControllerRestriction  restriction)

SetWirelessControllerRestriction.

Note
Only available on [5.0.0+].
LdnState must be LdnState_Initialized.
Parameters
[in]restrictionLdnWirelessControllerRestriction