summaryrefslogtreecommitdiff
path: root/fake-getnameinfo.c
diff options
context:
space:
mode:
authorBen Lindstrom <mouring@eviladmin.org>2001-01-31 21:52:01 +0000
committerBen Lindstrom <mouring@eviladmin.org>2001-01-31 21:52:01 +0000
commit3c06f6a0b234822c7b2d6c63ef1aaf554af7167b (patch)
tree86e5fe626cb9cbade752baf2440badfa19976200 /fake-getnameinfo.c
parentbf75776d415126a415ac92fb767c70dc67feba4f (diff)
- (bal) Reorder. Move all bsd-*, fake-*, next-*, and cygwin* stuff to
openbsd-compat/. And resolve all ./configure and Makefile.in issues assocated. Logic: * All OpenBSD functions should have the same filename as in the OpenBSD tree * All 'home brew' functions have bsd-* infront of them. * All 'not really implemented' functions have fake-* infront of them.
Diffstat (limited to 'fake-getnameinfo.c')
-rw-r--r--fake-getnameinfo.c53
1 files changed, 0 insertions, 53 deletions
diff --git a/fake-getnameinfo.c b/fake-getnameinfo.c
deleted file mode 100644
index 203621f0d..000000000
--- a/fake-getnameinfo.c
+++ /dev/null
@@ -1,53 +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#ifndef HAVE_GETNAMEINFO
16int getnameinfo(const struct sockaddr *sa, size_t salen, char *host,
17 size_t hostlen, char *serv, size_t servlen, int flags)
18{
19 struct sockaddr_in *sin = (struct sockaddr_in *)sa;
20 struct hostent *hp;
21 char tmpserv[16];
22
23 if (serv) {
24 snprintf(tmpserv, sizeof(tmpserv), "%d", ntohs(sin->sin_port));
25 if (strlen(tmpserv) >= servlen)
26 return EAI_MEMORY;
27 else
28 strcpy(serv, tmpserv);
29 }
30
31 if (host) {
32 if (flags & NI_NUMERICHOST) {
33 if (strlen(inet_ntoa(sin->sin_addr)) >= hostlen)
34 return EAI_MEMORY;
35
36 strcpy(host, inet_ntoa(sin->sin_addr));
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 (strlen(hp->h_name) >= hostlen)
45 return EAI_MEMORY;
46
47 strcpy(host, hp->h_name);
48 return 0;
49 }
50 }
51 return 0;
52}
53#endif /* !HAVE_GETNAMEINFO */