daniel has submitted this change. (
https://gerrit.osmocom.org/c/erlang/osmo_dia2gsup/+/20021 )
Change subject: server_cb: Improve handling resynchronization info
......................................................................
server_cb: Improve handling resynchronization info
This commit improves handling of the resynchronization information in
a DIAMETER request from a UE that has a sync failure. It factors
parsing of the resync info into a helper function with a defined spec,
and handles the resynchronization info as a binary rather than a
string.
Change-Id: I2aad313d4d37d07040bc5344de3a023d34fd8ded
---
M src/server_cb.erl
1 file changed, 24 insertions(+), 7 deletions(-)
Approvals:
Jenkins Builder: Verified
daniel: Looks good to me, approved
laforge: Looks good to me, approved
fixeria: Looks good to me, but someone else must approve
diff --git a/src/server_cb.erl b/src/server_cb.erl
index dc7fe59..fc8e397 100644
--- a/src/server_cb.erl
+++ b/src/server_cb.erl
@@ -100,6 +100,22 @@
req_num_of_vec([#'Requested-UTRAN-GERAN-Authentication-Info'{'Number-Of-Requested-Vectors'=[Num]}])
-> Num;
req_num_of_vec(_) -> false.
+
+-type binary_or_false() :: false | binary().
+-spec req_resynchronization_info([tuple()]) -> binary_or_false().
+req_resynchronization_info([#'Requested-EUTRAN-Authentication-Info'{'Re-Synchronization-Info'=[]}])
->
+ false;
+req_resynchronization_info([#'Requested-EUTRAN-Authentication-Info'{'Re-Synchronization-Info'=[Info]}])
->
+ list_to_binary(Info);
+
+req_resynchronization_info([#'Requested-UTRAN-GERAN-Authentication-Info'{'Re-Synchronization-Info'=[]}])
->
+ false;
+req_resynchronization_info([#'Requested-UTRAN-GERAN-Authentication-Info'{'Re-Synchronization-Info'=[Info]}])
->
+ list_to_binary(Info);
+
+req_resynchronization_info(_) ->
+ false.
+
-define(PDP_TYPE_DEFAULT, <<0,0,0,16#21>>). % IPv4
-define(PDP_QOS_DEFAULT, <<0,0,0,0,0,0,0,0,0,0,0,0,0,0>>). % fixme
@@ -188,13 +204,14 @@
% construct GSUP request to HLR and transceive it
GsupTx1 = #{message_type => send_auth_info_req, imsi => list_to_binary(UserName),
supported_rat_types => [rat_eutran_sgs], current_rat_type =>
rat_eutran_sgs},
- case ReqEU of
- #'Requested-EUTRAN-Authentication-Info'{'Re-Synchronization-Info' =
ReSyncInfo}
- when is_binary(ReSyncInfo) ->
- GsupTx2 = #{rand => string:substr(ReSyncInfo, 1, 16),
- auts => string:substr(ReSyncInfo, 17)};
- _ ->
- GsupTx2 = #{}
+ ResyncInfo = req_resynchronization_info(ReqEU),
+ case ResyncInfo of
+ false ->
+ GsupTx2 = #{};
+ ValidResyncInfo ->
+ lager:info("ResyncInfo is valid ~p", [ResyncInfo]),
+ GsupTx2 = #{rand => binary:part(ValidResyncInfo, 0, 16),
+ auts => binary:part(ValidResyncInfo, 16, 14)}
end,
GsupTx = maps:merge(GsupTx1, GsupTx2),
GsupRx = gen_server:call(gsup_client, {transceive_gsup, GsupTx, send_auth_info_res,
send_auth_info_err}),
--
To view, visit
https://gerrit.osmocom.org/c/erlang/osmo_dia2gsup/+/20021
To unsubscribe, or for help writing mail filters, visit
https://gerrit.osmocom.org/settings
Gerrit-Project: erlang/osmo_dia2gsup
Gerrit-Branch: master
Gerrit-Change-Id: I2aad313d4d37d07040bc5344de3a023d34fd8ded
Gerrit-Change-Number: 20021
Gerrit-PatchSet: 3
Gerrit-Owner: matt9j <matt9j(a)cs.washington.edu>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: daniel <dwillmann(a)sysmocom.de>
Gerrit-Reviewer: fixeria <axilirator(a)gmail.com>
Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-MessageType: merged