8000 minix/commands/simple/arp.c at R3.1.4 · blackskygg/minix · GitHub
[go: up one dir, main page]

Skip to content

Latest commit

 

History

History
473 lines (428 loc) · 9.12 KB

arp.c

File metadata and controls

473 lines (428 loc) · 9.12 KB
}
arp.nwa_ipaddr= ipaddr;
arp.nwa_ethaddr= ethaddr;
arp.nwa_flags= 0;
if (pub)
arp.nwa_flags |= NWAF_PUB;
if (!temp)
arp.nwa_flags |= NWAF_PERM;
r= ioctl(ipfd, NWIOARPSIP, &arp);
if (r == -1)
{
fatal("unable to set arp entry: %s",
errno == EEXIST ? "entry exists" : strerror(errno));
}
}
static ipaddr_t nametoipaddr(char *hostname)
{
ipaddr_t ipaddr;
struct hostent *he;
if (inet_aton(hostname, &ipaddr) == 0)
{
he= gethostbyname(hostname);
if (!he)
fatal("unknown hostname '%s'", hostname);
if (he->h_addrtype != AF_INET ||
he->h_length != sizeof(ipaddr))
{
fatal("strange host '%s': addrtype %d, length %d",
he->h_addrtype, he->h_length);
}
memcpy(&ipaddr, he->h_addr, sizeof(ipaddr));
}
return ipaddr;
}
#if 0
static char *ether_ntoa(struct ether_addr *eap)
{
static char buf[]= "xx:xx:xx:xx:xx:xx";
sprintf(buf, "%02x:%02x:%02x:%02x:%02x:%02x",
eap->ea_addr[0], eap->ea_addr[1],
eap->ea_addr[2], eap->ea_addr[3],
eap->ea_addr[4], eap->ea_addr[5]);
return buf;
}
#endif
static void fatal(char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
fprintf(stderr, "%s: ", progname);
vfprintf(stderr, fmt, ap);
fprintf(stderr, "\n");
va_end(ap);
exit(1);
}
static void usage(void)
{
fprintf(stderr, "Usage:\tarp [-I ip-dev] [-n] hostname\n"
"\tarp [-I ip-dev] [-n] -a\n"
"\tarp [-I ip-dev] -d hostname\n"
"\tarp [-I ip-dev] -d -a\n"
"\tarp [-I ip-dev] -s hostname ether-addr [temp] [pub]\n"
"\tarp [-I ip-dev] -S hostname ether-addr [temp] [pub]\n");
exit(1);
}
/*
* $PchId: arp.c,v 1.3 2005/01/31 22:31:45 philip Exp $
*/
0