anchor.diff:      LogStr = sipserver:make_logstr({response, Status, Reason, Header, Body}, FromIP),
       logger:log(normal, "Response to ~s: ~p ~s", [LogStr, Status, Reason]),
       siprequest:send_proxy_response(Socket, Status, Reason, Header, Body).
  +
  +add_caller_identity_for_pstn(Headers, URI, Gateway) ->
  +    NewHeaders1 = case sipserver:get_env(remote_party_id, false) of
  +	true ->
  +	    case local:get_remote_party_number(local:sipuser(URI), URI, Gateway) of
  +		none ->
  +		    Headers;
  +		RPI ->
  +		    RemotePartyId = RPI ++ ";party=calling",
  +		    logger:log(debug, "Remote-Party-Id: ~s", [RemotePartyId]),
  +		    NewHeaders2 = keylist:delete("Remote-Party-Id", Headers),
  +		    keylist:set("Remote-Party-Id", [RemotePartyId], NewHeaders2)
  +	    end;
  +	_ ->
  +	    Headers
  +    end.
  +
  +add_caller_identity_for_sip(Headers, URI, Gateway) ->
  +    {User, _, _, _, _} = URI,
  +    NewHeaders1 = case sipserver:get_env(remote_party_id, false) of
  +	true ->
  +	    case local:get_remote_party_name(User, URI, Gateway) of
  +		none ->
  +		    Headers;
  +		RPI ->
  +		    RemotePartyId = RPI ++ ";party=calling",
  +		    logger:log(debug, "Remote-Party-Id: ~s", [RemotePartyId]),
  +		    NewHeaders2 = keylist:delete("Remote-Party-Id", Headers),
  +		    keylist:set("Remote-Party-Id", [RemotePartyId], NewHeaders2)
  +	    end;
  +	_ ->
  +	    Headers
  +    end.
  
positive.code: 
  toSIPrequest(Method, URI, Header, Body, Socket) ->
      {User, Pass, Host, Port, Parameters} = URI,
      Newlocation = case localhostname(Host) of
  	true ->
  	    logger:log(debug, "Performing ENUM lookup on ~p", [User]),
  
negative.code: 		true -> siprequest:add_record_route(Header);
  	        false -> Header
  	    end,
  	    {_, _, DstHost, _, _} = Newlocation,
  	    Newheaders2 = add_caller_identity_for_sip(Newheaders, FromURI, DstHost),
  	    siprequest:send_proxy_request(Newheaders2, Socket, {Method, Newlocation, Body, []})
      end.
  
  toPSTNrequest(Method, URI, Header, Body, Socket) ->
      {Phone, _, _, _, _} = URI,
      PSTNgateway = lists:nth(1, sipserver:get_env(pstngatewaynames)),
      Newlocation = {Phone, none, PSTNgateway, none, []},
      {_, FromURI} = sipheader:to(keylist:fetch("From", Header)),
      Fromphone = local:sipuser(FromURI),
      Classdefs = sipserver:get_env(classdefs, [{"", unknown}]),
  