Skip to content

Commit

Permalink
Error out if the interface does not come up
Browse files Browse the repository at this point in the history
Wait for 2 seconds for the interface to become ready. On my netbook,
getting the datalink type will sometimes loop forever. When I ran tcpdump
on the interface there weren't any frames received. The interface seems
to be stuck.

Bringing the interface up and down, etc, didn't help but rebooting did.

Had something to do with the Ubuntu network manager running at the same
time the interface was being toggled into monitor mode. Usually this
works ok but it's better to shut down the network manager first:

service network-manager stop
  • Loading branch information
msantos committed Aug 11, 2011
1 parent e8f11b1 commit d451a30
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/wierl_monitor.erl
Original file line number Diff line number Diff line change
Expand Up @@ -249,12 +249,19 @@ dlt(wierl_radiotap) -> 803.
% from the socket. The interface may not be ready, so spin
% here until it comes up.
%
% XXX May end up looping forever here.
% In some cases the interface will never come up. tcpdump
% doesn't display any frames being received by the interface.
% Only fix so far is to reboot.
datalinktype(Socket) ->
datalinktype(Socket, 200).

datalinktype(_Socket, 0) ->
throw({error,enetdown});
datalinktype(Socket, N) ->
case read(Socket, 0) of
{error,eagain} ->
timer:sleep(10),
datalinktype(Socket);
datalinktype(Socket, N-1);
{ok, <<>>} ->
ok
end.
Expand Down

0 comments on commit d451a30

Please sign in to comment.