Skip to content

Commit

Permalink
Merge pull request #138 from Igalia/packet-access-sctp
Browse files Browse the repository at this point in the history
Keyword elision not implemented with packet access: igmp, pim, igrp, vrrp
  • Loading branch information
dpino committed Mar 24, 2015
2 parents ff86ac1 + afc6da1 commit 0b40231
Show file tree
Hide file tree
Showing 8 changed files with 384 additions and 3 deletions.
22 changes: 21 additions & 1 deletion doc/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,12 @@ EXAMPLES = \
decnet-host-10.15.md \
l1.md \
icmp6.md \
sctp.md
sctp.md \
packet-access-igmp.md \
packet-access-pim.md \
packet-access-igrp.md \
packet-access-vrrp.md \
packet-access-sctp.md

PFLUA = \
../src/pf.lua \
Expand Down Expand Up @@ -161,3 +166,18 @@ icmp6.md: $(PFLUA)

sctp.md: $(PFLUA)
../tools/dump-markdown "sctp" > $@.tmp && mv $@.tmp $@

packet-access-igmp.md: $(PFLUA)
../tools/dump-markdown "igmp[8] < 8" > $@.tmp && mv $@.tmp $@

packet-access-pim.md: $(PFLUA)
../tools/dump-markdown "pim[8] < 8" > $@.tmp && mv $@.tmp $@

packet-access-igrp.md : $(PFLUA)
../tools/dump-markdown "igrp[8] < 8" > $@.tmp && mv $@.tmp $@

packet-access-vrrp.md: $(PFLUA)
../tools/dump-markdown "vrrp[8] < 8" > $@.tmp && mv $@.tmp $@

packet-access-sctp.md: $(PFLUA)
../tools/dump-markdown "sctp[8] < 8" > $@.tmp && mv $@.tmp $@
68 changes: 68 additions & 0 deletions doc/packet-access-igmp.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# igmp[8] < 8


## BPF

```
000: A = P[12:2]
001: if (A == 2048) goto 2 else goto 10
002: A = P[23:1]
003: if (A == 2) goto 4 else goto 10
004: A = P[20:2]
005: if (A & 8191 != 0) goto 10 else goto 6
006: X = (P[14:1] & 0xF) << 2
007: A = P[X+22:1]
008: if (A >= 8) goto 10 else goto 9
009: return 65535
010: return 0
```


## BPF cross-compiled to Lua

```
return function (P, length)
local A = 0
local X = 0
local T = 0
if 14 > length then return false end
A = bit.bor(bit.lshift(P[12], 8), P[12+1])
if not (A==2048) then goto L9 end
if 24 > length then return false end
A = P[23]
if not (A==2) then goto L9 end
if 22 > length then return false end
A = bit.bor(bit.lshift(P[20], 8), P[20+1])
if not (bit.band(A, 8191)==0) then goto L9 end
if 14 >= length then return false end
X = bit.lshift(bit.band(P[14], 15), 2)
T = bit.tobit((X+22))
if T < 0 or T + 1 > length then return false end
A = P[T]
if (runtime_u32(A)>=8) then goto L9 end
do return true end
::L9::
do return false end
error("end of bpf")
end
```


## Direct pflang compilation

```
local lshift = require("bit").lshift
local band = require("bit").band
local cast = require("ffi").cast
return function(P,length)
if length < 42 then return false end
if cast("uint16_t*", P+12)[0] ~= 8 then return false end
if P[23] ~= 2 then return false end
if band(cast("uint16_t*", P+20)[0],65311) ~= 0 then return false end
local var7 = lshift(band(P[14],15),2)
if (var7 + 23) > length then return false end
return P[(var7 + 22)] < 8
end
```

68 changes: 68 additions & 0 deletions doc/packet-access-igrp.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# igrp[8] < 8


## BPF

```
000: A = P[12:2]
001: if (A == 2048) goto 2 else goto 10
002: A = P[23:1]
003: if (A == 9) goto 4 else goto 10
004: A = P[20:2]
005: if (A & 8191 != 0) goto 10 else goto 6
006: X = (P[14:1] & 0xF) << 2
007: A = P[X+22:1]
008: if (A >= 8) goto 10 else goto 9
009: return 65535
010: return 0
```


## BPF cross-compiled to Lua

```
return function (P, length)
local A = 0
local X = 0
local T = 0
if 14 > length then return false end
A = bit.bor(bit.lshift(P[12], 8), P[12+1])
if not (A==2048) then goto L9 end
if 24 > length then return false end
A = P[23]
if not (A==9) then goto L9 end
if 22 > length then return false end
A = bit.bor(bit.lshift(P[20], 8), P[20+1])
if not (bit.band(A, 8191)==0) then goto L9 end
if 14 >= length then return false end
X = bit.lshift(bit.band(P[14], 15), 2)
T = bit.tobit((X+22))
if T < 0 or T + 1 > length then return false end
A = P[T]
if (runtime_u32(A)>=8) then goto L9 end
do return true end
::L9::
do return false end
error("end of bpf")
end
```


## Direct pflang compilation

```
local lshift = require("bit").lshift
local band = require("bit").band
local cast = require("ffi").cast
return function(P,length)
if length < 42 then return false end
if cast("uint16_t*", P+12)[0] ~= 8 then return false end
if P[23] ~= 9 then return false end
if band(cast("uint16_t*", P+20)[0],65311) ~= 0 then return false end
local var7 = lshift(band(P[14],15),2)
if (var7 + 23) > length then return false end
return P[(var7 + 22)] < 8
end
```

68 changes: 68 additions & 0 deletions doc/packet-access-pim.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# pim[8] < 8


## BPF

```
000: A = P[12:2]
001: if (A == 2048) goto 2 else goto 10
002: A = P[23:1]
003: if (A == 103) goto 4 else goto 10
004: A = P[20:2]
005: if (A & 8191 != 0) goto 10 else goto 6
006: X = (P[14:1] & 0xF) << 2
007: A = P[X+22:1]
008: if (A >= 8) goto 10 else goto 9
009: return 65535
010: return 0
```


## BPF cross-compiled to Lua

```
return function (P, length)
local A = 0
local X = 0
local T = 0
if 14 > length then return false end
A = bit.bor(bit.lshift(P[12], 8), P[12+1])
if not (A==2048) then goto L9 end
if 24 > length then return false end
A = P[23]
if not (A==103) then goto L9 end
if 22 > length then return false end
A = bit.bor(bit.lshift(P[20], 8), P[20+1])
if not (bit.band(A, 8191)==0) then goto L9 end
if 14 >= length then return false end
X = bit.lshift(bit.band(P[14], 15), 2)
T = bit.tobit((X+22))
if T < 0 or T + 1 > length then return false end
A = P[T]
if (runtime_u32(A)>=8) then goto L9 end
do return true end
::L9::
do return false end
error("end of bpf")
end
```


## Direct pflang compilation

```
local lshift = require("bit").lshift
local band = require("bit").band
local cast = require("ffi").cast
return function(P,length)
if length < 42 then return false end
if cast("uint16_t*", P+12)[0] ~= 8 then return false end
if P[23] ~= 103 then return false end
if band(cast("uint16_t*", P+20)[0],65311) ~= 0 then return false end
local var7 = lshift(band(P[14],15),2)
if (var7 + 23) > length then return false end
return P[(var7 + 22)] < 8
end
```

68 changes: 68 additions & 0 deletions doc/packet-access-sctp.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# sctp[8] < 8


## BPF

```
000: A = P[12:2]
001: if (A == 2048) goto 2 else goto 10
002: A = P[23:1]
003: if (A == 132) goto 4 else goto 10
004: A = P[20:2]
005: if (A & 8191 != 0) goto 10 else goto 6
006: X = (P[14:1] & 0xF) << 2
007: A = P[X+22:1]
008: if (A >= 8) goto 10 else goto 9
009: return 65535
010: return 0
```


## BPF cross-compiled to Lua

```
return function (P, length)
local A = 0
local X = 0
local T = 0
if 14 > length then return false end
A = bit.bor(bit.lshift(P[12], 8), P[12+1])
if not (A==2048) then goto L9 end
if 24 > length then return false end
A = P[23]
if not (A==132) then goto L9 end
if 22 > length then return false end
A = bit.bor(bit.lshift(P[20], 8), P[20+1])
if not (bit.band(A, 8191)==0) then goto L9 end
if 14 >= length then return false end
X = bit.lshift(bit.band(P[14], 15), 2)
T = bit.tobit((X+22))
if T < 0 or T + 1 > length then return false end
A = P[T]
if (runtime_u32(A)>=8) then goto L9 end
do return true end
::L9::
do return false end
error("end of bpf")
end
```


## Direct pflang compilation

```
local lshift = require("bit").lshift
local band = require("bit").band
local cast = require("ffi").cast
return function(P,length)
if length < 42 then return false end
if cast("uint16_t*", P+12)[0] ~= 8 then return false end
if P[23] ~= 132 then return false end
if band(cast("uint16_t*", P+20)[0],65311) ~= 0 then return false end
local var7 = lshift(band(P[14],15),2)
if (var7 + 23) > length then return false end
return P[(var7 + 22)] < 8
end
```

68 changes: 68 additions & 0 deletions doc/packet-access-vrrp.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# vrrp[8] < 8


## BPF

```
000: A = P[12:2]
001: if (A == 2048) goto 2 else goto 10
002: A = P[23:1]
003: if (A == 112) goto 4 else goto 10
004: A = P[20:2]
005: if (A & 8191 != 0) goto 10 else goto 6
006: X = (P[14:1] & 0xF) << 2
007: A = P[X+22:1]
008: if (A >= 8) goto 10 else goto 9
009: return 65535
010: return 0
```


## BPF cross-compiled to Lua

```
return function (P, length)
local A = 0
local X = 0
local T = 0
if 14 > length then return false end
A = bit.bor(bit.lshift(P[12], 8), P[12+1])
if not (A==2048) then goto L9 end
if 24 > length then return false end
A = P[23]
if not (A==112) then goto L9 end
if 22 > length then return false end
A = bit.bor(bit.lshift(P[20], 8), P[20+1])
if not (bit.band(A, 8191)==0) then goto L9 end
if 14 >= length then return false end
X = bit.lshift(bit.band(P[14], 15), 2)
T = bit.tobit((X+22))
if T < 0 or T + 1 > length then return false end
A = P[T]
if (runtime_u32(A)>=8) then goto L9 end
do return true end
::L9::
do return false end
error("end of bpf")
end
```


## Direct pflang compilation

```
local lshift = require("bit").lshift
local band = require("bit").band
local cast = require("ffi").cast
return function(P,length)
if length < 42 then return false end
if cast("uint16_t*", P+12)[0] ~= 8 then return false end
if P[23] ~= 112 then return false end
if band(cast("uint16_t*", P+20)[0],65311) ~= 0 then return false end
local var7 = lshift(band(P[14],15),2)
if (var7 + 23) > length then return false end
return P[(var7 + 22)] < 8
end
```

Loading

0 comments on commit 0b40231

Please sign in to comment.