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 04: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(char *hostname
, int htype
)
42 /* XXX - How is this done on other systems? -gwr */
47 static struct ether_addr ea
;
48 /* This does a lookup in /etc/ethers */
49 if (ether_hostton(hostname
, &ea
)) {
50 report(LOG_ERR
, "no HW addr for host \"%s\"",
54 return (u_char
*) & ea
;
56 #endif /* ETC_ETHERS */
59 report(LOG_ERR
, "no lookup for HW addr type %d", htype
);
62 /* If the system can't do it, just return an error. */
68 * Lookup an IP address.
69 * Return non-zero on failure.
72 lookup_ipa(char *hostname
, u_int32
*result
)
75 hp
= gethostbyname(hostname
);
78 bcopy(hp
->h_addr
, result
, sizeof(*result
));
85 * addr and result are both in network order. Return non-zero on failure.
87 * XXX - This is OK as a default, but to really make this automatic,
88 * we would need to get the subnet mask from the ether interface.
89 * If this is wrong, specify the correct value in the bootptab.
92 lookup_netmask(u_int32 addr
, u_int32
*result
)
118 * c-argdecl-indent: 4
119 * c-continued-statement-offset: 4
120 * c-continued-brace-offset: -4