Some numeric literals are scattered throughout expand.lua, which makes it trickier to understand/maintain/modify, etc. It would be fantastic if the literals were given meaningful names, so it was more obvious what protocols they were from and an idea of their semantics.
In general, lines like { '=', { '[ether]', 14, 1 }, PROTO_STP } } are a bit nicer than { '=', { '[ether]', 14, 4 }, 2863268608 }; with the 14 replaced by a name, they'd be better yet.
Examples:
if proto > 1500 then return { '=', { '[ether]', 12, 2 }, proto } end
{ '<=', {'[ether]', 12, 2}, 1500 },
{ '=', { '[ether]', 14, 1}, proto } }
local function has_ipv6_protocol(proto)
{ '=', { '[ip6]', 6, 1 }, proto },
{ '=', { '[ip6]', 6, 1 }, 44 },
{ '=', { '[ip6]', 40, 1 }, proto } } }
local function expand_ip6_broadcast(expr)
return { '=', { '[ip]', 16, 1 }, 224 }
Some numeric literals are scattered throughout expand.lua, which makes it trickier to understand/maintain/modify, etc. It would be fantastic if the literals were given meaningful names, so it was more obvious what protocols they were from and an idea of their semantics.
In general, lines like
{ '=', { '[ether]', 14, 1 }, PROTO_STP } }
are a bit nicer than{ '=', { '[ether]', 14, 4 }, 2863268608 }
; with the 14 replaced by a name, they'd be better yet.Examples: