2 * lookup.c - Lookup IP address, HW address, netmask
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(hostname, htype)
43 /* XXX - How is this done on other systems? -gwr */
48 static struct ether_addr ea;
49 /* This does a lookup in /etc/ethers */
50 if (ether_hostton(hostname, &ea)) {
51 report(LOG_ERR, "no HW addr for host \"%s\"",
55 return (u_char *) & ea;
57 #endif /* ETC_ETHERS */
60 report(LOG_ERR, "no lookup for HW addr type %d", htype);
63 /* If the system can't do it, just return an error. */
69 * Lookup an IP address.
70 * Return non-zero on failure.
73 lookup_ipa(hostname, result)
78 hp = gethostbyname(hostname);
81 bcopy(hp->h_addr, result, sizeof(*result));
88 * Return non-zero on failure.
90 * XXX - This is OK as a default, but to really make this automatic,
91 * we would need to get the subnet mask from the ether interface.
92 * If this is wrong, specify the correct value in the bootptab.
95 lookup_netmask(addr, result)
96 u_int32 addr; /* both in network order */
123 * c-argdecl-indent: 4
124 * c-continued-statement-offset: 4
125 * c-continued-brace-offset: -4