
12-10 CHAPTER 12: CREATING AND USING PACKET FILTERS
The
Procedure for The following steps show the process of writing a packet filter. Detailed Writing a Filter examples are provided in the section “Examples of Creating Filters” on
page
You write the instructions for the packet filter using the following syntax:
<opcode>[.<size>] [<operand>...] [# <comment>]
The opcode descriptions are in the section Appendix A: Packet Filter Opcodes, Examples, and Syntax Errors. The description of the supported operand sizes can be found in Table
Implicit operands for an instruction must be of the size expected by the instruction. Any mismatch in implicit operand size results in an error “operand size mismatch” when you load the program into the system.
When writing a packet filter, be sure that you use comments (preceded by #) to describe each step in the filter. This habit will help you to revise filters in the future and enable others to understand and use the filters you create.
To write a packet filter:
1Assign a unique, descriptive name to the filter using the Name opcode.
2Specify what to test. For example, use the pushField opcode to select a field in the packet.
3Specify what to compare to the value in step 2. For example, use the pushLiteral opcode to select a constant value.