2 * larp.c (C) 1995-1998 Darren Reed
4 * See the IPFILTER.LICENCE file for details on licencing.
8 static const char sccsid[] = "@(#)larp.c 1.1 8/19/95 (C)1995 Darren Reed";
9 static const char rcsid[] = "@(#)$Id: larp.c,v 2.4 2003/12/01 02:01:16 darrenr Exp $";
11 #include <sys/param.h>
12 #include <sys/types.h>
13 #include <sys/socket.h>
14 #include <sys/ioctl.h>
15 #include <netinet/in.h>
17 #include <net/if_arp.h>
22 #include "ip_compat.h"
23 #include "iplang/iplang.h"
26 * lookup host and return
27 * its IP address in address
30 int resolve(host, address)
36 add = inet_addr(host);
39 if (!(hp = gethostbyname(host)))
41 fprintf(stderr, "unknown host: %s\n", host);
44 bcopy((char *)hp->h_addr, (char *)address, 4);
47 bcopy((char*)&add, address, 4);
52 * ARP for the MAC address corresponding
53 * to the IP address. This taken from
54 * some BSD program, I cant remember which.
62 struct sockaddr_in *sin;
66 if (arp_getipv4(ip, ether) == 0)
69 bzero((char *)&ar, sizeof(ar));
70 sin = (struct sockaddr_in *)&ar.arp_pa;
71 sin->sin_family = AF_INET;
72 bcopy(ip, (char *)&sin->sin_addr.s_addr, 4);
75 if ((s = socket(AF_INET, SOCK_DGRAM, 0)) == -1)
77 perror("arp: socket");
81 if (ioctl(s, SIOCGARP, (caddr_t)&ar) == -1)
83 fprintf(stderr, "(%s):", inet_ntoa(sin->sin_addr));
89 bcopy(ar.arp_ha.sa_data, ether, 6);