// C example #include <sys/sysctl.h> #include <string.h>

If this command works but loading the rules fails with the version error, the issue is definitely a kernel/binary mismatch. Getting Started - OpenBSD PF

freebsd-update fetch freebsd-update install # Rebuild any third-party modules if necessary shutdown -r now

freebsd-update fetch freebsd-update install # Reboot shutdown -r now # After reboot, update packages pkg update && pkg upgrade