diff --git a/kernel/SlippiFileWriter.c b/kernel/SlippiFileWriter.c index 030eac85..4b0fb05f 100644 --- a/kernel/SlippiFileWriter.c +++ b/kernel/SlippiFileWriter.c @@ -4,6 +4,7 @@ #include "debug.h" #include "string.h" #include "ff_utf8.h" +#include "net.h" #include "Config.h" @@ -33,6 +34,7 @@ u32 gameStartTime; void SlippiFileWriterInit() { + GetMacAddress(); // need to set the mac address before it can be used Slippi_Thread = do_thread_create( SlippiHandlerThread, ((u32 *)&__slippi_stack_addr), diff --git a/kernel/net.c b/kernel/net.c index 16aab609..306b557e 100644 --- a/kernel/net.c +++ b/kernel/net.c @@ -34,26 +34,8 @@ static const char top_name[15] ALIGNED(32) = "/dev/net/ip/top"; int NCDInit(void) { s32 res; - STACK_ALIGN(ioctlv, mac_vec, 2, 32); - dbgprintf("entered NCDInit()\n"); - - /* Fetch the MAC address of the Wi-Fi interface for use later when we - * broadcast messages to potential Slippi clients. - */ - - s32 ncd_fd = IOS_Open(ncd_name, 0); - void *ncd_buf = heap_alloc_aligned(0, 32, 32); - dbgprintf("ncd_fd: %i\n", ncd_fd); - - mac_vec[0].data = ncd_buf; - mac_vec[0].len = 32; - mac_vec[1].data = &wifi_mac_address; - mac_vec[1].len = 6; - - res = IOS_Ioctlv(ncd_fd, IOCTLV_NCD_GETMACADDRESS, 0, 2, mac_vec); - IOS_Close(ncd_fd); - heap_free(0, ncd_buf); - + + GetMacAddress(); /* NWC24 initialization. This happens in libogc, but do we actually * *need* to do this? Is NWC24 state somehow tied to whether or not @@ -94,6 +76,29 @@ int NCDInit(void) return 0; } +void GetMacAddress(void) { + s32 res; + STACK_ALIGN(ioctlv, mac_vec, 2, 32); + dbgprintf("entered NCDInit()\n"); + + /* Fetch the MAC address of the Wi-Fi interface for use later when we + * broadcast messages to potential Slippi clients. + */ + + s32 ncd_fd = IOS_Open(ncd_name, 0); + void *ncd_buf = heap_alloc_aligned(0, 32, 32); + dbgprintf("ncd_fd: %i\n", ncd_fd); + + mac_vec[0].data = ncd_buf; + mac_vec[0].len = 32; + mac_vec[1].data = &wifi_mac_address; + mac_vec[1].len = 6; + + res = IOS_Ioctlv(ncd_fd, IOCTLV_NCD_GETMACADDRESS, 0, 2, mac_vec); + IOS_Close(ncd_fd); + heap_free(0, ncd_buf); +} + /* ---------------------------------------------------------------------------- * Socket API functions diff --git a/kernel/net.h b/kernel/net.h index 13f23960..72ba6451 100644 --- a/kernel/net.h +++ b/kernel/net.h @@ -146,6 +146,7 @@ enum { /* Function declarations */ int NCDInit(void); +void GetMacAddress(void); s32 socket(s32 fd, u32 domain, u32 type, u32 protocol); s32 close(s32 fd, s32 socket); s32 bind(s32 fd, s32 socket, struct sockaddr *name); diff --git a/loader/loader.dol b/loader/loader.dol index 669482fa..2d0e2e40 100644 Binary files a/loader/loader.dol and b/loader/loader.dol differ