Skip to content

Commit

Permalink
- Check for a bound IP before entering device.
Browse files Browse the repository at this point in the history
  • Loading branch information
Extrems committed May 15, 2024
1 parent d840edd commit 9e3b096
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 8 deletions.
2 changes: 1 addition & 1 deletion cube/swiss/include/bba.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ extern struct in_addr bba_gateway;
extern u32 bba_location;

void wait_network();
void init_network();
bool init_network();
void init_network_async();
void init_wiiload_thread();
bool bba_exists(u32 location);
Expand Down
3 changes: 2 additions & 1 deletion cube/swiss/source/bba.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,11 @@ void init_network_async(void)
LWP_CreateThread(&net_thread, net_thread_func, NULL, NULL, 0, LWP_PRIO_NORMAL);
}

void init_network(void)
bool init_network(void)
{
init_network_async();
wait_network();
return net_initialized && (bba_localip.s_addr = net_gethostip()) != INADDR_ANY;
}

void wait_network(void)
Expand Down
3 changes: 1 addition & 2 deletions cube/swiss/source/devices/fsp/deviceHandler-FSP.c
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,7 @@ s32 deviceHandler_FSP_setupFile(file_handle* file, file_handle* file2, Executabl
}

s32 deviceHandler_FSP_init(file_handle* file) {
init_network();
if(!net_initialized) {
if(!init_network()) {
file->status = E_NONET;
return EFAULT;
}
Expand Down
3 changes: 1 addition & 2 deletions cube/swiss/source/devices/ftp/deviceHandler-FTP.c
Original file line number Diff line number Diff line change
Expand Up @@ -178,14 +178,13 @@ s32 deviceHandler_FTP_writeFile(file_handle* file, const void* buffer, u32 lengt
}

s32 deviceHandler_FTP_init(file_handle* file){
init_network();
// We need at least a share name and ip addr in the settings filled out
if(!strlen(&swissSettings.ftpHostIp[0])) {
file->status = E_CHECKCONFIG;
return EFAULT;
}

if(!net_initialized) { //Init if we have to
if(!init_network()) { //Init if we have to
file->status = E_NONET;
return EFAULT;
}
Expand Down
3 changes: 1 addition & 2 deletions cube/swiss/source/devices/smb/deviceHandler-SMB.c
Original file line number Diff line number Diff line change
Expand Up @@ -182,14 +182,13 @@ s32 deviceHandler_SMB_writeFile(file_handle* file, const void* buffer, u32 lengt
}

s32 deviceHandler_SMB_init(file_handle* file) {
init_network();
// We need at least a share name and ip addr in the settings filled out
if(!strlen(&swissSettings.smbShare[0]) || !strlen(&swissSettings.smbServerIp[0])) {
file->status = E_CHECKCONFIG;
return EFAULT;
}

if(!net_initialized) { //Init if we have to
if(!init_network()) { //Init if we have to
file->status = E_NONET;
return EFAULT;
}
Expand Down

0 comments on commit 9e3b096

Please sign in to comment.