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
|
# use variable IP header length -----------------------------------------------
tcc -xif:err 2>&1 | sed '/offset/p;/match/p;d'
#include "fields.tc"
prio {
class if udp_sport == 22;
}
EOF
offset 100 = 0+(0:4:4 << 5)
match 0:72:8=0x11 100:0:16=0x0016 action 1
match action 0
# use constant IP header length (trusting) ------------------------------------
tcc -xif:err 2>&1 | sed '/offset/p;/match/p;d'
#include "fields.tc"
field ip_nexthdr = ip_hdr[20];
prio {
class if udp_sport == 22;
}
EOF
match 0:72:8=0x11 0:160:16=0x0016 action 1
match action 0
# use constant IP header length (with check) ----------------------------------
tcc -xif:err 2>&1 | sed '/offset/p;/match/p;d'
#include "fields.tc"
field ip_nexthdr = ip_hdr[20] if ip_hl == 5;
prio {
class if udp_sport == 22;
}
EOF
match 0:4:4=0x5 0:72:8=0x11 0:160:16=0x0016 action 1
match action 0
# fields and negation: f == 1 -------------------------------------------------
LD_LIBRARY_PATH=. PATH=$PATH:tcc/ext tcsim -v -Xc,-xif:test | \
sed '/.*(1:\\(.\\),.*/s//\\1/p;d'
dev eth0 10000 {
field f = raw[1] if raw[0] == 1;
prio {
class if f == 1;
class if 1;
}
}
send 0 0
send 0 1
send 1 0
send 1 1
EOF
2
2
2
1
# fields and negation: f != 1 -------------------------------------------------
LD_LIBRARY_PATH=. PATH=$PATH:tcc/ext tcsim -v -Xc,-xif:test | \
sed '/.*(1:\\(.\\),.*/s//\\1/p;d'
dev eth0 10000 {
field f = raw[1] if raw[0] == 1;
prio {
class if f != 1;
class if 1;
}
}
send 0 0
send 0 1
send 1 0
send 1 1
EOF
2
2
1
2
# fields and negation: !(f == 1) ----------------------------------------------
LD_LIBRARY_PATH=. PATH=$PATH:tcc/ext tcsim -v -Xc,-xif:test | \
sed '/.*(1:\\(.\\),.*/s//\\1/p;d'
dev eth0 10000 {
field f = raw[1] if raw[0] == 1;
prio {
class if !(f == 1);
class if 1;
}
}
send 0 0
send 0 1
send 1 0
send 1 1
EOF
1
1
1
2
# fields and negation: !(f != 1) ----------------------------------------------
LD_LIBRARY_PATH=. PATH=$PATH:tcc/ext tcsim -v -Xc,-xif:test | \
sed '/.*(1:\\(.\\),.*/s//\\1/p;d'
dev eth0 10000 {
field f = raw[1] if raw[0] == 1;
prio {
class if !(f != 1);
class if 1;
}
}
send 0 0
send 0 1
send 1 0
send 1 1
EOF
1
1
2
1
|