Browse Source

Add Soc::host_address

pull/10/head
AzureMarker 3 years ago
parent
commit
ba3679199f
No known key found for this signature in database
GPG Key ID: 47A133F3BF9D03D3
  1. 8
      ctru-rs/src/services/soc.rs

8
ctru-rs/src/services/soc.rs

@ -1,5 +1,5 @@
use std::net::Ipv4Addr;
use libctru::{socInit, socExit}; use libctru::{socInit, socExit};
use libc::{memalign, free}; use libc::{memalign, free};
/// Soc service. Initializing this service will enable the use of network sockets and utilities /// 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 { impl Drop for Soc {

Loading…
Cancel
Save