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 $
5 * $DragonFly: src/libexec/bootpd/lookup.c,v 1.2 2003/06/17 06:27:07 dillon Exp $
9 #include <sys/socket.h>
11 #include <sys/time.h> /* for struct timeval in net/if.h */
13 #include <netinet/in.h>
16 #include <net/ethernet.h>
17 extern int ether_hostton();
25 /* Yes, memcpy is OK here (no overlapped copies). */
26 #define bcopy(a,b,c) memcpy(b,a,c)
34 * Lookup an Ethernet address and return it.
35 * Return NULL if addr not found.
38 lookup_hwa(hostname
, htype
)
44 /* XXX - How is this done on other systems? -gwr */
49 static struct ether_addr ea
;
50 /* This does a lookup in /etc/ethers */
51 if (ether_hostton(hostname
, &ea
)) {
52 report(LOG_ERR
, "no HW addr for host \"%s\"",
56 return (u_char
*) & ea
;
58 #endif /* ETC_ETHERS */
61 report(LOG_ERR
, "no lookup for HW addr type %d", htype
);
64 /* If the system can't do it, just return an error. */
70 * Lookup an IP address.
71 * Return non-zero on failure.
74 lookup_ipa(hostname
, result
)
79 hp
= gethostbyname(hostname
);
82 bcopy(hp
->h_addr
, result
, sizeof(*result
));
89 * Return non-zero on failure.
91 * XXX - This is OK as a default, but to really make this automatic,
92 * we would need to get the subnet mask from the ether interface.
93 * If this is wrong, specify the correct value in the bootptab.
96 lookup_netmask(addr
, result
)
97 u_int32 addr
; /* both in network order */
124 * c-argdecl-indent: 4
125 * c-continued-statement-offset: 4
126 * c-continued-brace-offset: -4