4 * decodenetnum - return a net number (this is crude, but careful)
9 #ifdef HAVE_SYS_SOCKET_H
10 #include <sys/socket.h>
12 #ifdef HAVE_NETINET_IN_H
13 #include <netinet/in.h>
16 #include "ntp_stdlib.h"
17 #include "ntp_assert.h"
25 struct addrinfo hints
, *ai
= NULL
;
27 register const char *cp
;
31 NTP_REQUIRE(num
!= NULL
);
32 NTP_REQUIRE(strlen(num
) < sizeof(name
));
39 while (*cp
&& ']' != *cp
)
44 memset(&hints
, 0, sizeof(hints
));
45 hints
.ai_flags
= AI_NUMERICHOST
;
46 err
= getaddrinfo(cp
, NULL
, &hints
, &ai
);
49 memcpy(netnum
, ai
->ai_addr
, ai
->ai_addrlen
);