#!/bin/sh
# DF-3422/DF-3423 evidence pack setup (run on the DragonFly guest as root).
# Idempotent tunnel setup mirroring a standard gre deployment.
# $1 = mode: gre (default) | mobile
MODE=${1:-gre}

ifconfig tap0 create 2>/dev/null || true
ifconfig tap0 up
ifconfig tap0 inet 10.99.0.1 netmask 255.255.255.0
kldload if_gre 2>/dev/null || true
ifconfig gre0 create 2>/dev/null || true
ifconfig gre0 tunnel 10.99.0.1 10.99.0.2
if [ "$MODE" = mobile ]; then
	ifconfig gre0 -link0 up       # g_proto = IPPROTO_MOBILE
else
	ifconfig gre0 link0 up        # g_proto = IPPROTO_GRE (default)
fi
ifconfig gre0
