-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #138 from Igalia/packet-access-sctp
Keyword elision not implemented with packet access: igmp, pim, igrp, vrrp
- Loading branch information
Showing
8 changed files
with
384 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
``` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
``` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
``` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
``` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
``` | ||
|
Oops, something went wrong.