modularise nxlink code

This commit is contained in:
Dave Murphy 2018-03-18 19:12:56 +00:00
parent a1c07b7e47
commit 821d503ef3
5 changed files with 39 additions and 13 deletions

View File

@ -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_*/

View File

@ -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"

View File

@ -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

View File

@ -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;
}

View File

@ -0,0 +1,23 @@
#include <string.h>
#include <stdlib.h>
#include <netinet/in.h>
// 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;
}