2 * lookup.c - Lookup IP address, HW address, netmask
4 * $FreeBSD: src/libexec/bootpd/lookup.c,v 1.7 1999/08/28 00:09:19 peter Exp $
8 #include <sys/socket.h>
10 #include <sys/time.h> /* for struct timeval in net/if.h */
12 #include <netinet/in.h>
15 #include <net/ethernet.h>
16 extern int ether_hostton();
24 /* Yes, memcpy is OK here (no overlapped copies). */
25 #define bcopy(a,b,c) memcpy(b,a,c)
33 * Lookup an Ethernet address and return it.
34 * Return NULL if addr not found.
37 lookup_hwa(char *hostname, int htype)
41 /* XXX - How is this done on other systems? -gwr */
46 static struct ether_addr ea;
47 /* This does a lookup in /etc/ethers */
48 if (ether_hostton(hostname, &ea)) {
49 report(LOG_ERR, "no HW addr for host \"%s\"",
53 return (u_char *) & ea;
55 #endif /* ETC_ETHERS */
58 report(LOG_ERR, "no lookup for HW addr type %d", htype);
61 /* If the system can't do it, just return an error. */
67 * Lookup an IP address.
68 * Return non-zero on failure.
71 lookup_ipa(char *hostname, u_int32 *result)
74 hp = gethostbyname(hostname);
77 bcopy(hp->h_addr, result, sizeof(*result));
84 * addr and result are both in network order. Return non-zero on failure.
86 * XXX - This is OK as a default, but to really make this automatic,
87 * we would need to get the subnet mask from the ether interface.
88 * If this is wrong, specify the correct value in the bootptab.
91 lookup_netmask(u_int32 addr, u_int32 *result)