Bugzilla – Attachment 574 Details for
Bug 748
HP-UX 11.11 (aka 11i) needs BROKEN_GETADDRINFO
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
Test getnameinfo/getaddrinfo
getaddrinfotest.c (text/plain), 2.58 KB, created by
Darren Tucker
on 2004-03-22 23:10:12 AEDT
(
hide
)
Description:
Test getnameinfo/getaddrinfo
Filename:
MIME Type:
Creator:
Darren Tucker
Created:
2004-03-22 23:10:12 AEDT
Size:
2.58 KB
patch
obsolete
>/* > * $Id: getaddrinfotest.c,v 1.3 2004/03/12 12:51:52 dtucker Exp $ > * getaddrinfotest.c: emulates what OpenSSH's sshd does when attempting > * to bind() to an address. Useful for debugging getaddrinfo/getnameinfo > * problems in sshd. > * > * Author: Darren Tucker. > * Placed in the public domain. > * > * AI_NUMERICHOST testing contributed by Sergio.Gelato (at) astro.su.se > */ >#include <stdio.h> >#include <sys/socket.h> >#include <netdb.h> >#include <netinet/in.h> > >#define TEST_PORT "2222" > >int >main(int argc, char *argv[]) >{ > struct addrinfo *gai_ai, *ai, hints; > struct sockaddr_in6 *sa; > int i, err, sock[64], sockno = 0; > char ntop[NI_MAXHOST], strport[NI_MAXSERV]; > const char *name = NULL; > > if (argc>1) > name = argv[1]; > > memset(&hints, 0, sizeof(hints)); > hints.ai_family = PF_UNSPEC; > hints.ai_socktype = SOCK_STREAM; > hints.ai_flags = AI_PASSIVE; > > err = getaddrinfo(name, TEST_PORT, &hints, &gai_ai); > printf("getaddrinfo returned %d", err); > if (err != 0) > printf("(%s)", gai_strerror(err)); > printf("\n"); > > for (ai = gai_ai; ai != NULL; ai = ai->ai_next) { > printf("Attempting to listen on family %d proto %d\n", > ai->ai_family, ai->ai_protocol); > > if (ai->ai_family == AF_INET6) { > printf("addr = 0x"); > sa = (struct sockaddr_in6 *)ai->ai_addr; > for (i=0; i < 16; i++) > printf("%02x", sa->sin6_addr.s6_addr[i]); > printf("\n"); > } > > err = getnameinfo(ai->ai_addr, ai->ai_addrlen, ntop, > sizeof(ntop), strport, sizeof(strport), > NI_NUMERICHOST|NI_NUMERICSERV); > if (err != 0) { > if (err == EAI_SYSTEM) > perror("getnameinfo EAI_SYSTEM"); > else > printf("getnameinfo failed: %s\n", > gai_strerror(err)); > } else > printf("getnameinfo returned name %s port %s\n", ntop, > strport); > > sock[sockno] = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol); > if (sock < 0) > perror("socket"); > if (bind(sock[sockno], ai->ai_addr, ai->ai_addrlen) < 0) > perror("bind"); > else > printf("bind() succeeded\n"); > sockno++; > > err = getnameinfo(ai->ai_addr, ai->ai_addrlen, > ntop, sizeof(ntop), strport, sizeof(strport), > NI_NAMEREQD); > if (err != 0) { > printf("getnameinfo(NI_NAMEREQD) failed: %s\n", > gai_strerror(err)); > } else { > struct addrinfo *gai_ai2; > memset(&hints, 0, sizeof(hints)); > hints.ai_family = PF_UNSPEC; > hints.ai_socktype = SOCK_STREAM; > hints.ai_flags = AI_NUMERICHOST; > printf("Resolved to %s:%s\n", ntop, strport); > err = getaddrinfo(ntop, "0", &hints, &gai_ai2); > if (err != 0) { > printf("getaddrinfo(AI_NUMERICHOST) failed: %s\n", > gai_strerror(err)); > } else { > printf("%s is numeric\n", ntop); > } > } > } >} >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 748
: 574 |
591
|
592