anchor.diff:  	    	    In ++ ".1"
   	    end
       end.
  -    
  +
  +%% Take a list of transport layer destinations as argument, and if the first one
  +%% does not have all elements filled out then resolve as necessary and return a
  +%% new list.
  +resolve_if_necessary([Dst | T]) when record(Dst, sipdst), Dst#sipdst.proto == undefined; Dst#sipdst.addr == undefined; Dst#sipdst.port == undefined ->
  +    URI = Dst#sipdst.uri,
  +    %% This is an incomplete sipdst, it should have it's URI set so we resolve the rest from here
  +    case URI of
  +	{_, _, _, _, _} ->
  +	    case siprequest:url_to_dstlist(URI, 500, URI) of    % XXX do better size estimation
  +		DstList when list(DstList) ->
  +		    DstList;
  +		Unknown ->
  +		    logger:log(error, "sippipe: Failed resolving URI ~s : ~p", [sipurl:print(Dst#sipdst.uri), Unknown]),
  +		    resolve_if_necessary(T)
  +	    end;
  +	InvalidURI ->
  +	    logger:log(error, "sippipe: Skipping destination with invalid URI : ~p", [InvalidURI]),
  +	    resolve_if_necessary(T)
  +    end;
  +resolve_if_necessary([Dst | T]) when record(Dst, sipdst) ->
  +    [Dst | T];
  +resolve_if_necessary([Dst | T]) ->
  +    logger:log(error, "sippipe: Skipping invalid destination : ~p", [Dst]),
  +    resolve_if_necessary(T);
  +resolve_if_necessary(Unknown) ->
  +    logger:log(error, "sippipe: Unrecognized destination input data : ~p", [Unknown]),
  +    [].
  +
   all_terminated(State) when record(State, state) ->
       ServerAlive = transactionlayer:is_good_transaction(State#state.serverhandler),
       ClientAlive = case util:safe_is_process_alive(State#state.clienthandler) of
  -	{true, _} -> true;
  -	_ -> false
  -    end,
  +		      {true, _} -> true;
  +		      _ -> false
  +		  end,
       if
   	ServerAlive == true -> false;
   	ClientAlive == true -> false;
  
positive.code: -module(sippipe).
  -export([start/7]).
  
  -record(state, {branch, serverhandler, clienthandler, request, dsturi, dstlist, parameters, timeout}).
  
  start(ServerHandler, ClientPid, Request, DstURI, DstList, Parameters, Timeout) ->
      case transactionlayer:is_good_transaction(ServerHandler) of
  	true ->
  	    Branch = get_branch_from_handler(ServerHandler) ++ "-UAC",
  	    start(Branch, ServerHandler, ClientPid, Request, DstURI, DstList, Parameters, Timeout);
  	false ->
  	    case transactionlayer:get_handler_for_request(Request) of
  		{error, E} ->
  		    logger:log(error, "sippipe: Could not start pipe, no valid server transaction " ++
  				"supplied (~p) and none found using transaction layer, error : ~p",
  				[ServerHandler, E]),
  		    error;
  		S ->
  		    Branch = get_branch_from_handler(S) ++ "-UAC",
  		    start(Branch, S, ClientPid, Request, DstURI, DstList, Parameters, Timeout)		    
  	    end	
      end.
  
  start(Branch, ServerHandler, ClientPid, Request, DstURI, DstListIn, Parameters, Timeout) when ClientPid == none ->
      {Method, URI, Header, Body} = Request,
      {_, UseDstURI, _} = siprequest:rewrite_route(Header, DstURI),
      DstList = case DstListIn of
  	none -> siprequest:url_to_dstlist(UseDstURI, 500); % XXX do better estimation
  	_ when list(DstListIn) -> DstListIn
      end,
      [FirstDst|_] = DstList,
      SendRequest = {Method, DstURI, Header, Body},
      case transactionlayer:start_client_transaction(SendRequest, none, FirstDst, Branch, Timeout, self()) of
      	BranchPid when pid(BranchPid) ->
  	    start(Branch, ServerHandler, BranchPid, Request, DstURI, DstList, Parameters, Timeout);
  	{error, E} ->
  	    logger:log(error, "sippipe: Failed starting client transaction : ~p", [E]),
  	    error
      end;
  
  start(Branch, ServerHandler, ClientPid, Request, DstURI, DstList, Parameters, Timeout) ->
      case transactionlayer:adopt_server_transaction_handler(ServerHandler) of
  	{error, E} ->
  	    logger:log(error, "sippipe: Could not adopt server transaction handler ~p : ~p", [ServerHandler, E]),
  	    error;
  	_ ->
  	    State=#state{branch=Branch, serverhandler=ServerHandler, clienthandler=ClientPid,
  			 request=Request, dsturi=DstURI, dstlist=DstList, parameters=Parameters,
  			 timeout=Timeout},
  	    loop(State)
      end.
  
  get_branch_from_handler(TH) ->
      CallBranch = transactionlayer:get_branch_from_handler(TH),
      case string:rstr(CallBranch, "-UAS") of
  
negative.code: 	Index when integer(Index) ->
  	    BranchBase = string:substr(CallBranch, 1, Index - 1),
  	    BranchBase
      end.
  
  get_next_target_branch(In) ->
  