blob: bd58b1dffd7ce5dc1fc8a1af4c2c5b5b793e99ea (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
/* posix */
#include <sys/types.h>
#include <unistd.h>
/* bsd extensions */
#include <sys/uio.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
int h_errno;
struct hostent*
gethostbyaddr(void *addr, int len, int type)
{
unsigned long a, y;
struct in_addr x;
unsigned char *p = addr;
if(type != AF_INET || len != 4){
h_errno = NO_RECOVERY;
return 0;
}
y = (p[0]<<24)|(p[1]<<16)|(p[2]<<8)|p[3];
x.s_addr = htonl(y);
return gethostbyname(inet_ntoa(x));
}
|