anchor.diff:      case List of
           [] ->
               % no NAPTR records -- try making SRV queries for all supported protocols
  -            if TLS -> Params = [tls]; not TLS -> Params = [] end,
  -            DomainTCP = service_proto(tcp, TLS) ++ Host,
  -            DestTCP = #sip_destination{transport = tcp, params = Params},
  -            case resolve_dest_srv(Host, DomainTCP, DestTCP) of
  +            Service = if TLS -> sips; true -> sip end,
  +            case resolve_dest_srv(Service, udp, Host) of
                   [] ->
  -                    DomainUDP = service_proto(udp, TLS) ++ Host,
  -                    DestUDP = #sip_destination{transport = udp, params = Params},
  -                    resolve_dest_srv(Host, DomainUDP, DestUDP);
  +                    resolve_dest_srv(Service, tcp, Host);
                   Dests -> Dests
               end;
           _ ->
               % choose with lowest order, preference, which is supported by this implementation
  -            List2 = [{Service, Name} || {_Order, _Pref, _Flags, Service, RegExp, Name} <- List,
  -                                        is_supported(Service, TLS),
  -                                        RegExp =:= []],
  -            [{Service, Name} | _Rest] = List2,
  -
  -            Dest2 = service_dest(Service),
  -            resolve_dest_srv(Host, Name, Dest2)
  +            List2 = [{Service, Replacement} || {_Order, _Pref, _Flags, Service, RegExp, Replacement} <- List,
  +                                               is_supported(Service, TLS),
  +                                               RegExp =:= []],
  +            [{Service, Replacement} | _Rest] = List2,
  +
  +            {Service2, Protocol} = service(Service),
  +            resolve_dest_srv(Service2, Protocol, Host, Replacement)
       end.
   
   %% @doc Create `#sip_destination{}' for given NAPTR service
  -service_dest("sip+d2u") -> #sip_destination{transport = udp};
  -service_dest("sip+d2t") -> #sip_destination{transport = tcp};
  -service_dest("sip+d2s") -> #sip_destination{transport = sctp};
  -service_dest("sips+d2t") -> #sip_destination{transport = tcp, params = [tls]};
  -service_dest("sips+d2s") -> #sip_destination{transport = sctp, params = [tls]}.
  +service("sip+d2u") -> {sip, udp};
  +service("sip+d2t") -> {sip, tcp};
  +service("sip+d2s") -> {sip, sctp};
  +service("sips+d2t") -> {sips, tcp};
  +service("sips+d2s") -> {sips, sctp}.
   
   %% @doc Check if we support given service/TLS requirement combination
   %% @end
  
positive.code:             resolve_dest_a(Target, Dest);
          Explicit ->
              % Transport is provided explicitly, make SRV query
              Domain = service_proto(Transport, TLS) ++ Target,
              Dest = #sip_destination{transport = Transport, params = Params},
              resolve_dest_srv(Target, Domain, Dest);
          true ->
              % make NAPTR query
              select_bynaptr(Target, TLS)
  
negative.code:     {ok, Addrs} = inet:getaddrs(Host, inet), % FIXME: ipv6
      [Destination#sip_destination{address = Addr} || Addr <- Addrs].
  
  %% @doc Determine SRV domain prefix based on pair of service and transport
  %% @end
  srv_prefix(sip, udp) -> "_sip._udp.";
  srv_prefix(sip, tcp) -> "_sip._tcp.";
  srv_prefix(sip, sctp) -> "_sip._sctp.";
  srv_prefix(sips, tcp) -> "_sips._tcp.";
  srv_prefix(sips, sctp) -> "_sips._sctp.".
  