1# $OpenBSD: Makefile,v 1.5 2020/12/17 00:51:13 bluhm Exp $ 2 3PROGS = mcsend mcrecv mcroute 4WARNINGS = Yes 5CLEANFILES = stamp-* *.log 6MSG !!= echo $$RANDOM 7 8SEND = ${.OBJDIR}/mcsend 9RECV = ${.OBJDIR}/mcrecv 10ROUTE = ${.OBJDIR}/mcroute 11LOCALHOST = 127.0.0.1 12LOCAL = ${LOCAL_ADDR} 13REMOTE = ${REMOTE_ADDR} 14OTHER = ${OTHER_ADDR} 15TARGET = ${TARGET_ADDR} 16GROUP_LOCAL = 224.0.0.123 17 18.if make (regress) || make (all) 19.BEGIN: 20.if ! empty (REMOTE_SSH) 21 ssh -t ${REMOTE_SSH} ${SUDO} true 22.endif 23.if ! empty(TARGET_SSH) 24 ssh -t ${TARGET_SSH} ${SUDO} true 25.endif 26.endif 27 28REGRESS_TARGETS += run-localhost 29run-localhost: 30 # send over localhost interface 31 ${RECV} -f recv.log -i ${LOCALHOST} -r 5 -- \ 32 ${SEND} -f send.log -i ${LOCALHOST} -m '${MSG}' 33 grep '> ${MSG}$$' send.log 34 grep '< ${MSG}$$' recv.log 35 36REGRESS_TARGETS += run-localhost-loop 37run-localhost-loop: 38 # explicitly enable loop back on multicast interface 39 ${RECV} -f recv.log -i ${LOCALHOST} -r 5 -- \ 40 ${SEND} -f send.log -i ${LOCALHOST} -l 1 -m '${MSG}' 41 grep '> ${MSG}$$' send.log 42 grep '< ${MSG}$$' recv.log 43 44REGRESS_TARGETS += run-localhost-loop0 45run-localhost-loop0: 46 # disable loop back on multicast interface, must fail 47 ${RECV} -f recv.log -i ${LOCALHOST} -n 1 -- \ 48 ${SEND} -f send.log -i ${LOCALHOST} -l 0 -m '${MSG}' 49 grep '> ${MSG}$$' send.log 50 ! grep '< ' recv.log 51 52REGRESS_TARGETS += run-localhost-ttl0 53run-localhost-ttl0: 54 # send over localhost interface 55 ${RECV} -f recv.log -i ${LOCALHOST} -r 5 -- \ 56 ${SEND} -f send.log -i ${LOCALHOST} -m '${MSG}' -t 0 57 grep '> ${MSG}$$' send.log 58 grep '< ${MSG}$$' recv.log 59 60REGRESS_TARGETS += run-localhost-local 61run-localhost-local: 62 # send over localhost interface 63 ${RECV} -f recv.log -g ${GROUP_LOCAL} -i ${LOCALHOST} -r 5 -- \ 64 ${SEND} -f send.log -g ${GROUP_LOCAL} -i ${LOCALHOST} -m '${MSG}' -t 0 65 grep '> ${MSG}$$' send.log 66 grep '< ${MSG}$$' recv.log 67 68REGRESS_TARGETS += run-localaddr 69run-localaddr: 70 # send over a local physical interface 71 ${RECV} -f recv.log -i ${LOCAL} -r 5 -- \ 72 ${SEND} -f send.log -i ${LOCAL} -m '${MSG}' 73 grep '> ${MSG}$$' send.log 74 grep '< ${MSG}$$' recv.log 75 76REGRESS_TARGETS += run-localaddr-loop0 77run-localaddr-loop0: 78 # send over physical interface to loopback, ttl is 0 79 ${RECV} -f recv.log -i ${LOCAL} -n 1 -- \ 80 ${SEND} -f send.log -i ${LOCAL} -l 0 -m '${MSG}' 81 grep '> ${MSG}$$' send.log 82 ! grep '< ' recv.log 83 84REGRESS_TARGETS += run-localaddr-ttl0 85run-localaddr-ttl0: 86 # send over physical interface to loopback, ttl is 0 87 ${RECV} -f recv.log -i ${LOCAL} -r 5 -- \ 88 ${SEND} -f send.log -i ${LOCAL} -m '${MSG}' -t 0 89 grep '> ${MSG}$$' send.log 90 grep '< ${MSG}$$' recv.log 91 92REGRESS_TARGETS += run-localaddr-local 93run-localaddr-local: 94 # send over physical interface to loopback, ttl is 0 95 ${RECV} -f recv.log -g ${GROUP_LOCAL} -i ${LOCAL} -r 5 -- \ 96 ${SEND} -f send.log -g ${GROUP_LOCAL} -i ${LOCAL} -m '${MSG}' -t 0 97 grep '> ${MSG}$$' send.log 98 grep '< ${MSG}$$' recv.log 99 100REGRESS_TARGETS += run-remoteaddr 101run-remoteaddr: 102 # send over a local physical interface 103 ${RECV} -f recv.log -i ${LOCAL} -r 5 -- \ 104 ssh ${REMOTE_SSH} ${SEND} -f ${.OBJDIR}/send.log \ 105 -i ${REMOTE} -m '${MSG}' 106 grep '< ${MSG}$$' recv.log 107 108REGRESS_TARGETS += run-remoteaddr-loop0 109run-remoteaddr-loop0: 110 # send over a local physical interface 111 ${RECV} -f recv.log -i ${LOCAL} -r 5 -- \ 112 ssh ${REMOTE_SSH} ${SEND} -f ${.OBJDIR}/send.log \ 113 -i ${REMOTE} -l 0 -m '${MSG}' 114 grep '< ${MSG}$$' recv.log 115 116REGRESS_TARGETS += run-remoteaddr-ttl0 117run-remoteaddr-ttl0: 118 # send over a local physical interface 119 ${RECV} -f recv.log -i ${LOCAL} -n 2 -- \ 120 ssh ${REMOTE_SSH} ${SEND} -f ${.OBJDIR}/send.log \ 121 -i ${REMOTE} -m '${MSG}' -t 0 122 ! grep '< ' recv.log 123 124REGRESS_TARGETS += run-forward 125run-forward: 126 # start multicast router, start receiver, start sender 127 ssh ${REMOTE_SSH} ${SUDO} pkill mcroute mc6route || true 128 ssh ${REMOTE_SSH} ${SUDO} ${ROUTE} -f ${.OBJDIR}/route.log \ 129 -b -i ${OTHER} -o ${REMOTE} -r 5 130.if empty(TARGET_SSH) 131 ${RECV} -f recv.log -i ${LOCAL} -r 5 -- \ 132 ${SEND} -f send.log \ 133 -i ${TARGET} -l 0 -m '${MSG}' -t 2 134 grep '> ${MSG}$$' send.log 135.else 136 ${RECV} -f recv.log -i ${LOCAL} -r 5 -- \ 137 ssh ${TARGET_SSH} ${SEND} -f ${.OBJDIR}/send.log \ 138 -i ${TARGET} -l 0 -m '${MSG}' -t 2 139.endif 140 grep '< ${MSG}$$' recv.log 141 142REGRESS_TARGETS += run-forward-ttl1 143run-forward-ttl1: 144 # try to get ttl 1 over multicast router, must fail 145 ssh ${REMOTE_SSH} ${SUDO} pkill mcroute mc6route || true 146 ssh ${REMOTE_SSH} ${SUDO} ${ROUTE} -f ${.OBJDIR}/route.log \ 147 -b -i ${OTHER} -o ${REMOTE} -n 3 148.if empty(TARGET_SSH) 149 ${RECV} -f recv.log -i ${LOCAL} -n 2 -- \ 150 ${SEND} -f send.log \ 151 -i ${TARGET} -l 0 -m '${MSG}' -t 1 152 grep '> ${MSG}$$' send.log 153.else 154 ${RECV} -f recv.log -i ${LOCAL} -n 2 -- \ 155 ssh ${TARGET_SSH} ${SEND} -f ${.OBJDIR}/send.log \ 156 -i ${TARGET} -l 0 -m '${MSG}' -t 1 157.endif 158 ! grep '< ' recv.log 159 160REGRESS_TARGETS += run-forward-local 161run-forward-local: 162 # try to get local multicast group over router, must fail 163 ssh ${REMOTE_SSH} ${SUDO} pkill mcroute mc6route || true 164 ssh ${REMOTE_SSH} ${SUDO} ${ROUTE} -f ${.OBJDIR}/route.log \ 165 -b -g ${GROUP_LOCAL} -i ${OTHER} -o ${REMOTE} -n 3 166.if empty(TARGET_SSH) 167 ${RECV} -f recv.log -g ${GROUP_LOCAL} -i ${LOCAL} -n 2 -- \ 168 ${SEND} -f send.log \ 169 -g ${GROUP_LOCAL} -i ${TARGET} -l 0 -m '${MSG}' -t 2 170 grep '> ${MSG}$$' send.log 171.else 172 ${RECV} -f recv.log -g ${GROUP_LOCAL} -i ${LOCAL} -n 2 -- \ 173 ssh ${TARGET_SSH} ${SEND} -f ${.OBJDIR}/send.log \ 174 -g ${GROUP_LOCAL} -i ${TARGET} -l 0 -m '${MSG}' -t 2 175.endif 176 ! grep '< ' recv.log 177 178stamp-remote-build: 179 ssh ${REMOTE_SSH} ${MAKE} -C ${.CURDIR} ${PROGS} 180 date >$@ 181 182stamp-target-build: 183 ssh ${TARGET_SSH} ${MAKE} -C ${.CURDIR} ${PROGS} 184 date >$@ 185 186${REGRESS_TARGETS}: ${PROGS} 187${REGRESS_TARGETS:M*-remoteaddr*}: stamp-remote-build 188${REGRESS_TARGETS:M*-forward*}: stamp-remote-build 189.if ! empty(TARGET_SSH) 190${REGRESS_TARGETS:M*-forward*}: stamp-target-build 191.endif 192 193.if empty(LOCAL) 194REGRESS_SKIP_TARGETS += ${REGRESS_TARGETS:M*-localaddr*} 195REGRESS_SKIP_TARGETS += ${REGRESS_TARGETS:M*-remoteaddr*} 196REGRESS_SKIP_TARGETS += ${REGRESS_TARGETS:M*-forward*} 197.endif 198.if empty(REMOTE) || empty(REMOTE_SSH) 199REGRESS_SKIP_TARGETS += ${REGRESS_TARGETS:M*-remoteaddr*} 200REGRESS_SKIP_TARGETS += ${REGRESS_TARGETS:M*-forward*} 201.endif 202.if empty(OTHER) || empty(TARGET) 203REGRESS_SKIP_TARGETS += ${REGRESS_TARGETS:M*-forward*} 204.endif 205 206check-setup: 207 ! ssh ${REMOTE_SSH} route -n get 224/4 208 ssh ${REMOTE_SSH} sysctl net.inet.ip.mforwarding | fgrep =1 209 210.include <bsd.regress.mk> 211 212stamp-remote-build: ${SRCS} 213stamp-target-build: ${SRCS} 214