Skip to content

Commit

Permalink
initialize mac address for file write
Browse files Browse the repository at this point in the history
  • Loading branch information
NikhilNarayana committed Mar 5, 2020
1 parent 1349074 commit ce9ba3c
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 20 deletions.
2 changes: 2 additions & 0 deletions kernel/SlippiFileWriter.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "debug.h"
#include "string.h"
#include "ff_utf8.h"
#include "net.h"

#include "Config.h"

Expand Down Expand Up @@ -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),
Expand Down
45 changes: 25 additions & 20 deletions kernel/net.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions kernel/net.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Binary file modified loader/loader.dol
Binary file not shown.

0 comments on commit ce9ba3c

Please sign in to comment.