anchor.diff:  %%                                        Gateway)
   %%           Method  = string()
   %%           Headers = keylist record()
  -%%           URI     = sipurl record()
  +%%           URI     = sipurl record(), Request URI of outgoing req.
  +%%           User    = string(), SIP authentication username
   %%           Gateway = string()
   %% Descrip.: If configured to, add Remote-Party-Id information
   %%           about caller to this request before it is sent to a
   %%           PSTN gateway. Useful to get proper caller-id.
   %% Returns : NewHeader, keylist record()
   %%--------------------------------------------------------------------
  -add_caller_identity_for_pstn("INVITE", Headers, URI, Gateway) when is_record(URI, sipurl) ->
  +add_caller_identity_for_pstn("INVITE", Header, URI, User, Gateway) when is_record(Header, keylist),
  +									is_record(URI, sipurl),
  +									is_list(User) ->
       case sipserver:get_env(remote_party_id, false) of
   	true ->
  -	    case local:get_remote_party_number(URI, Gateway) of
  -		{ok, Number} when is_list(Number) ->
  -		    Parameters = [{"party", "calling"}, {"screen", "yes"}, {"privacy", "off"}],
  -		    RPURI = sipurl:set([{user, Number}, {pass, none}, {param, []}], URI),
  -		    RPI = contact:new(none, RPURI, Parameters),
  +	    case local:get_remote_party_number(User, Header, URI, Gateway) of
  +		{ok, RPI, Number} when is_record(RPI, contact), is_list(Number) ->
   		    RemotePartyId = contact:print(RPI),
   		    logger:log(debug, "Remote-Party-Id: ~s", [RemotePartyId]),
  -		    NewHeaders1 = keylist:set("Remote-Party-Id", [RemotePartyId], Headers),
  +		    NewHeader1 = keylist:set("Remote-Party-Id", [RemotePartyId], Header),
   		    logger:log(debug, "P-Preferred-Identity: ~s", ["tel:" ++ Number]),
  -		    keylist:set("P-Preferred-Identity", ["tel:" ++ Number], NewHeaders1);
  +		    keylist:set("P-Preferred-Identity", ["tel:" ++ Number], NewHeader1);
   		none ->
  -		    Headers
  +		    %% Add RPI information saying to not show any caller id, in case the From:
  +		    %% contains something the gateway interprets as a phone number when it shouldn't
  +		    logger:log(debug, "Remote-Party-Id: Blocking Caller-Id for third party user "
  +			       "or user without number to avoid incorrect/spoofed A-number in PSTN"),
  +		    Parameters = [{"party", "calling"}, {"screen", "yes"}, {"privacy", "on"}],
  +		    RPURI = sipurl:new([{host, siprequest:myhostname()}, {param, []}]),
  +		    RPI = contact:print( contact:new("Anonymous", RPURI, Parameters) ),
  +		    keylist:set("Remote-Party-Id", [RPI], Header)
   	    end;
  -	_ ->
  -	    Headers
  +	false ->
  +	    Header
       end;
  -add_caller_identity_for_pstn(_Method, Headers, _URI, _Gateway) when is_record(Headers, keylist) ->
  +add_caller_identity_for_pstn(_Method, Header, _URI, _User, _Gateway) when is_record(Header, keylist) ->
       %% non-INVITE request, don't add Remote-Party-Id
  -    Headers.
  +    Header.
   
   
   %%--------------------------------------------------------------------
  
positive.code: 	    logger:log(debug, "Auth: User ~p is allowed to call dst ~s (class ~s)", [User, DstNumber, Class]),
  	    logger:log(normal, "~s: pstnproxy: Relay ~s to PSTN ~s (authenticated, user ~p, class ~p) (~s)",
  		       [LogTag, Method, DstNumber, User, Class, sipurl:print(DstURI)]),
  	    sippipe:start(THandler, none, Request, DstURI, 900);
  	{stale, User, Class} ->
  	    logger:log(debug, "Auth: User ~p must authenticate (stale) for dst ~s (class ~s)", [User, DstNumber, Class]),
  	    logger:log(normal, "~s: pstnproxy: Relay ~s to PSTN ~s (~s) -> STALE authentication, sending challenge",
  
negative.code: %% Returns : Does not matter
  %%--------------------------------------------------------------------
  request_to_pstn(Request, Origin, THandler, LogTag) when is_record(Request, request), is_record(Origin, siporigin) ->
      {URI, Header} = {Request#request.uri, Request#request.header},
      {DstNumber, ToHost} = {URI#sipurl.user, URI#sipurl.host},
      %% XXX check port to, not just hostname? Maybe not since pstnproxy by definition
      %% should be running alone on a host.
  