anchor.diff:  %%--------------------------------------------------------------------
   
   %%--------------------------------------------------------------------
  -%% Function: received_new_request(Request, Socket, LogStr, State)
  +%% Function: received_new_request(Request, Socket, LogStr, Mode,
  +%%                                AppModule)
   %%           Request = request record()
   %%           Socket  = sipsocket record(), the socket this request was
   %%                                         received on
   %%           LogStr  = string(), describes the request
  -%%           State   = record()
  +%%           Mode    = stateless | stateful
  +%%           AppModule = atom(), Yxa application module
   %% Descrip.: Act on a new request that has just been delivered to the
   %%           transaction layer from the transport layer, where the
   %%           transaction layer did not have any prior transaction.
  +%%           This code executes in the request handler process - NOT
  +%%           in the transaction_layer. This is to achieve better
  +%%           concurrency by not doing alot of work in the
  +%%           transaction_layer process.
   %% Returns : {reply, Reply, State, ?TIMEOUT}
   %%           Reply   = {pass_to_core, AppModule} |
   %%                     {continue}
  
positive.code: %%           Pid = pid()
  %%           E   = string()
  %%--------------------------------------------------------------------
  start_client_transaction(Request, SocketIn, Dst, Branch, Timeout, Parent) ->
      %% XXX we probably want a shorter timeout on this, but since we send out the initial request
      %% in clienttransaction:init() it can take some time (if a TCP connection has to be established
      %% first etc).
      case catch gen_server:call(transaction_layer, {start_client_transaction, Request, SocketIn,
  						   Dst, Branch, Timeout, Parent}, 10000) of
  	{error, E} ->
  	    {error, E};
  	{ok, Pid} ->
  	    Pid;
  	Unknown ->
  	    logger:log(debug, "Transaction layer: Failed starting client transaction, gen_server call result :~n~p",
  		       [Unknown]),
  	    {error, "Transaction layer failure"}
      end.
  
  %%--------------------------------------------------------------------
  
negative.code: debug_show_transactions() ->
      gen_server:cast(transaction_layer, {debug_show_transactions, self()}),
      ok.
  
  %%--------------------------------------------------------------------
  %% Function: from_transportlayer(Request, Origin, LogStr)
  %% Descrip.: The transport layer passes us a request it has just
  %%           received.
  %% Returns : {pass_to_core, AppModule} |
  %%           {continue}
  %%           AppModule = atom(), Yxa application module name
  %%--------------------------------------------------------------------
  from_transportlayer(Request, Origin, LogStr) when is_record(Request, request),
  						  is_record(Origin, siporigin),
  						  is_list(LogStr) ->
      case get_server_transaction_pid(Request) of
  	none ->
  	    {ok, [{mode, Mode}, {appmodule, AppModule}]} = gen_server:call(transaction_layer, {get_settings}),
  	    received_new_request(Request, Origin#siporigin.sipsocket, LogStr, Mode, AppModule);
  	TPid when is_pid(TPid) ->
  	    case gen_server:call(TPid, {siprequest, Request, Origin}) of
  		{pass_to_core, AppModule1} ->
  		    {pass_to_core, AppModule1};
  		{continue} ->
  		    {continue}
  	    end
      end;
  
  %%--------------------------------------------------------------------
  %% Function: from_transportlayer(Response, Origin, LogStr)
  %% Descrip.: The transport layer passes us a response it has just
  %%           received.
  %% Returns : {pass_to_core, AppModule} |
  %%           {continue}
  %%           AppModule = atom(), Yxa application module name
  %%--------------------------------------------------------------------
  from_transportlayer(Response, Origin, LogStr) when is_record(Response, response),
  						   is_record(Origin, siporigin),
  						   is_list(LogStr) ->
      case get_client_transaction_pid(Response) of
  	none ->
  	    {ok, [{mode, _}, {appmodule, AppModule}]} = gen_server:call(transaction_layer, {get_settings}),
  	    logger:log(debug, "Transaction layer: No state for received response '~p ~s', passing to ~p:response().",
  		       [Response#response.status, Response#response.reason, AppModule]),
  	    {pass_to_core, AppModule};
  	TPid when is_pid(TPid) ->
  	    logger:log(debug, "Transaction layer: Passing response '~p ~s' to registered handler ~p",
  		       [Response#response.status, Response#response.reason, TPid]),
  	    gen_server:cast(TPid, {sipmessage, Response, Origin, LogStr}),
  	    {continue}
      end.
  