#!/bin/sh
# DF-2575 setup + run — loads modules, then calls poc.sh (the trigger).
# Must be run as ROOT.
set -e

echo "=== DF-2575 setup ==="

# 1. default-to-accept BEFORE loading ipfw3 (or ssh dies on the deny default)
sysctl -w net.filters_default_to_accept=1 2>&1

# 2. Load ipfw3 core + basic filters + dummynet3 (the ipfw3-native dummynet
#    that registers the 'pipe' action opcode with ipfw3)
kldload ipfw3 2>&1 || true
kldload ipfw3_basic 2>&1 || true
kldload dummynet3 2>&1 || true
echo "loaded modules:"
kldstat | grep -iE 'ipfw|dummynet'

echo "=== ipfw3 module list ==="
ipfw3 module list 2>&1

# 3. Run the trigger
echo "=== running trigger ==="
sh /root/poc/DF-2575/poc.sh 100 3000 500 2>&1
RC=$?
echo "=== trigger exit code: $RC ==="
