mirror of
https://github.com/wiiu-env/wut.git
synced 2024-12-05 03:04:16 +01:00
wutsocket: implement gethostid and gethostname
This commit is contained in:
parent
f1e9cbd58a
commit
174b0c0a86
21
libraries/wutsocket/hostid.c
Normal file
21
libraries/wutsocket/hostid.c
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
#include "wut_socket.h"
|
||||||
|
|
||||||
|
#include <nn/ac.h>
|
||||||
|
|
||||||
|
long
|
||||||
|
gethostid(void)
|
||||||
|
{
|
||||||
|
long ip = -1;
|
||||||
|
ACGetAssignedAddress((uint32_t*) &ip);
|
||||||
|
return ip;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
gethostname(char *name,
|
||||||
|
size_t len)
|
||||||
|
{
|
||||||
|
struct in_addr in;
|
||||||
|
in.s_addr = gethostid();
|
||||||
|
const char *hostname = inet_ntop(AF_INET, &in, name, len);
|
||||||
|
return hostname ? 0 : -1;
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user