anchor.diff:  %%           {error, Reason}
   %%           DstList = list() of sipdst record()
   %%--------------------------------------------------------------------
  -host_port_to_dstlist(Proto, InHost, InPort, URI) when is_integer(InPort) ; InPort == none,
  -						      is_record(URI, sipurl) ->
  -    case dnsutil:get_ip_port(InHost, InPort) of
  +host_port_to_dstlist(Proto, Host, Port, URI, SSLHost) when is_integer(Port) ; Port == none,
  +							   is_record(URI, sipurl),
  +							   is_list(SSLHost) ; SSLHost == undefined ->
  +    case dnsutil:get_ip_port(Host, Port) of
   	{error, What} ->
   	    {error, What};
   	L when is_list(L) ->
  -	    %% L is a list of tuples like {Inet, Addr, Port}. Addr is the
  -	    %% IP address (be it v4 or v6) as a string. Inet is 'inet' or 'inet6'.
  -	    DstList = make_sipdst_from_hostport(Proto, URI, L),
  -	    DstList
  +	    %% L is a list of sipdns_hostport record()
  +	    make_sipdst_from_hostport(Proto, URI, SSLHost, L)
       end.
   
   %%--------------------------------------------------------------------
  -%% Function: make_sipdst_from_hostport(Proto, URI, L)
  -%%           Proto = atom(), tcp | udp | tls
  -%%           URI   = sipurl record(), URI to stick into the resulting
  -%%                   sipdst records
  -%%           L     = list() of {Proto, Addr, Port} tuples - typically
  -%%                   the result of a call to dnsutil:get_ip_port()
  +%% Function: make_sipdst_from_hostport(Proto, URI, SSLHost, In)
  +%%           Proto   = atom(), tcp | udp | tls
  +%%           URI     = sipurl record(), URI to stick into the
  +%%                     resulting sipdst records
  +%%           SSLHost = string() | undefined, SSL hostname to expect
  +%%           In      = list() of sipdns_hostport record() - typically
  +%%                     the result of a call to dnsutil:get_ip_port()
   %% Descrip.: Turns the result of a dnsutil:get_ip_port() into a list
   %%           of sipdst records. get_ip_port() return a list of tuples
   %%           like {Inet, Addr, Port} where IP is a string ("10.0.0.1",
  
positive.code: 
  %%
  %% URL port specified
  %%
  url_to_dstlist_not_ip(URL, ApproxMsgSize, ReqURI)
    when is_record(URL, sipurl), is_integer(ApproxMsgSize), URL#sipurl.port /= none, is_record(ReqURI, sipurl) ->
      case (URL#sipurl.proto == tls) or (URL#sipurl.proto == tls6) of
  	true ->
  	    TLS = host_port_to_dstlist(tcp, URL#sipurl.host, sipurl:get_port(URL), ReqURI),
  	    logger:log(debug, "Resolver: Port was explicitly supplied and URL protocol is TLS - only try TCP"),
  	    TLS;
  	false ->
  	    TCP = host_port_to_dstlist(tcp, URL#sipurl.host, sipurl:get_port(URL), ReqURI),
  	    UDP = host_port_to_dstlist(udp, URL#sipurl.host, sipurl:get_port(URL), ReqURI),
  	    case ApproxMsgSize > 1200 of
  		true ->
  		    logger:log(debug, "Resolver: Port was explicitly supplied, and size of message is > 1200."
  			       " Try TCP and then UDP."),
  		    combine_host_portres([TCP, UDP]);
  		false ->
  		    %% RFC3263 4.1 says we SHOULD use UDP as default in this case, since UDP was the only thing
  		    %% mandated by RFC2543. Sucks. We do however append any TCP destinations too, even though
  		    %% any transactions will probably time out if UDP does not work...
  		    logger:log(debug, "Resolver: Port was explicitly supplied, and size of message is <= 1200."
  			       " Try UDP and then TCP."),
  		    combine_host_portres([UDP, TCP])
  	    end
      end;
  
  %%
  %% URL port NOT specified, do SRV lookup on host from URL
  %%
  url_to_dstlist_not_ip(URL, ApproxMsgSize, ReqURI) when is_record(URL, sipurl), is_integer(ApproxMsgSize),
  						       is_record(ReqURI, sipurl) ->
      case dnsutil:siplookup(URL#sipurl.host) of
  	[{error, nxdomain} | _] ->
  	    %% A SRV-lookup of the Host part of the URL returned NXDOMAIN, this is
  	    %% not an error and we will now try to resolve the Host-part directly
  	    %% (look for A or AAAA record)
  	    host_port_to_dstlist(udp, URL#sipurl.host, sipurl:get_port(URL), ReqURI);
  	[{error, What} | _] ->
  	    %% If first element returned from siplookup is an error then they all are.
  	    {error, What};
  	none ->
  	    TCP = host_port_to_dstlist(tcp, URL#sipurl.host, sipurl:get_port(URL), ReqURI),
  	    UDP = host_port_to_dstlist(udp, URL#sipurl.host, sipurl:get_port(URL), ReqURI),
  	    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]),
  		    combine_host_portres([TCP, UDP]);
  		false ->
  		    logger:log(debug, "Warning: ~p has no SRV records in DNS, and the message size "
  			       "is =< 1200 bytes. 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(sipurl:get_port(URL), ReqURI, DstList2)
      end.
  
  %%--------------------------------------------------------------------
  %% Function: combine_host_portres(In)
  
negative.code:     [TCP6, UDP6] = remove_tls_destinations([TLS6, TCP6, TLS4, UDP6, TLS4]),
  
  
      %% test remove_non_tls_destinations(SRVList)
      %%--------------------------------------------------------------------
      io:format("test: remove_non_tls_destinations/2 - 1~n"),
      %% test normal case
      [TLS4, TLS6] = remove_non_tls_destinations([TLS4, TCP6, TLS6, UDP6]),
  
  
      %% test make_sipdst_from_hostport(Proto, URI, SSLHost, In)
      %%--------------------------------------------------------------------
      URL = sipurl:parse("sip:ft@example.org:1234"),
  
      io:format("test: make_sipdst_from_hostport/3 - 1~n"),
      %% simple case, tcp and no supplied port in the tuple
      HostPort1 = #sipdns_hostport{family=inet, addr="address", port=none},
      Dst1 = #sipdst{proto=tcp, addr="address", port=5060, uri=URL, ssl_hostname="ssl1"},
      [Dst1] = make_sipdst_from_hostport(tcp, URL, "ssl1", [HostPort1]),
  
      io:format("test: make_sipdst_from_hostport/3 - 2~n"),
      %% tcp 'upped' to tcp6 since tuple protocol is inet6. port from tuple used.
      HostPort2 = #sipdns_hostport{family=inet6, addr="address", port=5070},
      Dst2 = #sipdst{proto=tcp6, addr="address", port=5070, uri=URL, ssl_hostname=undefined},
      [Dst2] = make_sipdst_from_hostport(tcp, URL, undefined, [HostPort2]),
  
      io:format("test: make_sipdst_from_hostport/3 - 3~n"),
      %% mixed
      Dst2_2 = Dst2#sipdst{ssl_hostname="ssl1"},
      [Dst1, Dst2_2] =
  	make_sipdst_from_hostport(tcp, URL, "ssl1", [HostPort1, HostPort2]),
  
  
      %% test get_response_host_proto(TopVia)
      %% NOTE: We can currently only test with IPv4 addresses since IPv6 is
      %% off by default, so when the tests are run enable_v6 might not be
      %% 'true'.
  