pespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/erlang/osmo-epdg/+/35698?usp=email )
Change subject: WIP: Make Auth Compl procedure more similar to specs ...................................................................... WIP: Make Auth Compl procedure more similar to specs Change-Id: I480c110deeb04abf1ff19147a70e10be9cbafae8 --- M src/aaa_diameter_swm.erl M src/epdg_diameter_swm.erl M src/epdg_ue_fsm.erl M src/gsup_server.erl 4 files changed, 88 insertions(+), 13 deletions(-) git pull ssh://gerrit.osmocom.org:29418/erlang/osmo-epdg refs/changes/98/35698/1 diff --git a/src/aaa_diameter_swm.erl b/src/aaa_diameter_swm.erl index c8ae250..ad4178d 100644 --- a/src/aaa_diameter_swm.erl +++ b/src/aaa_diameter_swm.erl @@ -14,12 +14,10 @@ -export([init/1, handle_call/3, handle_cast/2, handle_info/2]). -export([code_change/3, terminate/2]). --export[(auth_request/1)]. +-export([auth_request/1, auth_compl_request/1]). -define(SERVER, ?MODULE). -% The ets table contains only IMSIs - start_link() -> gen_server:start_link({local, ?MODULE}, ?MODULE, [], []). @@ -31,6 +29,9 @@ auth_request(Imsi) -> gen_server:cast(?SERVER, {epdg_auth_req, Imsi}). +auth_compl_request(Imsi) -> + gen_server:cast(?SERVER, {epdg_auth_compl_req, Imsi}). + handle_cast({epdg_auth_req, Imsi}, State) -> % request the diameter code for a tuple CKey = [], @@ -38,11 +39,21 @@ Result = aaa_diameter_swx:multimedia_auth_request(Imsi, 1, "EAP-AKA", 1, CKey, IntegrityKey), case Result of {ok, _MAA} -> epdg_diameter_swm:auth_response(Imsi, Result); - {error, Err} -> epdg_diameter_swm:auth_response(Imsi, Result); + {error, _Err} -> epdg_diameter_swm:auth_response(Imsi, Result); _ -> epdg_diameter_swm:auth_response(Imsi, {error, unknown}) end, {noreply, State}; +handle_cast({epdg_auth_compl_req, Imsi}, State) -> + % request the diameter code for a tuple + Result = aaa_diameter_swx:server_assignment_request(Imsi, 1, "internet"), + case Result of + {ok, _SAA} -> epdg_diameter_swm:auth_compl_response(Imsi, Result); + {error, _Err} -> epdg_diameter_swm:auth_compl_response(Imsi, Result); + _ -> epdg_diameter_swm:auth_compl_response(Imsi, {error, unknown}) + end, + {noreply, State}; + handle_cast(Info, S) -> error_logger:error_report(["unknown handle_cast", {module, ?MODULE}, {info, Info}, {state, S}]), {noreply, S}. diff --git a/src/epdg_diameter_swm.erl b/src/epdg_diameter_swm.erl index dbb764f..59d9412 100644 --- a/src/epdg_diameter_swm.erl +++ b/src/epdg_diameter_swm.erl @@ -19,8 +19,8 @@ -export([init/1, handle_call/3, handle_cast/2, handle_info/2]). -export([code_change/3, terminate/2]). --export[(auth_request/1)]. --export[(auth_response/2)]. +-export([auth_request/1, auth_compl_request/1]). +-export([auth_response/2, auth_compl_response/2]). -define(SERVER, ?MODULE). @@ -42,12 +42,33 @@ _ -> Result end. +% Rx "GSUP CEAI LU Req" is our way of saying Rx "Swm Diameter-EAP REQ (DER) with EAP AVP containing successuful auth": +auth_compl_request(Imsi) -> + Result = gen_server:call(?SERVER, {epdg_auth_compl_req, Imsi}), + case Result of + {ok, _Mar} -> + epdg_ue_fsm:received_swm_auth_response(self(), Result), + ok; + _ -> Result + end. + handle_call({epdg_auth_req, Imsi}, {Pid, _Tag} = _From, State0) -> % we yet don't implement the Diameter SWm interface on the wire, we process the call internally: {_Sess, State1} = find_or_new_swm_session(Imsi, Pid, State0), ok = aaa_diameter_swm:auth_request(Imsi), - {reply, ok, State1}. + {reply, ok, State1}; + +handle_call({epdg_auth_compl_req, Imsi}, _From, State) -> + % we yet don't implement the Diameter SWm interface on the wire, we process the call internally: + Sess = find_swm_session_by_imsi(Imsi, State), + case Sess of + #swm_session{imsi = Imsi} -> + Reply = aaa_diameter_swm:auth_compl_request(Imsi); + undefined -> + Reply = {error,unknown_imsi} + end, + {reply, Reply, State}. handle_cast({epdg_auth_resp, Imsi, Result}, State) -> Sess = find_swm_session_by_imsi(Imsi, State), @@ -59,6 +80,16 @@ end, {noreply, State}; +handle_cast({epdg_auth_compl_resp, Imsi, Result}, State) -> + Sess = find_swm_session_by_imsi(Imsi, State), + case Sess of + #swm_session{imsi = Imsi} -> + epdg_ue_fsm:received_swm_auth_compl_response(Sess#swm_session.pid, Result); + undefined -> + error_logger:error_report(["unknown swm_session", {module, ?MODULE}, {imsi, Imsi}, {state, State}]) + end, + {noreply, State}; + handle_cast(Info, S) -> error_logger:error_report(["unknown handle_cast", {module, ?MODULE}, {info, Info}, {state, S}]), {noreply, S}. @@ -80,6 +111,11 @@ auth_response(Imsi, Result) -> ok = gen_server:cast(?SERVER, {epdg_auth_resp, Imsi, Result}). +%Rx Swm Diameter-EAP Answer (DEA) containing APN-Configuration, triggered by +%earlier Tx DER EAP AVP containing successuful auth": +auth_compl_response(Imsi, Result) -> + ok = gen_server:cast(?SERVER, {epdg_auth_compl_resp, Imsi, Result}). + %% ------------------------------------------------------------------ %% Internal Function Definitions %% ------------------------------------------------------------------ diff --git a/src/epdg_ue_fsm.erl b/src/epdg_ue_fsm.erl index 9d20a73..6c6c3ca 100644 --- a/src/epdg_ue_fsm.erl +++ b/src/epdg_ue_fsm.erl @@ -40,7 +40,7 @@ -export([start_link/1]). -export([init/1,callback_mode/0,terminate/3]). -export([auth_request/1, lu_request/1, tunnel_request/1, purge_ms_request/1]). --export([received_swm_auth_response/2]). +-export([received_swm_auth_response/2, received_swm_auth_compl_response/2]). -export([received_gtpc_create_session_response/2, received_gtpc_delete_session_response/2]). -export([state_new/3, state_wait_auth_resp/3, state_authenticated/3, state_wait_delete_session_resp/3]). @@ -98,6 +98,15 @@ {error, Err} end. +received_swm_auth_compl_response(Pid, Result) -> + lager:info("ue_fsm received_swm_auth_compl_response ~p~n", [Result]), + try + gen_statem:call(Pid, {received_swm_auth_compl_response, Result}) + catch + exit:Err -> + {error, Err} + end. + received_gtpc_create_session_response(Pid, Msg) -> lager:info("ue_fsm received_gtpc_create_session_response ~p~n", [Msg]), try @@ -161,14 +170,24 @@ state_authenticated({call, From}, lu_request, Data) -> lager:info("ue_fsm state_authenticated event=lu_request, ~p~n", [Data]), - Result = aaa_diameter_swx:server_assignment_request(Data#ue_fsm_data.imsi, 1, "internet"), + % Rx "GSUP CEAI LU Req" is our way of saying Rx "Swm Diameter-EAP REQ (DER) with EAP AVP containing successuful auth": + ok = aaa_diameter_swx:server_assignment_request(Data#ue_fsm_data.imsi, 1, "internet"), + {keep_state, Data, [{reply,From,ok}]}; + +% Rx Swm Diameter-EAP Answer (DEA) containing APN-Configuration, triggered by +% earlier Tx DER EAP AVP containing successuful auth", when we received GSUP LU Req: +state_authenticated({call, From}, {received_swm_auth_compl_response, Result}, Data) -> + lager:info("ue_fsm state_authenticated event=lu_request, ~p, ~p~n", [Result, Data]), + % Rx "GSUP CEAI LU Req" is our way of saying Rx "Swm Diameter-EAP REQ (DER) with EAP AVP containing successuful auth": gsup_server:lu_response(Data#ue_fsm_data.imsi, Result), case Result of {ok, _} -> - {keep_state, Data, [{reply,From,ok}]}; + Ret = ok; {error, Err} -> - {stop, Err, Data, [{reply,From,{error,Err}}]} - end; + Ret = {error, Err} + end, + gsup_server:lu_response(Data#ue_fsm_data.imsi, Ret), + {keep_state, Data, [{reply,From,Ret}]}; state_authenticated({call, From}, tunnel_request, Data) -> lager:info("ue_fsm state_authenticated event=tunnel_request, ~p~n", [Data]), diff --git a/src/gsup_server.erl b/src/gsup_server.erl index ae677c9..4d50fba 100644 --- a/src/gsup_server.erl +++ b/src/gsup_server.erl @@ -138,7 +138,7 @@ lager:info("lu_response for ~p: ~p~n", [Imsi, Result]), Socket = State#gsups_state.socket, case Result of - {ok, _Sar} -> Resp = #{message_type => location_upd_res, + ok -> Resp = #{message_type => location_upd_res, imsi => Imsi, message_class => 5 }; -- To view, visit https://gerrit.osmocom.org/c/erlang/osmo-epdg/+/35698?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: erlang/osmo-epdg Gerrit-Branch: master Gerrit-Change-Id: I480c110deeb04abf1ff19147a70e10be9cbafae8 Gerrit-Change-Number: 35698 Gerrit-PatchSet: 1 Gerrit-Owner: pespin <pes...@sysmocom.de> Gerrit-MessageType: newchange