anchor.diff:  %% @see //stdlib/gen_fsm:init/1
   %% @private
   %%
  -init( [Address, Port] = _Args) ->
  +init([Address, Port] = _Args) ->
  +	SvcName = ?AUTHENTICATION,
  +	diameter:subscribe(SvcName),
  +	StateData  = #statedata{address = Address, port = Port},
  +	process_flag(trap_exit, true),
  +	{ok, wait_for_start, StateData, 0}.
  +
  +-spec wait_for_start(Event, StateData) -> Result
  +	when
  +		Event :: timeout | term(), 
  +		StateData :: #statedata{},
  +		Result :: {next_state, NextStateName, NewStateData}
  +			| {next_state, NextStateName, NewStateData, Timeout}
  +			| {next_state, NextStateName, NewStateData, hibernate}
  +			| {stop, Reason, NewStateData},
  +		NextStateName :: atom(),
  +		NewStateData :: #statedata{},
  +		Timeout :: non_neg_integer() | infinity,
  +		Reason :: normal | term().
  +%% @doc Handle events sent with {@link //stdlib/gen_fsm:send_event/2.
  +%%		gen_fsm:send_event/2} in the <b>wait_for_start</b> state.
  +%% @@see //stdlib/gen_fsm:StateName/2
  +%% @private
  +%%
  +wait_for_start(timeout, StateData) ->
  +	{next_state, wait_for_start, StateData}.
  +
  +-spec started(Event, StateData) -> Result
  +	when
  +		Event :: timeout | term(), 
  +		StateData :: #statedata{},
  +		Result :: {next_state, NextStateName, NewStateData}
  +			| {next_state, NextStateName, NewStateData, Timeout}
  +			| {next_state, NextStateName, NewStateData, hibernate}
  +			| {stop, Reason, NewStateData},
  +		NextStateName :: atom(),
  +		NewStateData :: #statedata{},
  +		Timeout :: non_neg_integer() | infinity,
  +		Reason :: normal | term().
  +%% @doc Handle events sent with {@link //stdlib/gen_fsm:send_event/2.
  +%%		gen_fsm:send_event/2} in the <b>started</b> state.
  +%% @@see //stdlib/gen_fsm:StateName/2
  +%% @private
  +%%
  +started(timeout, #statedata{address = Address, port = Port} = StateData) ->
   	SvcName = ?AUTHENTICATION,
   	SOptions = service_options(SvcName),
   	TOptions = transport_options(diameter_tcp, Address, Port),
   	diameter:start_service(SvcName, SOptions),
   	diameter:add_transport(SvcName, TOptions),
  -	{ok, start, #statedata{}}.
  -
  --spec start(Event, StateData) -> Result
  +	{next_state, started, StateData}.
  +
  +-spec wait_for_stop(Event, StateData) -> Result
   	when
   		Event :: timeout | term(), 
   		StateData :: #statedata{},
  
positive.code: %% @see //stdlib/gen_fsm:handle_info/3
  %% @private
  %%
  handle_info(_Event, _StateName, StateData) ->
  	{stop, not_implemented, StateData}.
  
  -spec terminate(Reason, StateName, StateData) -> any()
  	when
  
negative.code: 							{port, Port}]}],
  	{listen, Opts}.
  
  -spec change_state(EventInfo, StateData) -> Result
  	when
  		EventInfo :: term(),
  		StateData :: #statedata{},
  		Result :: {next_state, NextStateName, NewStateData}
  			| {next_state, NextStateName, NewStateData, Timeout}
  			| {next_state, NextStateName, NewStateData, hibernate}
  			| {stop, Reason, NewStateData},
  		NextStateName :: atom(),
  		NewStateData :: #statedata{},
  		Timeout :: non_neg_integer() | infinity,
  		Reason :: normal | term().
  %% @doc Chnage the state of the fsm based on the event sent
  %% by the diameter service.
  %% @hidden
  change_state(start, StateData) ->
  	{next_state, started, StateData, 0};
  change_state({up, _, _, _, _}, StateData) ->
  	{next_state, started, StateData, 0};
  change_state({up, _, _, __}, StateData) ->
  	{next_state, started, StateData, 0};
  change_state({down, _, _,  _}, StateData) ->
  	{next_state, wait_for_stop, StateData, 0};
  change_state({reconnect, _, _}, StateData) ->
  	{next_state, started, StateData, 0};
  change_state(closed, StateData) ->
  	{next_state, started, StateData, 0};
  change_state({watchdog, _, _, {_, down}, _}, StateData) ->
  	{next_state, wait_for_stop, StateData, 0};
  change_state({watchdog, _, _, _, _}, StateData) ->
  	{next_state, started, StateData, 0};
  change_state(stop, StateData) ->
  	{next_state, wait_for_stop, StateData, 0}.
  
  