pespin has submitted this change. ( https://gerrit.osmocom.org/c/erlang/osmo-s1gw/+/37805?usp=email )
Change subject: s1ap_proxy: handle E-RAB RELEASE COMMAND/RESPONSE ......................................................................
s1ap_proxy: handle E-RAB RELEASE COMMAND/RESPONSE
Change-Id: I9c5f279886b548c539211e1e709ae0c6e1cd2788 --- M src/s1ap_proxy.erl M test/s1ap_proxy_test.erl 2 files changed, 106 insertions(+), 0 deletions(-)
Approvals: laforge: Looks good to me, but someone else must approve Jenkins Builder: Verified pespin: Looks good to me, approved
diff --git a/src/s1ap_proxy.erl b/src/s1ap_proxy.erl index 048b91d..f28ff56 100644 --- a/src/s1ap_proxy.erl +++ b/src/s1ap_proxy.erl @@ -47,6 +47,7 @@ -include("S1AP-PDU-Contents.hrl"). -include("S1AP-Containers.hrl"). -include("S1AP-Constants.hrl"). +-include("S1AP-IEs.hrl").
-type mme_ue_id() :: 0..16#ffffffff. @@ -149,6 +150,26 @@
%% TODO: 9.1.3.3 E-RAB MODIFY REQUEST / (Optional) Transport Information
+%% 9.1.3.5 E-RAB RELEASE COMMAND +handle_pdu(Data, {Outcome = initiatingMessage, + #'InitiatingMessage'{procedureCode = ?'id-E-RABRelease', + value = Content} = Pdu}, S0) -> + ?LOG_DEBUG("Processing E-RAB RELEASE COMMAND"), + {IEs, S1} = handle_ies(Content#'E-RABReleaseCommand'.protocolIEs, + ?'id-E-RABToBeReleasedList', S0), + NewContent = Content#'E-RABReleaseCommand'{protocolIEs = IEs}, + handle_pdu_new(Data, {Outcome, Pdu#'InitiatingMessage'{value = NewContent}}, S1); + +%% 9.1.3.6 E-RAB RELEASE RESPONSE +handle_pdu(Data, {Outcome = successfulOutcome, + #'SuccessfulOutcome'{procedureCode = ?'id-E-RABRelease', + value = Content} = Pdu}, S0) -> + ?LOG_DEBUG("Processing E-RAB RELEASE RESPONSE"), + {IEs, S1} = handle_ies(Content#'E-RABReleaseResponse'.protocolIEs, + ?'id-E-RABReleaseListBearerRelComp', S0), + NewContent = Content#'E-RABReleaseResponse'{protocolIEs = IEs}, + handle_pdu_new(Data, {Outcome, Pdu#'SuccessfulOutcome'{value = NewContent}}, S1); + %% 9.1.3.8 E-RAB MODIFICATION INDICATION handle_pdu(Data, {Outcome = initiatingMessage, #'InitiatingMessage'{procedureCode = ?'id-E-RABModificationIndication', @@ -238,6 +259,42 @@ end, {C1, S};
+%% 9.1.3.5 E-RAB RELEASE COMMAND related IEs +handle_ie(#'ProtocolIE-Field'{id = ?'id-E-RABToBeReleasedList', + value = Content}, S) -> + %% This IE contains a list of E-RABItem + handle_ies(Content, ?'id-E-RABItem', S); + +handle_ie(#'ProtocolIE-Field'{id = ?'id-E-RABItem', + value = Content}, S) -> + %% poke E-RAB FSM + #'E-RABItem'{'e-RAB-ID' = ERABId} = Content, + case dict:find(ERABId, S#proxy_state.erabs) of + {ok, Pid} -> + ok = erab_fsm:erab_release_req(Pid); + error -> + ?LOG_ERROR("E-RAB-ID ~p is not registered", [ERABId]) + end, + {Content, S}; + +%% 9.1.3.6 E-RAB RELEASE RESPONSE related IEs +handle_ie(#'ProtocolIE-Field'{id = ?'id-E-RABReleaseListBearerRelComp', + value = Content}, S) -> + %% This IE contains a list of E-RABReleaseItemBearerRelComp + handle_ies(Content, ?'id-E-RABReleaseItemBearerRelComp', S); + +handle_ie(#'ProtocolIE-Field'{id = ?'id-E-RABReleaseItemBearerRelComp', + value = Content}, S) -> + %% poke E-RAB FSM + #'E-RABReleaseItemBearerRelComp'{'e-RAB-ID' = ERABId} = Content, + case dict:find(ERABId, S#proxy_state.erabs) of + {ok, Pid} -> + ok = erab_fsm:erab_release_rsp(Pid); + error -> + ?LOG_ERROR("E-RAB-ID ~p is not registered", [ERABId]) + end, + {Content, S}; + %% E-RAB MODIFICATION INDICATION related IEs handle_ie(#'ProtocolIE-Field'{id = ?'id-E-RABToBeModifiedListBearerModInd', value = Content}, S) -> diff --git a/test/s1ap_proxy_test.erl b/test/s1ap_proxy_test.erl index 9426119..9534980 100644 --- a/test/s1ap_proxy_test.erl +++ b/test/s1ap_proxy_test.erl @@ -32,6 +32,8 @@ ?TC(fun test_s1_setup_req/1)}, {"E-RAB SETUP REQUEST/RESPONSE", ?TC(fun test_e_rab_setup/1)}, + {"E-RAB RELEASE COMMAND/RESPONSE", + ?TC(fun test_e_rab_release/1)}, {"E-RAB MODIFICATION INDICATION", ?TC(fun test_e_rab_modify_ind/1)}, {"INITIAL CONTEXT SETUP REQUEST/RESPONSE", @@ -63,6 +65,29 @@ ?_assertEqual(SetupRspExp, SetupRspOut)].
+test_e_rab_release(S0) -> + %% [eNB <- MME] E-RAB SETUP REQUEST + SetupReqIn = e_rab_setup_req_pdu(?ADDR_U2C, ?TEID_U2C), + {_, S1} = s1ap_proxy:handle_pdu(SetupReqIn, S0), + + %% [eNB -> MME] E-RAB SETUP RESPONSE + SetupRspIn = e_rab_setup_rsp_pdu(?ADDR_U2A, ?TEID_U2A), + {_, S2} = s1ap_proxy:handle_pdu(SetupRspIn, S1), + + %% [eNB <- MME] E-RAB RELEASE COMMAND + ReleaseCmd = e_rab_release_cmd_pdu(), + {ReleaseCmdOut, S3} = s1ap_proxy:handle_pdu(ReleaseCmd, S2), + + %% [eNB -> MME] E-RAB RELEASE RESPONSE + ReleaseRsp = e_rab_release_rsp_pdu(), + {ReleaseRspOut, _S4} = s1ap_proxy:handle_pdu(ReleaseRsp, S3), + + %% TODO: make sure that the E-RAB FSM has been terminated + + [?_assertEqual(ReleaseCmd, ReleaseCmdOut), + ?_assertEqual(ReleaseRsp, ReleaseRspOut)]. + + test_e_rab_modify_ind(S0) -> %% [eNB -> MME] E-RAB MODIFICATION INDICATION ModifyIndIn = e_rab_modify_ind_pdu(?ADDR_U2A, ?TEID_U2A), @@ -140,6 +165,30 @@ >>.
+%% [eNB <- MME] E-RAB RELEASE COMMAND +%% TODO: make E-RAB IDs configurable +e_rab_release_cmd_pdu() -> + << 16#00, 16#07, 16#00, 16#37, 16#00, 16#00, 16#05, 16#00, + 16#00, 16#00, 16#02, 16#00, 16#01, 16#00, 16#08, 16#00, + 16#02, 16#00, 16#00, 16#00, 16#42, 16#00, 16#0a, 16#18, + 16#3e, 16#80, 16#00, 16#00, 16#60, 16#3e, 16#80, 16#00, + 16#00, 16#00, 16#21, 16#40, 16#07, 16#00, 16#00, 16#23, + 16#40, 16#02, 16#0c, 16#40, 16#00, 16#1a, 16#40, 16#0b, + 16#0a, 16#27, 16#d3, 16#76, 16#43, 16#e7, 16#07, 16#72, + 16#47, 16#cd, 16#24 + >>. + + +%% [eNB -> MME] E-RAB RELEASE RESPONSE +%% TODO: make E-RAB IDs configurable +e_rab_release_rsp_pdu() -> + << 16#20, 16#07, 16#00, 16#19, 16#00, 16#00, 16#03, 16#00, + 16#00, 16#40, 16#02, 16#00, 16#02, 16#00, 16#08, 16#40, + 16#02, 16#00, 16#01, 16#00, 16#45, 16#40, 16#06, 16#00, + 16#00, 16#0f, 16#40, 16#01, 16#0c + >>. + + %% [eNB -> MME] E-RAB MODIFICATION INDICATION e_rab_modify_ind_pdu(TLA, TEID) when is_binary(TLA), is_integer(TEID) ->