anchor.diff:      end.
   
   %%--------------------------------------------------------------------
  -%% Function: dst2str/1
  -%% Description: Turn a sipdst into something printable (for debugging)
  -%% Returns: DstString
  +%% Function: dst2str(Dst)
  +%%           Dst = sipdst record()
  +%% Descrip.: Turn a sipdst into something printable (for debugging)
  +%% Returns : DstString, Dst as string()
   %%--------------------------------------------------------------------
   
   %%
   %% URI present
   %%
  -dst2str(Dst) when record(Dst, sipdst), Dst#sipdst.uri /= undefined ->
  -    lists:flatten(io_lib:format("~p:~s:~p (~s)", [Dst#sipdst.proto, Dst#sipdst.addr, Dst#sipdst.port,
  -						  sipurl:print(Dst#sipdst.uri)]));
  +dst2str(Dst) when is_record(Dst, sipdst), Dst#sipdst.uri /= undefined ->
  +    lists:flatten(io_lib:format("~p:~s:~p (~s)",
  +				[Dst#sipdst.proto, Dst#sipdst.addr, Dst#sipdst.port,
  +				 sipurl:print(Dst#sipdst.uri)]));
   
   %%
   %% No URI, for example Response sipdst record
  
positive.code: 
  -module(sipdst).
  
  -export([url_to_dstlist/3, get_response_destination/1, dst2str/1,
  	 debugfriendly/1]).
  
  -include("siprecords.hrl").
  -include("sipsocket.hrl").
  
  
  %%--------------------------------------------------------------------
  %% Function: url_to_dstlist/3
  %% Description: Make a list of sipdst records from an URL. We need the
  %%              approximate message size to determine if we can use
  %%              UDP or have to do TCP only.
  %% Returns: ListOfDsts | {error, Reason}
  %%--------------------------------------------------------------------
  url_to_dstlist(URL, ApproxMsgSize, ReqURI) when record(URL, sipurl), integer(ApproxMsgSize) ->
      {Host, Port, Parameters} = {URL#sipurl.host, URL#sipurl.port, URL#sipurl.param},
      %% Check if Host is either IPv4 or IPv6 address
      case inet_parse:address(Host) of
  	{ok, _} ->
  	    logger:log(debug, "url_to_dstlist: ~p is an IP address, not performing domain NAPTR/SRV lookup", [Host]),
  
negative.code: 	    UDP = host_port_to_dstlist(udp, URL#sipurl.host, URL#sipurl.port, ReqURI),
  	    logger:log(debug, "Warning: ~p has no SRV records in DNS, defaulting to TCP and then UDP",
  		       [URL#sipurl.host]),
  	    case ApproxMsgSize > 1200 of
  		true ->
  		    logger:log(debug, "Warning: ~p has no SRV records in DNS, and the message size" ++
  			       "is > 1200 bytes. Resolving hostname and trying TCP and then UDP.",
  			       [URL#sipurl.host]),
  		    lists:append(TCP, UDP);
  		false ->
  		    logger:log(debug, "Warning: ~p has no SRV records in DNS. Resolving hostname " ++
  			       "and defaulting to UDP (only).", [URL#sipurl.host]),
  		    UDP
  	    end;
  	DstList when is_list(DstList) ->
  	    DstList2 = case sipserver:get_env(enable_experimental_tls, false) of
  			   false ->
  			       remove_tls_destinations(DstList, []);
  			   true ->
  			       DstList
  		       end,
  	    format_siplookup_result(URL#sipurl.port, ReqURI, ApproxMsgSize, DstList2)
      end.
  
  %%--------------------------------------------------------------------
  %% Function: remove_tls_destinations(In, [])
  %%           In = list() of {Proto, Host, Port} tuples
  %% Descrip.: Remove all tuples having Proto 'tls' | tls6 from In, and
  %%           return a new list() of tuples.
  %% Returns : DstList = list() of {Proto, Host, Port} tuples
  %%--------------------------------------------------------------------
  remove_tls_destinations([], Res) ->
      lists:reverse(Res);
  remove_tls_destinations([{Proto, Host, Port} | T], Res) when Proto /= tls, Proto /= tls6 ->
      remove_tls_destinations(T, [{Proto, Host, Port} | Res]);
  remove_tls_destinations([{Proto, Host, Port} | T], Res) ->
      %% Proto is tls or tls6
      logger:log(debug, "Resolver: Removing TLS destination ~p:~s:~p from result set since "
  	       "experimental TLS is not enabled", [Proto, Host, Port]),
      remove_tls_destinations(T, Res).
  
  %%--------------------------------------------------------------------
  %% Function: host_port_to_dstlist/4
  %% Descrip.: Resolves a hostname and returns a list of sipdst
  %%           records of the protocol requested.
  %%           Inport should either be an integer, or the atom 'none'
  %%           to use the default port for the protocol.
  %% Returns : DstList         |
  %%           {error, Reason}
  %%           DstList = list() of sipdst record()
  %%--------------------------------------------------------------------
  host_port_to_dstlist(Proto, InHost, PortStr, URI) when list(PortStr) ->
      host_port_to_dstlist(Proto, InHost, list_to_integer(PortStr), URI);
  