4 * This file includes getnameinfo().
5 * These funtions are defined in rfc2133.
7 * But these functions are not implemented correctly. The minimum subset
8 * is implemented for ssh use only. For exapmle, this routine assumes
9 * that ai_family is AF_INET. Don't use it for another purpose.
17 #ifndef HAVE_GETNAMEINFO
18 int getnameinfo(const struct sockaddr *sa, size_t salen, char *host,
19 size_t hostlen, char *serv, size_t servlen, int flags)
21 struct sockaddr_in *sin = (struct sockaddr_in *)sa;
26 snprintf(tmpserv, sizeof(tmpserv), "%d", ntohs(sin->sin_port));
27 if (strlen(tmpserv) >= servlen)
30 strcpy(serv, tmpserv);
34 if (flags & NI_NUMERICHOST) {
35 if (strlen(inet_ntoa(sin->sin_addr)) >= hostlen)
38 strcpy(host, inet_ntoa(sin->sin_addr));
41 hp = gethostbyaddr((char *)&sin->sin_addr,
42 sizeof(struct in_addr), AF_INET);
46 if (strlen(hp->h_name) >= hostlen)
49 strcpy(host, hp->h_name);
55 #endif /* !HAVE_GETNAMEINFO */