File: ext

package info (click to toggle)
tcng 10b-1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 3,632 kB
  • ctags: 2,515
  • sloc: ansic: 19,038; pascal: 4,640; yacc: 2,619; sh: 1,908; perl: 1,546; lex: 772; makefile: 755
file content (67 lines) | stat: -rw-r--r-- 1,714 bytes parent folder | download | duplicates (5)
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
# "if" test using "external" target -------------------------------------------
LD_LIBRARY_PATH=. PATH=$PATH:tcc/ext \
  tcsim -v -Xc,-xif:test | sed '/.* c .*returns /s///p;d'
dev eth0 {
    prio {
	class if raw[0] == 42;
    }
}

send 00 01 02 03
send 0x2a 01 02 03
EOF
UNSPEC (-1)
OK (0) (1:1, 0x0)
# idem, with offsets ----------------------------------------------------------
LD_LIBRARY_PATH=. PATH=$PATH:tcc/ext \
  tcsim -n -v -Xc,-xif:test | sed '/.* c .*returns /s///p;d'
#include "ip.def"

dev eth0 {
    #include "fields.tc"

    prio {
	class if udp_dport == PORT_DOMAIN;
    }
}

send UDP_PCK($src=10.0.0.1 $dst=10.0.0.2 $sport=PORT_USER $dport=PORT_USER)
send UDP_PCK($src=10.0.0.1 $dst=10.0.0.2 $sport=PORT_USER $dport=PORT_DOMAIN)
send TCP_PCK($src=10.0.0.1 $dst=10.0.0.2 $sport=PORT_USER $dport=PORT_DOMAIN)
EOF
UNSPEC (-1)
OK (0) (1:1, 0x0)
UNSPEC (-1)
# idem, comparing all three classifiers ---------------------------------------
trinity -v
#define PORT_USER 0x1234

dev eth0 {
    prio {
        class if udp_dport == PORT_DOMAIN;
    }
}

send UDP_PCK($udp_sport=PORT_USER $udp_dport=PORT_USER)
send UDP_PCK($udp_sport=PORT_USER $udp_dport=PORT_DOMAIN)
send TCP_PCK($udp_sport=PORT_USER $udp_dport=PORT_DOMAIN)
EOF
UNSPEC (-1)
OK (0) (1:1)
UNSPEC (-1)
# "external" eliminates redundant bits ----------------------------------------
tcc -xif:err 2>&1 | sed '/^match/s/ action.*//p;d'
prio {
    class if raw[0] == 5 && raw[0].ns == 0x501;
}
EOF
match 0:0:16=0x0501
match
# "external" sorts bits -------------------------------------------------------
tcc -xif:err 2>&1 | sed '/^match/s/ action.*//p;d'
prio {
    class if raw[2] == 1 && raw[0] == 2;
}
EOF
match 0:0:8=0x02 0:16:8=0x01
match