diff options
Diffstat (limited to 'openbsd-compat/fake-getnameinfo.c')
-rw-r--r-- | openbsd-compat/fake-getnameinfo.c | 52 |
1 files changed, 0 insertions, 52 deletions
diff --git a/openbsd-compat/fake-getnameinfo.c b/openbsd-compat/fake-getnameinfo.c deleted file mode 100644 index f3b0913de..000000000 --- a/openbsd-compat/fake-getnameinfo.c +++ /dev/null | |||
@@ -1,52 +0,0 @@ | |||
1 | /* | ||
2 | * fake library for ssh | ||
3 | * | ||
4 | * This file includes getnameinfo(). | ||
5 | * These funtions are defined in rfc2133. | ||
6 | * | ||
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. | ||
10 | */ | ||
11 | |||
12 | #include "includes.h" | ||
13 | #include "ssh.h" | ||
14 | |||
15 | RCSID("$Id: fake-getnameinfo.c,v 1.3 2003/05/18 14:13:39 djm Exp $"); | ||
16 | |||
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) | ||
20 | { | ||
21 | struct sockaddr_in *sin = (struct sockaddr_in *)sa; | ||
22 | struct hostent *hp; | ||
23 | char tmpserv[16]; | ||
24 | |||
25 | if (serv != NULL) { | ||
26 | snprintf(tmpserv, sizeof(tmpserv), "%d", ntohs(sin->sin_port)); | ||
27 | if (strlcpy(serv, tmpserv, servlen) >= servlen) | ||
28 | return (EAI_MEMORY); | ||
29 | } | ||
30 | |||
31 | if (host != NULL) { | ||
32 | if (flags & NI_NUMERICHOST) { | ||
33 | if (strlcpy(host, inet_ntoa(sin->sin_addr), | ||
34 | hostlen) >= hostlen) | ||
35 | return (EAI_MEMORY); | ||
36 | else | ||
37 | return (0); | ||
38 | } else { | ||
39 | hp = gethostbyaddr((char *)&sin->sin_addr, | ||
40 | sizeof(struct in_addr), AF_INET); | ||
41 | if (hp == NULL) | ||
42 | return (EAI_NODATA); | ||
43 | |||
44 | if (strlcpy(host, hp->h_name, hostlen) >= hostlen) | ||
45 | return (EAI_MEMORY); | ||
46 | else | ||
47 | return (0); | ||
48 | } | ||
49 | } | ||
50 | return (0); | ||
51 | } | ||
52 | #endif /* !HAVE_GETNAMEINFO */ | ||