#!/bin/sh
# DF-0401 PoC build.
#
# Two artifacts:
#   1. poc.c               -- the intended VALE overflow PoC (needs netmap
#                             userland headers + live /dev/netmap). Will
#                             fail to build/run on this master because the
#                             netmap subsystem is dead (see netmap_build_attempt.log).
#   2. reachability_probe.c -- self-contained probe that opens /dev/netmap.
#                             Proves the device node is absent on this kernel.
cd "$(dirname "$0")"
RC=0

echo "=== Building reachability probe (self-contained, no netmap headers) ==="
cc -O2 -Wall -o reachability_probe reachability_probe.c 2>&1
echo "REACHABILITY_PROBE_BUILD_RC=$?"

echo ""
echo "=== Attempting to build intended PoC (poc.c) -- vendored net/ headers ==="
echo "=== Expected to fail: netmap.h needs IFNAMSIZ from <net/if.h> which ==="
echo "=== is not in the standard userspace path on this guest.            ==="
cc -O2 -Wall -I. -o poc poc.c 2>&1 | head -8
POC_RC=$?
echo "POC_BUILD_RC=$POC_RC"

echo ""
echo "=== The netmap.ko kernel module also fails to build ==="
echo "=== (see netmap_build_attempt.log: if_unused7 no longer in ifnet) ==="

exit 0
