10Sstevel@tonic-gate /*
2*2546Scarlsonj * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
30Sstevel@tonic-gate * Use is subject to license terms.
40Sstevel@tonic-gate */
50Sstevel@tonic-gate /*
60Sstevel@tonic-gate * Copyright (c) 1984 Regents of the University of California.
70Sstevel@tonic-gate * All rights reserved.
80Sstevel@tonic-gate *
90Sstevel@tonic-gate * This code is derived from software contributed to Berkeley by
100Sstevel@tonic-gate * Sun Microsystems, Inc.
110Sstevel@tonic-gate *
120Sstevel@tonic-gate * Redistribution and use in source and binary forms, with or without
130Sstevel@tonic-gate * modification, are permitted provided that the following conditions
140Sstevel@tonic-gate * are met:
150Sstevel@tonic-gate * 1. Redistributions of source code must retain the above copyright
160Sstevel@tonic-gate * notice, this list of conditions and the following disclaimer.
170Sstevel@tonic-gate * 2. Redistributions in binary form must reproduce the above copyright
180Sstevel@tonic-gate * notice, this list of conditions and the following disclaimer in the
190Sstevel@tonic-gate * documentation and/or other materials provided with the distribution.
200Sstevel@tonic-gate * 3. All advertising materials mentioning features or use of this software
210Sstevel@tonic-gate * must display the following acknowledgement:
220Sstevel@tonic-gate * This product includes software developed by the University of
230Sstevel@tonic-gate * California, Berkeley and its contributors.
240Sstevel@tonic-gate * 4. Neither the name of the University nor the names of its contributors
250Sstevel@tonic-gate * may be used to endorse or promote products derived from this software
260Sstevel@tonic-gate * without specific prior written permission.
270Sstevel@tonic-gate *
280Sstevel@tonic-gate * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
290Sstevel@tonic-gate * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
300Sstevel@tonic-gate * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
310Sstevel@tonic-gate * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
320Sstevel@tonic-gate * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
330Sstevel@tonic-gate * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
340Sstevel@tonic-gate * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
350Sstevel@tonic-gate * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
360Sstevel@tonic-gate * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
370Sstevel@tonic-gate * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
380Sstevel@tonic-gate * SUCH DAMAGE.
390Sstevel@tonic-gate */
400Sstevel@tonic-gate
410Sstevel@tonic-gate
420Sstevel@tonic-gate
430Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI"
440Sstevel@tonic-gate
450Sstevel@tonic-gate /*
460Sstevel@tonic-gate * arp - display, set, and delete arp table entries
470Sstevel@tonic-gate */
480Sstevel@tonic-gate
490Sstevel@tonic-gate #include <stdio.h>
500Sstevel@tonic-gate #include <sys/types.h>
510Sstevel@tonic-gate #include <sys/socket.h>
520Sstevel@tonic-gate #include <netinet/in.h>
530Sstevel@tonic-gate #include <sys/ioctl.h>
540Sstevel@tonic-gate #include <errno.h>
550Sstevel@tonic-gate #include <netdb.h>
560Sstevel@tonic-gate #include <net/if.h>
570Sstevel@tonic-gate #include <net/if_arp.h>
580Sstevel@tonic-gate #include <stdlib.h>
590Sstevel@tonic-gate #include <unistd.h>
600Sstevel@tonic-gate #include <string.h>
610Sstevel@tonic-gate #include <arpa/inet.h>
620Sstevel@tonic-gate #include <net/if_types.h>
630Sstevel@tonic-gate #include <net/if_dl.h>
640Sstevel@tonic-gate
650Sstevel@tonic-gate static int file(char *);
660Sstevel@tonic-gate static int set(int, char *[]);
670Sstevel@tonic-gate static void get(char *);
680Sstevel@tonic-gate static void delete(char *);
690Sstevel@tonic-gate static void usage(void);
700Sstevel@tonic-gate
710Sstevel@tonic-gate int
main(int argc,char * argv[])720Sstevel@tonic-gate main(int argc, char *argv[])
730Sstevel@tonic-gate {
740Sstevel@tonic-gate int c, nflags = 0, argsleft;
750Sstevel@tonic-gate int n_flag, a_flag, d_flag, f_flag, s_flag;
760Sstevel@tonic-gate
770Sstevel@tonic-gate n_flag = a_flag = d_flag = f_flag = s_flag = 0;
780Sstevel@tonic-gate
790Sstevel@tonic-gate #define CASE(x, y) \
800Sstevel@tonic-gate case x: \
810Sstevel@tonic-gate if (nflags > 0) { \
820Sstevel@tonic-gate usage(); \
830Sstevel@tonic-gate exit(1); \
840Sstevel@tonic-gate } else \
850Sstevel@tonic-gate y##_flag = 1; \
860Sstevel@tonic-gate nflags++; \
870Sstevel@tonic-gate break
880Sstevel@tonic-gate
890Sstevel@tonic-gate while ((c = getopt(argc, argv, "nadfs")) != EOF) {
900Sstevel@tonic-gate switch (c) {
910Sstevel@tonic-gate case '?':
920Sstevel@tonic-gate usage();
930Sstevel@tonic-gate exit(1);
940Sstevel@tonic-gate /* NOTREACHED */
950Sstevel@tonic-gate break;
960Sstevel@tonic-gate case 'n':
970Sstevel@tonic-gate n_flag = 1;
980Sstevel@tonic-gate break;
990Sstevel@tonic-gate CASE('a', a);
1000Sstevel@tonic-gate CASE('d', d);
1010Sstevel@tonic-gate CASE('f', f);
1020Sstevel@tonic-gate CASE('s', s);
1030Sstevel@tonic-gate }
1040Sstevel@tonic-gate }
1050Sstevel@tonic-gate
1060Sstevel@tonic-gate #undef CASE
1070Sstevel@tonic-gate
1080Sstevel@tonic-gate /*
1090Sstevel@tonic-gate * -n only allowed with -a
1100Sstevel@tonic-gate */
1110Sstevel@tonic-gate if (n_flag && !a_flag) {
1120Sstevel@tonic-gate usage();
1130Sstevel@tonic-gate exit(1);
1140Sstevel@tonic-gate }
1150Sstevel@tonic-gate
1160Sstevel@tonic-gate argsleft = argc - optind;
1170Sstevel@tonic-gate
1180Sstevel@tonic-gate if (a_flag && (argsleft == 0)) {
1190Sstevel@tonic-gate /*
1200Sstevel@tonic-gate * the easiest way to get the complete arp table
1210Sstevel@tonic-gate * is to let netstat, which prints it as part of
1220Sstevel@tonic-gate * the MIB statistics, do it.
1230Sstevel@tonic-gate */
1240Sstevel@tonic-gate (void) execl("/usr/bin/netstat", "netstat",
1250Sstevel@tonic-gate (n_flag ? "-np" : "-p"),
1260Sstevel@tonic-gate "-f", "inet", (char *)0);
1270Sstevel@tonic-gate exit(1);
1280Sstevel@tonic-gate
1290Sstevel@tonic-gate } else if (s_flag && (argsleft >= 2)) {
1300Sstevel@tonic-gate if (set(argsleft, &argv[optind]) != 0)
1310Sstevel@tonic-gate exit(1);
1320Sstevel@tonic-gate
1330Sstevel@tonic-gate } else if (d_flag && (argsleft == 1)) {
1340Sstevel@tonic-gate delete(argv[optind]);
1350Sstevel@tonic-gate
1360Sstevel@tonic-gate } else if (f_flag && (argsleft == 1)) {
1370Sstevel@tonic-gate if (file(argv[optind]) != 0)
1380Sstevel@tonic-gate exit(1);
1390Sstevel@tonic-gate
1400Sstevel@tonic-gate } else if ((nflags == 0) && (argsleft == 1)) {
1410Sstevel@tonic-gate get(argv[optind]);
1420Sstevel@tonic-gate
1430Sstevel@tonic-gate } else {
1440Sstevel@tonic-gate usage();
1450Sstevel@tonic-gate exit(1);
1460Sstevel@tonic-gate }
1470Sstevel@tonic-gate return (0);
1480Sstevel@tonic-gate }
1490Sstevel@tonic-gate
1500Sstevel@tonic-gate /*
1510Sstevel@tonic-gate * Process a file to set standard arp entries
1520Sstevel@tonic-gate */
153*2546Scarlsonj static int
file(char * name)154*2546Scarlsonj file(char *name)
1550Sstevel@tonic-gate {
1560Sstevel@tonic-gate /*
1570Sstevel@tonic-gate * A line of input can be:
158*2546Scarlsonj * <hostname> <macaddr> ["temp"] ["pub"] ["trail"] ["permanent"]
1590Sstevel@tonic-gate */
1600Sstevel@tonic-gate #define MAX_LINE_LEN (MAXHOSTNAMELEN + \
161*2546Scarlsonj sizeof (" xx:xx:xx:xx:xx:xx temp pub trail permanent\n"))
1620Sstevel@tonic-gate #define MIN_ARGS 2
1630Sstevel@tonic-gate #define MAX_ARGS 5
1640Sstevel@tonic-gate
1650Sstevel@tonic-gate FILE *fp;
1660Sstevel@tonic-gate char line[MAX_LINE_LEN];
1670Sstevel@tonic-gate int retval;
1680Sstevel@tonic-gate
1690Sstevel@tonic-gate if ((fp = fopen(name, "r")) == NULL) {
1700Sstevel@tonic-gate (void) fprintf(stderr, "arp: cannot open %s\n", name);
1710Sstevel@tonic-gate exit(1);
1720Sstevel@tonic-gate }
1730Sstevel@tonic-gate
1740Sstevel@tonic-gate retval = 0;
1750Sstevel@tonic-gate while (fgets(line, MAX_LINE_LEN, fp) != NULL) {
1760Sstevel@tonic-gate char line_copy[MAX_LINE_LEN];
1770Sstevel@tonic-gate char *args[MAX_ARGS];
1780Sstevel@tonic-gate char *start;
1790Sstevel@tonic-gate int i;
1800Sstevel@tonic-gate
1810Sstevel@tonic-gate /*
1820Sstevel@tonic-gate * Keep a copy of the un-altered line for error
1830Sstevel@tonic-gate * reporting.
1840Sstevel@tonic-gate */
1850Sstevel@tonic-gate (void) strlcpy(line_copy, line, MAX_LINE_LEN);
1860Sstevel@tonic-gate
1870Sstevel@tonic-gate start = line_copy;
1880Sstevel@tonic-gate for (i = 0; i < MAX_ARGS; i++) {
1890Sstevel@tonic-gate if ((args[i] = strtok(start, " \t\n")) == NULL)
1900Sstevel@tonic-gate break;
1910Sstevel@tonic-gate
1920Sstevel@tonic-gate start = NULL;
1930Sstevel@tonic-gate }
1940Sstevel@tonic-gate
1950Sstevel@tonic-gate if (i < MIN_ARGS) {
1960Sstevel@tonic-gate (void) fprintf(stderr, "arp: bad line: %s\n",
1970Sstevel@tonic-gate line);
1980Sstevel@tonic-gate retval = 1;
1990Sstevel@tonic-gate continue;
2000Sstevel@tonic-gate }
2010Sstevel@tonic-gate
2020Sstevel@tonic-gate if (set(i, args) != 0)
2030Sstevel@tonic-gate retval = 1;
2040Sstevel@tonic-gate }
2050Sstevel@tonic-gate
2060Sstevel@tonic-gate #undef MAX_LINE_LEN
2070Sstevel@tonic-gate #undef MIN_ARGS
2080Sstevel@tonic-gate #undef MAX_ARGS
2090Sstevel@tonic-gate
2100Sstevel@tonic-gate (void) fclose(fp);
2110Sstevel@tonic-gate return (retval);
2120Sstevel@tonic-gate }
2130Sstevel@tonic-gate
2140Sstevel@tonic-gate /*
2150Sstevel@tonic-gate * Set an individual arp entry
2160Sstevel@tonic-gate */
217*2546Scarlsonj static int
set(int argc,char * argv[])218*2546Scarlsonj set(int argc, char *argv[])
2190Sstevel@tonic-gate {
2200Sstevel@tonic-gate struct xarpreq ar;
2210Sstevel@tonic-gate struct hostent *hp;
2220Sstevel@tonic-gate struct sockaddr_in *sin;
2230Sstevel@tonic-gate uchar_t *ea;
2240Sstevel@tonic-gate int s;
2250Sstevel@tonic-gate char *host = argv[0], *eaddr = argv[1];
2260Sstevel@tonic-gate
2270Sstevel@tonic-gate argc -= 2;
2280Sstevel@tonic-gate argv += 2;
2290Sstevel@tonic-gate (void) memset(&ar, 0, sizeof (ar));
2300Sstevel@tonic-gate sin = (struct sockaddr_in *)&ar.xarp_pa;
2310Sstevel@tonic-gate sin->sin_family = AF_INET;
2320Sstevel@tonic-gate sin->sin_addr.s_addr = inet_addr(host);
2330Sstevel@tonic-gate if (sin->sin_addr.s_addr == (in_addr_t)-1) {
2340Sstevel@tonic-gate hp = gethostbyname(host);
2350Sstevel@tonic-gate if (hp == NULL) {
2360Sstevel@tonic-gate (void) fprintf(stderr, "arp: %s: unknown host\n",
2370Sstevel@tonic-gate host);
2380Sstevel@tonic-gate return (1);
2390Sstevel@tonic-gate }
2400Sstevel@tonic-gate (void) memcpy(&sin->sin_addr, hp->h_addr,
2410Sstevel@tonic-gate sizeof (sin->sin_addr));
2420Sstevel@tonic-gate }
2430Sstevel@tonic-gate ea = _link_aton(eaddr, &s);
2440Sstevel@tonic-gate if (ea == NULL) {
2450Sstevel@tonic-gate if (s == -1) {
2460Sstevel@tonic-gate (void) fprintf(stderr,
2470Sstevel@tonic-gate "arp: invalid link layer address '%s'\n", eaddr);
2480Sstevel@tonic-gate return (1);
2490Sstevel@tonic-gate }
2500Sstevel@tonic-gate perror("arp: nomem");
2510Sstevel@tonic-gate exit(1);
2520Sstevel@tonic-gate }
2530Sstevel@tonic-gate ar.xarp_ha.sdl_alen = s;
2540Sstevel@tonic-gate (void) memcpy(LLADDR(&ar.xarp_ha), ea, ar.xarp_ha.sdl_alen);
2550Sstevel@tonic-gate free(ea);
2560Sstevel@tonic-gate ar.xarp_ha.sdl_family = AF_LINK;
2570Sstevel@tonic-gate ar.xarp_flags = ATF_PERM;
2580Sstevel@tonic-gate while (argc-- > 0) {
259*2546Scarlsonj if (strncmp(argv[0], "temp", 4) == 0) {
2600Sstevel@tonic-gate ar.xarp_flags &= ~ATF_PERM;
261*2546Scarlsonj } else if (strncmp(argv[0], "pub", 3) == 0) {
2620Sstevel@tonic-gate ar.xarp_flags |= ATF_PUBL;
263*2546Scarlsonj } else if (strncmp(argv[0], "trail", 5) == 0) {
2640Sstevel@tonic-gate ar.xarp_flags |= ATF_USETRAILERS;
265*2546Scarlsonj } else if (strcmp(argv[0], "permanent") == 0) {
266*2546Scarlsonj ar.xarp_flags |= ATF_AUTHORITY;
267*2546Scarlsonj } else {
268*2546Scarlsonj (void) fprintf(stderr,
269*2546Scarlsonj "arp: unknown keyword '%s'\n", argv[0]);
270*2546Scarlsonj return (1);
271*2546Scarlsonj }
2720Sstevel@tonic-gate argv++;
2730Sstevel@tonic-gate }
2740Sstevel@tonic-gate
275*2546Scarlsonj if ((ar.xarp_flags & (ATF_PERM|ATF_AUTHORITY)) == ATF_AUTHORITY) {
276*2546Scarlsonj (void) fprintf(stderr, "arp: 'temp' and 'permanent' flags are "
277*2546Scarlsonj "not usable together.\n");
278*2546Scarlsonj return (1);
279*2546Scarlsonj }
280*2546Scarlsonj
2810Sstevel@tonic-gate s = socket(AF_INET, SOCK_DGRAM, 0);
2820Sstevel@tonic-gate if (s < 0) {
2830Sstevel@tonic-gate perror("arp: socket");
2840Sstevel@tonic-gate exit(1);
2850Sstevel@tonic-gate }
2860Sstevel@tonic-gate if (ioctl(s, SIOCSXARP, (caddr_t)&ar) < 0) {
2870Sstevel@tonic-gate perror(host);
2880Sstevel@tonic-gate exit(1);
2890Sstevel@tonic-gate }
2900Sstevel@tonic-gate (void) close(s);
2910Sstevel@tonic-gate return (0);
2920Sstevel@tonic-gate }
2930Sstevel@tonic-gate
2940Sstevel@tonic-gate /*
2950Sstevel@tonic-gate * Display an individual arp entry
2960Sstevel@tonic-gate */
297*2546Scarlsonj static void
get(char * host)298*2546Scarlsonj get(char *host)
2990Sstevel@tonic-gate {
3000Sstevel@tonic-gate struct xarpreq ar;
3010Sstevel@tonic-gate struct hostent *hp;
3020Sstevel@tonic-gate struct sockaddr_in *sin;
3030Sstevel@tonic-gate uchar_t *ea;
3040Sstevel@tonic-gate int s;
3050Sstevel@tonic-gate char *str = NULL;
3060Sstevel@tonic-gate
3070Sstevel@tonic-gate (void) memset(&ar, 0, sizeof (ar));
3080Sstevel@tonic-gate sin = (struct sockaddr_in *)&ar.xarp_pa;
3090Sstevel@tonic-gate sin->sin_family = AF_INET;
3100Sstevel@tonic-gate sin->sin_addr.s_addr = inet_addr(host);
3110Sstevel@tonic-gate if (sin->sin_addr.s_addr == (in_addr_t)-1) {
3120Sstevel@tonic-gate hp = gethostbyname(host);
3130Sstevel@tonic-gate if (hp == NULL) {
3140Sstevel@tonic-gate (void) fprintf(stderr, "arp: %s: unknown host\n",
3150Sstevel@tonic-gate host);
3160Sstevel@tonic-gate exit(1);
3170Sstevel@tonic-gate }
3180Sstevel@tonic-gate (void) memcpy(&sin->sin_addr, hp->h_addr,
3190Sstevel@tonic-gate sizeof (sin->sin_addr));
3200Sstevel@tonic-gate }
3210Sstevel@tonic-gate s = socket(AF_INET, SOCK_DGRAM, 0);
3220Sstevel@tonic-gate if (s < 0) {
3230Sstevel@tonic-gate perror("arp: socket");
3240Sstevel@tonic-gate exit(1);
3250Sstevel@tonic-gate }
3260Sstevel@tonic-gate ar.xarp_ha.sdl_family = AF_LINK;
3270Sstevel@tonic-gate if (ioctl(s, SIOCGXARP, (caddr_t)&ar) < 0) {
3280Sstevel@tonic-gate if (errno == ENXIO)
3290Sstevel@tonic-gate (void) printf("%s (%s) -- no entry\n",
3300Sstevel@tonic-gate host, inet_ntoa(sin->sin_addr));
3310Sstevel@tonic-gate else
3320Sstevel@tonic-gate perror("SIOCGXARP");
3330Sstevel@tonic-gate exit(1);
3340Sstevel@tonic-gate }
3350Sstevel@tonic-gate (void) close(s);
3360Sstevel@tonic-gate ea = (uchar_t *)LLADDR(&ar.xarp_ha);
3370Sstevel@tonic-gate if (ar.xarp_flags & ATF_COM) {
3380Sstevel@tonic-gate str = _link_ntoa(ea, str, ar.xarp_ha.sdl_alen, IFT_OTHER);
3390Sstevel@tonic-gate if (str != NULL) {
3400Sstevel@tonic-gate (void) printf("%s (%s) at %s", host,
3410Sstevel@tonic-gate inet_ntoa(sin->sin_addr), str);
3420Sstevel@tonic-gate free(str);
3430Sstevel@tonic-gate } else {
3440Sstevel@tonic-gate perror("arp: nomem");
3450Sstevel@tonic-gate exit(1);
3460Sstevel@tonic-gate }
3470Sstevel@tonic-gate } else {
3480Sstevel@tonic-gate (void) printf("%s (%s) at (incomplete)", host,
3490Sstevel@tonic-gate inet_ntoa(sin->sin_addr));
3500Sstevel@tonic-gate }
351*2546Scarlsonj if (!(ar.xarp_flags & ATF_PERM))
352*2546Scarlsonj (void) printf(" temp");
3530Sstevel@tonic-gate if (ar.xarp_flags & ATF_PUBL)
354*2546Scarlsonj (void) printf(" pub");
3550Sstevel@tonic-gate if (ar.xarp_flags & ATF_USETRAILERS)
356*2546Scarlsonj (void) printf(" trail");
357*2546Scarlsonj if (ar.xarp_flags & ATF_AUTHORITY)
358*2546Scarlsonj (void) printf(" permanent");
3590Sstevel@tonic-gate (void) printf("\n");
3600Sstevel@tonic-gate }
3610Sstevel@tonic-gate
3620Sstevel@tonic-gate /*
3630Sstevel@tonic-gate * Delete an arp entry
3640Sstevel@tonic-gate */
365*2546Scarlsonj static void
delete(char * host)366*2546Scarlsonj delete(char *host)
3670Sstevel@tonic-gate {
3680Sstevel@tonic-gate struct xarpreq ar;
3690Sstevel@tonic-gate struct hostent *hp;
3700Sstevel@tonic-gate struct sockaddr_in *sin;
3710Sstevel@tonic-gate int s;
3720Sstevel@tonic-gate
3730Sstevel@tonic-gate (void) memset(&ar, 0, sizeof (ar));
3740Sstevel@tonic-gate sin = (struct sockaddr_in *)&ar.xarp_pa;
3750Sstevel@tonic-gate sin->sin_family = AF_INET;
3760Sstevel@tonic-gate sin->sin_addr.s_addr = inet_addr(host);
3770Sstevel@tonic-gate if (sin->sin_addr.s_addr == (in_addr_t)-1) {
3780Sstevel@tonic-gate hp = gethostbyname(host);
3790Sstevel@tonic-gate if (hp == NULL) {
3800Sstevel@tonic-gate (void) fprintf(stderr, "arp: %s: unknown host\n",
3810Sstevel@tonic-gate host);
3820Sstevel@tonic-gate exit(1);
3830Sstevel@tonic-gate }
3840Sstevel@tonic-gate (void) memcpy(&sin->sin_addr, hp->h_addr,
3850Sstevel@tonic-gate sizeof (sin->sin_addr));
3860Sstevel@tonic-gate }
3870Sstevel@tonic-gate s = socket(AF_INET, SOCK_DGRAM, 0);
3880Sstevel@tonic-gate if (s < 0) {
3890Sstevel@tonic-gate perror("arp: socket");
3900Sstevel@tonic-gate exit(1);
3910Sstevel@tonic-gate }
3920Sstevel@tonic-gate ar.xarp_ha.sdl_family = AF_LINK;
3930Sstevel@tonic-gate if (ioctl(s, SIOCDXARP, (caddr_t)&ar) < 0) {
3940Sstevel@tonic-gate if (errno == ENXIO)
3950Sstevel@tonic-gate (void) printf("%s (%s) -- no entry\n",
3960Sstevel@tonic-gate host, inet_ntoa(sin->sin_addr));
3970Sstevel@tonic-gate else
3980Sstevel@tonic-gate perror("SIOCDXARP");
3990Sstevel@tonic-gate exit(1);
4000Sstevel@tonic-gate }
4010Sstevel@tonic-gate (void) close(s);
4020Sstevel@tonic-gate (void) printf("%s (%s) deleted\n", host, inet_ntoa(sin->sin_addr));
4030Sstevel@tonic-gate }
4040Sstevel@tonic-gate
405*2546Scarlsonj static void
usage(void)406*2546Scarlsonj usage(void)
4070Sstevel@tonic-gate {
4080Sstevel@tonic-gate (void) printf("Usage: arp hostname\n");
4090Sstevel@tonic-gate (void) printf(" arp -a [-n]\n");
4100Sstevel@tonic-gate (void) printf(" arp -d hostname\n");
4110Sstevel@tonic-gate (void) printf(" arp -s hostname ether_addr "
412*2546Scarlsonj "[temp] [pub] [trail] [permanent]\n");
4130Sstevel@tonic-gate (void) printf(" arp -f filename\n");
4140Sstevel@tonic-gate }
415