View | Details | Raw Unified | Return to bug 139346
Collapse All | Expand All

(-)b/usr.sbin/arp/arp.c (-8 / +33 lines)
Lines 101-107 static int valid_type(int type); Link Here
101
static int nflag;	/* no reverse dns lookups */
101
static int nflag;	/* no reverse dns lookups */
102
static char *rifname;
102
static char *rifname;
103
103
104
static int	expire_time, flags, doing_proxy, proxy_only;
104
static int	expire_time, flags, func, doing_proxy, proxy_only;
105
105
106
/* which function we're supposed to do */
106
/* which function we're supposed to do */
107
#define F_GET		1
107
#define F_GET		1
Lines 109-131 static int expire_time, flags, doing_proxy, proxy_only; Link Here
109
#define F_FILESET	3
109
#define F_FILESET	3
110
#define F_REPLACE	4
110
#define F_REPLACE	4
111
#define F_DELETE	5
111
#define F_DELETE	5
112
#define F_FILEDELETE	6
112
113
113
#define SETFUNC(f)	{ if (func) usage(); func = (f); }
114
#define SETFUNC(f)	{ if (func) usage(); func = (f); }
114
115
115
int
116
int
116
main(int argc, char *argv[])
117
main(int argc, char *argv[])
117
{
118
{
118
	int ch, func = 0;
119
	int ch;
119
	int rtn = 0;
120
	int rtn = 0;
120
	int aflag = 0;	/* do it for all entries */
121
	int aflag = 0;	/* do it for all entries */
121
122
123
	func = 0;
122
	while ((ch = getopt(argc, argv, "andfsSi:")) != -1)
124
	while ((ch = getopt(argc, argv, "andfsSi:")) != -1)
123
		switch(ch) {
125
		switch(ch) {
124
		case 'a':
126
		case 'a':
125
			aflag = 1;
127
			aflag = 1;
126
			break;
128
			break;
127
		case 'd':
129
		case 'd':
128
			SETFUNC(F_DELETE);
130
			if (func == F_FILESET)
131
				func = F_FILEDELETE;
132
			else 
133
				SETFUNC(F_DELETE);
129
			break;
134
			break;
130
		case 'n':
135
		case 'n':
131
			nflag = 1;
136
			nflag = 1;
Lines 137-143 main(int argc, char *argv[]) Link Here
137
			SETFUNC(F_SET);
142
			SETFUNC(F_SET);
138
			break;
143
			break;
139
		case 'f' :
144
		case 'f' :
140
			SETFUNC(F_FILESET);
145
			if (func == F_DELETE)
146
				func = F_FILEDELETE;
147
			else
148
				SETFUNC(F_FILESET);
141
			break;
149
			break;
142
		case 'i':
150
		case 'i':
143
			rifname = optarg;
151
			rifname = optarg;
Lines 197-202 main(int argc, char *argv[]) Link Here
197
		}
205
		}
198
		break;
206
		break;
199
	case F_FILESET:
207
	case F_FILESET:
208
	case F_FILEDELETE:
200
		if (argc != 1)
209
		if (argc != 1)
201
			usage();
210
			usage();
202
		rtn = file(argv[0]);
211
		rtn = file(argv[0]);
Lines 213-219 static int Link Here
213
file(char *name)
222
file(char *name)
214
{
223
{
215
	FILE *fp;
224
	FILE *fp;
216
	int i, retval;
225
	int i, j, retval;
217
	char line[100], arg[5][50], *args[5], *p;
226
	char line[100], arg[5][50], *args[5], *p;
218
227
219
	if ((fp = fopen(name, "r")) == NULL)
228
	if ((fp = fopen(name, "r")) == NULL)
Lines 237-244 file(char *name) Link Here
237
			retval = 1;
246
			retval = 1;
238
			continue;
247
			continue;
239
		}
248
		}
240
		if (set(i, args))
249
		switch (func) {
241
			retval = 1;
250
		case F_FILESET:
251
			if (set(i, args))
252
				retval = 1;
253
			break;
254
		case F_FILEDELETE:
255
			for (j = 2; j < i; j++)
256
				if (strncmp(args[j], "pub", 3) == 0) {
257
					j = 0;
258
					break;
259
				}
260
			if (delete(args[0], j == 0 ? SIN_PROXY : 0))
261
				retval = 1;
262
			break;
263
		default:
264
			usage();
265
		}
242
	}
266
	}
243
	fclose(fp);
267
	fclose(fp);
244
	return (retval);
268
	return (retval);
Lines 650-660 nuke_entry(struct sockaddr_dl *sdl __unused, Link Here
650
static void
674
static void
651
usage(void)
675
usage(void)
652
{
676
{
653
	fprintf(stderr, "%s\n%s\n%s\n%s\n%s\n%s\n%s\n",
677
	fprintf(stderr, "%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n",
654
		"usage: arp [-n] [-i interface] hostname",
678
		"usage: arp [-n] [-i interface] hostname",
655
		"       arp [-n] [-i interface] -a",
679
		"       arp [-n] [-i interface] -a",
656
		"       arp -d hostname [pub]",
680
		"       arp -d hostname [pub]",
657
		"       arp -d [-i interface] -a",
681
		"       arp -d [-i interface] -a",
682
		"       arp -d -f filename",
658
		"       arp -s hostname ether_addr [temp] [reject | blackhole] [pub [only]]",
683
		"       arp -s hostname ether_addr [temp] [reject | blackhole] [pub [only]]",
659
		"       arp -S hostname ether_addr [temp] [reject | blackhole] [pub [only]]",
684
		"       arp -S hostname ether_addr [temp] [reject | blackhole] [pub [only]]",
660
		"       arp -f filename");
685
		"       arp -f filename");

Return to bug 139346