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
changes/21/20021/3
Matt Johnson 2 years ago committed by daniel
parent 6e28afb504
commit 9e0bd808bf
  1. 31
      src/server_cb.erl

@ -100,6 +100,22 @@ req_num_of_vec([#'Requested-UTRAN-GERAN-Authentication-Info'{'Number-Of-Requeste
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 @@ handle_request(#diameter_packet{msg = Req, errors = []}, _SvcName, {_, Caps}) wh
% 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}),

Loading…
Cancel
Save