1 /* $NetBSD: decodenetnum.c,v 1.2 2003/12/04 16:23:36 drochner Exp $ */
4 * decodenetnum - return a net number (this is crude, but careful)
8 #include <sys/socket.h>
9 #include <netinet/in.h>
11 #include "ntp_stdlib.h"
16 struct sockaddr_storage
*netnum
19 struct addrinfo hints
, *ai
= NULL
;
21 register const char *cp
;
28 for (i
= 0; *cp
!= ']'; cp
++, i
++)
33 memset(&hints
, 0, sizeof(struct addrinfo
));
34 hints
.ai_flags
= AI_NUMERICHOST
;
35 err
= getaddrinfo(num
, NULL
, &hints
, &ai
);
38 memcpy(netnum
, (struct sockaddr_storage
*)ai
->ai_addr
, ai
->ai_addrlen
);