mirror of
https://github.com/moparisthebest/curl
synced 2025-02-28 17:31:46 -05:00
Applied Joe Halpin's bugfixes to the NI_WITHSCOPEID test program.
This commit is contained in:
parent
b643d148b1
commit
1fc7ff878e
17
acinclude.m4
17
acinclude.m4
@ -282,25 +282,27 @@ AC_DEFUN([CURL_CHECK_NI_WITHSCOPEID],[
|
|||||||
AC_CACHE_CHECK(for working NI_WITHSCOPEID, ac_cv_working_ni_withscopeid,[
|
AC_CACHE_CHECK(for working NI_WITHSCOPEID, ac_cv_working_ni_withscopeid,[
|
||||||
|
|
||||||
AC_RUN_IFELSE([[
|
AC_RUN_IFELSE([[
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <sys/types.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include <netdb.h>
|
#include <netdb.h>
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
#ifdef NI_WITHSCOPEID
|
#ifdef NI_WITHSCOPEID
|
||||||
struct sockaddr_storage ss;
|
struct sockaddr_storage ss;
|
||||||
int sslen;
|
int sslen = sizeof(ss);
|
||||||
int rc;
|
int rc;
|
||||||
char hbuf[NI_MAXHOST];
|
char hbuf[NI_MAXHOST];
|
||||||
int fd = socket(AF_INET6, SOCK_STREAM, 0);
|
int fd = socket(AF_INET6, SOCK_STREAM, 0);
|
||||||
if(fd < 0) {
|
if(fd < 0) {
|
||||||
printf("couldn't create AF_INET6 socket\n");
|
perror("socket()");
|
||||||
return 4; /* couldn't create socket of either kind */
|
return 1; /* couldn't create socket of either kind */
|
||||||
}
|
}
|
||||||
|
|
||||||
rc = getsockname(fd, (struct sockaddr *)&ss, &sslen);
|
rc = getsockname(fd, (struct sockaddr *)&ss, &sslen);
|
||||||
if(rc) {
|
if(rc) {
|
||||||
printf("getsockname() failed\n");
|
perror("getsockname()");
|
||||||
return 1; /* getsockname() failed unexpectedly */
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
rc = getnameinfo((struct sockaddr *)&ss, sslen, hbuf, sizeof(hbuf),
|
rc = getnameinfo((struct sockaddr *)&ss, sslen, hbuf, sizeof(hbuf),
|
||||||
@ -309,13 +311,12 @@ int main()
|
|||||||
|
|
||||||
if(rc) {
|
if(rc) {
|
||||||
printf("rc = %s\n", gai_strerror(rc));
|
printf("rc = %s\n", gai_strerror(rc));
|
||||||
return 2; /* getnameinfo() failed, we take this as an indication to
|
return 3;
|
||||||
avoid NI_WITHSCOPEID */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0; /* everything works fine, use NI_WITHSCOPEID! */
|
return 0; /* everything works fine, use NI_WITHSCOPEID! */
|
||||||
#else
|
#else
|
||||||
return 3; /* we don't seem to have the definition, don't use it */
|
return 4; /* we don't seem to have the definition, don't use it */
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
]],
|
]],
|
||||||
|
Loading…
x
Reference in New Issue
Block a user