1 /* $NetBSD: lookup.c,v 1.5 2002/07/14 00:26:17 wiz Exp $ */
5 __RCSID("$NetBSD: lookup.c,v 1.5 2002/07/14 00:26:17 wiz Exp $");
9 * lookup.c - Lookup IP address, HW address, netmask
12 #include <sys/types.h>
13 #include <sys/socket.h>
16 #include <netinet/in.h>
19 #include <net/if_ether.h>
31 * Lookup an Ethernet address and return it.
32 * Return NULL if addr not found.
35 lookup_hwa(char *hostname
, int htype
)
39 /* XXX - How is this done on other systems? -gwr */
44 static struct ether_addr ea
;
45 /* This does a lookup in /etc/ethers */
46 if (ether_hostton(hostname
, &ea
)) {
47 report(LOG_ERR
, "no HW addr for host \"%s\"",
51 return (u_char
*) & ea
;
53 #endif /* ETC_ETHERS */
56 report(LOG_ERR
, "no lookup for HW addr type %d", htype
);
59 /* If the system can't do it, just return an error. */
65 * Lookup an IP address.
66 * Return non-zero on failure.
69 lookup_ipa(char *hostname
, u_int32
*result
)
72 hp
= gethostbyname(hostname
);
75 bcopy(hp
->h_addr
, result
, sizeof(*result
));
82 * Return non-zero on failure.
84 * XXX - This is OK as a default, but to really make this automatic,
85 * we would need to get the subnet mask from the ether interface.
86 * If this is wrong, specify the correct value in the bootptab.
88 * Both inputs are in network order.
91 lookup_netmask(u_int32 addr
, u_int32
*result
)
117 * c-argdecl-indent: 4
118 * c-continued-statement-offset: 4
119 * c-continued-brace-offset: -4