diff options
author | Michael Santos <[email protected]> | 2010-07-21 14:50:58 -0400 |
---|---|---|
committer | Raimo Niskanen <[email protected]> | 2010-09-03 16:52:28 +0200 |
commit | 8393c5d5b682f8acbdc0ecf5b0e6f87589a314cb (patch) | |
tree | 969d5157e09771f4743cfa52987abb62a2fc9a28 /lib/kernel/test/inet_SUITE.erl | |
parent | d61d41e235bc464a15925e6fd1b7e9138477d3b3 (diff) | |
download | otp-8393c5d5b682f8acbdc0ecf5b0e6f87589a314cb.tar.gz otp-8393c5d5b682f8acbdc0ecf5b0e6f87589a314cb.tar.bz2 otp-8393c5d5b682f8acbdc0ecf5b0e6f87589a314cb.zip |
inet: support retrieving MAC address on BSD
On systems supporting getaddrinfo(), support looking up the MAC
address from inet:ifget/2. The results have the same quirks as with
Linux: if the MAC address is longer than 6 bytes (e.g., fw0 under
Mac OS X), the address is truncated; if the interface does not have
a MAC address (e.g., lo0), an address consisting of 0's is returned.
Diffstat (limited to 'lib/kernel/test/inet_SUITE.erl')
-rw-r--r-- | lib/kernel/test/inet_SUITE.erl | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/kernel/test/inet_SUITE.erl b/lib/kernel/test/inet_SUITE.erl index 86c2a0cbca..f4f27933a5 100644 --- a/lib/kernel/test/inet_SUITE.erl +++ b/lib/kernel/test/inet_SUITE.erl @@ -877,6 +877,17 @@ getif(Config) when is_list(Config) -> ?line {ok,Address} = inet:getaddr(Hostname, inet), ?line {ok,Loopback} = inet:getaddr("localhost", inet), ?line {ok,Interfaces} = inet:getiflist(), + ?line HWAs = + lists:sort( + lists:foldl( + fun (I, Acc) -> + case inet:ifget(I, [hwaddr]) of + {ok,[{hwaddr,A}]} -> [A|Acc]; + {ok,[]} -> Acc + end + end, [], Interfaces)), + ?line io:format("HWAs = ~p~n", [HWAs]), + ?line length(HWAs) > 0 orelse ?t:fail(no_HWAs), ?line Addresses = lists:sort( lists:foldl( |