Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
sniff: represent flags as a list of atoms
  • Loading branch information
msantos committed Mar 9, 2011
1 parent 407ef30 commit 4e8c510
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/sniff.erl
Expand Up @@ -184,11 +184,19 @@ to_ascii(_) -> $..


ether_addr(B) when is_binary(B) -> ether_addr(B) when is_binary(B) ->
ether_addr(binary_to_list(B)); ether_addr(binary_to_list(B));
ether_addr(L) when is_list(L) -> ether_addr(L) when is_list(L) ->
[ hd(io_lib:format("~.16B", [N])) || N <- L ]. [ hd(io_lib:format("~.16B", [N])) || N <- L ].


tcp_flags(#tcp{cwr = CWR, ece = ECE, urg = URG, ack = ACK, tcp_flags(#tcp{cwr = CWR, ece = ECE, urg = URG, ack = ACK,
psh = PSH, rst = RST, syn = SYN, fin = FIN}) -> psh = PSH, rst = RST, syn = SYN, fin = FIN}) ->
[ atom_to_list(F) || {F,V} <- [ F || {F,V} <- [
[{cwr,CWR}, {ece,ECE}, {urg,URG}, {ack,ACK}, {psh,PSH}, {rst,RST}, {syn,SYN}, {fin,FIN}], V =:= 1 ]. {cwr, CWR},
{ece, ECE},
{urg, URG},
{ack, ACK},
{psh, PSH},
{rst, RST},
{syn, SYN},
{fin, FIN}
], V =:= 1 ].


0 comments on commit 4e8c510

Please sign in to comment.