libnx  v4.6.0
Data Structures | Enumerations | Functions
lp2p.h File Reference

lp2p service IPC wrapper, for local-WLAN communications with accessories. More...

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

Go to the source code of this file.

Data Structures

struct  Lp2pMacAddress
 MacAddress. More...
 
struct  Lp2pGroupId
 GroupId. More...
 
struct  Lp2pGroupInfo
 GroupInfo lp2pScan only uses the following fields for the cmd input struct: supported_platform/priority, frequency/channel, and preshared_key_binary_size/preshared_key. More...
 
struct  Lp2pScanResult
 ScanResult. More...
 
struct  Lp2pNodeInfo
 NodeInfo. More...
 
struct  Lp2pIpConfig
 IpConfig. Only contains IPv4 addresses. More...
 

Enumerations

enum  Lp2pServiceType {
  Lp2pServiceType_App = 0 ,
  Lp2pServiceType_System = 1
}
 

Functions

Result lp2pInitialize (Lp2pServiceType service_type)
 Initialize lp2p.
 
void lp2pExit (void)
 Exit lp2p.
 
Servicelp2pGetServiceSession_INetworkService (void)
 Gets the Service object for INetworkService.
 
Servicelp2pGetServiceSession_INetworkServiceMonitor (void)
 Gets the Service object for INetworkServiceMonitor.
 
void lp2pCreateGroupInfo (Lp2pGroupInfo *info)
 Creates a default Lp2pGroupInfo for use with lp2pCreateGroup / lp2pJoin. More...
 
void lp2pCreateGroupInfoScan (Lp2pGroupInfo *info)
 Creates a default Lp2pGroupInfo for use with lp2pScan. More...
 
void lp2pGroupInfoSetServiceName (Lp2pGroupInfo *info, const char *name)
 Sets Lp2pGroupInfo::service_name. More...
 
void lp2pGroupInfoSetFlags (Lp2pGroupInfo *info, s8 *flags, size_t count)
 Sets Lp2pGroupInfo::flags_count and Lp2pGroupInfo::flags. More...
 
static void lp2pGroupInfoSetMemberCountMax (Lp2pGroupInfo *info, size_t count)
 Sets Lp2pGroupInfo::member_count_max. More...
 
static void lp2pGroupInfoSetFrequencyChannel (Lp2pGroupInfo *info, u16 frequency, s16 channel)
 Sets Lp2pGroupInfo::frequency and Lp2pGroupInfo::channel. More...
 
static void lp2pGroupInfoSetStealthEnabled (Lp2pGroupInfo *info, bool flag)
 Sets Lp2pGroupInfo::stealth_enabled. More...
 
void lp2pGroupInfoSetPresharedKey (Lp2pGroupInfo *info, const void *key, size_t size)
 Sets the PresharedKey for the specified Lp2pGroupInfo. More...
 
Result lp2pGroupInfoSetPassphrase (Lp2pGroupInfo *info, const char *passphrase)
 Sets the passphrase, for when standard WPA2-PSK is being used. More...
 
INetworkService
Result lp2pScan (const Lp2pGroupInfo *info, Lp2pScanResult *results, s32 count, s32 *total_out)
 Scan. More...
 
Result lp2pCreateGroup (const Lp2pGroupInfo *info)
 CreateGroup. More...
 
Result lp2pDestroyGroup (void)
 This destroys the previously created group from lp2pCreateGroup. More...
 
Result lp2pSetAdvertiseData (const void *buffer, size_t size)
 SetAdvertiseData. More...
 
Result lp2pSendToOtherGroup (const void *buffer, size_t size, Lp2pMacAddress addr, Lp2pGroupId group_id, s16 frequency, s16 channel, u32 flags)
 This sends an Action frame to the specified Lp2pGroupId, with the specified destination Lp2pMacAddress. More...
 
Result lp2pRecvFromOtherGroup (void *buffer, size_t size, u32 flags, Lp2pMacAddress *addr, u16 *unk0, s32 *unk1, u64 *out_size, s32 *unk2)
 This receives an Action frame. More...
 
Result lp2pAddAcceptableGroupId (Lp2pGroupId group_id)
 AddAcceptableGroupId. More...
 
Result lp2pRemoveAcceptableGroupId (void)
 RemoveAcceptableGroupId.
 
INetworkServiceMonitor
Result lp2pAttachNetworkInterfaceStateChangeEvent (Event *out_event)
 AttachNetworkInterfaceStateChangeEvent. More...
 
Result lp2pGetNetworkInterfaceLastError (void)
 GetNetworkInterfaceLastError.
 
Result lp2pGetRole (u8 *out)
 GetRole. More...
 
Result lp2pGetAdvertiseData (void *buffer, size_t size, u16 *transfer_size, u16 *original_size)
 GetAdvertiseData. More...
 
Result lp2pGetAdvertiseData2 (void *buffer, size_t size, u16 *transfer_size, u16 *original_size)
 GetAdvertiseData2. More...
 
Result lp2pGetGroupInfo (Lp2pGroupInfo *out)
 GetGroupInfo. More...
 
Result lp2pJoin (Lp2pGroupInfo *out, const Lp2pGroupInfo *info)
 This runs the same code as lp2pCreateGroup to generate the Lp2pGroupInfo for the input struct. More...
 
Result lp2pGetGroupOwner (Lp2pNodeInfo *out)
 GetGroupOwner. More...
 
Result lp2pGetIpConfig (Lp2pIpConfig *out)
 GetIpConfig. More...
 
Result lp2pLeave (u32 *out)
 Leave. More...
 
Result lp2pAttachJoinEvent (Event *out_event)
 AttachJoinEvent. More...
 
Result lp2pGetMembers (Lp2pNodeInfo *members, s32 count, s32 *total_out)
 GetMembers. More...
 

Detailed Description

lp2p service IPC wrapper, for local-WLAN communications with accessories.

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

Note
Only available on [9.1.0+].
Author
yellows8

Enumeration Type Documentation

◆ Lp2pServiceType

Enumerator
Lp2pServiceType_App 

Initializes lp2p:app.

Lp2pServiceType_System 

Initializes lp2p:sys.

Function Documentation

◆ lp2pAddAcceptableGroupId()

Result lp2pAddAcceptableGroupId ( Lp2pGroupId  group_id)

AddAcceptableGroupId.

Parameters
[in]group_idLp2pGroupId

◆ lp2pAttachJoinEvent()

Result lp2pAttachJoinEvent ( Event out_event)

AttachJoinEvent.

Note
The Event must be closed by the user once finished with it.
Parameters
[out]out_eventOutput Event with autoclear=false.

◆ lp2pAttachNetworkInterfaceStateChangeEvent()

Result lp2pAttachNetworkInterfaceStateChangeEvent ( Event out_event)

AttachNetworkInterfaceStateChangeEvent.

Note
The Event must be closed by the user once finished with it.
Parameters
[out]out_eventOutput Event with autoclear=false.

◆ lp2pCreateGroup()

Result lp2pCreateGroup ( const Lp2pGroupInfo info)

CreateGroup.

Note
The role (lp2pGetRole) must be 0. This eventually sets the role to value 1.
Parameters
[in]infoLp2pGroupInfo

◆ lp2pCreateGroupInfo()

void lp2pCreateGroupInfo ( Lp2pGroupInfo info)

Creates a default Lp2pGroupInfo for use with lp2pCreateGroup / lp2pJoin.

Parameters
infoLp2pGroupInfo

◆ lp2pCreateGroupInfoScan()

void lp2pCreateGroupInfoScan ( Lp2pGroupInfo info)

Creates a default Lp2pGroupInfo for use with lp2pScan.

Parameters
infoLp2pGroupInfo

◆ lp2pDestroyGroup()

Result lp2pDestroyGroup ( void  )

This destroys the previously created group from lp2pCreateGroup.

Note
If no group was previously created (role from lp2pGetRole is not 1), this just returns 0.

◆ lp2pGetAdvertiseData()

Result lp2pGetAdvertiseData ( void *  buffer,
size_t  size,
u16 transfer_size,
u16 original_size 
)

GetAdvertiseData.

Note
The role from lp2pGetRole must be value 2.
Parameters
[out]bufferOutput buffer data.
[in]sizeOutput buffer size.
[out]transfer_sizeSize of the data copied into the buffer.
[out]original_sizeOriginal size from state.

◆ lp2pGetAdvertiseData2()

Result lp2pGetAdvertiseData2 ( void *  buffer,
size_t  size,
u16 transfer_size,
u16 original_size 
)

GetAdvertiseData2.

Note
This is identical to lp2pGetAdvertiseData except this doesn't run the role validation.
Parameters
[out]bufferOutput buffer data.
[in]sizeOutput buffer size.
[out]transfer_sizeSize of the data copied into the buffer.
[out]original_sizeOriginal size from state.

◆ lp2pGetGroupInfo()

Result lp2pGetGroupInfo ( Lp2pGroupInfo out)

GetGroupInfo.

Note
The role from lp2pGetRole must be non-zero.
Parameters
[out]outLp2pGroupInfo

◆ lp2pGetGroupOwner()

Result lp2pGetGroupOwner ( Lp2pNodeInfo out)

GetGroupOwner.

Note
The role from lp2pGetRole must be non-zero.
Parameters
[out]outLp2pNodeInfo

◆ lp2pGetIpConfig()

Result lp2pGetIpConfig ( Lp2pIpConfig out)

GetIpConfig.

Note
The role from lp2pGetRole must be non-zero.
Parameters
[out]outLp2pIpConfig

◆ lp2pGetMembers()

Result lp2pGetMembers ( Lp2pNodeInfo members,
s32  count,
s32 total_out 
)

GetMembers.

Note
The role from lp2pGetRole must be value 1.
Parameters
[out]membersOutput array of Lp2pNodeInfo.
[in]countSize of the members array in entries. A maximum of 8 entries can be returned.
[out]total_outTotal output entries.

◆ lp2pGetRole()

Result lp2pGetRole ( u8 out)

GetRole.

Parameters
[out]outOutput Role.

◆ lp2pGroupInfoSetFlags()

void lp2pGroupInfoSetFlags ( Lp2pGroupInfo info,
s8 flags,
size_t  count 
)

Sets Lp2pGroupInfo::flags_count and Lp2pGroupInfo::flags.

Note
The default is count=1 flags[0]=1, which is used by lp2pCreateGroupInfo. [11.0.0+] To use standard WPA2-PSK, you can use flags[0]=0.
Parameters
infoLp2pGroupInfo
[in]flagsLp2pGroupInfo::flags
[in]countLp2pGroupInfo::flags_count

◆ lp2pGroupInfoSetFrequencyChannel()

static void lp2pGroupInfoSetFrequencyChannel ( Lp2pGroupInfo info,
u16  frequency,
s16  channel 
)
inlinestatic

◆ lp2pGroupInfoSetMemberCountMax()

static void lp2pGroupInfoSetMemberCountMax ( Lp2pGroupInfo info,
size_t  count 
)
inlinestatic

Sets Lp2pGroupInfo::member_count_max.

Parameters
infoLp2pGroupInfo
[in]countMemberCountMax

◆ lp2pGroupInfoSetPassphrase()

Result lp2pGroupInfoSetPassphrase ( Lp2pGroupInfo info,
const char *  passphrase 
)

Sets the passphrase, for when standard WPA2-PSK is being used.

Note
Configure standard WPA2-PSK usage via lp2pGroupInfoSetFlags / Lp2pGroupInfo::security_type.
Only available on [11.0.0+].
Parameters
infoLp2pGroupInfo
[in]passphrasePassphrase string, the required length is 0x8-0x3F.

◆ lp2pGroupInfoSetPresharedKey()

void lp2pGroupInfoSetPresharedKey ( Lp2pGroupInfo info,
const void *  key,
size_t  size 
)

Sets the PresharedKey for the specified Lp2pGroupInfo.

Note
Using this is required before using the Lp2pGroupInfo as input for any cmds, so that Lp2pGroupInfo::preshared_key_binary_size gets initialized.
If standard WPA2-PSK is being used, use lp2pGroupInfoSetPassphrase instead.
Parameters
infoLp2pGroupInfo
[in]keyData for the PresharedKey.
[in]sizeSize to copy into the PresharedKey, max is 0x20.

◆ lp2pGroupInfoSetServiceName()

void lp2pGroupInfoSetServiceName ( Lp2pGroupInfo info,
const char *  name 
)

Sets Lp2pGroupInfo::service_name.

Parameters
infoLp2pGroupInfo
[in]nameServiceName / SSID.

◆ lp2pGroupInfoSetStealthEnabled()

static void lp2pGroupInfoSetStealthEnabled ( Lp2pGroupInfo info,
bool  flag 
)
inlinestatic

◆ lp2pJoin()

Result lp2pJoin ( Lp2pGroupInfo out,
const Lp2pGroupInfo info 
)

This runs the same code as lp2pCreateGroup to generate the Lp2pGroupInfo for the input struct.

Parameters
[out]outLp2pGroupInfo
[in]infoLp2pGroupInfo

◆ lp2pLeave()

Result lp2pLeave ( u32 out)

Leave.

Parameters
[out]outOutput value.

◆ lp2pRecvFromOtherGroup()

Result lp2pRecvFromOtherGroup ( void *  buffer,
size_t  size,
u32  flags,
Lp2pMacAddress addr,
u16 unk0,
s32 unk1,
u64 out_size,
s32 unk2 
)

This receives an Action frame.

Note
The role (lp2pGetRole) must be non-zero.
When data is not available, the error from lp2pGetNetworkInterfaceLastError will be returned if it's set.
Parameters
[out]bufferOutput buffer containing arbitrary user data.
[in]sizeOutput buffer size.
[in]flagsOnly bit0 is used: clear = block until data is available, set = return error when data is not available.
[in]addrLp2pMacAddress
[in]unk0Unknown
[in]unk1Unknown
[out]out_sizeThis is the original size used for copying to the output buffer, before it's clamped to the output-buffer size.
[out]unk2Unknown

◆ lp2pScan()

Result lp2pScan ( const Lp2pGroupInfo info,
Lp2pScanResult results,
s32  count,
s32 total_out 
)

Scan.

Parameters
[in]infoLp2pGroupInfo
[out]resultsOutput array of Lp2pScanResult.
[in]countSize of the results array in entries.
[out]total_outTotal output entries.

◆ lp2pSendToOtherGroup()

Result lp2pSendToOtherGroup ( const void *  buffer,
size_t  size,
Lp2pMacAddress  addr,
Lp2pGroupId  group_id,
s16  frequency,
s16  channel,
u32  flags 
)

This sends an Action frame to the specified Lp2pGroupId, with the specified destination Lp2pMacAddress.

Note
The role (lp2pGetRole) must be non-zero.
The error from lp2pGetNetworkInterfaceLastError will be returned if it's set.
[11.0.0+] Lp2pGroupInfo::security_type must be value 2 (default encryption), otherwise an error is returned.
Parameters
[in]bufferInput buffer containing arbitrary user data.
[in]sizeInput buffer size, must be <=0x400.
[in]addrLp2pMacAddress, this can be a broadcast address. This must be non-zero.
[in]group_idLp2pGroupId
[in]frequencyMust be >=1. See Lp2pGroupInfo::frequency.
[in]channelMust be >=1. See Lp2pGroupInfo::channel.
[in]flagsOnly bit0 is used: clear = block until the data can be sent, set = return error when the data can't be sent.

◆ lp2pSetAdvertiseData()

Result lp2pSetAdvertiseData ( const void *  buffer,
size_t  size 
)

SetAdvertiseData.

Note
The role (lp2pGetRole) must be <=1.
An empty buffer (buffer=NULL/size=0) can be used to reset the AdvertiseData size in state to zero.
Parameters
[out]bufferInput buffer containing arbitrary user data.
[in]sizeInput buffer size, must be <=0x80.