anchor.diff:  					NewEapID = StartEapID + 1,
   					NewEapPacket = #eap_packet{code = request, type = ?TTLS,
   							identifier = NewEapID, data = EapData},
  -					gen_fsm:send_event(AaahFsm, {ttls_socket, self(), SslSocket}),
   					send_response(NewEapPacket, ?AccessChallenge,
   							RadiusID, [], RequestAuthenticator, Secret, RadiusFsm),
  -					NextStateData = NewStateData#statedata{eap_id = NewEapID},
  +					NextStateData = StateData#statedata{eap_id = NewEapID},
   					{next_state, ttls, NextStateData, ?TIMEOUT};
   				#eap_packet{code = request, identifier = NewEapID} ->
   					NewEapPacket = #eap_packet{code = response, type = ?LegacyNak,
   							identifier = NewEapID, data = <<0>>},
   					send_response(NewEapPacket, ?AccessReject,
   							RadiusID, [], RequestAuthenticator, Secret, RadiusFsm),
  -					{stop, {shutdown, SessionID}, NewStateData};
  +					{stop, {shutdown, SessionID}, StateData};
   				#eap_packet{code = Code,
   							type = EapType, identifier = NewEapID, data = Data} ->
   					error_logger:warning_report(["Unknown EAP received",
  
positive.code: %%
  ttls(timeout, #statedata{session_id = SessionID} = StateData) ->
  	{stop, {shutdown, SessionID}, StateData};
  ttls({ssl_pid, SslPid}, StateData) ->
  	NewStateData = StateData#statedata{ssl_pid = SslPid},
  	{next_state, ttls, NewStateData, ?TIMEOUT};
  ttls({ssl_setopts, Options}, StateData) ->
  	NewStateData = StateData#statedata{socket_options = Options},
  	{next_state, ttls, NewStateData, ?TIMEOUT};
  
negative.code: 			server_id = list_to_binary(Hostname), start = AccessRequest,
  			tls_key = TLSkey, tls_crt = TLScert},
  	process_flag(trap_exit, true),
  	{ok, ssl_start, StateData, 0}.
  
  -spec ssl_start(Event :: timeout | term(), StateData :: #statedata{}) ->
  	Result :: {next_state, NextStateName :: atom(), NewStateData :: #statedata{}}
  		| {next_state, NextStateName :: atom(), NewStateData :: #statedata{},
  		Timeout :: non_neg_integer() | infinity}
  		| {next_state, NextStateName :: atom(), NewStateData :: #statedata{}, hibernate}
  		| {stop, Reason :: normal | term(), NewStateData :: #statedata{}}.
  %% @doc Handle events sent with {@link //stdlib/gen_fsm:send_event/2.
  %%		gen_fsm:send_event/2} in the <b>ssl_start</b> state.
  %% @@see //stdlib/gen_fsm:StateName/2
  %% @private
  %%
  ssl_start(timeout, #statedata{start = #radius{code = ?AccessRequest},
  		ssl_socket = undefined, sup = Sup,
  		tls_key = TLSkey, tls_crt = TLScert} = StateData) ->
  	Children = supervisor:which_children(Sup),
  	{_, AaahFsm, _, _} = lists:keyfind(ocs_eap_ttls_aaah_fsm, 1, Children),
  	Options = [{certfile, TLScert}, {keyfile, TLSkey}],
  	{ok, SslSocket} = ocs_eap_ttls_transport:ssl_listen(self(), Options),
  	gen_fsm:send_event(AaahFsm, {ttls_socket, self(), SslSocket}),
  	NewStateData = StateData#statedata{aaah_fsm = AaahFsm,
  			ssl_socket = SslSocket},
  	{next_state, ssl_start, NewStateData, ?TIMEOUT};
  ssl_start(timeout, #statedata{session_id = SessionID} = StateData) ->
  	{stop, {shutdown, SessionID}, StateData};
  ssl_start({ssl_pid, SslPid}, StateData) ->
  	NewStateData = StateData#statedata{ssl_pid = SslPid},
  	{next_state, eap_start, NewStateData, 0}.
  
  -spec eap_start(Event :: timeout | term(), StateData :: #statedata{}) ->
  	Result :: {next_state, NextStateName :: atom(), NewStateData :: #statedata{}}
  		| {next_state, NextStateName :: atom(), NewStateData :: #statedata{},
  		Timeout :: non_neg_integer() | infinity}
  		| {next_state, NextStateName :: atom(), NewStateData :: #statedata{}, hibernate}
  		| {stop, Reason :: normal | term(), NewStateData :: #statedata{}}.
  %% @doc Handle events sent with {@link //stdlib/gen_fsm:send_event/2.
  %%		gen_fsm:send_event/2} in the <b>eap_start</b> state.
  %% @@see //stdlib/gen_fsm:StateName/2
  %% @private
  %%
  eap_start(timeout, #statedata{start = #radius{code = ?AccessRequest,
  		id = RadiusID, authenticator = RequestAuthenticator, 
  		attributes = Attributes}, radius_fsm = RadiusFsm, eap_id = EapID,
  		session_id = SessionID, secret = Secret, aaah_fsm = AaahFsm,
  		ssl_socket = SslSocket} = StateData) ->
  	EapTtls = #eap_ttls{start = true},
  	EapData = ocs_eap_codec:eap_ttls(EapTtls),
  	case radius_attributes:find(?EAPMessage, Attributes) of
  		{ok, <<>>} ->
  			EapPacket = #eap_packet{code = request, type = ?TTLS,
  					identifier = EapID, data = EapData},
  			send_response(EapPacket, ?AccessChallenge,
  					RadiusID, [], RequestAuthenticator, Secret, RadiusFsm),
  			{next_state, ttls, StateData, ?TIMEOUT};
  		{ok, EAPMessage} ->
  			case catch ocs_eap_codec:eap_packet(EAPMessage) of
  				#eap_packet{code = response,
  