Browse files

Use the documented interface to find the MAC addr

  • Loading branch information...
1 parent 0215df4 commit 6fb81a9479839a97245ccfb6495e675e9df42ba4 @msantos committed Apr 5, 2012
Showing with 7 additions and 3 deletions.
  1. +7 −3 src/spood.erl
View
10 src/spood.erl
@@ -53,9 +53,13 @@ nameserver() ->
proplists:get_value(resolv_conf, inet_db:get_rc(), "/etc/resolv.conf")),
proplists:get_value(nameserver, PL).
-macaddr({client, Dev}) ->
- {ok, [{hwaddr, MAC}]} = inet:ifget(Dev, [hwaddr]),
- list_to_tuple(MAC);
+macaddr({Type, Dev}) when is_binary(Dev) ->
+ macaddr({Type, binary_to_list(Dev)});
+macaddr({client, Dev}) when is_list(Dev) ->
+ {ok, Ifs} = inet:getifaddrs(),
+ Cfg = proplists:get_value(Dev, Ifs),
+ [MAC] = [ list_to_tuple(N) || {hwaddr, N} <- Cfg ],
+ MAC;
macaddr({server, IPAddr}) ->
% Force an ARP cache entry
{ok, Socket} = gen_udp:open(0, [{active, false}]),

0 comments on commit 6fb81a9

Please sign in to comment.