anchor.diff:  -ifdef(TEST).
   -compile(export_all).
   -endif.
  +
  +-type ifopt() :: {flag,[atom()]} | {addr, inet:ip_address()} |
  +                 {netmask,inet:ip_address()} | {broadaddr,inet:ip_address()} |
  +                 {dstaddr,inet:ip_address()} | {hwaddr,[byte()]}.
   
   
   %%--------------------------------------------------------------------
  
positive.code:   {ok, Interfaces} = inet:getifaddrs(),
    nic_ipv4(Device, Interfaces).
  
  nic_ipv4(_, []) -> {error, not_found};
  nic_ipv4(Device, [{Interface, Opts}|_]) when Interface =:= Device ->
    {ok, nic_ipv4_address(Opts)};
  
negative.code:   nic_ipv4(Device,T).
  
  
  %%--------------------------------------------------------------------
  %% @doc
  %% Return the formatted IPv4 address out of the list of addresses
  %% for the interface.
  %% @end
  %%--------------------------------------------------------------------
  -spec nic_ipv4_address([ifopt()]) -> {ok, string()} | {error, not_found}.
  nic_ipv4_address([]) -> {error, not_found};
  nic_ipv4_address([{addr, {A,B,C,D}}|_]) ->
    inet_parse:ntoa({A,B,C,D});
  nic_ipv4_address([_|T]) ->
    nic_ipv4_address(T).
  
  
  %%--------------------------------------------------------------------
  