wut/libraries/wutsocket/hostid.c
GaryOderNichts 2c98cc91aa
Some checks failed
C/C++ CI / ubuntu-latest (push) Has been cancelled
Run clang-format
`find . -regex '.*\.\(cpp\|hpp\|cu\|cuh\|c\|h\)' -exec clang-format -style=file -i {} \;`
2025-06-05 11:06:04 +01:00

22 lines
358 B
C

#include "wut_socket.h"
#include <nn/ac.h>
long
gethostid(void)
{
uint32_t ip = UINT32_MAX;
ACGetAssignedAddress(&ip);
return (long)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;
}