Appendix A: How to use the layer 4 mask in classifiers
Example 2: ports 5004-5008
In some more complex situations, we may need more than one classifier to cover all the range we want to. Let’s take UDP destination ports between
5004 | = | 00010011 10001100 |
5005 | = | 00010011 10001101 |
5006 | = | 00010011 10001110 |
5007 | = | 00010011 10001111 |
5008 | = | 00010011 10010000 |
According to the bolded bits, we may think that the changed bits are the last 5 bits so the mask should be 11111111 11100000.
But remember that if we set the last 5 bits to 0, the mask will cover 25 = 32 ports. But we want to cover only 5 ports, so let’s divide 5 into 4+1.
5004 | = | 00010011 10001100 |
|
|
5005 | = | 00010011 10001101 |
|
|
5006 | = | 00010011 10001110 | 4 | ports |
5007 | = | 00010011 10001111 |
|
|
|
|
| + |
|
5008 | = | 00010011 10010000 | 1 | port |
Now it is really easy to write the classifiers!
create class=1 udpdp=5004 l4dmask=FFFC
create class=2 udpdp=5008
add swi hwfilt class=1,2 action=drop
Example 3: ports 333-777
A more complex situation, let’s try to write the classifiers for UDP ports between
z
z256 + 128 + 32 + 16 + 8 + 4 = 444 (7 classifiers)
z7 classifiers + 1 classifier (for 333) = 8 classifiers
Now the question is how to locate these blocks. The
0 | - | 255 |
256 | - | 512 |
512 | - | 767 |
768- 1024
...
65280 - 65536
Page 15 AlliedWare™ OS How To Note: Hardware Filters