From dfee0c8ba22700d9223f5dc37e484b9b24099934 Mon Sep 17 00:00:00 2001 From: yellows8 Date: Wed, 18 Jun 2025 18:17:05 -0400 Subject: [PATCH] ldn: Added ldnSetProtocol. --- nx/include/switch/services/ldn.h | 13 +++++++++++++ nx/source/services/ldn.c | 7 +++++++ 2 files changed, 20 insertions(+) diff --git a/nx/include/switch/services/ldn.h b/nx/include/switch/services/ldn.h index 1da556c7..7bef8811 100644 --- a/nx/include/switch/services/ldn.h +++ b/nx/include/switch/services/ldn.h @@ -67,6 +67,12 @@ typedef enum { LdnWirelessControllerRestriction_Unknown1 = 1, ///< Unknown } LdnWirelessControllerRestriction; +/// Protocol +typedef enum { + LdnProtocol_NX = 1, ///< NX (default) + LdnProtocol_Unknown3 = 3, ///< (NXAndOunce?) +} LdnProtocol; + /// Ipv4Address. This is essentially the same as struct in_addr - hence this can be used with standard sockets (byteswap required). typedef struct { u32 addr; ///< Address @@ -331,6 +337,13 @@ Result ldnScanPrivate(s32 channel, const LdnScanFilter *filter, LdnNetworkInfo * */ Result ldnSetWirelessControllerRestriction(LdnWirelessControllerRestriction restriction); +/** + * @brief SetProtocol + * @note This is only usable with [20.0.0+] (with [18.0.0-19-0.1] this is available but not usable). + * @param[in] protocol \ref LdnProtocol + */ +Result ldnSetProtocol(LdnProtocol protocol); + /** * @brief OpenAccessPoint * @note \ref LdnState must be ::LdnState_Initialized, this eventually sets the State to ::LdnState_AccessPointOpened. diff --git a/nx/source/services/ldn.c b/nx/source/services/ldn.c index 0dd55265..705ddcfe 100644 --- a/nx/source/services/ldn.c +++ b/nx/source/services/ldn.c @@ -289,6 +289,13 @@ Result ldnSetWirelessControllerRestriction(LdnWirelessControllerRestriction rest return _ldnCmdInU32NoOut(&g_ldnSrv, restriction, 104); } +Result ldnSetProtocol(LdnProtocol protocol) { + if (hosversionBefore(18,0,0)) + return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer); + + return _ldnCmdInU32NoOut(&g_ldnSrv, protocol, 106); +} + Result ldnOpenAccessPoint(void) { return _ldnCmdNoIO(&g_ldnSrv, 200); }