2 * larp.c (C) 1995-1998 Darren Reed
4 * See the IPFILTER.LICENCE file for details on licencing.
7 static const char sccsid[] = "@(#)larp.c 1.1 8/19/95 (C)1995 Darren Reed";
8 static const char rcsid[] = "@(#)$Id: larp.c,v 2.1.4.1 2001/06/26 10:43:22 darrenr Exp $";
12 #include <sys/types.h>
13 #include <sys/socket.h>
14 #include <sys/ioctl.h>
16 #include <netinet/in.h>
18 #include <net/if_arp.h>
20 #include "ip_compat.h"
21 #include "iplang/iplang.h"
24 * lookup host and return
25 * its IP address in address
28 int resolve(host, address)
34 add = inet_addr(host);
37 if (!(hp = gethostbyname(host)))
39 fprintf(stderr, "unknown host: %s\n", host);
42 bcopy((char *)hp->h_addr, (char *)address, 4);
45 bcopy((char*)&add, address, 4);
50 * ARP for the MAC address corresponding
51 * to the IP address. This taken from
52 * some BSD program, I cant remember which.
60 struct sockaddr_in *sin;
64 if (arp_getipv4(ip, ether) == 0)
67 bzero((char *)&ar, sizeof(ar));
68 sin = (struct sockaddr_in *)&ar.arp_pa;
69 sin->sin_family = AF_INET;
70 bcopy(ip, (char *)&sin->sin_addr.s_addr, 4);
73 if ((s = socket(AF_INET, SOCK_DGRAM, 0)) == -1)
75 perror("arp: socket");
79 if (ioctl(s, SIOCGARP, (caddr_t)&ar) == -1)
81 fprintf(stderr, "(%s):", inet_ntoa(sin->sin_addr));
87 bcopy(ar.arp_ha.sa_data, ether, 6);