diff --git a/nx/external/bsd/include/netinet/in.h b/nx/external/bsd/include/netinet/in.h index fa065291..0f624398 100644 --- a/nx/external/bsd/include/netinet/in.h +++ b/nx/external/bsd/include/netinet/in.h @@ -678,12 +678,6 @@ struct sockaddr_in6 { extern const struct in6_addr in6addr_any; extern const struct in6_addr in6addr_loopback; -extern struct in_addr __nxlink_host; - -#define NETLOADER_SERVER_PORT 28280 -#define NETLOADER_CLIENT_PORT 28771 - - #endif #endif /* !_NETINET_IN_H_*/ diff --git a/nx/include/switch.h b/nx/include/switch.h index 2e51182e..f9fef872 100644 --- a/nx/include/switch.h +++ b/nx/include/switch.h @@ -57,6 +57,7 @@ extern "C" { #include "switch/gfx/nvgfx.h" #include "switch/runtime/env.h" +#include "switch/runtime/nxlink.h" #include "switch/runtime/util/utf.h" diff --git a/nx/include/switch/runtime/nxlink.h b/nx/include/switch/runtime/nxlink.h new file mode 100644 index 00000000..0f178811 --- /dev/null +++ b/nx/include/switch/runtime/nxlink.h @@ -0,0 +1,8 @@ +#pragma once + +struct in_addr; + +extern struct in_addr __nxlink_host; + +#define NXLINK_SERVER_PORT 28280 +#define NXLINK_CLIENT_PORT 28771 diff --git a/nx/source/runtime/argv.c b/nx/source/runtime/argv.c index 44446fb0..6796621b 100644 --- a/nx/source/runtime/argv.c +++ b/nx/source/runtime/argv.c @@ -19,6 +19,8 @@ extern u32 __argdata__; static char* g_argv_empty = NULL; +void nxlinkSetup(void); + void argvSetup(void) { Result rc=0; @@ -140,14 +142,12 @@ void argvSetup(void) __system_argc++; } - if ( __system_argc > 1 && - strlen(__system_argv[__system_argc - 1]) == 16 && - strncmp(&__system_argv[__system_argc - 1][8], "_NXLINK_", 8) == 0 ) - { - __system_argc--; - __nxlink_host.s_addr = strtoul(__system_argv[__system_argc], NULL, 16); - } + + // Check for nxlink parameters + nxlinkSetup(); __system_argv[__system_argc] = NULL; + + } diff --git a/nx/source/runtime/nxlink.c b/nx/source/runtime/nxlink.c new file mode 100644 index 00000000..9e42090c --- /dev/null +++ b/nx/source/runtime/nxlink.c @@ -0,0 +1,23 @@ +#include +#include +#include + + +// System globals we define here +extern int __system_argc; +extern char** __system_argv; + +struct in_addr __nxlink_host; + + +void nxlinkSetup(void) +{ + if ( __system_argc > 1 && + strlen(__system_argv[__system_argc - 1]) == 16 && + strncmp(&__system_argv[__system_argc - 1][8], "_NXLINK_", 8) == 0 ) + { + __system_argc--; + __nxlink_host.s_addr = strtoul(__system_argv[__system_argc], NULL, 16); + } + __system_argv[__system_argc] = NULL; +}