Permalink
Browse files

Retrieve BPF stats

  • Loading branch information...
msantos committed Apr 20, 2011
1 parent d24b8b5 commit 19766801d9c0c015052ab5894e66bd4d5ac5e7bc
Showing with 13 additions and 0 deletions.
  1. +13 −0 src/bpf.erl
View
@@ -126,6 +126,19 @@ ctl(Socket, seesent) ->
Error
end;
+%% struct bpf_stat {
+%% u_int bs_recv;
+%% u_int bs_drop;
+%% };
+ctl(Socket, stats) ->
+ case procket:ioctl(Socket, ?BIOCGSTATS, <<0:32, 0:32>>) of
+ {ok, <<Recv:4/native-unsigned-integer-unit:8,
+ Drop:4/native-unsigned-integer-unit:8>>} ->
+ {ok, {Recv, Drop}};
+ Error ->
+ Error
+ end;
+
%ctl(Socket, timeout) ->
% Size = sizeof(timeval),
% procket:ioctl(Socket, ?BIOCGRTIMEOUT, <<0:Size/bytes>>);

0 comments on commit 1976680

Please sign in to comment.