wutsocket: implement gethostid and gethostname

This commit is contained in:
GaryOderNichts 2021-03-01 19:44:49 +01:00 committed by fincs
parent f1e9cbd58a
commit 174b0c0a86

View 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;
}