anchor.diff:  			100 -> AnswerHeader4;
   			_ -> keylist:delete("Timestamp", AnswerHeader4)
   		    end,
  -    {Status, Reason, AnswerHeader5, Body}.
  +    #response{status=Status, reason=Reason, header=AnswerHeader5, body=Body}.
  
positive.code: 	    lists:nth(1, Hostnames)
      end.
  
  add_record_route(Proto, Hostname, Port, Header) ->
      Param1 = ["maddr=" ++ siphost:myip(), "lr=true"],
      Param2 = case Proto of
  
negative.code: 	    false
      end.
  
  %% Function: check_proxy_request/3
  %% Description: Prepares a request for proxying. Checks Max-Forwards,
  %%              etc. Not guaranteed to return, might
  %%              throw a siperror if the request should not be proxied.
  %% Returns: {ok, NewHeader, ApproxMsgSize}
  %%--------------------------------------------------------------------
  check_proxy_request(Request) when record(Request, request) ->
      NewHeader1 = proxy_check_maxforwards(Request#request.header),
      check_valid_proxy_request(Request#request.method, NewHeader1),
      NewHeader2 = fix_content_length(NewHeader1, Request#request.body),
      %% The size is _approximate_. The exact size cannot be calculated here
      %% since it is dependent on the right Request-URI and length of the final
      %% Via header we insert, not the 92 bytes + hostname _estimate_.
      Line1 = Request#request.method ++ " " ++ sipurl:print(Request#request.uri) ++ " SIP/2.0",
      ViaLen = 92 + length(siprequest:myhostname()),
      ApproxMsgSize = length(Line1 ++ "\r\n" ++ sipheader:build_header(NewHeader2) ++ "\r\n" ++ Request#request.body) + ViaLen,
      {ok, NewHeader2, ApproxMsgSize}.
  
  
  send_proxy_request(SrvTHandler, Request, Dst, ViaParameters) when record(Dst, sipdst) ->
      send_proxy_request(SrvTHandler, Request, [Dst], ViaParameters);
  
  send_proxy_request(SrvTHandler, Request, [Dst | DstT], ViaParameters) when record(Request, request), record(Dst, sipdst) ->
      {Method, OrigURI, Header, Body} = {Request#request.method, Request#request.uri,
  				       Request#request.header, Request#request.body},
      {ok, NewHeader1, ApproxMsgSize} = check_proxy_request(Request),
      DstList = [Dst | DstT],
      logger:log(debug, "Siprequest: Destination list for request is :~n~p",
  	       [DstList]),
      NewRequest = Request#request{header=NewHeader1},
      send_to_available_dst(DstList, NewRequest, ViaParameters, SrvTHandler);
  
  send_proxy_request(SrvTHandler, Request, URI, ViaParameters) when record(URI, sipurl) ->
      {ok, _, ApproxMsgSize} = check_proxy_request(Request),
      case process_route_header(Request#request.header, URI) of
  	nomatch ->
  	    case siprequest:url_to_dstlist(URI, ApproxMsgSize, URI) of
  		DstList when list(DstList) ->
  		    send_proxy_request(SrvTHandler, Request, DstList, ViaParameters);
  		Unknown ->
  		    logger:log(error, "Siprequest: Failed resolving URI ~s : ~p", [sipurl:print(URI), Unknown]),
  		    {error, "Failed resolving destination"}
  	    end;
  	{ok, NewHeader, DstURI, ReqURI} when record(DstURI, sipurl), record(ReqURI, sipurl) ->
  	    logger:log(debug, "sippipe: Routing request as per the Route header, Destination ~p, Request-URI ~p",
  		       [sipurl:print(DstURI), sipurl:print(ReqURI)]),
  	    case siprequest:url_to_dstlist(DstURI, 500, ReqURI) of
  		DstList when list(DstList) ->
  		    send_proxy_request(SrvTHandler, Request, DstList, ViaParameters);
  		Unknown ->
  		    logger:log(error, "Siprequest: Failed resolving URI (from Route header) ~s : ~p", [sipurl:print(URI), Unknown]),
  		    {error, "Failed resolving destination"}
  	    end
      end.
  
  send_to_available_dst([], Request, ViaParam, SrvTHandler) when record(Request, request) ->
      Line1 = Request#request.method ++ " " ++ sipurl:print(Request#request.uri) ++ " SIP/2.0",
      lists:flatten(Message = Line1 ++ "\r\n" ++ sipheader:build_header(Request#request.header) ++ "\r\n" ++ Request#request.body),
      logger:log(debug, "Failed sending request (my Via not added, original URI shown) :~n~s", [Message]),
      {senderror, "failed"};
  send_to_available_dst([Dst | DstT], Request, ViaParam, SrvTHandler) when record(Dst, sipdst), record(Request, request) ->
      IP = Dst#sipdst.addr,
      Port = Dst#sipdst.port,
      Proto = Dst#sipdst.proto,
      SocketModule = sipsocket:proto2module(Proto),
      DestStr = dst2str(Dst),
      case sipsocket:get_socket(SocketModule, Proto, IP, Port) of
  	{error, What} ->
  	    logger:log(debug, "Failed to get ~p socket (~s:~p) for ~s : ~p", [Proto, IP, Port, DestStr, What]),
  	    %% try next
  	    send_to_available_dst(DstT, Request, ViaParam, SrvTHandler);
  	SipSocket when record(SipSocket, sipsocket) ->
  	    {Method, OrigURI, Header, Body} = {Request#request.method, Request#request.uri,
  					   Request#request.header, Request#request.body},
  	    NewHeader1 = proxy_add_via(Header, Method, OrigURI, ViaParam, Proto, SrvTHandler),
  	    Line1 = Method ++ " " ++ sipurl:print(Dst#sipdst.uri) ++ " SIP/2.0",
  	    Message = lists:flatten(Line1 ++ "\r\n" ++ sipheader:build_header(NewHeader1) ++ "\r\n" ++ Body),
  	    case sipsocket:send(SipSocket, Proto, IP, Port, Message) of
  		ok ->
  		    logger:log(debug, "sent request(dst=~s) :~n~s~n",
  			       [DestStr, Message]),
  		    TopVia = sipheader:topvia(NewHeader1),
  		    UsedBranch = lists:flatten(sipheader:get_via_branch_full(TopVia)),
  		    {ok, SipSocket, UsedBranch};
  		{error, E} ->
  		    logger:log(debug, "Failed sending message to ~p:~s:~p, error ~p",
  			       [Proto, IP, Port, E]),
  		    send_to_available_dst(DstT, Request, ViaParam, SrvTHandler)
  	    end
      end;
  send_to_available_dst([Dst | DstT], Request, ViaParam, SrvTHandler) ->
      logger:log(error, "Siprequest: send_to_available_dst called with illegal dst ~p", [Dst]),
      send_to_available_dst(DstT, Request, ViaParam, SrvTHandler).
  
  dst2str(Dst) when record(Dst, sipdst) ->
      lists:flatten(io_lib:format("~p:~s:~p (~s)", [Dst#sipdst.proto, Dst#sipdst.addr, Dst#sipdst.port,
  						  sipurl:print(Dst#sipdst.uri)])).
  
  proxy_check_maxforwards(Header) ->
      MaxForwards =
  