Add in more NIFM functionality

This commit is contained in:
shibbo 2019-01-25 00:10:33 -05:00
parent 6b91ac26a5
commit 8ed8e36a39
2 changed files with 180 additions and 0 deletions

View File

@ -2,6 +2,7 @@
* @file nifm.h
* @brief Network interface service IPC wrapper.
* @author shadowninja108
* @author shibboleet
* @copyright libnx Authors
*/
@ -16,3 +17,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);

View File

@ -2,6 +2,7 @@
* @file nifm.h
* @brief Network interface service IPC wrapper.
* @author shadowninja108
* @author shibboleet
* @copyright libnx Authors
*/
@ -81,6 +82,177 @@ 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;
*out = resp->out;
}
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;
*out = resp->out;
}
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;
*out = resp->out;
}
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);