From 9fd737e1a4614f0f9eb1dc3102a355ba4dc9c8d5 Mon Sep 17 00:00:00 2001 From: Pau Espin Pedrol Date: Mon, 5 Feb 2024 20:13:45 +0100 Subject: [PATCH] epdg: Do CEAI CancelLocationReq upon rx of S2B Delete Bearer Req Change-Id: Iee20619902db74da4b8cec5ba767f7c5c9bb3907 --- src/epdg_ue_fsm.erl | 1 + src/gsup_server.erl | 27 ++++++++++++++++++++++++++- 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/src/epdg_ue_fsm.erl b/src/epdg_ue_fsm.erl index 350a991..3d325a0 100644 --- a/src/epdg_ue_fsm.erl +++ b/src/epdg_ue_fsm.erl @@ -244,6 +244,7 @@ state_authenticated({call, From}, purge_ms_request, Data) -> state_authenticated({call, From}, received_gtpc_delete_bearer_request, Data) -> lager:info("ue_fsm state_authenticated event=received_gtpc_delete_bearer_request, ~p~n", [Data]), + gsup_server:cancel_location_request(Data#ue_fsm_data.imsi), Data1 = Data#ue_fsm_data{tear_down_gsup_needed = false}, {next_state, state_wait_swm_session_termination_answer, Data1, [{reply,From,ok}]}; diff --git a/src/gsup_server.erl b/src/gsup_server.erl index 4d50fba..8659c95 100644 --- a/src/gsup_server.erl +++ b/src/gsup_server.erl @@ -62,7 +62,7 @@ -export([init/1, handle_call/3, handle_cast/2, handle_info/2]). -export([code_change/3, terminate/2]). --export([auth_response/2, lu_response/2, tunnel_response/2, purge_ms_response/2]). +-export([auth_response/2, lu_response/2, tunnel_response/2, purge_ms_response/2, cancel_location_request/1]). % TODO: -spec dia_sip2gsup('SIP-Auth-Data-Item'()) -> #'GSUPAuthTuple'{}. dia_sip2gsup(#'SIP-Auth-Data-Item'{'SIP-Authenticate' = [Authenticate], 'SIP-Authorization' = [Authorization], @@ -201,6 +201,16 @@ handle_cast({purge_ms_response, {Imsi, Result}}, State0) -> State1 = delete_gsups_ue(Imsi, State0), {noreply, State1}; +% Our GSUP CEAI implementation for "IKEv2 Information Delete Request" +handle_cast({cancel_location_request, Imsi}, State) -> + lager:info("cancel_location_request for ~p~n", [Imsi]), + Socket = State#gsups_state.socket, + Resp = #{message_type => location_cancellation_req, + imsi => Imsi + }, + tx_gsup(Socket, Resp), + {noreply, State}; + handle_cast(Info, S) -> error_logger:error_report(["unknown handle_cast", {module, ?MODULE}, {info, Info}, {state, S}]), {noreply, S}. @@ -313,6 +323,16 @@ handle_info({ipa, Socket, ?IPAC_PROTO_EXT_GSUP, GsupMsgRx = #{message_type := pu end, {noreply, State}; +% Our GSUP CEAI implementation for "IKEv2 Information Delete Response". +handle_info({ipa, Socket, ?IPAC_PROTO_EXT_GSUP, GsupMsgRx = #{message_type := location_cancellation_res, imsi := Imsi}}, State0) -> + lager:info("GSUP: Rx ~p~n", [GsupMsgRx]), + UE = find_gsups_ue_by_imsi(Imsi, State0), + case UE of + #gsups_ue{imsi = Imsi} -> State1 = delete_gsups_ue(Imsi, State0); + undefined -> State1 = State0 + end, + {noreply, State1}; + handle_info(Info, S) -> error_logger:error_report(["unknown handle_info", {module, ?MODULE}, {info, Info}, {state, S}]), {noreply, S}. @@ -339,6 +359,11 @@ purge_ms_response(Imsi, Result) -> lager:info("purge_ms_response(~p): ~p~n", [Imsi, Result]), gen_server:cast(?SERVER, {purge_ms_response, {Imsi, Result}}). +% Our GSUP CEAI implementation for "IKEv2 Information Delete Request" +cancel_location_request(Imsi) -> + lager:info("cancel_location_request(~p): ~p~n", [Imsi]), + gen_server:cast(?SERVER, {cancel_location_request, Imsi}). + %% ------------------------------------------------------------------ %% Internal Function Definitions %% ------------------------------------------------------------------