#[repr(u8)]pub enum Opcode {
Show 28 variants
PushTrue = 1,
PushFalse = 2,
Contains = 16,
StartsWith = 17,
EndsWith = 18,
Equals = 19,
Matches = 32,
And = 48,
Or = 49,
Not = 50,
PartContains = 64,
PartStartsWith = 65,
PartEndsWith = 66,
PartEquals = 67,
PartMatches = 68,
PartIsEmpty = 69,
PartNotEmpty = 70,
PartInSet = 71,
PartIEquals = 72,
PartIContains = 73,
HeaderEquals = 80,
HeaderIEquals = 81,
HeaderContains = 82,
HeaderExists = 83,
JumpIfFalse = 112,
JumpIfTrue = 113,
Rand = 96,
Return = 255,
}Expand description
Bytecode opcodes for the filter VM.
Encoding:
- 1-byte opcode
- Variable operands depending on opcode type
Variants§
PushTrue = 1
Push true onto the stack.
PushFalse = 2
Push false onto the stack.
Contains = 16
Check if payload contains the string at index.
Bytecode: [0x10, idx_lo, idx_hi]
StartsWith = 17
Check if payload starts with the string at index.
Bytecode: [0x11, idx_lo, idx_hi]
EndsWith = 18
Check if payload ends with the string at index.
Bytecode: [0x12, idx_lo, idx_hi]
Equals = 19
Check if payload equals the string at index.
Bytecode: [0x13, idx_lo, idx_hi]
Matches = 32
Check if payload matches the regex at index.
Bytecode: [0x20, idx_lo, idx_hi]
And = 48
Pop 2 booleans, push (a AND b).
Bytecode: [0x30]
Or = 49
Pop 2 booleans, push (a OR b).
Bytecode: [0x31]
Not = 50
Pop 1 boolean, push (NOT a).
Bytecode: [0x32]
PartContains = 64
Check if parts[part_idx] contains string at index.
Bytecode: [0x40, part_idx, str_idx_lo, str_idx_hi]
PartStartsWith = 65
Check if parts[part_idx] starts with string at index.
Bytecode: [0x41, part_idx, str_idx_lo, str_idx_hi]
PartEndsWith = 66
Check if parts[part_idx] ends with string at index.
Bytecode: [0x42, part_idx, str_idx_lo, str_idx_hi]
PartEquals = 67
Check if parts[part_idx] equals string at index.
Bytecode: [0x43, part_idx, str_idx_lo, str_idx_hi]
PartMatches = 68
Check if parts[part_idx] matches regex at index.
Bytecode: [0x44, part_idx, regex_idx_lo, regex_idx_hi]
PartIsEmpty = 69
Check if parts[part_idx] is empty.
Bytecode: [0x45, part_idx]
PartNotEmpty = 70
Check if parts[part_idx] is not empty.
Bytecode: [0x46, part_idx]
PartInSet = 71
Check if parts[part_idx] equals any string in a set.
Bytecode: [0x47, part_idx, set_idx_lo, set_idx_hi]
PartIEquals = 72
Case-insensitive equality check for parts[part_idx].
Bytecode: [0x48, part_idx, str_idx_lo, str_idx_hi]
PartIContains = 73
Case-insensitive contains check for parts[part_idx].
Bytecode: [0x49, part_idx, str_idx_lo, str_idx_hi]
HeaderEquals = 80
Extract header from parts[part_idx], check exact equality.
Bytecode: [0x50, part_idx, hdr_idx_lo, hdr_idx_hi, val_idx_lo, val_idx_hi]
HeaderIEquals = 81
Extract header from parts[part_idx], check case-insensitive equality.
Bytecode: [0x51, part_idx, hdr_idx_lo, hdr_idx_hi, val_idx_lo, val_idx_hi]
HeaderContains = 82
Extract header from parts[part_idx], check if value contains string.
Bytecode: [0x52, part_idx, hdr_idx_lo, hdr_idx_hi, val_idx_lo, val_idx_hi]
HeaderExists = 83
Check if header exists in parts[part_idx].
Bytecode: [0x53, part_idx, hdr_idx_lo, hdr_idx_hi]
JumpIfFalse = 112
If top of stack is false, jump by i16 offset (leave false on stack).
If true, pop and continue to evaluate right operand.
Bytecode: [0x70, offset_lo, offset_hi]
JumpIfTrue = 113
If top of stack is true, jump by i16 offset (leave true on stack).
If false, pop and continue to evaluate right operand.
Bytecode: [0x71, offset_lo, offset_hi]
Rand = 96
Returns true with probability 1/N.
Bytecode: [0x60, n_lo, n_hi]
Return = 255
Return the top of the stack as the filter result.
Bytecode: [0xFF]