1# $OpenBSD: Makefile,v 1.10 2022/04/29 17:27:38 bluhm Exp $
2#
3#  template_v10
4#  ----------------
5#  * create pflow0 sending from 127.0.0.1 to 127.0.0.1:9996
6#  * wait for first template and compare it to known good template
7#  * destroy pflow0
8#
9#  flow_10_{4,6}
10#  -----------------
11#  * create pflow0 sending from 127.0.0.1 to 127.0.0.1:9996
12#  * add 10.11.12.13 and 2001:db8::13 to lo0
13#  * load pf ruleset which skips on all interfaces except lo0 to not lose
14#    existing ssh sessions, e.g.:
15#	set skip on {em0 cas0 cas1 enc0}
16#	pass on lo0 no state
17#	pass on lo0 proto tcp from port 12345 to port 12346 keep state (pflow)
18#  * enable pf
19#  * generate IPv4 or IPv6 traffic
20#  * wait for flow and compare it with known good flow
21#  * destroy pflow0
22#  * delete 10.11.12.13 and 2001:db8::13 from lo0
23#
24# ifconfig
25# --------
26# Take up pflow0 and test various combinations of flowdst, flowsrc and proto.
27# Destroy it in the end.
28
29REGRESS_TARGETS=template_v10 flow_10_4 flow_10_6 ifconfig
30REGRESS_ROOT_TARGETS=${REGRESS_TARGETS}
31
32PROG=	gen_traffic
33LDADD=	-levent
34
35.if ! (make(clean) || make(cleandir) || make(obj))
36
37PF_STATUS !=	${SUDO} /sbin/pfctl -si | sed -n 's/^Status: \([^ ]*\) .*/\1/p'
38.if empty(PF_STATUS:MEnabled)
39regress:
40	@echo pf status: "${PF_STATUS}"
41	@echo Enable pf to run this regress.
42	@echo SKIPPED
43.endif
44
45PERL_REQUIRE !=	perl -e 'eval { require Net::Flow } or print $@'
46.if ! empty(PERL_REQUIRE)
47regress:
48	@echo "${PERL_REQUIRE}"
49	@echo Install the p5-Net-Flow package to run pflow test.
50	@echo SKIPPED
51.endif
52
53.endif
54
55template_v10:
56	${SUDO} perl ${.CURDIR}/template.pl 10 \
57	    | diff -up ${.CURDIR}/template.v10 /dev/stdin
58
59flow_10_4: gen_traffic
60	${SUDO} perl ${.CURDIR}/flow.pl 10 4 \
61	    | diff -up ${.CURDIR}/flow.10_4 /dev/stdin
62flow_10_6: gen_traffic
63	${SUDO} perl ${.CURDIR}/flow.pl 10 6 \
64	    | diff -up ${.CURDIR}/flow.10_6 /dev/stdin
65
66ifconfig:
67	${SUDO} sh ${.CURDIR}/ifconfig.sh 2>&1 \
68	    | diff -up ${.CURDIR}/ifconfig.ok /dev/stdin
69
70.PHONY: ${REGRESS_TARGETS}
71
72.include <bsd.regress.mk>
73