xref: /plan9/sys/src/ape/lib/bsd/gethostbyaddr.c (revision 219b2ee8daee37f4aad58d63f21287faa8e4ffdc)
1 /* posix */
2 #include <sys/types.h>
3 #include <unistd.h>
4 
5 /* bsd extensions */
6 #include <sys/uio.h>
7 #include <sys/socket.h>
8 #include <netinet/in.h>
9 #include <netdb.h>
10 
11 int h_errno;
12 
13 struct hostent*
14 gethostbyaddr(char *addr, int len, int type)
15 {
16 	struct in_addr x;
17 
18 	if(type != AF_INET){
19 		h_errno = NO_RECOVERY;
20 		return 0;
21 	}
22 
23 	x.s_addr = (addr[0]<<24)|(addr[1]<<16)|(addr[2]<<8)|addr[3];
24 
25 	return gethostbyname(inet_ntoa(x));
26 }
27