Skip to content

Commit

Permalink
wall-spy: Convert port numbers to host endianness for flow reporting
Browse files Browse the repository at this point in the history
The port numbers where showing oddily because of the missing network-to-host
endianness conversion.
  • Loading branch information
aperezdc committed Aug 17, 2016
1 parent ff62edc commit 439437e
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/program/wall/spy/spy.lua
Expand Up @@ -8,6 +8,7 @@ local ipv6 = require("lib.protocol.ipv6")
local util = require("apps.wall.util")
local scan = require("apps.wall.scanner")
local proto = require("ndpi").protocol
local ntohs = lib.ntohs

local long_opts = {
help = "h",
Expand All @@ -33,15 +34,15 @@ local function report_flow(scanner, flow)
if flow.proto_master ~= proto.PROTOCOL_UNKNOWN then
printf("%#010x %4dp %15s:%-5d - %15s:%-5d %s:%s\n",
flow.key:hash(), flow.packets,
lo_addr, flow.key.lo_port,
hi_addr, flow.key.hi_port,
lo_addr, ntohs(flow.key.lo_port),
hi_addr, ntohs(flow.key.hi_port),
scanner:protocol_name(flow.protocol),
scanner:protocol_name(flow.proto_master))
else
printf("%#010x %4dp %15s:%-5d - %15s:%-5d %s\n",
flow.key:hash(), flow.packets,
lo_addr, flow.key.lo_port,
hi_addr, flow.key.hi_port,
lo_addr, ntohs(flow.key.lo_port),
hi_addr, ntohs(flow.key.hi_port),
scanner:protocol_name(flow.protocol))
end
end
Expand Down

0 comments on commit 439437e

Please sign in to comment.