mirror of
https://github.com/switchbrew/libnx.git
synced 2025-06-21 20:42:44 +02:00
Add in more NIFM functionality (#236)
This commit is contained in:
parent
6b91ac26a5
commit
131b92a8c8
@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file nifm.h
|
||||
* @brief Network interface service IPC wrapper.
|
||||
* @author shadowninja108
|
||||
* @author shadowninja108, shibboleet
|
||||
* @copyright libnx Authors
|
||||
*/
|
||||
|
||||
@ -16,3 +16,10 @@ Result nifmInitialize(void);
|
||||
void nifmExit(void);
|
||||
|
||||
Result nifmGetCurrentIpAddress(u32* out);
|
||||
|
||||
Result nifmIsWirelessCommunicationEnabled(bool* out);
|
||||
|
||||
Result nifmIsEthernetCommunicationEnabled(bool* out);
|
||||
Result nifmIsAnyForegroundRequestAccepted(bool* out);
|
||||
Result nifmPutToSleep(void);
|
||||
Result nifmWakeUp(void);
|
||||
|
@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file nifm.h
|
||||
* @file nifm.c
|
||||
* @brief Network interface service IPC wrapper.
|
||||
* @author shadowninja108
|
||||
* @author shadowninja108, shibboleet
|
||||
* @copyright libnx Authors
|
||||
*/
|
||||
|
||||
@ -20,7 +20,7 @@ Result nifmInitialize(void) {
|
||||
|
||||
if (serviceIsActive(&g_nifmSrv))
|
||||
return 0;
|
||||
|
||||
|
||||
Result rc;
|
||||
rc = smGetService(&g_nifmSrv, "nifm:u");
|
||||
|
||||
@ -81,6 +81,183 @@ Result nifmGetCurrentIpAddress(u32* out) {
|
||||
return rc;
|
||||
}
|
||||
|
||||
Result nifmIsWirelessCommunicationEnabled(bool* out) {
|
||||
IpcCommand c;
|
||||
ipcInitialize(&c);
|
||||
|
||||
struct {
|
||||
u64 magic;
|
||||
u64 cmd_id;
|
||||
} *raw;
|
||||
|
||||
raw = serviceIpcPrepareHeader(&g_nifmIGS, &c, sizeof(*raw));
|
||||
|
||||
raw->magic = SFCI_MAGIC;
|
||||
raw->cmd_id = 17;
|
||||
|
||||
Result rc = serviceIpcDispatch(&g_nifmIGS);
|
||||
|
||||
if (R_SUCCEEDED(rc)) {
|
||||
IpcParsedCommand r;
|
||||
|
||||
struct {
|
||||
u64 magic;
|
||||
u64 result;
|
||||
u8 out;
|
||||
} *resp;
|
||||
|
||||
serviceIpcParse(&g_nifmIGS, &r, sizeof(*resp));
|
||||
resp = r.Raw;
|
||||
|
||||
rc = resp->result;
|
||||
|
||||
if (R_SUCCEEDED(rc) && out)
|
||||
*out = resp->out != 0;
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
Result nifmIsEthernetCommunicationEnabled(bool* out) {
|
||||
IpcCommand c;
|
||||
ipcInitialize(&c);
|
||||
|
||||
struct {
|
||||
u64 magic;
|
||||
u64 cmd_id;
|
||||
} *raw;
|
||||
|
||||
raw = serviceIpcPrepareHeader(&g_nifmIGS, &c, sizeof(*raw));
|
||||
|
||||
raw->magic = SFCI_MAGIC;
|
||||
raw->cmd_id = 20;
|
||||
|
||||
Result rc = serviceIpcDispatch(&g_nifmIGS);
|
||||
|
||||
if (R_SUCCEEDED(rc)) {
|
||||
IpcParsedCommand r;
|
||||
|
||||
struct {
|
||||
u64 magic;
|
||||
u64 result;
|
||||
u8 out;
|
||||
} *resp;
|
||||
|
||||
serviceIpcParse(&g_nifmIGS, &r, sizeof(*resp));
|
||||
resp = r.Raw;
|
||||
|
||||
rc = resp->result;
|
||||
|
||||
if (R_SUCCEEDED(rc) && out)
|
||||
*out = resp->out != 0;
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
Result nifmIsAnyForegroundRequestAccepted(bool* out) {
|
||||
IpcCommand c;
|
||||
ipcInitialize(&c);
|
||||
|
||||
struct {
|
||||
u64 magic;
|
||||
u64 cmd_id;
|
||||
} *raw;
|
||||
|
||||
raw = serviceIpcPrepareHeader(&g_nifmIGS, &c, sizeof(*raw));
|
||||
|
||||
raw->magic = SFCI_MAGIC;
|
||||
raw->cmd_id = 22;
|
||||
|
||||
Result rc = serviceIpcDispatch(&g_nifmIGS);
|
||||
|
||||
if (R_SUCCEEDED(rc)) {
|
||||
IpcParsedCommand r;
|
||||
|
||||
struct {
|
||||
u64 magic;
|
||||
u64 result;
|
||||
u8 out;
|
||||
} *resp;
|
||||
|
||||
serviceIpcParse(&g_nifmIGS, &r, sizeof(*resp));
|
||||
resp = r.Raw;
|
||||
|
||||
rc = resp->result;
|
||||
|
||||
if (R_SUCCEEDED(rc) && out)
|
||||
*out = resp->out != 0;
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
Result nifmPutToSleep(void) {
|
||||
IpcCommand c;
|
||||
ipcInitialize(&c);
|
||||
|
||||
struct {
|
||||
u64 magic;
|
||||
u64 cmd_id;
|
||||
} *raw;
|
||||
|
||||
raw = serviceIpcPrepareHeader(&g_nifmIGS, &c, sizeof(*raw));
|
||||
|
||||
raw->magic = SFCI_MAGIC;
|
||||
raw->cmd_id = 23;
|
||||
|
||||
Result rc = serviceIpcDispatch(&g_nifmIGS);
|
||||
|
||||
if (R_SUCCEEDED(rc)) {
|
||||
IpcParsedCommand r;
|
||||
|
||||
struct {
|
||||
u64 magic;
|
||||
u64 result;
|
||||
} *resp;
|
||||
|
||||
serviceIpcParse(&g_nifmIGS, &r, sizeof(*resp));
|
||||
resp = r.Raw;
|
||||
|
||||
rc = resp->result;
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
Result nifmWakeUp(void) {
|
||||
IpcCommand c;
|
||||
ipcInitialize(&c);
|
||||
|
||||
struct {
|
||||
u64 magic;
|
||||
u64 cmd_id;
|
||||
} *raw;
|
||||
|
||||
raw = serviceIpcPrepareHeader(&g_nifmIGS, &c, sizeof(*raw));
|
||||
|
||||
raw->magic = SFCI_MAGIC;
|
||||
raw->cmd_id = 24;
|
||||
|
||||
Result rc = serviceIpcDispatch(&g_nifmIGS);
|
||||
|
||||
if (R_SUCCEEDED(rc)) {
|
||||
IpcParsedCommand r;
|
||||
|
||||
struct {
|
||||
u64 magic;
|
||||
u64 result;
|
||||
} *resp;
|
||||
|
||||
serviceIpcParse(&g_nifmIGS, &r, sizeof(*resp));
|
||||
resp = r.Raw;
|
||||
|
||||
rc = resp->result;
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
static Result _nifmCreateGeneralService(Service* out, u64 in) {
|
||||
IpcCommand c;
|
||||
ipcInitialize(&c);
|
||||
|
Loading…
Reference in New Issue
Block a user