fixeria submitted this change.

View Change

Approvals: laforge: Looks good to me, but someone else must approve fixeria: Looks good to me, approved pespin: Looks good to me, but someone else must approve Jenkins Builder: Verified
s1ap_proxy: handle_ies(): reorder arguments

This patch prepares for a follow-up change adding E-RAB MODIFY REQ/RSP.

It's common for many Erlang's built-in functions to have the Key argument first
(e.g. dict:store/3, dict:take/2, proplists:lookup/2, proplists:delete/2),
and also makes handle_ies() consistent with handle_ie().

Change-Id: Ic9c7257bef290a7f0c2546d4c1ca3b9d4aed20d2
---
M src/s1ap_proxy.erl
1 file changed, 34 insertions(+), 34 deletions(-)

diff --git a/src/s1ap_proxy.erl b/src/s1ap_proxy.erl
index 4d78b29..b0d174d 100644
--- a/src/s1ap_proxy.erl
+++ b/src/s1ap_proxy.erl
@@ -234,8 +234,8 @@
value = C0} = Msg}, S0) ->
?LOG_DEBUG("Processing E-RAB SETUP REQUEST"),
s1gw_metrics:ctr_inc(?S1GW_CTR_S1AP_PROXY_IN_PKT_ERAB_SETUP_REQ),
- case handle_ies(C0#'E-RABSetupRequest'.protocolIEs,
- ?'id-E-RABToBeSetupListBearerSUReq', S0) of
+ case handle_ies(?'id-E-RABToBeSetupListBearerSUReq',
+ C0#'E-RABSetupRequest'.protocolIEs, S0) of
{{ok, IEs}, S1} ->
C1 = C0#'E-RABSetupRequest'{protocolIEs = IEs},
PDU = {Outcome, Msg#'InitiatingMessage'{value = C1}},
@@ -254,8 +254,8 @@
value = C0} = Msg}, S0) ->
?LOG_DEBUG("Processing E-RAB SETUP RESPONSE"),
s1gw_metrics:ctr_inc(?S1GW_CTR_S1AP_PROXY_IN_PKT_ERAB_SETUP_RSP),
- case handle_ies(C0#'E-RABSetupResponse'.protocolIEs,
- ?'id-E-RABSetupListBearerSURes', S0) of
+ case handle_ies(?'id-E-RABSetupListBearerSURes',
+ C0#'E-RABSetupResponse'.protocolIEs, S0) of
{{ok, IEs}, S1} ->
C1 = C0#'E-RABSetupResponse'{protocolIEs = IEs},
PDU = {Outcome, Msg#'SuccessfulOutcome'{value = C1}},
@@ -274,8 +274,8 @@
value = C0} = Msg}, S0) ->
?LOG_DEBUG("Processing E-RAB RELEASE COMMAND"),
s1gw_metrics:ctr_inc(?S1GW_CTR_S1AP_PROXY_IN_PKT_ERAB_RELEASE_CMD),
- case handle_ies(C0#'E-RABReleaseCommand'.protocolIEs,
- ?'id-E-RABToBeReleasedList',
+ case handle_ies(?'id-E-RABToBeReleasedList',
+ C0#'E-RABReleaseCommand'.protocolIEs,
S0#proxy_state{rel_kind = cmd}) of
{{ok, IEs}, S1} ->
C1 = C0#'E-RABReleaseCommand'{protocolIEs = IEs},
@@ -293,8 +293,8 @@
value = C0} = Msg}, S0) ->
?LOG_DEBUG("Processing E-RAB RELEASE RESPONSE"),
s1gw_metrics:ctr_inc(?S1GW_CTR_S1AP_PROXY_IN_PKT_ERAB_RELEASE_RSP),
- case handle_ies(C0#'E-RABReleaseResponse'.protocolIEs,
- ?'id-E-RABReleaseListBearerRelComp', S0) of
+ case handle_ies(?'id-E-RABReleaseListBearerRelComp',
+ C0#'E-RABReleaseResponse'.protocolIEs, S0) of
{{ok, IEs}, S1} ->
C1 = C0#'E-RABReleaseResponse'{protocolIEs = IEs},
PDU = {Outcome, Msg#'SuccessfulOutcome'{value = C1}},
@@ -311,8 +311,8 @@
value = C0} = Msg}, S0) ->
?LOG_DEBUG("Processing E-RAB RELEASE INDICATION"),
s1gw_metrics:ctr_inc(?S1GW_CTR_S1AP_PROXY_IN_PKT_ERAB_RELEASE_IND),
- case handle_ies(C0#'E-RABReleaseIndication'.protocolIEs,
- ?'id-E-RABReleasedList',
+ case handle_ies(?'id-E-RABReleasedList',
+ C0#'E-RABReleaseIndication'.protocolIEs,
S0#proxy_state{rel_kind = ind}) of
{{ok, IEs}, S1} ->
C1 = C0#'E-RABReleaseIndication'{protocolIEs = IEs},
@@ -333,10 +333,10 @@
IEs0 = C0#'E-RABModificationIndication'.protocolIEs,
%% E-RAB to be Modified List
%% TODO: handle {error, Reason}
- {{ok, IEs1}, S1} = handle_ies(IEs0, ?'id-E-RABToBeModifiedListBearerModInd', S0),
+ {{ok, IEs1}, S1} = handle_ies(?'id-E-RABToBeModifiedListBearerModInd', IEs0, S0),
%% E-RAB not to be Modified List
%% TODO: handle {error, Reason}
- {{ok, IEs2}, S2} = handle_ies(IEs1, ?'id-E-RABNotToBeModifiedListBearerModInd', S1),
+ {{ok, IEs2}, S2} = handle_ies(?'id-E-RABNotToBeModifiedListBearerModInd', IEs1, S1),
C1 = C0#'E-RABModificationIndication'{protocolIEs = IEs2},
PDU = {Outcome, Msg#'InitiatingMessage'{value = C1}},
{{forward, PDU}, S2};
@@ -347,8 +347,8 @@
value = C0} = Msg}, S0) ->
?LOG_DEBUG("Processing INITIAL CONTEXT SETUP REQUEST"),
s1gw_metrics:ctr_inc(?S1GW_CTR_S1AP_PROXY_IN_PKT_INIT_CTX_REQ),
- case handle_ies(C0#'InitialContextSetupRequest'.protocolIEs,
- ?'id-E-RABToBeSetupListCtxtSUReq', S0) of
+ case handle_ies(?'id-E-RABToBeSetupListCtxtSUReq',
+ C0#'InitialContextSetupRequest'.protocolIEs, S0) of
{{ok, IEs}, S1} ->
C1 = C0#'InitialContextSetupRequest'{protocolIEs = IEs},
PDU = {Outcome, Msg#'InitiatingMessage'{value = C1}},
@@ -366,8 +366,8 @@
?LOG_DEBUG("Processing INITIAL CONTEXT SETUP RESPONSE"),
s1gw_metrics:ctr_inc(?S1GW_CTR_S1AP_PROXY_IN_PKT_INIT_CTX_RSP),
%% TODO: handle optional E-RAB Failed to Setup List IE
- case handle_ies(C0#'InitialContextSetupResponse'.protocolIEs,
- ?'id-E-RABSetupListCtxtSURes', S0) of
+ case handle_ies(?'id-E-RABSetupListCtxtSURes',
+ C0#'InitialContextSetupResponse'.protocolIEs, S0) of
{{ok, IEs}, S1} ->
C1 = C0#'InitialContextSetupResponse'{protocolIEs = IEs},
PDU = {Outcome, Msg#'SuccessfulOutcome'{value = C1}},
@@ -402,7 +402,7 @@
%% E-RAB SETUP REQUEST related IEs
handle_ie(?'id-E-RABToBeSetupListBearerSUReq', C, S) ->
%% This IE contains a list of BearerSUReq, so patch inner IEs
- handle_ies(C, ?'id-E-RABToBeSetupItemBearerSUReq', S);
+ handle_ies(?'id-E-RABToBeSetupItemBearerSUReq', C, S);

handle_ie(?'id-E-RABToBeSetupItemBearerSUReq',
#'E-RABToBeSetupItemBearerSUReq'{'e-RAB-ID' = ERABId,
@@ -422,7 +422,7 @@
%% E-RAB SETUP RESPONSE related IEs
handle_ie(?'id-E-RABSetupListBearerSURes', C, S) ->
%% This IE contains a list of BearerSURes, so patch inner IEs
- handle_ies(C, ?'id-E-RABSetupItemBearerSURes', S);
+ handle_ies(?'id-E-RABSetupItemBearerSURes', C, S);

handle_ie(?'id-E-RABSetupItemBearerSURes',
#'E-RABSetupItemBearerSURes'{'e-RAB-ID' = ERABId,
@@ -447,7 +447,7 @@
%% 9.1.3.5 E-RAB RELEASE COMMAND related IEs
handle_ie(?'id-E-RABToBeReleasedList', C, S) ->
%% This IE contains a list of E-RABItem
- handle_ies(C, ?'id-E-RABItem', S);
+ handle_ies(?'id-E-RABItem', C, S);

handle_ie(?'id-E-RABItem',
#'E-RABItem'{'e-RAB-ID' = ERABId} = C,
@@ -465,7 +465,7 @@
%% 9.1.3.6 E-RAB RELEASE RESPONSE related IEs
handle_ie(?'id-E-RABReleaseListBearerRelComp', C, S) ->
%% This IE contains a list of E-RABReleaseItemBearerRelComp
- handle_ies(C, ?'id-E-RABReleaseItemBearerRelComp', S);
+ handle_ies(?'id-E-RABReleaseItemBearerRelComp', C, S);

handle_ie(?'id-E-RABReleaseItemBearerRelComp',
#'E-RABReleaseItemBearerRelComp'{'e-RAB-ID' = ERABId} = C, S) ->
@@ -482,12 +482,12 @@
%% 9.1.3.7 E-RAB RELEASE INDICATION related IEs
handle_ie(?'id-E-RABReleasedList', C, S) ->
%% This IE contains a list of E-RABItem
- handle_ies(C, ?'id-E-RABItem', S);
+ handle_ies(?'id-E-RABItem', C, S);

%% E-RAB MODIFICATION INDICATION related IEs
handle_ie(?'id-E-RABToBeModifiedListBearerModInd', C, S) ->
%% This IE contains a list of BearerModInd, so patch inner IEs
- handle_ies(C, ?'id-E-RABToBeModifiedItemBearerModInd', S);
+ handle_ies(?'id-E-RABToBeModifiedItemBearerModInd', C, S);

handle_ie(?'id-E-RABToBeModifiedItemBearerModInd',
#'E-RABToBeModifiedItemBearerModInd'{} = C, S) ->
@@ -496,7 +496,7 @@

handle_ie(?'id-E-RABNotToBeModifiedListBearerModInd', C, S) ->
%% This IE contains a list of BearerModInd, so patch inner IEs
- handle_ies(C, ?'id-E-RABNotToBeModifiedItemBearerModInd', S);
+ handle_ies(?'id-E-RABNotToBeModifiedItemBearerModInd', C, S);

handle_ie(?'id-E-RABNotToBeModifiedItemBearerModInd',
#'E-RABNotToBeModifiedItemBearerModInd'{} = C, S) ->
@@ -506,7 +506,7 @@
%% INITIAL CONTEXT SETUP REQUEST related IEs
handle_ie(?'id-E-RABToBeSetupListCtxtSUReq', C, S) ->
%% This IE contains a list of CtxtSUReq, so patch inner IEs
- handle_ies(C, ?'id-E-RABToBeSetupItemCtxtSUReq', S);
+ handle_ies(?'id-E-RABToBeSetupItemCtxtSUReq', C, S);

handle_ie(?'id-E-RABToBeSetupItemCtxtSUReq',
#'E-RABToBeSetupItemCtxtSUReq'{'e-RAB-ID' = ERABId,
@@ -526,7 +526,7 @@
%% INITIAL CONTEXT SETUP RESPONSE related IEs
handle_ie(?'id-E-RABSetupListCtxtSURes', C, S) ->
%% This IE contains a list of CtxtSURes, so patch inner IEs
- handle_ies(C, ?'id-E-RABSetupItemCtxtSURes', S);
+ handle_ies(?'id-E-RABSetupItemCtxtSURes', C, S);

handle_ie(?'id-E-RABSetupItemCtxtSURes',
#'E-RABSetupItemCtxtSURes'{'e-RAB-ID' = ERABId,
@@ -558,31 +558,31 @@
%% calling function handle_ie/1 for IEs matching the given IEI.
%% Additionally look for {MME,eNB}-UE-S1AP-ID IEs and store their values.
-type handle_ies_result() :: {ok, list()} | {error, term()}.
--spec handle_ies(list(), s1ap_ie_id(), proxy_state()) -> {handle_ies_result(), proxy_state()}.
-handle_ies(IEs, IEI, S) ->
- handle_ies([], IEs, IEI, S).
+-spec handle_ies(s1ap_ie_id(), list(), proxy_state()) -> {handle_ies_result(), proxy_state()}.
+handle_ies(IEI, IEs, S) ->
+ handle_ies([], IEI, IEs, S).

-handle_ies(Acc, [IE | IEs], IEI, S0) ->
+handle_ies(Acc, IEI, [IE | IEs], S0) ->
case IE of
#'ProtocolIE-Field'{id = IEI, value = C0} ->
case handle_ie(IEI, C0, S0) of
{{ok, C1}, S1} ->
NewIE = IE#'ProtocolIE-Field'{value = C1},
- handle_ies([NewIE | Acc], IEs, IEI, S1);
+ handle_ies([NewIE | Acc], IEI, IEs, S1);
{{error, Reason}, S1} ->
{{error, Reason}, S1}
end;
#'ProtocolIE-Field'{id = ?'id-MME-UE-S1AP-ID', value = Id} ->
S1 = S0#proxy_state{mme_ue_id = Id},
- handle_ies([IE | Acc], IEs, IEI, S1);
+ handle_ies([IE | Acc], IEI, IEs, S1);
#'ProtocolIE-Field'{id = ?'id-eNB-UE-S1AP-ID', value = Id} ->
S1 = S0#proxy_state{enb_ue_id = Id},
- handle_ies([IE | Acc], IEs, IEI, S1);
+ handle_ies([IE | Acc], IEI, IEs, S1);
_ ->
- handle_ies([IE | Acc], IEs, IEI, S0)
+ handle_ies([IE | Acc], IEI, IEs, S0)
end;

-handle_ies(Acc, [], _IEI, S) ->
+handle_ies(Acc, _IEI, [], S) ->
IEs = lists:reverse(Acc),
{{ok, IEs}, S}.


To view, visit change 39112. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-MessageType: merged
Gerrit-Project: erlang/osmo-s1gw
Gerrit-Branch: master
Gerrit-Change-Id: Ic9c7257bef290a7f0c2546d4c1ca3b9d4aed20d2
Gerrit-Change-Number: 39112
Gerrit-PatchSet: 1
Gerrit-Owner: fixeria <vyanitskiy@sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <vyanitskiy@sysmocom.de>
Gerrit-Reviewer: laforge <laforge@osmocom.org>
Gerrit-Reviewer: pespin <pespin@sysmocom.de>