summaryrefslogtreecommitdiff
path: root/regress/sbin/ifconfig/Makefile
blob: 8a7acc19c08521c4cccb7f095c363d713037b2cf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
# $OpenBSD: Makefile,v 1.6 2020/12/17 00:51:12 bluhm Exp $

# Copyright (c) 2019 Alexander Bluhm <bluhm@openbsd.org>
#
# Permission to use, copy, modify, and distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

# test ifconfig address configuration for ethernet and point-to-point

IFCONFIG ?=	${SUDO} ${KTRACE} /sbin/ifconfig
IFADDR =	${SUDO} ${KTRACE} ./ifaddr

ETHER_IF ?=	vether99
ETHER_ADDR ?=	10.188.254.74
ETHER_ADDR6 ?=	fdd7:e83e:66bc:254::74
ETHER_NET =	${ETHER_ADDR:C/\.[0-9][0-9]*$//}
ETHER_NET6 =	${ETHER_ADDR6:C/::[0-9a-f:]*$/::/}
PPP_IF ?=	tun99
PPP_ADDR ?=	10.188.253.74
PPP_ADDR6 ?=	fdd7:e83e:66bc:253::74
PPP_DEST ?=	10.188.253.75
PPP_DEST6 ?=	fdd7:e83e:66bc:253::75
PPP_NET =	${PPP_ADDR:C/\.[0-9][0-9]*$//}
PPP_NET6 =	${PPP_ADDR6:C/::[0-9a-f:]*$/::/}

PROG =		ifaddr

CLEANFILES =	ifconfig.out ktrace.out

### ether

REGRESS_TARGETS +=	run-ether-addr
run-ether-addr:
	${IFCONFIG} ${ETHER_IF} ${ETHER_ADDR}
	/sbin/ifconfig ${ETHER_IF} >ifconfig.out
	grep 'inet ${ETHER_ADDR} ' ifconfig.out

REGRESS_TARGETS +=	run-ether-inet
run-ether-inet:
	${IFCONFIG} ${ETHER_IF} inet ${ETHER_ADDR}
	/sbin/ifconfig ${ETHER_IF} >ifconfig.out
	grep 'inet ${ETHER_ADDR} ' ifconfig.out

REGRESS_TARGETS +=	run-ether-netmask
run-ether-netmask:
	${IFCONFIG} ${ETHER_IF} ${ETHER_ADDR} netmask 255.255.255.0
	/sbin/ifconfig ${ETHER_IF} >ifconfig.out
	grep 'inet ${ETHER_ADDR} netmask 0xffffff00 ' ifconfig.out

REGRESS_TARGETS +=	run-ether-contiguous-netmask
run-ether-contiguous-netmask:
	${IFCONFIG} ${ETHER_IF} ${ETHER_ADDR} netmask 255.255.255.0
	${IFCONFIG} ${ETHER_IF} ${ETHER_ADDR} delete
	! ${IFCONFIG} ${ETHER_IF} ${ETHER_ADDR} netmask 255.255.255.64
	/sbin/ifconfig ${ETHER_IF} >ifconfig.out
	! grep 'inet ${ETHER_ADDR} ' ifconfig.out

REGRESS_TARGETS +=	run-ether-len
run-ether-len:
	${IFCONFIG} ${ETHER_IF} ${ETHER_ADDR}/24
	/sbin/ifconfig ${ETHER_IF} >ifconfig.out
	grep 'inet ${ETHER_ADDR} netmask 0xffffff00 ' ifconfig.out

REGRESS_TARGETS +=	run-ether-prefixlen
run-ether-prefixlen:
	${IFCONFIG} ${ETHER_IF} ${ETHER_ADDR} prefixlen 24
	/sbin/ifconfig ${ETHER_IF} >ifconfig.out
	grep 'inet ${ETHER_ADDR} netmask 0xffffff00 ' ifconfig.out

REGRESS_TARGETS +=	run-ether-hexmask
run-ether-hexmask:
	${IFCONFIG} ${ETHER_IF} ${ETHER_ADDR} netmask 0xffffff00
	/sbin/ifconfig ${ETHER_IF} >ifconfig.out
	grep 'inet ${ETHER_ADDR} netmask 0xffffff00 ' ifconfig.out

REGRESS_TARGETS +=	run-ether-broadcast
run-ether-broadcast:
	${IFCONFIG} ${ETHER_IF} ${ETHER_ADDR}/24
	/sbin/ifconfig ${ETHER_IF} >ifconfig.out
	grep 'inet ${ETHER_ADDR} .* broadcast ${ETHER_NET}.255$$' ifconfig.out

REGRESS_TARGETS +=	run-ether-replace
run-ether-replace:
	${IFCONFIG} ${ETHER_IF} ${ETHER_NET}.1/24
	${IFCONFIG} ${ETHER_IF} ${ETHER_NET}.2/24
	/sbin/ifconfig ${ETHER_IF} >ifconfig.out
	! grep 'inet ${ETHER_NET}.1 ' ifconfig.out
	grep 'inet ${ETHER_NET}.2 ' ifconfig.out

REGRESS_TARGETS +=	run-ether-duplicate
run-ether-duplicate:
	${IFCONFIG} ${ETHER_IF} ${ETHER_NET}.1/24
	${IFCONFIG} ${ETHER_IF} ${ETHER_NET}.1/24
	/sbin/ifconfig ${ETHER_IF} >ifconfig.out
	grep 'inet ${ETHER_NET}.1 ' ifconfig.out
	grep -c 'inet ' ifconfig.out | grep -q 1

REGRESS_TARGETS +=	run-ether-host
run-ether-host:
	${IFCONFIG} ${ETHER_IF} ${ETHER_NET}.1/24
	${IFCONFIG} ${ETHER_IF} ${ETHER_NET}.1/32
	/sbin/ifconfig ${ETHER_IF} >ifconfig.out
	grep 'inet ${ETHER_NET}.1 netmask 0xffffffff$$' ifconfig.out
	grep -c 'inet ' ifconfig.out | grep -q 1

REGRESS_TARGETS +=	run-ether-alias
run-ether-alias:
	${IFCONFIG} ${ETHER_IF} ${ETHER_NET}.1/24
	${IFCONFIG} ${ETHER_IF} ${ETHER_NET}.2/24 alias
	/sbin/ifconfig ${ETHER_IF} >ifconfig.out
	grep 'inet ${ETHER_NET}.1 ' ifconfig.out
	grep 'inet ${ETHER_NET}.2 ' ifconfig.out

REGRESS_TARGETS +=	run-ether-alias-duplicate
run-ether-alias-duplicate:
	${IFCONFIG} ${ETHER_IF} ${ETHER_NET}.1/24
	${IFCONFIG} ${ETHER_IF} ${ETHER_NET}.1/24 alias
	/sbin/ifconfig ${ETHER_IF} >ifconfig.out
	grep 'inet ${ETHER_NET}.1 ' ifconfig.out
	grep -c 'inet ' ifconfig.out | grep -q 1

REGRESS_TARGETS +=	run-ether-replace-first
run-ether-replace-first:
	${IFCONFIG} ${ETHER_IF} ${ETHER_NET}.1/24
	${IFCONFIG} ${ETHER_IF} ${ETHER_NET}.2/24 alias
	${IFCONFIG} ${ETHER_IF} ${ETHER_NET}.3/24
	/sbin/ifconfig ${ETHER_IF} >ifconfig.out
	! grep 'inet ${ETHER_NET}.1 ' ifconfig.out
	grep 'inet ${ETHER_NET}.2 ' ifconfig.out
	grep 'inet ${ETHER_NET}.3 ' ifconfig.out

REGRESS_TARGETS +=	run-ether-alias-host
run-ether-alias-host:
	${IFCONFIG} ${ETHER_IF} ${ETHER_NET}.1/24
	${IFCONFIG} ${ETHER_IF} ${ETHER_NET}.1/32 alias
	/sbin/ifconfig ${ETHER_IF} >ifconfig.out
	grep 'inet ${ETHER_NET}.1 netmask 0xffffffff$$' ifconfig.out
	grep -c 'inet ' ifconfig.out | grep -q 1

REGRESS_TARGETS +=	run-ether-change-netmask
run-ether-change-netmask:
	${IFCONFIG} ${ETHER_IF} ${ETHER_NET}.1/24
	${IFCONFIG} ${ETHER_IF} ${ETHER_NET}.2/24 alias
	${IFCONFIG} ${ETHER_IF} ${ETHER_NET}.1/32
	/sbin/ifconfig ${ETHER_IF} >ifconfig.out
	grep 'inet ${ETHER_NET}.1 netmask 0xffffffff$$' ifconfig.out
	grep 'inet ${ETHER_NET}.2 ' ifconfig.out
	grep -c 'inet ' ifconfig.out | grep -q 2

REGRESS_TARGETS +=	run-ether-delete-netmask
run-ether-delete-netmask:
	${IFCONFIG} ${ETHER_IF} ${ETHER_NET}.1/24
	${IFCONFIG} ${ETHER_IF} ${ETHER_NET}.2/24 alias
	# XXX ifconfig deletes .1 and changes .2 netmask
	${IFCONFIG} ${ETHER_IF} ${ETHER_NET}.2/32
	/sbin/ifconfig ${ETHER_IF} >ifconfig.out
	! grep 'inet ${ETHER_NET}.1 ' ifconfig.out
	grep 'inet ${ETHER_NET}.2 netmask 0xffffffff$$' ifconfig.out
	grep -c 'inet ' ifconfig.out | grep -q 1

REGRESS_TARGETS +=	run-ether-alias-netmask
run-ether-alias-netmask:
	${IFCONFIG} ${ETHER_IF} ${ETHER_NET}.1/24
	${IFCONFIG} ${ETHER_IF} ${ETHER_NET}.2/24 alias
	${IFCONFIG} ${ETHER_IF} ${ETHER_NET}.2/32 alias
	/sbin/ifconfig ${ETHER_IF} >ifconfig.out
	grep 'inet ${ETHER_NET}.1 ' ifconfig.out
	grep 'inet ${ETHER_NET}.2 netmask 0xffffffff$$' ifconfig.out
	grep -c 'inet ${ETHER_NET}.2 ' ifconfig.out | grep -q 1

REGRESS_TARGETS +=	run-ether-delete
run-ether-delete:
	${IFCONFIG} ${ETHER_IF} ${ETHER_NET}.1/24
	${IFCONFIG} ${ETHER_IF} ${ETHER_NET}.1 delete
	/sbin/ifconfig ${ETHER_IF} >ifconfig.out
	! grep 'inet ' ifconfig.out

REGRESS_TARGETS +=	run-ether-delete-first
run-ether-delete-first:
	${IFCONFIG} ${ETHER_IF} ${ETHER_NET}.1/24
	${IFCONFIG} ${ETHER_IF} ${ETHER_NET}.2/24 alias
	${IFCONFIG} ${ETHER_IF} ${ETHER_NET}.1 delete
	/sbin/ifconfig ${ETHER_IF} >ifconfig.out
	! grep 'inet ${ETHER_NET}.1 ' ifconfig.out
	grep 'inet ${ETHER_NET}.2 ' ifconfig.out

REGRESS_TARGETS +=	run-ether-delete-second
run-ether-delete-second:
	${IFCONFIG} ${ETHER_IF} ${ETHER_NET}.1/24
	${IFCONFIG} ${ETHER_IF} ${ETHER_NET}.2/24 alias
	${IFCONFIG} ${ETHER_IF} ${ETHER_NET}.2 delete
	/sbin/ifconfig ${ETHER_IF} >ifconfig.out
	grep 'inet ${ETHER_NET}.1 ' ifconfig.out
	! grep 'inet ${ETHER_NET}.2 ' ifconfig.out

### ppp

REGRESS_TARGETS +=	run-ppp-addr
run-ppp-addr:
	${IFCONFIG} ${PPP_IF} ${PPP_ADDR}
	/sbin/ifconfig ${PPP_IF} >ifconfig.out
	grep 'inet ${PPP_ADDR} ' ifconfig.out

REGRESS_TARGETS +=	run-ppp-inet
run-ppp-inet:
	${IFCONFIG} ${PPP_IF} inet ${PPP_ADDR}
	/sbin/ifconfig ${PPP_IF} >ifconfig.out
	grep 'inet ${PPP_ADDR} ' ifconfig.out

REGRESS_TARGETS +=	run-ppp-netmask
run-ppp-netmask:
	${IFCONFIG} ${PPP_IF} ${PPP_ADDR} netmask 255.255.255.0
	/sbin/ifconfig ${PPP_IF} >ifconfig.out
	grep 'inet ${PPP_ADDR} .* netmask 0xffffff00$$' ifconfig.out

REGRESS_TARGETS +=	run-ppp-len
run-ppp-len:
	${IFCONFIG} ${PPP_IF} ${PPP_ADDR}/24
	/sbin/ifconfig ${PPP_IF} >ifconfig.out
	grep 'inet ${PPP_ADDR} .* netmask 0xffffff00$$' ifconfig.out

REGRESS_TARGETS +=	run-ppp-prefixlen
run-ppp-prefixlen:
	${IFCONFIG} ${PPP_IF} ${PPP_ADDR} prefixlen 24
	/sbin/ifconfig ${PPP_IF} >ifconfig.out
	grep 'inet ${PPP_ADDR} .* netmask 0xffffff00$$' ifconfig.out

REGRESS_TARGETS +=	run-ppp-destination
run-ppp-destination:
	${IFCONFIG} ${PPP_IF} ${PPP_ADDR}/24 ${PPP_DEST}
	/sbin/ifconfig ${PPP_IF} >ifconfig.out
	grep 'inet ${PPP_ADDR} --> ${PPP_DEST} ' ifconfig.out

REGRESS_TARGETS +=	run-ppp-replace
run-ppp-replace:
	${IFCONFIG} ${PPP_IF} ${PPP_NET}.1/24 ${PPP_DEST}
	${IFCONFIG} ${PPP_IF} ${PPP_NET}.2/24 ${PPP_DEST}
	/sbin/ifconfig ${PPP_IF} >ifconfig.out
	grep 'inet ${PPP_NET}.2 --> ${PPP_DEST} ' ifconfig.out
	! grep 'inet ${PPP_NET}.1 --> ${PPP_DEST} ' ifconfig.out

REGRESS_TARGETS +=	run-ppp-alias
run-ppp-alias:
	${IFCONFIG} ${PPP_IF} ${PPP_NET}.1/24 ${PPP_DEST}
	${IFCONFIG} ${PPP_IF} ${PPP_NET}.2/24 ${PPP_DEST} alias
	/sbin/ifconfig ${PPP_IF} >ifconfig.out
	grep 'inet ${PPP_NET}.1 --> ${PPP_DEST} ' ifconfig.out
	grep 'inet ${PPP_NET}.2 --> ${PPP_DEST} ' ifconfig.out

### ifaddr

REGRESS_TARGETS +=	run-ether-ifaddr-set
run-ether-ifaddr-set:
	${IFADDR} ${ETHER_IF} ${ETHER_ADDR}
	/sbin/ifconfig ${ETHER_IF} >ifconfig.out
	grep 'inet ${ETHER_ADDR} ' ifconfig.out

REGRESS_TARGETS +=	run-ether-ifaddr-get
run-ether-ifaddr-get:
	${IFADDR} ${ETHER_IF} ${ETHER_ADDR}
	${KTRACE} ./ifaddr ${ETHER_IF} >ifconfig.out
	grep 'inet ${ETHER_ADDR} ' ifconfig.out

REGRESS_TARGETS +=	run-ether-ifaddr-netmask
run-ether-ifaddr-netmask:
	${IFADDR} ${ETHER_IF} ${ETHER_ADDR} netmask 255.255.255.0
	/sbin/ifconfig ${ETHER_IF} >ifconfig.out
	grep 'inet ${ETHER_ADDR} netmask 0xffffff00 ' ifconfig.out

REGRESS_TARGETS +=	run-ether-ifaddr-contiguous-netmask
run-ether-ifaddr-contiguous-netmask:
	${IFADDR} ${ETHER_IF} ${ETHER_ADDR} netmask 255.255.255.0
	${IFADDR} ${ETHER_IF} ${ETHER_ADDR} delete
	! ${IFADDR} ${ETHER_IF} ${ETHER_ADDR} netmask 255.255.255.64
	/sbin/ifconfig ${ETHER_IF} >ifconfig.out
	! grep 'inet ${ETHER_ADDR} netmask 0xffffff' ifconfig.out

REGRESS_TARGETS +=	run-ether-ifaddr-prefixlen
run-ether-ifaddr-prefixlen:
	${IFADDR} ${ETHER_IF} ${ETHER_ADDR}/24
	/sbin/ifconfig ${ETHER_IF} >ifconfig.out
	grep 'inet ${ETHER_ADDR} netmask 0xffffff00 ' ifconfig.out

REGRESS_TARGETS +=	run-ppp-ifaddr-destination
run-ppp-ifaddr-destination:
	${IFADDR} ${PPP_IF} ${PPP_ADDR} ${PPP_DEST}
	/sbin/ifconfig ${PPP_IF} >ifconfig.out
	grep 'inet ${PPP_ADDR} --> ${PPP_DEST} ' ifconfig.out

REGRESS_TARGETS +=	run-ether-ifaddr-broadcast
run-ether-ifaddr-broadcast:
	${IFADDR} ${ETHER_IF} ${ETHER_ADDR} broadcast ${ETHER_NET}.255
	/sbin/ifconfig ${ETHER_IF} >ifconfig.out
	grep 'inet ${ETHER_ADDR} .* broadcast ${ETHER_NET}.255$$' ifconfig.out

REGRESS_TARGETS +=	run-ether-ifaddr-alias
run-ether-ifaddr-alias:
	${IFADDR} ${ETHER_IF} ${ETHER_NET}.1/24
	${IFADDR} ${ETHER_IF} ${ETHER_NET}.2/24 alias
	/sbin/ifconfig ${ETHER_IF} >ifconfig.out
	grep 'inet ${ETHER_NET}.1 ' ifconfig.out
	grep 'inet ${ETHER_NET}.2 ' ifconfig.out

REGRESS_TARGETS +=	run-ether-ifaddr-change-netmask
run-ether-ifaddr-change-netmask:
	${IFADDR} ${ETHER_IF} ${ETHER_NET}.1/24
	${IFADDR} ${ETHER_IF} ${ETHER_NET}.2/24 alias
	${IFADDR} ${ETHER_IF} netmask 255.255.255.255
	/sbin/ifconfig ${ETHER_IF} >ifconfig.out
	grep 'inet ${ETHER_NET}.1 netmask 0xffffffff ' ifconfig.out
	grep 'inet ${ETHER_NET}.2 netmask 0xffffff00 ' ifconfig.out

REGRESS_TARGETS +=	run-ppp-ifaddr-change-destination
run-ppp-ifaddr-change-destination:
	${IFADDR} ${PPP_IF} ${PPP_NET}.1 ${PPP_NET}.11
	${IFADDR} ${PPP_IF} ${PPP_NET}.2 ${PPP_NET}.12 alias
	${IFADDR} ${PPP_IF} ipdst ${PPP_NET}.13
	/sbin/ifconfig ${PPP_IF} >ifconfig.out
	grep 'inet ${PPP_NET}.1 --> ${PPP_NET}.13 ' ifconfig.out
	grep 'inet ${PPP_NET}.2 --> ${PPP_NET}.12 ' ifconfig.out

REGRESS_TARGETS +=	run-ether-ifaddr-change-broadcast
run-ether-ifaddr-change-broadcast:
	${IFADDR} ${ETHER_IF} ${ETHER_NET}.1/24 broadcast ${ETHER_NET}.255
	${IFADDR} ${ETHER_IF} ${ETHER_NET}.2/24 broadcast ${ETHER_NET}.255 alias
	${IFADDR} ${ETHER_IF} broadcast 255.255.255.255
	/sbin/ifconfig ${ETHER_IF} >ifconfig.out
	grep 'inet ${ETHER_NET}.1 .* broadcast 255.255.255.255$$' ifconfig.out
	grep 'inet ${ETHER_NET}.2 .* broadcast ${ETHER_NET}.255$$' ifconfig.out

REGRESS_TARGETS +=	run-ether-ifaddr-duplicate
run-ether-ifaddr-duplicate:
	${IFADDR} ${ETHER_IF} ${ETHER_NET}.1/24
	${IFADDR} ${ETHER_IF} ${ETHER_NET}.2/16 alias
	# XXX replace the first address and create two identical addresses
	${IFADDR} ${ETHER_IF} ${ETHER_NET}.2/24
	/sbin/ifconfig ${ETHER_IF} >ifconfig.out
	! grep 'inet ${ETHER_NET}.1 ' ifconfig.out
	grep 'inet ${ETHER_NET}.2 netmask 0xffffff00 ' ifconfig.out
	grep -c 'inet ' ifconfig.out | grep -q 2

### ether-inet6

REGRESS_TARGETS +=	run-ether-inet6-eui64
run-ether-inet6-eui64:
	${IFCONFIG} ${ETHER_IF} inet6 eui64
	/sbin/ifconfig ${ETHER_IF} >ifconfig.out
	grep 'inet6 fe80::[0-9a-f:]*ff:fe[0-9a-f:]*%${ETHER_IF} ' ifconfig.out

REGRESS_TARGETS +=	run-ether-inet6-addr
run-ether-inet6-addr:
	${IFCONFIG} ${ETHER_IF} inet6 ${ETHER_ADDR6}
	/sbin/ifconfig ${ETHER_IF} >ifconfig.out
	grep 'inet6 ${ETHER_ADDR6} ' ifconfig.out
	# setting an address creates eui64 automatically
	grep 'inet6 fe80::[0-9a-f:]*ff:fe[0-9a-f:]*%${ETHER_IF} ' ifconfig.out

REGRESS_TARGETS +=	run-ether-inet6-netmask
run-ether-inet6-netmask:
	${IFCONFIG} ${ETHER_IF} inet6 ${ETHER_ADDR6}\
	    netmask ffff:ffff:ffff:ffff:ffff::
	/sbin/ifconfig ${ETHER_IF} >ifconfig.out
	grep 'inet6 ${ETHER_ADDR6} prefixlen 80 ' ifconfig.out

REGRESS_TARGETS +=	run-ether-inet6-contiguous-netmask
run-ether-inet6-contiguous-netmask:
	${IFCONFIG} ${ETHER_IF} inet6 ${ETHER_ADDR6}\
	    netmask ffff:ffff:ffff:ffff:ffff::
	${IFCONFIG} ${ETHER_IF} inet6 ${ETHER_ADDR6} delete
	! ${IFCONFIG} ${ETHER_IF} inet6 ${ETHER_ADDR6}\
	    netmask ffff:ffff:ffff:ffff:ffff:4000::
	/sbin/ifconfig ${ETHER_IF} >ifconfig.out
	! grep 'inet6 ${ETHER_ADDR6} ' ifconfig.out

REGRESS_TARGETS +=	run-ether-inet6-contiguous-gap
run-ether-inet6-contiguous-gap:
	${IFCONFIG} ${ETHER_IF} inet6 ${ETHER_ADDR6} netmask ffff::
	${IFCONFIG} ${ETHER_IF} inet6 ${ETHER_ADDR6} delete
	! ${IFCONFIG} ${ETHER_IF} inet6 ${ETHER_ADDR6} netmask ffff::ff00:8
	/sbin/ifconfig ${ETHER_IF} >ifconfig.out
	! grep 'inet6 ${ETHER_ADDR6} ' ifconfig.out

REGRESS_TARGETS +=	run-ether-inet6-len
run-ether-inet6-len:
	${IFCONFIG} ${ETHER_IF} inet6 ${ETHER_ADDR6}/80
	/sbin/ifconfig ${ETHER_IF} >ifconfig.out
	grep 'inet6 ${ETHER_ADDR6} prefixlen 80 ' ifconfig.out

REGRESS_TARGETS +=	run-ether-inet6-prefixlen
run-ether-inet6-prefixlen:
	${IFCONFIG} ${ETHER_IF} inet6 ${ETHER_ADDR6} prefixlen 80
	/sbin/ifconfig ${ETHER_IF} >ifconfig.out
	grep 'inet6 ${ETHER_ADDR6} prefixlen 80 ' ifconfig.out

REGRESS_TARGETS +=	run-ether-inet6-noreplace
run-ether-inet6-noreplace:
	${IFCONFIG} ${ETHER_IF} inet6 ${ETHER_NET6}1
	${IFCONFIG} ${ETHER_IF} inet6 ${ETHER_NET6}2
	/sbin/ifconfig ${ETHER_IF} >ifconfig.out
	grep 'inet6 ${ETHER_NET6}1 ' ifconfig.out
	grep 'inet6 ${ETHER_NET6}2 ' ifconfig.out

REGRESS_TARGETS +=	run-ether-inet6-duplicate
run-ether-inet6-duplicate:
	${IFCONFIG} ${ETHER_IF} inet6 ${ETHER_NET6}1
	${IFCONFIG} ${ETHER_IF} inet6 ${ETHER_NET6}1
	/sbin/ifconfig ${ETHER_IF} >ifconfig.out
	grep 'inet6 ${ETHER_NET6}1 ' ifconfig.out
	grep -c 'inet6 ${ETHER_NET6}' ifconfig.out | grep -q 1

REGRESS_TARGETS +=	run-ether-inet6-host
run-ether-inet6-host:
	${IFCONFIG} ${ETHER_IF} inet6 ${ETHER_NET6}1/128
	# changing netmask of an exisintg address is not allowed
	! ${IFCONFIG} ${ETHER_IF} inet6 ${ETHER_NET6}1/64
	/sbin/ifconfig ${ETHER_IF} >ifconfig.out
	grep 'inet6 ${ETHER_NET6}1 prefixlen 128 ' ifconfig.out
	grep -c 'inet6 ${ETHER_NET6}' ifconfig.out | grep -q 1

REGRESS_TARGETS +=	run-ether-inet6-alias
run-ether-inet6-alias:
	${IFCONFIG} ${ETHER_IF} inet6 ${ETHER_NET6}1
	${IFCONFIG} ${ETHER_IF} inet6 ${ETHER_NET6}2 alias
	/sbin/ifconfig ${ETHER_IF} >ifconfig.out
	grep 'inet6 ${ETHER_NET6}1 ' ifconfig.out
	grep 'inet6 ${ETHER_NET6}2 ' ifconfig.out

REGRESS_TARGETS +=	run-ether-inet6-delete
run-ether-inet6-delete:
	${IFCONFIG} ${ETHER_IF} inet6 ${ETHER_NET6}1
	${IFCONFIG} ${ETHER_IF} inet6 ${ETHER_NET6}1 delete
	/sbin/ifconfig ${ETHER_IF} >ifconfig.out
	! grep 'inet6 ${ETHER_NET6}' ifconfig.out

REGRESS_TARGETS +=	run-ether-inet6-delete-first
run-ether-inet6-delete-first:
	${IFCONFIG} ${ETHER_IF} inet6 ${ETHER_NET6}1
	${IFCONFIG} ${ETHER_IF} inet6 ${ETHER_NET6}2 alias
	${IFCONFIG} ${ETHER_IF} inet6 ${ETHER_NET6}1 delete
	/sbin/ifconfig ${ETHER_IF} >ifconfig.out
	! grep 'inet6 ${ETHER_NET6}1 ' ifconfig.out
	grep 'inet6 ${ETHER_NET6}2 ' ifconfig.out

REGRESS_TARGETS +=	run-ether-inet6-delete-second
run-ether-inet6-delete-second:
	${IFCONFIG} ${ETHER_IF} inet6 ${ETHER_NET6}1
	${IFCONFIG} ${ETHER_IF} inet6 ${ETHER_NET6}2 alias
	${IFCONFIG} ${ETHER_IF} inet6 ${ETHER_NET6}2 delete
	/sbin/ifconfig ${ETHER_IF} >ifconfig.out
	grep 'inet6 ${ETHER_NET6}1 ' ifconfig.out
	! grep 'inet6 ${ETHER_NET6}2 ' ifconfig.out

### ppp-inet6

REGRESS_TARGETS +=	run-ppp-inet6-eui64
run-ppp-inet6-eui64:
	${IFCONFIG} ${PPP_IF} inet6 eui64
	/sbin/ifconfig ${PPP_IF} >ifconfig.out
	grep 'inet6 fe80::[0-9a-f:]*ff:fe[0-9a-f:]*%${PPP_IF} ' ifconfig.out

REGRESS_TARGETS +=	run-ppp-inet6-addr
run-ppp-inet6-addr:
	${IFCONFIG} ${PPP_IF} inet6 ${PPP_ADDR6}
	/sbin/ifconfig ${PPP_IF} >ifconfig.out
	grep 'inet6 ${PPP_ADDR6} ' ifconfig.out
	# setting an address creates eui64 automatically
	grep 'inet6 fe80::[0-9a-f:]*ff:fe[0-9a-f:]*%${PPP_IF} ' ifconfig.out

REGRESS_TARGETS +=	run-ppp-inet6-len
run-ppp-inet6-len:
	${IFCONFIG} ${PPP_IF} inet6 ${PPP_ADDR6}/80
	/sbin/ifconfig ${PPP_IF} >ifconfig.out
	grep 'inet6 ${PPP_ADDR6} .* prefixlen 80 ' ifconfig.out

REGRESS_TARGETS +=	run-ppp-inet6-destination
run-ppp-inet6-destination:
	${IFCONFIG} ${PPP_IF} inet6 ${PPP_ADDR6} ${PPP_DEST6}
	/sbin/ifconfig ${PPP_IF} >ifconfig.out
	grep 'inet6 ${PPP_ADDR6} --> ${PPP_DEST6} ' ifconfig.out

REGRESS_TARGETS +=	run-ppp-inet6-noreplace
run-ppp-inet6-noreplace:
	${IFCONFIG} ${PPP_IF} inet6 ${PPP_NET6}1 ${PPP_DEST6}
	${IFCONFIG} ${PPP_IF} inet6 ${PPP_NET6}2 ${PPP_DEST6}
	/sbin/ifconfig ${PPP_IF} >ifconfig.out
	grep 'inet6 ${PPP_NET6}1 --> ${PPP_DEST6} ' ifconfig.out
	grep 'inet6 ${PPP_NET6}2 --> ${PPP_DEST6} ' ifconfig.out

REGRESS_TARGETS +=	run-ppp-inet6-alias
run-ppp-inet6-alias:
	${IFCONFIG} ${PPP_IF} inet6 ${PPP_NET6}1 ${PPP_DEST6}
	${IFCONFIG} ${PPP_IF} inet6 ${PPP_NET6}2 ${PPP_DEST6} alias
	/sbin/ifconfig ${PPP_IF} >ifconfig.out
	grep 'inet6 ${PPP_NET6}1 --> ${PPP_DEST6} ' ifconfig.out
	grep 'inet6 ${PPP_NET6}2 --> ${PPP_DEST6} ' ifconfig.out

### setup cleanup

REGRESS_ROOT_TARGETS =	${REGRESS_TARGETS}

${REGRESS_TARGETS:Mrun-*-ifaddr-*}: ifaddr

${REGRESS_TARGETS:Mrun-ether-*}: setup-ether
setup-ether:
	${SUDO} /sbin/ifconfig ${ETHER_IF} destroy 2>/dev/null || true
	${SUDO} /sbin/ifconfig ${ETHER_IF} create

${REGRESS_TARGETS:Mrun-ppp-*}: setup-ppp
setup-ppp:
	${SUDO} /sbin/ifconfig ${PPP_IF} destroy 2>/dev/null || true
	${SUDO} /sbin/ifconfig ${PPP_IF} create

REGRESS_CLEANUP =	cleanup
cleanup:
	${SUDO} /sbin/ifconfig ${ETHER_IF} destroy || true
	${SUDO} /sbin/ifconfig ${PPP_IF} destroy || true

### check

check: check-targets

check-targets:
	# REGRESS_TARGETS must not contain duplicates, prevent copy paste error
	! echo ${REGRESS_TARGETS} | tr ' ' '\n' | sort | uniq -d | grep .

.include <bsd.regress.mk>