anchor.diff:  init() ->
       [[user, numbers, phone], stateful, none].
   
  +
   %% Function: request/3
   %% Description: Yxa applications must export an request/3 function.
   %% Returns: See XXX
   %%--------------------------------------------------------------------
  +
  +%%
  +%% REGISTER
  +%%
   request(Request, Origin, LogStr) when record(Request, request), record(Origin, siporigin), Request#request.method == "REGISTER" ->
       logger:log(normal, "Appserver: ~s Method not applicable here -> 403 Forbidden", [LogStr]),
       CompatRequest = {Request#request.method, Request#request.uri, Request#request.header, Request#request.body},
       transactionlayer:send_response_request(CompatRequest, 403, "Forbidden");
   
  +%%
  +%% ACK
  +%%
   request(Request, Origin, LogStr) when record(Request, request), record(Origin, siporigin), Request#request.method == "ACK" ->
       case local:get_user_with_contact(Request#request.uri) of
   	none ->
   	    logger:log(debug, "Appserver: ~s -> no transaction state, unknown user, ignoring",
  -	    		[LogStr]),
  +		       [LogStr]),
   	    ok;
   	SIPuser ->
   	    logger:log(normal, "Appserver: ~s -> Forwarding statelessly (SIP user ~p)",
  -	    		[LogStr, SIPuser]),
  +		       [LogStr, SIPuser]),
   	    CompatRequest = {Request#request.method, Request#request.uri, Request#request.header, Request#request.body},
   	    transportlayer:send_proxy_request(none, CompatRequest, Request#request.uri, [])
       end;
   
  +%%
  +%% CANCEL
  +%%
   request(Request, Origin, LogStr) when record(Request, request), record(Origin, siporigin), Request#request.method == "CANCEL" ->
       CompatRequest = {Request#request.method, Request#request.uri, Request#request.header, Request#request.body},
       case local:get_user_with_contact(Request#request.uri) of
   	none ->
   	    logger:log(debug, "Appserver: ~s -> CANCEL not matching any existing transaction received, " ++
  -	    	"answer 481 Call/Transaction Does Not Exist", [LogStr]),
  +		       "answer 481 Call/Transaction Does Not Exist", [LogStr]),
   	    transactionlayer:send_response_request(CompatRequest, 481, "Call/Transaction Does Not Exist");
   	SIPuser ->
   	    logger:log(normal, "Appserver: ~s -> Forwarding statelessly (SIP user ~p)",
  -	    		[LogStr, SIPuser]),
  +		       [LogStr, SIPuser]),
   	    transportlayer:send_proxy_request(none, CompatRequest, Request#request.uri, [])
       end;
  -	    
  -
  +
  +%%
  +%% Anything but REGISTER, ACK and CANCEL
   request(Request, Origin, LogStr) when record(Request, request), record(Origin, siporigin) ->
       Header = case sipserver:get_env(record_route, false) of
  -	true -> siprequest:add_record_route(Request#request.header, Origin);
  -	false -> Request#request.header
  -    end,
  +		 true -> siprequest:add_record_route(Request#request.header, Origin);
  +		 false -> Request#request.header
  +	     end,
       NewRequest = Request#request{header=Header},
       create_session(Request, Origin, LogStr).
   
  +
  +%% Function: response/3
  +%% Description: Yxa applications must export an response/3 function.
  +%% Returns: See XXX
  +%%--------------------------------------------------------------------
  +response(Response, Origin, LogStr) when record(Response, response), record(Origin, siporigin) ->
  +    %% RFC 3261 16.7 says we MUST act like a stateless proxy when no
  +    %% transaction can be found
  +    CompatResponse = {Response#response.status, Response#response.reason, Response#response.header, Response#response.body},
  +    Status = Response#response.status,
  +    Reason = Response#response.reason,
  +    case transactionlayer:get_server_handler_for_stateless_response(CompatResponse) of
  +	{error, E} ->
  +	    logger:log(error, "Failed getting server transaction for stateless response: ~p", [E]),
  +	    logger:log(normal, "Response to ~s: ~p ~s, failed fetching state - proxying", [LogStr, Status, Reason]),
  +	    transportlayer:send_proxy_response(none, CompatResponse);
  +	none ->
  +	    logger:log(normal, "Response to ~s: ~p ~s, found no state - proxying", [LogStr, Status, Reason]),
  +	    transportlayer:send_proxy_response(none, CompatResponse);
  +	TH ->
  +	    logger:log(debug, "Response to ~s: ~p ~s, server transaction ~p", [LogStr, Status, Reason, TH]),
  +	    transactionlayer:send_proxy_response_handler(TH, CompatResponse)
  +    end.
  +
  +
  +%%--------------------------------------------------------------------
  +%%% Internal functions
  +%%--------------------------------------------------------------------
  +
  +
   create_session(Request, Origin, LogStr) when record(Request, request), record(Origin, siporigin) ->
  -    % create header suitable for answering the incoming request
  +    %% create header suitable for answering the incoming request
       CompatRequest = {Request#request.method, Request#request.uri, Request#request.header, Request#request.body},
       URI = Request#request.uri,
       case keylist:fetch("Route", Request#request.header) of
  
positive.code: 	    end;
  	Unknown ->
  	    logger:log(error, "Appserver: Unexpected result from lookup_address_to_users(~p) : ~p",
  	    		[sipurl:print(LookupURL), Unknown]),
  	    throw({siperror, 500, "Server Internal Error"})
      end.
  
  
negative.code: 	    forward_call_actions(Forwards, Actions);
  	Unknown ->
  	    logger:log(error, "Appserver: Unexpected result from get_forwards_for_user(~p) in fetch_actions_for_users",
  		       [Users]),
  	    throw({siperror, 500, "Server Internal Error"})
      end.
  
  