This directory contains comprehensive documentation for the Velocity Filter Machine (VFM).
programming_manual.md- Complete programming guide with examplessimple_filter.vfm- Basic IPv4 filter exampletcp_port_filter.vfm- TCP port 80/443 filter exampledns_amplification_filter.vfm- DNS amplification attack preventionarithmetic_example.vfm- Basic arithmetic operationstest_filter.c- C example showing API usageunit_test_style.c- Working C test based on unit test patterns
All .vfm files can be compiled using the assembler:
../tools/vfm-asm example.vfm -o example.binAnd disassembled for verification:
../tools/vfm-dis example.binThe C test programs demonstrate proper API usage. The unit_test_style.c shows the correct way to integrate with VFM:
gcc -I../src unit_test_style.c ../libvfm.a -o unit_test_style
./unit_test_styleThis example demonstrates:
- Proper VM initialization
- Bytecode loading using raw arrays (recommended approach)
- Correct packet structure creation
- Error handling and cleanup
- Always use proper packet structures with valid headers
- Provide correct packet lengths to vfm_execute
- Check return codes from all VFM functions
- Use vfm_verify for untrusted programs
- Initialize flow tables if using stateful filtering
Use the built-in tools for performance analysis:
# Test against packet captures
../tools/vfm-test filter.bin packets.pcap
# Generate performance benchmarks
cd ../bench && make && ./bench