1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122
|
# dsmark without nounspec (base for following tests) --------------------------
LD_LIBRARY_PATH=. PATH=$PATH:tcc/ext tcsim -n -Xc,-xif:test -v | \
sed '/.* c .*returns /s///p;d'
#include "ip.def"
dev eth0 10000 {
#include "fields.tc"
dsmark (indices 256) {
class (5) if ip_tos == 4;
}
}
$ipproto=TCP $src=1.2.3.4 $dst=5.6.7.8
send IP_HDR($tos=1)
send IP_HDR($tos=4)
send IP_HDR($tos=8)
EOF
UNSPEC (-1)
OK (0) (1:5, 0x0)
UNSPEC (-1)
# dsmark with nounspec: using default_index -----------------------------------
LD_LIBRARY_PATH=. PATH=$PATH:tcc/ext tcsim -n -Xc,-xif:test -Xx,nounspec -v | \
sed '/.* c .*returns /s///p;d'
#include "ip.def"
dev eth0 10000 {
dsmark (indices 256,default_index 7) {
class (0)
if 0; /* we need this to make -x work */
}
}
$ipproto=TCP $src=1.2.3.4 $dst=5.6.7.8
send IP_HDR($tos=1)
send IP_HDR($tos=4)
send IP_HDR($tos=8)
EOF
OK (0) (1:7, 0x0)
OK (0) (1:7, 0x0)
OK (0) (1:7, 0x0)
# dsmark with nounspec: using default_index and classifier --------------------
LD_LIBRARY_PATH=. PATH=$PATH:tcc/ext tcsim -n -Xc,-xif:test -Xx,nounspec -v | \
sed '/.* c .*returns /s///p;d'
#include "ip.def"
dev eth0 10000 {
#include "fields.tc"
dsmark (indices 256,default_index 7) {
class (5) if ip_tos == 4;
}
}
$ipproto=TCP $src=1.2.3.4 $dst=5.6.7.8
send IP_HDR($tos=1)
send IP_HDR($tos=4)
send IP_HDR($tos=8)
EOF
OK (0) (1:7, 0x0)
OK (0) (1:5, 0x0)
OK (0) (1:7, 0x0)
# dsmark with nounspec: using set_tc_index ------------------------------------
LD_LIBRARY_PATH=. PATH=$PATH:tcc/ext tcsim -n -Xc,-xif:test -Xx,nounspec -v | \
sed '/.* c .*returns /s///p;d'
#include "ip.def"
dev eth0 10000 {
dsmark (indices 256,set_tc_index) {
class (0)
if 0; /* we need this to make -x work */
}
}
$ipproto=TCP $src=1.2.3.4 $dst=5.6.7.8
send IP_HDR($tos=0)
send IP_HDR($tos=1)
send IP_HDR($tos=4)
send IP_HDR($tos=80)
send IP_HDR($tos=0xff)
EOF
OK (0) (1:0, 0x0)
OK (0) (1:1, 0x0)
OK (0) (1:4, 0x0)
OK (0) (1:50, 0x0)
OK (0) (1:ff, 0x0)
# dsmark with nounspec: using set_tc_index and classifier ---------------------
LD_LIBRARY_PATH=. PATH=$PATH:tcc/ext tcsim -n -Xc,-xif:test -Xx,nounspec -v | \
sed '/.* c .*returns /s///p;d'
#include "ip.def"
dev eth0 10000 {
#include "fields.tc"
dsmark (indices 256,set_tc_index) {
class (7)
if ip_tos == 4;
}
}
$ipproto=TCP $src=1.2.3.4 $dst=5.6.7.8
send IP_HDR($tos=0)
send IP_HDR($tos=1)
send IP_HDR($tos=4)
send IP_HDR($tos=80)
send IP_HDR($tos=0xff)
EOF
OK (0) (1:0, 0x0)
OK (0) (1:1, 0x0)
OK (0) (1:7, 0x0)
OK (0) (1:50, 0x0)
OK (0) (1:ff, 0x0)
# dsmark with nounspec: none of the above -------------------------------------
PATH=$PATH:tcc/ext tcc -xif:test -Xx,nounspec 2>&1 >/dev/null
#include "fields.tc"
dsmark (indices 256) {
class (5) if ip_tos == 4;
}
EOF
ERROR
<stdin>:3: dsmark_default_class: need "default_index" or "set_tc_index"
|