ldn: Updated/added structs+enums and docs.

This commit is contained in:
yellows8 2025-07-25 21:54:32 -04:00
parent 0d1db81224
commit 83bb6a7103
No known key found for this signature in database
GPG Key ID: 0AF90DA3F1E60E43
2 changed files with 127 additions and 104 deletions

View File

@ -19,9 +19,9 @@ typedef enum {
typedef enum { typedef enum {
LdnState_None = 0, ///< None LdnState_None = 0, ///< None
LdnState_Initialized = 1, ///< Initialized LdnState_Initialized = 1, ///< Initialized
LdnState_AccessPointOpened = 2, ///< AccessPointOpened (\ref ldnOpenAccessPoint) LdnState_AccessPoint = 2, ///< AccessPoint (\ref ldnOpenAccessPoint)
LdnState_AccessPointCreated = 3, ///< AccessPointCreated (\ref ldnCreateNetwork / \ref ldnCreateNetworkPrivate) LdnState_AccessPointCreated = 3, ///< AccessPointCreated (\ref ldnCreateNetwork / \ref ldnCreateNetworkPrivate)
LdnState_StationOpened = 4, ///< StationOpened (\ref ldnOpenStation) LdnState_Station = 4, ///< Station (\ref ldnOpenStation)
LdnState_StationConnected = 5, ///< StationConnected (\ref ldnConnect / \ref ldnConnectPrivate) LdnState_StationConnected = 5, ///< StationConnected (\ref ldnConnect / \ref ldnConnectPrivate)
LdnState_Error = 6, ///< Error LdnState_Error = 6, ///< Error
} LdnState; } LdnState;
@ -29,42 +29,52 @@ typedef enum {
/// DisconnectReason loaded by \ref ldnGetDisconnectReason. /// DisconnectReason loaded by \ref ldnGetDisconnectReason.
typedef enum { typedef enum {
LdnDisconnectReason_None = 0, ///< None LdnDisconnectReason_None = 0, ///< None
LdnDisconnectReason_User = 1, ///< User LdnDisconnectReason_DisconnectedByUser = 1, ///< DisconnectedByUser
LdnDisconnectReason_SystemRequest = 2, ///< SystemRequest LdnDisconnectReason_DisconnectedBySystem = 2, ///< DisconnectedBySystem
LdnDisconnectReason_DestroyedByAdmin = 3, ///< DestroyedByAdmin LdnDisconnectReason_DestroyedByUser = 3, ///< DestroyedByUser
LdnDisconnectReason_DestroyedBySystemRequest = 4, ///< DestroyedBySystemRequest LdnDisconnectReason_DestroyedBySystem = 4, ///< DestroyedBySystem
LdnDisconnectReason_Admin = 5, ///< Admin LdnDisconnectReason_Rejected = 5, ///< Rejected
LdnDisconnectReason_SignalLost = 6, ///< SignalLost LdnDisconnectReason_SignalLost = 6, ///< SignalLost
} LdnDisconnectReason; } LdnDisconnectReason;
/// ScanFilterFlags /// ScanFilterFlag
typedef enum { typedef enum {
LdnScanFilterFlags_LocalCommunicationId = BIT(0), ///< When set, enables using LdnScanFilter::local_communication_id. LdnScanFilterFlag_LocalCommunicationId = BIT(0), ///< Enables using LdnScanFilter::network_id LdnIntentId::local_communication_id.
LdnScanFilterFlags_NetworkId = BIT(1), ///< When set, enables using LdnScanFilter::network_id. LdnScanFilterFlag_SessionId = BIT(1), ///< Enables using LdnScanFilter::network_id session_id.
LdnScanFilterFlags_Unknown2 = BIT(2), ///< When set, enables using LdnScanFilter::unk_x20. LdnScanFilterFlag_NetworkType = BIT(2), ///< Enables using LdnScanFilter::network_type.
LdnScanFilterFlags_MacAddr = BIT(3), ///< When set, enables using LdnScanFilter::mac_addr. Only available with \ref ldnScanPrivate. LdnScanFilterFlag_Bssid = BIT(3), ///< Enables using LdnScanFilter::bssid. Only available with \ref ldnScanPrivate.
LdnScanFilterFlags_Ssid = BIT(4), ///< When set, enables using the LdnScanFilter::ssid. LdnScanFilterFlag_Ssid = BIT(4), ///< Enables using LdnScanFilter::ssid.
LdnScanFilterFlags_UserData = BIT(5), ///< When set, enables using LdnScanFilter::userdata_filter. LdnScanFilterFlag_SceneId = BIT(5), ///< Enables using LdnScanFilter::network_id LdnIntentId::scene_id.
} LdnScanFilterFlags; LdnScanFilterFlag_IntentId = LdnScanFilterFlag_LocalCommunicationId | LdnScanFilterFlag_SceneId, ///< Enables using LdnScanFilter::network_id intent_id.
LdnScanFilterFlag_NetworkId = LdnScanFilterFlag_IntentId | LdnScanFilterFlag_SessionId, ///< Enables using LdnScanFilter::network_id.
} LdnScanFilterFlag;
/// AcceptPolicy /// AcceptPolicy
typedef enum { typedef enum {
LdnAcceptPolicy_AllowAll = 0, ///< Allow all. LdnAcceptPolicy_AlwaysAccept = 0, ///< AlwaysAccept
LdnAcceptPolicy_DenyAll = 1, ///< Deny all. LdnAcceptPolicy_AlwaysReject = 1, ///< AlwaysReject
LdnAcceptPolicy_Blacklist = 2, ///< Blacklist, addresses in the list (\ref ldnAddAcceptFilterEntry) are not allowed. LdnAcceptPolicy_BlackList = 2, ///< BlackList, addresses in the list (\ref ldnAddAcceptFilterEntry) are not allowed.
LdnAcceptPolicy_Whitelist = 3, ///< Whitelist, only addresses in the list (\ref ldnAddAcceptFilterEntry) are allowed. LdnAcceptPolicy_WhiteList = 3, ///< WhiteList, only addresses in the list (\ref ldnAddAcceptFilterEntry) are allowed.
} LdnAcceptPolicy; } LdnAcceptPolicy;
/// SecurityMode. LdnSecurityMode_Product can be used as the default value. The ldn cmds which use an input SecurityMode normally overwrite the SecurityMode.
typedef enum {
LdnSecurityMode_Any = 0, ///< Any
LdnSecurityMode_Product = 1, ///< Product
LdnSecurityMode_Debug = 2, ///< Debug
LdnSecurityMode_SystemDebug = 3, ///< SystemDebug
} LdnSecurityMode;
/// OperationMode /// OperationMode
typedef enum { typedef enum {
LdnOperationMode_Unknown0 = 0, ///< Unknown LdnOperationMode_Stable = 0, ///< Stable
LdnOperationMode_Unknown1 = 1, ///< Unknown LdnOperationMode_HighSpeed = 1, ///< HighSpeed
} LdnOperationMode; } LdnOperationMode;
/// WirelessControllerRestriction /// WirelessControllerRestriction
typedef enum { typedef enum {
LdnWirelessControllerRestriction_Unknown0 = 0, ///< Unknown LdnWirelessControllerRestriction_Disabled = 0, ///< Disabled
LdnWirelessControllerRestriction_Unknown1 = 1, ///< Unknown LdnWirelessControllerRestriction_Enabled = 1, ///< Enabled
} LdnWirelessControllerRestriction; } LdnWirelessControllerRestriction;
/// Protocol /// Protocol
@ -96,98 +106,111 @@ typedef struct {
/// NodeLatestUpdate /// NodeLatestUpdate
typedef struct { typedef struct {
u8 val; ///< The field in state is reset to zero by \ref ldnGetNetworkInfoLatestUpdate after loading it. u8 state_change; ///< StateChange. The field in state is reset to zero by \ref ldnGetNetworkInfoLatestUpdate after loading it.
u8 reserved[0x7]; ///< Not initialized with \ref ldnGetNetworkInfoLatestUpdate. u8 reserved[0x7]; ///< Reserved
} LdnNodeLatestUpdate; } LdnNodeLatestUpdate;
/// AddressEntry /// AddressEntry
typedef struct { typedef struct {
LdnIpv4Address ip_addr; ///< \ref LdnIpv4Address LdnIpv4Address ip_addr; ///< \ref LdnIpv4Address
LdnMacAddress mac_addr; ///< \ref LdnMacAddress LdnMacAddress mac_addr; ///< \ref LdnMacAddress
u8 pad[0x2]; ///< Padding u8 reserved[0x2]; ///< Reserved
} LdnAddressEntry; } LdnAddressEntry;
/// NodeInfo /// NodeInfo
typedef struct { typedef struct {
LdnIpv4Address ip_addr; ///< \ref LdnIpv4Address LdnIpv4Address ip_addr; ///< \ref LdnIpv4Address
LdnMacAddress mac_addr; ///< \ref LdnMacAddress LdnMacAddress mac_addr; ///< \ref LdnMacAddress
s8 id; ///< ID / index s8 node_id; ///< NodeId
u8 is_connected; ///< IsConnected flag u8 is_connected; ///< IsConnected flag
char nickname[0x20]; ///< LdnUserConfig::nickname char user_name[0x21]; ///< LdnUserConfig::user_name
u8 reserved_x2C[0x2]; ///< Reserved u8 platform; ///< [19.0.0+] Platform? (0 = NX, 1 = Ounce)
s16 local_communication_version; ///< LocalCommunicationVersion s16 local_communication_version; ///< LocalCommunicationVersion
u8 reserved_x30[0x10]; ///< Reserved u8 reserved_x30[0x10]; ///< Reserved
} LdnNodeInfo; } LdnNodeInfo;
/// UserConfig. The input struct is copied to a tmp struct, which is then used with the cmd. /// UserConfig. The input struct is copied to a tmp struct, which is then used with the cmd.
typedef struct { typedef struct {
char nickname[0x20]; ///< NUL-terminated string for the user nickname. char user_name[0x21]; ///< UserName (NUL-terminated string for the user name)
u8 reserved[0x10]; ///< Cleared to zero for the tmp struct. u8 reserved[0xF]; ///< Reserved
} LdnUserConfig; } LdnUserConfig;
/// IntentId
typedef struct {
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.
u8 reserved_x8[0x2]; ///< Reserved
u16 scene_id; ///< SceneId. Arbitrary user data, this can be used for filtering with \ref LdnScanFilter (::LdnScanFilterFlag_SceneId) for example.
u8 reserved_xC[0x4]; ///< Reserved
} LdnIntentId;
/// SessionId
typedef struct {
u8 random[0x10]; ///< Random. Used to generate/overwrite the ssid when needed.
} LdnSessionId;
/// NetworkId
typedef struct {
LdnIntentId intent_id; ///< IntentId
LdnSessionId session_id; ///< SessionId
} LdnNetworkId;
/// CommonNetworkInfo
typedef struct {
LdnMacAddress bssid; ///< \ref LdnMacAddress
LdnSsid ssid; ///< \ref LdnSsid
s16 channel; ///< Channel
s8 link_level; ///< LinkLevel
u8 network_type; ///< NetworkType
u8 reserved[0x4]; ///< Reserved
} LdnCommonNetworkInfo;
/// NetworkInfo /// NetworkInfo
typedef struct { typedef struct {
u64 local_communication_id; ///< LocalCommunicationId LdnNetworkId network_id; ///< NetworkId
u8 reserved_x8[0x2]; ///< Reserved LdnCommonNetworkInfo common; ///< CommonNetworkInfo
u16 userdata_filter; ///< Arbitrary user data which can be used for filtering with \ref LdnScanFilter. u8 server_random[0x10]; ///< LdnSecurityParameter::server_random
u8 reserved_xC[0x4]; ///< Reserved u16 security_mode; ///< LdnSecurityConfig::security_mode
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. u8 station_accept_policy; ///< \ref LdnAcceptPolicy
LdnMacAddress mac_addr; ///< \ref LdnMacAddress u8 version; ///< Version
LdnSsid ssid; ///< \ref LdnSsid u8 reserved_x14[0x2]; ///< Reserved
s16 network_channel; ///< NetworkChannel s8 node_count_max; ///< NodeCountMax
s8 link_level; ///< LinkLevel u8 node_count; ///< NodeCount, number of set entries in nodes.
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.
u8 pad_x4C[0x4]; ///< Padding
u8 sec_param_data[0x10]; ///< LdnSecurityParameter::data
u16 sec_type; ///< LdnSecurityConfig::type
u8 accept_policy; ///< \ref LdnAcceptPolicy
u8 unk_x63; ///< Only set with \ref ldnScan / \ref ldnScanPrivate, when unk_x4B is value 0x2.
u8 pad_x64[0x2]; ///< Padding
s8 participant_max; ///< Maximum participants, for nodes.
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.
LdnNodeInfo nodes[8]; ///< Array of \ref LdnNodeInfo, starting with the AccessPoint node. LdnNodeInfo nodes[8]; ///< Array of \ref LdnNodeInfo, starting with the AccessPoint node.
u8 reserved_x268[0x2]; ///< Reserved u8 reserved_x218[0x2]; ///< Reserved
u16 advertise_data_size; ///< AdvertiseData size (\ref ldnSetAdvertiseData) u16 advertise_data_size; ///< AdvertiseDataSize (\ref ldnSetAdvertiseData)
u8 advertise_data[0x180]; ///< AdvertiseData (\ref ldnSetAdvertiseData) u8 advertise_data[0x180]; ///< AdvertiseData (\ref ldnSetAdvertiseData)
u8 reserved_x3EC[0x8C]; ///< Reserved u8 reserved_x39C[0x8C]; ///< Reserved
u64 auth_id; ///< Random AuthenticationId. u64 reserved_x428; ///< Reserved
} LdnNetworkInfo; } LdnNetworkInfo;
/// ScanFilter. The input struct is copied to a tmp struct, which is then used with the cmd (\ref ldnScan and \ref ldnScanPrivate). /// 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.
typedef struct { typedef struct {
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. LdnNetworkId network_id; ///< NetworkId
u8 pad_x8[0x2]; ///< Padding u32 network_type; ///< NetworkType (::LdnScanFilterFlag_NetworkType)
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. LdnMacAddress bssid; ///< Bssid (::LdnScanFilterFlag_Bssid)
u8 pad_xC[0x4]; ///< Padding LdnSsid ssid; ///< Ssid (::LdnScanFilterFlag_Ssid)
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. u8 reserved[0x10]; ///< Reserved
u32 unk_x20; ///< See ::LdnScanFilterFlags_Unknown2. When enabled, this must be <=0x3, and during filtering must match LdnNetworkInfo::unk_x4B. u32 flags; ///< Bitmask for \ref LdnScanFilterFlag.
LdnMacAddress mac_addr; ///< \ref LdnMacAddress (::LdnScanFilterFlags_MacAddr, during filtering if enabled this must match LdnNetworkInfo::mac_addr)
LdnSsid ssid; ///< \ref LdnSsid (::LdnScanFilterFlags_Ssid, during filtering if enabled this must match LdnNetworkInfo::ssid)
u8 reserved[0x10]; ///< Cleared to zero for the tmp struct.
u32 flags; ///< Bitmask for \ref LdnScanFilterFlags. Masked with value 0x37 for \ref ldnScan, with \ref ldnScanPrivate this is masked with 0x3F.
} LdnScanFilter; } LdnScanFilter;
/// SecurityConfig /// SecurityConfig
typedef struct { typedef struct {
u16 type; ///< Type, a default of value 0x1 can be used here. Overwritten by \ref ldnCreateNetwork, \ref ldnCreateNetworkPrivate, \ref ldnConnect, \ref ldnConnectPrivate. u16 security_mode; ///< \ref LdnSecurityMode Overwritten by \ref ldnCreateNetwork, \ref ldnCreateNetworkPrivate, \ref ldnConnect, \ref ldnConnectPrivate.
u16 data_size; ///< Data size. Must be 0x10-0x40. u16 passphrase_size; ///< PassphraseSize. Must be 0x10-0x40.
u8 data[0x40]; ///< Data, used with key derivation. u8 passphrase[0x40]; ///< Passphrase, used with key derivation.
} LdnSecurityConfig; } LdnSecurityConfig;
/// SecurityParameter. The struct used by \ref ldnCreateNetwork internally is randomly-generated. /// SecurityParameter. The struct used by \ref ldnCreateNetwork internally is randomly-generated.
typedef struct { typedef struct {
u8 data[0x10]; ///< Data, used with the same key derivation as \ref LdnSecurityConfig. u8 server_random[0x10]; ///< ServerRandom, used with the same key derivation as \ref LdnSecurityConfig.
u8 network_id[0x10]; ///< LdnNetworkInfo::network_id LdnSessionId session_id; ///< SessionId
} LdnSecurityParameter; } LdnSecurityParameter;
/// NetworkConfig. The input struct is copied to a tmp struct, which is then used with the cmd (\ref ldnCreateNetwork, \ref ldnCreateNetworkPrivate, \ref ldnConnectPrivate). /// NetworkConfig. The input struct is copied to a tmp struct, which is then used with the cmd (\ref ldnCreateNetwork, \ref ldnCreateNetworkPrivate, \ref ldnConnectPrivate).
typedef struct { typedef struct {
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. LdnIntentId intent_id; ///< IntentId
u8 reserved_x8[2]; ///< Cleared to zero for the tmp struct. s16 channel; ///< LdnCommonNetworkInfo::channel. Channel, can be zero. Overwritten internally by \ref ldnCreateNetwork.
u16 userdata_filter; ///< LdnNetworkInfo::userdata_filter s8 node_count_max; ///< LdnNetworkInfo::node_count_max. \ref ldnCreateNetwork / \ref ldnCreateNetworkPrivate: Must be 0x1-0x8.
u8 reserved_xC[4]; ///< Cleared to zero for the tmp struct.
s16 network_channel; ///< LdnNetworkInfo::network_channel. Channel, can be zero. Overwritten internally by \ref ldnCreateNetwork.
s8 participant_max; ///< LdnNetworkInfo::participant_max. \ref ldnCreateNetwork / \ref ldnCreateNetworkPrivate: Must be 0x1-0x8.
u8 reserved_x13; ///< Cleared to zero for the tmp struct. u8 reserved_x13; ///< Cleared to zero for the tmp struct.
s16 local_communication_version; ///< LdnNodeInfo::local_communication_version, for the first entry in LdnNetworkInfo::nodes. Must not be negative. s16 local_communication_version; ///< LdnNodeInfo::local_communication_version, for the first entry in LdnNetworkInfo::nodes. Must not be negative.
u8 reserved_x16[0xA]; ///< Cleared to zero for the tmp struct. u8 reserved_x16[0xA]; ///< Cleared to zero for the tmp struct.
@ -195,9 +218,9 @@ typedef struct {
/// ActionFrameSettings /// ActionFrameSettings
typedef struct { typedef struct {
s64 local_communication_id; ///< LocalCommunicationId (Same handling as LdnNetworkConfig::local_communication_id) s64 local_communication_id; ///< LocalCommunicationId (Same handling as LdnIntentId::local_communication_id)
u8 reserved[0x34]; ///< Reserved u8 reserved[0x34]; ///< Reserved
u16 security_mode; ///< SecurityMode (Must be 1-2, internally this is overriden) u16 security_mode; ///< \ref LdnSecurityMode (Must be ::LdnSecurityMode_Product or ::LdnSecurityMode_Debug, internally this is overriden)
u16 passphrase_size; ///< PassphraseSize (Must be 0x10-0x40) u16 passphrase_size; ///< PassphraseSize (Must be 0x10-0x40)
u8 passphrase[0x40]; ///< Passphrase u8 passphrase[0x40]; ///< Passphrase
} LdnActionFrameSettings; } LdnActionFrameSettings;
@ -316,7 +339,7 @@ Result ldnGetNetworkInfoLatestUpdate(LdnNetworkInfo *network_info, LdnNodeLatest
/** /**
* @brief Scan * @brief Scan
* @note \ref LdnState must be ::LdnState_AccessPointCreated, ::LdnState_StationOpened, or ::LdnState_StationConnected. * @note \ref LdnState must be ::LdnState_AccessPointCreated, ::LdnState_Station, or ::LdnState_StationConnected.
* @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. * @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.
* @param[in] channel Channel, value 0 can be used for this. * @param[in] channel Channel, value 0 can be used for this.
* @param[in] filter \ref LdnScanFilter * @param[in] filter \ref LdnScanFilter
@ -328,7 +351,7 @@ Result ldnScan(s32 channel, const LdnScanFilter *filter, LdnNetworkInfo *network
/** /**
* @brief ScanPrivate * @brief ScanPrivate
* @note \ref LdnState must be ::LdnState_AccessPointCreated, ::LdnState_StationOpened, or ::LdnState_StationConnected. * @note \ref LdnState must be ::LdnState_AccessPointCreated, ::LdnState_Station, or ::LdnState_StationConnected.
* @note See \ref ldnScan. * @note See \ref ldnScan.
* @param[in] channel Channel, value 0 can be used for this. * @param[in] channel Channel, value 0 can be used for this.
* @param[in] filter \ref LdnScanFilter * @param[in] filter \ref LdnScanFilter
@ -356,20 +379,20 @@ Result ldnSetProtocol(LdnProtocol protocol);
/** /**
* @brief OpenAccessPoint * @brief OpenAccessPoint
* @note \ref LdnState must be ::LdnState_Initialized, this eventually sets the State to ::LdnState_AccessPointOpened. * @note \ref LdnState must be ::LdnState_Initialized, this eventually sets the State to ::LdnState_AccessPoint.
*/ */
Result ldnOpenAccessPoint(void); Result ldnOpenAccessPoint(void);
/** /**
* @brief CloseAccessPoint * @brief CloseAccessPoint
* @note \ref LdnState must be ::LdnState_AccessPointOpened or ::LdnState_AccessPointCreated, this eventually sets the State to ::LdnState_Initialized. * @note \ref LdnState must be ::LdnState_AccessPoint or ::LdnState_AccessPointCreated, this eventually sets the State to ::LdnState_Initialized.
* @note Used automatically internally by \ref ldnExit if needed. * @note Used automatically internally by \ref ldnExit if needed.
*/ */
Result ldnCloseAccessPoint(void); Result ldnCloseAccessPoint(void);
/** /**
* @brief CreateNetwork * @brief CreateNetwork
* @note \ref LdnState must be ::LdnState_AccessPointOpened, this eventually sets the State to ::LdnState_AccessPointCreated. * @note \ref LdnState must be ::LdnState_AccessPoint, this eventually sets the State to ::LdnState_AccessPointCreated.
* @param[in] sec_config \ref LdnSecurityConfig * @param[in] sec_config \ref LdnSecurityConfig
* @param[in] user_config \ref LdnUserConfig * @param[in] user_config \ref LdnUserConfig
* @param[in] network_config \ref LdnNetworkConfig * @param[in] network_config \ref LdnNetworkConfig
@ -378,7 +401,7 @@ Result ldnCreateNetwork(const LdnSecurityConfig *sec_config, const LdnUserConfig
/** /**
* @brief CreateNetworkPrivate * @brief CreateNetworkPrivate
* @note \ref LdnState must be ::LdnState_AccessPointOpened, this eventually sets the State to ::LdnState_AccessPointCreated. * @note \ref LdnState must be ::LdnState_AccessPoint, this eventually sets the State to ::LdnState_AccessPointCreated.
* @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). * @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).
* @param[in] sec_config \ref LdnSecurityConfig * @param[in] sec_config \ref LdnSecurityConfig
* @param[in] sec_param \ref LdnSecurityParameter * @param[in] sec_param \ref LdnSecurityParameter
@ -391,7 +414,7 @@ Result ldnCreateNetworkPrivate(const LdnSecurityConfig *sec_config, const LdnSec
/** /**
* @brief DestroyNetwork * @brief DestroyNetwork
* @note \ref LdnState must be ::LdnState_AccessPointCreated, this eventually sets the State to ::LdnState_AccessPointOpened. * @note \ref LdnState must be ::LdnState_AccessPointCreated, this eventually sets the State to ::LdnState_AccessPoint.
*/ */
Result ldnDestroyNetwork(void); Result ldnDestroyNetwork(void);
@ -405,22 +428,22 @@ Result ldnReject(LdnIpv4Address addr);
/** /**
* @brief SetAdvertiseData * @brief SetAdvertiseData
* @note An empty buffer (buffer=NULL/size=0) can be used to reset the AdvertiseData size in state to zero. * @note An empty buffer (buffer=NULL/size=0) can be used to reset the AdvertiseData size in state to zero.
* @note \ref LdnState must be ::LdnState_AccessPointOpened or ::LdnState_AccessPointCreated. * @note \ref LdnState must be ::LdnState_AccessPoint or ::LdnState_AccessPointCreated.
* @param[in] buffer Input buffer containing arbitrary user data. * @param[in] buffer Input buffer containing arbitrary user data.
* @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). * @param[in] size Input buffer size, must be <=0x180.
*/ */
Result ldnSetAdvertiseData(const void* buffer, size_t size); Result ldnSetAdvertiseData(const void* buffer, size_t size);
/** /**
* @brief SetStationAcceptPolicy * @brief SetStationAcceptPolicy
* @note \ref LdnState must be ::LdnState_AccessPointOpened or ::LdnState_AccessPointCreated. * @note \ref LdnState must be ::LdnState_AccessPoint or ::LdnState_AccessPointCreated.
* @param[in] policy \ref LdnAcceptPolicy * @param[in] policy \ref LdnAcceptPolicy
*/ */
Result ldnSetStationAcceptPolicy(LdnAcceptPolicy policy); Result ldnSetStationAcceptPolicy(LdnAcceptPolicy policy);
/** /**
* @brief AddAcceptFilterEntry * @brief AddAcceptFilterEntry
* @note \ref LdnState must be ::LdnState_AccessPointOpened or ::LdnState_AccessPointCreated. * @note \ref LdnState must be ::LdnState_AccessPoint or ::LdnState_AccessPointCreated.
* @note See \ref LdnAcceptPolicy. * @note See \ref LdnAcceptPolicy.
* @param[in] addr \ref LdnMacAddress. If you want, you can also pass LdnNodeInfo::mac_addr for this. * @param[in] addr \ref LdnMacAddress. If you want, you can also pass LdnNodeInfo::mac_addr for this.
*/ */
@ -428,26 +451,26 @@ Result ldnAddAcceptFilterEntry(LdnMacAddress addr);
/** /**
* @brief ClearAcceptFilter * @brief ClearAcceptFilter
* @note \ref LdnState must be ::LdnState_AccessPointOpened or ::LdnState_AccessPointCreated. * @note \ref LdnState must be ::LdnState_AccessPoint or ::LdnState_AccessPointCreated.
*/ */
Result ldnClearAcceptFilter(void); Result ldnClearAcceptFilter(void);
/** /**
* @brief OpenStation * @brief OpenStation
* @note \ref LdnState must be ::LdnState_Initialized, this eventually sets the State to ::LdnState_StationOpened. * @note \ref LdnState must be ::LdnState_Initialized, this eventually sets the State to ::LdnState_Station.
*/ */
Result ldnOpenStation(void); Result ldnOpenStation(void);
/** /**
* @brief CloseStation * @brief CloseStation
* @note \ref LdnState must be ::LdnState_StationOpened or ::LdnState_StationConnected, this eventually sets the State to ::LdnState_Initialized. * @note \ref LdnState must be ::LdnState_Station or ::LdnState_StationConnected, this eventually sets the State to ::LdnState_Initialized.
* @note Used automatically internally by \ref ldnExit if needed. * @note Used automatically internally by \ref ldnExit if needed.
*/ */
Result ldnCloseStation(void); Result ldnCloseStation(void);
/** /**
* @brief Connect * @brief Connect
* @note \ref LdnState must be ::LdnState_StationOpened, this eventually sets the State to ::LdnState_StationConnected. * @note \ref LdnState must be ::LdnState_Station, this eventually sets the State to ::LdnState_StationConnected.
* @note This is identical to \ref ldnConnectPrivate besides the used params, the code overwriting LdnSecurityConfig::type also differs. * @note This is identical to \ref ldnConnectPrivate besides the used params, the code overwriting LdnSecurityConfig::type also differs.
* @param[in] sec_config \ref LdnSecurityConfig * @param[in] sec_config \ref LdnSecurityConfig
* @param[in] user_config \ref LdnUserConfig * @param[in] user_config \ref LdnUserConfig
@ -459,7 +482,7 @@ Result ldnConnect(const LdnSecurityConfig *sec_config, const LdnUserConfig *user
/** /**
* @brief ConnectPrivate * @brief ConnectPrivate
* @note \ref LdnState must be ::LdnState_StationOpened, this eventually sets the State to ::LdnState_StationConnected. * @note \ref LdnState must be ::LdnState_Station, this eventually sets the State to ::LdnState_StationConnected.
* @note See \ref ldnConnect. * @note See \ref ldnConnect.
* @param[in] sec_config \ref LdnSecurityConfig * @param[in] sec_config \ref LdnSecurityConfig
* @param[in] sec_param \ref LdnSecurityParameter * @param[in] sec_param \ref LdnSecurityParameter
@ -472,7 +495,7 @@ Result ldnConnectPrivate(const LdnSecurityConfig *sec_config, const LdnSecurityP
/** /**
* @brief Disconnect * @brief Disconnect
* @note \ref LdnState must be ::LdnState_StationConnected, this eventually sets the State to ::LdnState_StationOpened. * @note \ref LdnState must be ::LdnState_StationConnected, this eventually sets the State to ::LdnState_Station.
*/ */
Result ldnDisconnect(void); Result ldnDisconnect(void);
@ -503,7 +526,7 @@ Result ldnDisableActionFrame(void);
/** /**
* @brief SendActionFrame * @brief SendActionFrame
* @note Only available on [18.0.0+]. * @note Only available on [18.0.0+].
* @note \ref LdnState must be ::LdnState_AccessPointCreated / ::LdnState_StationOpened. * @note \ref LdnState must be ::LdnState_AccessPointCreated / ::LdnState_Station.
* @param[in] data Data buffer. * @param[in] data Data buffer.
* @param[in] size Data buffer size. * @param[in] size Data buffer size.
* @param[in] destination Destination \ref LdnMacAddress. * @param[in] destination Destination \ref LdnMacAddress.
@ -531,7 +554,7 @@ Result ldnRecvActionFrame(void* data, size_t size, LdnMacAddress *addr0, LdnMacA
/** /**
* @brief SetHomeChannel * @brief SetHomeChannel
* @note Only available on [18.0.0+]. * @note Only available on [18.0.0+].
* @note \ref LdnState must be ::LdnState_StationOpened. * @note \ref LdnState must be ::LdnState_Station.
* @param[in] channel Channel, must be non-zero. * @param[in] channel Channel, must be non-zero.
*/ */
Result ldnSetHomeChannel(s16 channel); Result ldnSetHomeChannel(s16 channel);

View File

@ -223,10 +223,10 @@ static Result _ldnScan(s32 channel, const LdnScanFilter *filter, LdnNetworkInfo
static void _ldnCopyNetworkConfig(const LdnNetworkConfig *in, LdnNetworkConfig *out) { static void _ldnCopyNetworkConfig(const LdnNetworkConfig *in, LdnNetworkConfig *out) {
memset(out, 0, sizeof(*out)); memset(out, 0, sizeof(*out));
out->local_communication_id = in->local_communication_id; out->intent_id.local_communication_id = in->intent_id.local_communication_id;
out->userdata_filter = in->userdata_filter; out->intent_id.scene_id = in->intent_id.scene_id;
out->network_channel = in->network_channel; out->channel = in->channel;
out->participant_max = in->participant_max; out->node_count_max = in->node_count_max;
out->local_communication_version = in->local_communication_version; out->local_communication_version = in->local_communication_version;
} }
@ -331,7 +331,7 @@ Result ldnCloseAccessPoint(void) {
Result ldnCreateNetwork(const LdnSecurityConfig *sec_config, const LdnUserConfig *user_config, const LdnNetworkConfig *network_config) { Result ldnCreateNetwork(const LdnSecurityConfig *sec_config, const LdnUserConfig *user_config, const LdnNetworkConfig *network_config) {
LdnNetworkConfig tmp_network_config; LdnNetworkConfig tmp_network_config;
LdnUserConfig tmp_user={0}; LdnUserConfig tmp_user={0};
memcpy(tmp_user.nickname, user_config->nickname, sizeof(tmp_user.nickname)); memcpy(tmp_user.user_name, user_config->user_name, sizeof(tmp_user.user_name)-1);
_ldnCopyNetworkConfig(network_config, &tmp_network_config); _ldnCopyNetworkConfig(network_config, &tmp_network_config);
const struct { const struct {
@ -347,7 +347,7 @@ Result ldnCreateNetwork(const LdnSecurityConfig *sec_config, const LdnUserConfig
Result ldnCreateNetworkPrivate(const LdnSecurityConfig *sec_config, const LdnSecurityParameter *sec_param, const LdnUserConfig *user_config, const LdnNetworkConfig *network_config, const LdnAddressEntry *addrs, s32 count) { Result ldnCreateNetworkPrivate(const LdnSecurityConfig *sec_config, const LdnSecurityParameter *sec_param, const LdnUserConfig *user_config, const LdnNetworkConfig *network_config, const LdnAddressEntry *addrs, s32 count) {
LdnNetworkConfig tmp_network_config; LdnNetworkConfig tmp_network_config;
LdnUserConfig tmp_user={0}; LdnUserConfig tmp_user={0};
memcpy(tmp_user.nickname, user_config->nickname, sizeof(tmp_user.nickname)); memcpy(tmp_user.user_name, user_config->user_name, sizeof(tmp_user.user_name)-1);
_ldnCopyNetworkConfig(network_config, &tmp_network_config); _ldnCopyNetworkConfig(network_config, &tmp_network_config);
const struct { const struct {
@ -402,7 +402,7 @@ Result ldnCloseStation(void) {
Result ldnConnect(const LdnSecurityConfig *sec_config, const LdnUserConfig *user_config, s32 version, u32 option, const LdnNetworkInfo *network_info) { Result ldnConnect(const LdnSecurityConfig *sec_config, const LdnUserConfig *user_config, s32 version, u32 option, const LdnNetworkInfo *network_info) {
LdnUserConfig tmp_user={0}; LdnUserConfig tmp_user={0};
memcpy(tmp_user.nickname, user_config->nickname, sizeof(tmp_user.nickname)); memcpy(tmp_user.user_name, user_config->user_name, sizeof(tmp_user.user_name)-1);
const struct { const struct {
LdnSecurityConfig sec_config; LdnSecurityConfig sec_config;
@ -420,7 +420,7 @@ Result ldnConnect(const LdnSecurityConfig *sec_config, const LdnUserConfig *user
Result ldnConnectPrivate(const LdnSecurityConfig *sec_config, const LdnSecurityParameter *sec_param, const LdnUserConfig *user_config, s32 version, u32 option, const LdnNetworkConfig *network_config) { Result ldnConnectPrivate(const LdnSecurityConfig *sec_config, const LdnSecurityParameter *sec_param, const LdnUserConfig *user_config, s32 version, u32 option, const LdnNetworkConfig *network_config) {
LdnNetworkConfig tmp_network_config; LdnNetworkConfig tmp_network_config;
LdnUserConfig tmp_user={0}; LdnUserConfig tmp_user={0};
memcpy(tmp_user.nickname, user_config->nickname, sizeof(tmp_user.nickname)); memcpy(tmp_user.user_name, user_config->user_name, sizeof(tmp_user.user_name)-1);
_ldnCopyNetworkConfig(network_config, &tmp_network_config); _ldnCopyNetworkConfig(network_config, &tmp_network_config);
const struct { const struct {