osmith has uploaded this change for review. ( https://gerrit.osmocom.org/c/erlang/osmo-s1gw/+/37103?usp=email )
Change subject: s1ap_proxy: implement patching of E-RAB MODIFICATION IND ...................................................................... s1ap_proxy: implement patching of E-RAB MODIFICATION IND Change-Id: I054b874b39d4e39a51c00385d1553da065131047 --- M src/s1ap_proxy.erl M test/s1ap_proxy_test.erl 2 files changed, 71 insertions(+), 2 deletions(-) git pull ssh://gerrit.osmocom.org:29418/erlang/osmo-s1gw refs/changes/03/37103/1 diff --git a/src/s1ap_proxy.erl b/src/s1ap_proxy.erl index f24f3c8..0c6cba0 100644 --- a/src/s1ap_proxy.erl +++ b/src/s1ap_proxy.erl @@ -91,7 +91,7 @@ end. -%% E-RAB SETUP REQUEST +%% 9.1.3.1 E-RAB SETUP REQUEST handle_pdu(Data, {Outcome = initiatingMessage, #'InitiatingMessage'{procedureCode = ?'id-E-RABSetup', value = Content} = Pdu}) -> @@ -101,7 +101,7 @@ NewContent = Content#'E-RABSetupRequest'{protocolIEs = IEs}, handle_pdu_new(Data, {Outcome, Pdu#'InitiatingMessage'{value = NewContent}}); -%% E-RAB SETUP RESPONSE +%% 9.1.3.2 E-RAB SETUP RESPONSE handle_pdu(Data, {Outcome = successfulOutcome, #'SuccessfulOutcome'{procedureCode = ?'id-E-RABSetup', value = Content} = Pdu}) -> @@ -111,6 +111,19 @@ NewContent = Content#'E-RABSetupResponse'{protocolIEs = IEs}, handle_pdu_new(Data, {Outcome, Pdu#'SuccessfulOutcome'{value = NewContent}}); +%% 9.1.3.8 E-RAB MODIFICATION INDICATION +handle_pdu(Data, {Outcome = initiatingMessage, + #'InitiatingMessage'{procedureCode = ?'id-E-RABModificationIndication', + value = Content} = Pdu}) -> + logger:debug("Patching E-RAB MODIFICATION INDICATION"), + IEs = Content#'E-RABModificationIndication'.protocolIEs, + %% E-RAB to be Modified List + IEs1 = handle_ies(IEs, ?'id-E-RABToBeModifiedListBearerModInd'), + %% E-RAB not to be Modified List + IEs2 = handle_ies(IEs1, ?'id-E-RABNotToBeModifiedListBearerModInd'), + NewContent = Content#'E-RABModificationIndication'{protocolIEs = IEs2}, + handle_pdu_new(Data, {Outcome, Pdu#'InitiatingMessage'{value = NewContent}}); + %% Proxy all other messages unmodified handle_pdu(Data, _Pdu) -> Data. @@ -143,6 +156,29 @@ TLA = transp_layer_addr(s1gw_bind_addr), Content#'E-RABSetupItemBearerSURes'{transportLayerAddress = TLA}; +%% E-RAB MODIFICATION INDICATION related IEs +handle_ie(#'ProtocolIE-Field'{id = ?'id-E-RABToBeModifiedListBearerModInd', + value = Content}) -> + %% This IE contains a list of BearerModInd, so patch inner IEs + handle_ies(Content, ?'id-E-RABToBeModifiedItemBearerModInd'); + +handle_ie(#'ProtocolIE-Field'{id = ?'id-E-RABToBeModifiedItemBearerModInd', + value = Content}) -> + %% eNB -> MME direction: we pass our MME facing local address + TLA = transp_layer_addr(mme_loc_addr), + Content#'E-RABToBeModifiedItemBearerModInd'{transportLayerAddress = TLA}; + +handle_ie(#'ProtocolIE-Field'{id = ?'id-E-RABNotToBeModifiedListBearerModInd', + value = Content}) -> + %% This IE contains a list of BearerModInd, so patch inner IEs + handle_ies(Content, ?'id-E-RABNotToBeModifiedItemBearerModInd'); + +handle_ie(#'ProtocolIE-Field'{id = ?'id-E-RABNotToBeModifiedItemBearerModInd', + value = Content}) -> + %% eNB -> MME direction: we pass our MME facing local address + TLA = transp_layer_addr(mme_loc_addr), + Content#'E-RABNotToBeModifiedItemBearerModInd'{transportLayerAddress = TLA}; + %% Catch-all variant, which should not be called normally handle_ie(#'ProtocolIE-Field'{value = Content} = IE) -> logger:error("[BUG] Unhandled S1AP IE: ~p", [IE]), diff --git a/test/s1ap_proxy_test.erl b/test/s1ap_proxy_test.erl index 2bc8392..4123085 100644 --- a/test/s1ap_proxy_test.erl +++ b/test/s1ap_proxy_test.erl @@ -86,4 +86,28 @@ application:set_env(osmo_s1gw, s1gw_bind_addr, ?EXP_ADDR_STR), ?assertEqual(ExpData, s1ap_proxy:handle_pdu(OrigData)). + +%% [eNB -> MME] E-RAB MODIFICATION INDICATION +e_rab_modify_ind_pdu(TLA, TEID) when is_binary(TLA), + is_binary(TEID) -> + << 16#00, 16#32, 16#00, 16#24, 16#00, 16#00, 16#03, 16#00, + 16#00, 16#00, 16#02, 16#00, 16#02, 16#00, 16#08, 16#00, + 16#04, 16#80, 16#06, 16#69, 16#2d, 16#00, 16#c7, 16#00, + 16#0f, 16#00, 16#00, 16#c8, 16#00, 16#0a, 16#0a, 16#1f, + TLA/bytes, %% transportLayerAddress (IPv4) + TEID/bytes %% GTP-TEID + >>. + +e_rab_modify_ind_test() -> + %% Original input data + TEID = << 16#3d, 16#b0, 16#b5, 16#1d >>, + OrigTLA = << 16#c0, 16#a8, 16#12, 16#c6 >>, + OrigData = e_rab_modify_ind_pdu(OrigTLA, TEID), + + %% Expected output data + ExpData = e_rab_modify_ind_pdu(?EXP_ADDR_BIN, TEID), + + application:set_env(osmo_s1gw, mme_loc_addr, ?EXP_ADDR_STR), + ?assertEqual(ExpData, s1ap_proxy:handle_pdu(OrigData)). + %% vim:set ts=4 sw=4 et: -- To view, visit https://gerrit.osmocom.org/c/erlang/osmo-s1gw/+/37103?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: erlang/osmo-s1gw Gerrit-Branch: master Gerrit-Change-Id: I054b874b39d4e39a51c00385d1553da065131047 Gerrit-Change-Number: 37103 Gerrit-PatchSet: 1 Gerrit-Owner: osmith <osm...@sysmocom.de> Gerrit-CC: fixeria <vyanits...@sysmocom.de> Gerrit-MessageType: newchange