Slide 10
Slide 10 text
Network Packet Filtering
Suchakrapani Datt Sharma
BPF Virtual Machine
- Not tied to any protocol. Packets are byte arrays
- A generic machine, easily programmable
- Variable length packets support*
- Simple switch-case dispatch mechanism
- Simple instruction set; A, X and scratch memory
registers
{ 0x28, 0, 0, 0x0000000c }, /* 0x28 is opcode for ldh */
{ 0x15, 1, 0, 0x00000800 }, /* jump next to next instr if A = 0x800 */
{ 0x15, 0, 5, 0x00000805 }, /* jump to FALSE (offset 5) if A != 0x805 */
Instruction Format
Sample Instructions { OP, JT, JF, K }
l0: ldh [12]
l1: jeq #0x800, l3, l2
l2: jeq #0x805, l3, l8
L3:
...
l7: ret #0xffff
l8: ret #0
Instr Representation