Return, advance, jump, and tag operations.
0x00 NPF_OPCODE_RET <return value>
Finish processing and return passed value.
0x01 NPF_OPCODE_ADVR <register>
Advance current network buffer offset by a value, passed in the specified register. Value represents bytes and cannot be negative or zero.
0x02 NPF_OPCODE_J <relative address>
Jump processor to a relative address (from this instruction). The address value is the amount of words forwards or backwards. It can point only to a valid instruction, at valid boundaries.
0x03 NPF_OPCODE_INVL
Invalidate all data in the packet cache.
0x04 NPF_OPCODE_TAG <key> <value>
Add a tag with specified key and value to the primary network buffer (nbuf).
Set and load operations.
0x10 NPF_OPCODE_MOV <value>, <register>
Set the specified value to a register.
0x11 NPF_OPCODE_LOAD <length>, <register>
Load specified length of packet data into the register. The data is read starting from the current network buffer offset. The operation does not advance the offset after read, however. The value of length represents bytes and must be in the range from 1 to 4. Returned data is in network byte order.
Compare and jump operations.
0x21 NPF_OPCODE_CMP <value>, <register>
Compare the specified value and value in a register. The result is stored internally and can be tested by jump instructions.
0x22 NPF_OPCODE_CMPR <register>, <register>
Compare values of two registers. The result is stored internally and can be tested by jump instructions.
0x23 NPF_OPCODE_BEQ <relative address>
Jump if the result of the last comparison was "equal". Otherwise, continue processing with the next instruction.
0x24 NPF_OPCODE_BNE <relative address>
Jump if the result of last comparison was "not equal". Otherwise, continue processing with the next instruction.
0x25 NPF_OPCODE_BGT <relative address>
Jump if the result of last comparison was "greater than". Otherwise, continue processing with the next instruction.
0x26 NPF_OPCODE_BLT <relative address>
Jump if the result of last comparison was "less than". Otherwise, continue processing with the next instruction.
Bitwise operations.
0x30 NPF_OPCODE_AND <value>, <register>
Perform bitwise AND with a specified value and the value in the register. The result is stored in the register.
CISC-like n-code instructions.
0x80 NPF_OPCODE_ETHER <s/d>, <_reserved>, <ether type>
Read Ethernet type in the frame, handle possible VLAN and match with the value passed in the argument. Return value to advance to layer 3 header in R3.
0x90 NPF_OPCODE_IP4MASK <s/d>, <network address>, <subnet mask>
Match passed network address with subnet mask against source or destination address in the IPv4 header. Address and mask should be in network byte order. Value of first argument indicates whether source (if 0x1) or destination (if 0x0) address should be matched.
0x91 NPF_OPCODE_IP4TABLE <s/d>, <table id>
Match the source or destination address with NPF table contents specified by table ID. Value of the first argument indicates whether source (if 0x1) or destination (if 0x0) address should be matched.
0x92 NPF_OPCODE_ICMP4 <type/code>
Match that packet is ICMP and compare type and code values, if required. Highest 32nd and 31st bits indicate whether the type and code values, accordingly, should be compared. If comparison is required, the type and code values are represented by lower 16 bits. The higher 8 bits represent type, and the lower 8 bits code number.
0xa0 NPF_OPCODE_TCP_PORT <s/d>, <port range>
Match the TCP source or destination port with a specified port range. The higher 16 bits of the second argument represent the "from" and the lower 16 bits represent the "to" values of the range. The 32-bit port range value is in host byte order, however the actual "from" and "to" values should be in network byte order. The value of the first argument indicates whether source (if 0x1) or destination (if 0x0) port should be matched.
0xa1 NPF_OPCODE_UDP_PORT <s/d>, <port range>
Equivalent of NPF_OPCODE_TCP_PORT, but for UDP protocol.
0xa2 NPF_OPCODE_TCP_FLAGS <fl/mask>
Match the TCP flags with the a specified flags and mask, represented by the lower 16 bits. The higher 8 bits represent flags and the lower 8 bits mask to apply.