Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Use the documented interface to find the MAC addr

  • Loading branch information...
commit 6fb81a9479839a97245ccfb6495e675e9df42ba4 1 parent 0215df4
Michael Santos authored

Showing 1 changed file with 7 additions and 3 deletions. Show diff stats Hide diff stats

  1. +7 3 src/spood.erl
10 src/spood.erl
@@ -53,9 +53,13 @@ nameserver() ->
53 53 proplists:get_value(resolv_conf, inet_db:get_rc(), "/etc/resolv.conf")),
54 54 proplists:get_value(nameserver, PL).
55 55
56   -macaddr({client, Dev}) ->
57   - {ok, [{hwaddr, MAC}]} = inet:ifget(Dev, [hwaddr]),
58   - list_to_tuple(MAC);
  56 +macaddr({Type, Dev}) when is_binary(Dev) ->
  57 + macaddr({Type, binary_to_list(Dev)});
  58 +macaddr({client, Dev}) when is_list(Dev) ->
  59 + {ok, Ifs} = inet:getifaddrs(),
  60 + Cfg = proplists:get_value(Dev, Ifs),
  61 + [MAC] = [ list_to_tuple(N) || {hwaddr, N} <- Cfg ],
  62 + MAC;
59 63 macaddr({server, IPAddr}) ->
60 64 % Force an ARP cache entry
61 65 {ok, Socket} = gen_udp:open(0, [{active, false}]),

0 comments on commit 6fb81a9

Please sign in to comment.
Something went wrong with that request. Please try again.