+ local line, connt = nil, (not callback) and { }
+ for line in nfct do
+ local fam, l3, l4, timeout, state, tuples =
+ line:match("^(ipv[46]) +(%d+) +%S+ +(%d+) +(%d+) +([A-Z_]+) +(.+)$")
+
+ if fam and l3 and l4 and timeout and state and tuples and
+ state ~= "TIME_WAIT"
+ then
+ l4 = nixio.getprotobynumber(l4)
+
+ local entry = {
+ bytes = 0,
+ packets = 0,
+ layer3 = fam,
+ layer4 = l4 and l4.name or "unknown",
+ timeout = tonumber(timeout, 10)
+ }
+
+ local key, val
+ for key, val in tuples:gmatch("(%w+)=(%S+)") do
+ if key == "bytes" or key == "packets" then
+ entry[key] = entry[key] + tonumber(val, 10)
+ elseif key == "src" or key == "dst" or key == "sport" or key == "dport" then
+ if entry[key] == nil then
+ entry[key] = val
+ end
+ elseif val then
+ entry[key] = val