From ba3679199fecf39daeb83231e4da5af3f667dd9e Mon Sep 17 00:00:00 2001 From: AzureMarker Date: Thu, 30 Dec 2021 11:56:08 -0500 Subject: [PATCH] Add Soc::host_address --- ctru-rs/src/services/soc.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/ctru-rs/src/services/soc.rs b/ctru-rs/src/services/soc.rs index 23cba3f..bb150df 100644 --- a/ctru-rs/src/services/soc.rs +++ b/ctru-rs/src/services/soc.rs @@ -1,5 +1,5 @@ +use std::net::Ipv4Addr; use libctru::{socInit, socExit}; - use libc::{memalign, free}; /// Soc service. Initializing this service will enable the use of network sockets and utilities @@ -37,6 +37,12 @@ impl Soc { } } } + + /// IP Address of the Nintendo 3DS system. + pub fn host_address(&self) -> Ipv4Addr { + let raw_id = unsafe { libc::gethostid() }; + Ipv4Addr::from(raw_id.to_ne_bytes()) + } } impl Drop for Soc {