Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The templates v{4,6}_HTTP exract the host name, request method and URL from HTTP GET requests using the standard IPFIX elements httpRequestHost, httpRequestMethod and httpRequestTarget. Currently, only the GET method is supported.
- Loading branch information
1 parent
57b71a0
commit 045f48e
Showing
4 changed files
with
215 additions
and
2 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,86 @@ | ||
module(..., package.seeall) | ||
|
||
local ffi = require("ffi") | ||
|
||
ct_t = ffi.typeof([[ | ||
struct { | ||
uint8_t *text; | ||
uint16_t length; | ||
uint16_t pos; | ||
} | ||
]]) | ||
|
||
function ct_set(ct, pos) | ||
ct.pos = pos | ||
end | ||
|
||
function ct_get(ct) | ||
return ct.pos | ||
end | ||
|
||
function ct_at(ct) | ||
return ct.text + ct.pos | ||
end | ||
|
||
function ct_init(ct, text, length, pos) | ||
ct.text = text | ||
ct.length = length | ||
ct.pos = pos or 0 | ||
end | ||
|
||
function search(string, ct, tail) | ||
local slen = string.len | ||
local pos = ct.pos | ||
while (pos + slen < ct.length) do | ||
if ffi.C.strncasecmp(string.buf, ct.text + pos, slen) == 0 then | ||
if tail then pos = pos + slen end | ||
ct.pos = pos | ||
return pos | ||
end | ||
pos = pos + 1 | ||
end | ||
return nil | ||
end | ||
|
||
function upto_space_or_cr(ct) | ||
local text = ct.text | ||
local pos = ct.pos | ||
local pos_start = pos | ||
while (pos < ct.length and text[pos] ~= 32 and text[pos] ~= 13) do | ||
pos = pos + 1 | ||
end | ||
ct.pos = pos | ||
return pos, pos - pos_start | ||
end | ||
|
||
function skip_space(ct) | ||
local text = ct.text | ||
local pos = ct.pos | ||
local pos_start = pos | ||
while (pos < ct.length and text[pos] == 32) do | ||
pos = pos + 1 | ||
end | ||
ct.pos = pos | ||
return pos, pos - pos_start | ||
end | ||
|
||
function string_to_buf(s) | ||
-- Using ffi.new("uint8_t[?]", #s) results in trace aborts due to | ||
-- "bad argument type" in ffi.sizeof() | ||
local buf = ffi.new("uint8_t["..#s.."]") | ||
for i = 1, #s do | ||
buf[i-1] = s:byte(i,i) | ||
end | ||
return buf | ||
end | ||
|
||
function strings_to_buf(t) | ||
local result = {} | ||
for k, v in pairs(t) do | ||
result[k] = { | ||
buf = string_to_buf(v), | ||
len = #v | ||
} | ||
end | ||
return result | ||
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
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