From 220e839fa628f6bf10f5354129c1043b304f2f47 Mon Sep 17 00:00:00 2001 From: "Javier M. Torres" Date: Thu, 16 May 2024 10:47:36 +0200 Subject: [PATCH] Add IMEISV to NASREQ --- dia/diameter_3gpp_ts29_061_sgi.dia | 2 ++ test/diameter_nasreq_SUITE.erl | 2 +- test/diameter_test_server.erl | 44 +++++++++++++++++------------- test/ergw_aaa_test_lib.hrl | 2 ++ 4 files changed, 30 insertions(+), 20 deletions(-) diff --git a/dia/diameter_3gpp_ts29_061_sgi.dia b/dia/diameter_3gpp_ts29_061_sgi.dia index a5c3771f..3c7d7676 100644 --- a/dia/diameter_3gpp_ts29_061_sgi.dia +++ b/dia/diameter_3gpp_ts29_061_sgi.dia @@ -103,6 +103,8 @@ [ 3GPP-CAMEL-Charging-Info ] [ 3GPP-Negotiated-DSCP ] [ 3GPP-Allocate-IP-Type ] + ;; Added for consistency with RADIUS + [ 3GPP-IMEISV ] [ TP-NAT-Pool-Id ] * [ AVP ] diff --git a/test/diameter_nasreq_SUITE.erl b/test/diameter_nasreq_SUITE.erl index a132f732..1790d95e 100644 --- a/test/diameter_nasreq_SUITE.erl +++ b/test/diameter_nasreq_SUITE.erl @@ -409,7 +409,7 @@ simple(Config, TermOpts) -> simple_tdf_userid(Config, TermOpts) -> Stats0 = get_stats(?SERVICE), - Msisdn = <<"543148000012345">>, + Msisdn = ?MSISDN_FOR_IMEI_SV, Imsi = <<"250071234567890">>, Imei = <<82,21,50,96,32,80,30,0>>, {ok, Session} = ergw_aaa_session_sup:new_session( diff --git a/test/diameter_test_server.erl b/test/diameter_test_server.erl index c37fa7ec..1d9bf554 100644 --- a/test/diameter_test_server.erl +++ b/test/diameter_test_server.erl @@ -18,6 +18,7 @@ -include("../include/diameter_3gpp_ts29_212.hrl"). -include("../include/diameter_3gpp_ts32_299.hrl"). -include("../include/diameter_3gpp_ts32_299_ro.hrl"). +-include("ergw_aaa_test_lib.hrl"). -export([start/0, start/2, start_nasreq/0, start_nasreq/2, @@ -275,30 +276,35 @@ handle_request(#diameter_packet{msg = ['AAR' | Msg]}, _SvcName, {_, Caps}, _Extr #{'Session-Id' := Id, 'Auth-Request-Type' := Type, 'Auth-Application-Id' := AppId} = Msg, + ct:pal("AAR received: ~p", [Msg]), FramedIP = case maps:get('Framed-IP-Address', Msg, [<<0,0,0,0>>]) of [<<0,0,0,0>>] -> [<<10,106,14,227>>]; FramedIPReq -> FramedIPReq end, AAA0 = #{'Session-Id' => Id, - 'Result-Code' => 2001, - 'Origin-Host' => OH, - 'Origin-Realm' => OR, - 'SN-Primary-DNS-Server' => [{1,2,3,4}], - 'SN-Secondary-DNS-Server' => [{5,6,7,8}], - 'Acct-Interim-Interval' => [InterimAccounting], - 'Authorization-Lifetime' => [AuthLifeTime], - 'Framed-IP-Address' => FramedIP, - 'Framed-MTU' => 1500, - 'Auth-Request-Type' => Type, - 'Auth-Application-Id' => AppId}, + 'Result-Code' => 2001, + 'Origin-Host' => OH, + 'Origin-Realm' => OR, + 'SN-Primary-DNS-Server' => [{1,2,3,4}], + 'SN-Secondary-DNS-Server' => [{5,6,7,8}], + 'Acct-Interim-Interval' => [InterimAccounting], + 'Authorization-Lifetime' => [AuthLifeTime], + 'Framed-IP-Address' => FramedIP, + 'Framed-MTU' => 1500, + 'Auth-Request-Type' => Type, + 'Auth-Application-Id' => AppId}, AAA = if is_map_key('Framed-IPv6-Prefix', Msg) -> - AAA0#{'3GPP-IPv6-DNS-Servers' => - ergw_aaa_3gpp_dict:encode('3GPP-IPv6-DNS-Servers', - [{16#fe80,0,0,0,0,0,0,1}, - {16#fe80,0,0,0,0,0,0,2}])}; - true -> AAA0 - end, - {reply, ['AAA' | AAA]}; + AAA0#{'3GPP-IPv6-DNS-Servers' => + ergw_aaa_3gpp_dict:encode('3GPP-IPv6-DNS-Servers', + [{16#fe80,0,0,0,0,0,0,1}, + {16#fe80,0,0,0,0,0,0,2}])}; + true -> AAA0 + end, + case Msg of + #{'Calling-Station-Id' := ?MSISDN_FOR_IMEI_SV, '3GPP-IMEISV' := _} -> {reply, ['AAA' | AAA]}; + #{'Calling-Station-Id' := ?MSISDN_FOR_IMEI_SV} -> {answer_message, 5005}; + _ -> {reply, ['AAA' | AAA]} + end; handle_request(#diameter_packet{msg = ['STR' | Msg]}, _SvcName, {_, Caps}, _Extra) when is_map(Msg) -> @@ -592,7 +598,7 @@ discard_msg(#{'Service-Information' := [#{'Subscription-Id' := Ids}]}) -> lists:member(#{'Subscription-Id-Type' => 1,'Subscription-Id-Data' => <<"999999999999999">>}, Ids); discard_msg(_) -> - false. + false. fail_answer(<<"FAIL-BROKEN-ANSWER">>, Pkt) -> broken_answer(Pkt); diff --git a/test/ergw_aaa_test_lib.hrl b/test/ergw_aaa_test_lib.hrl index 881f1b0e..13d9a684 100644 --- a/test/ergw_aaa_test_lib.hrl +++ b/test/ergw_aaa_test_lib.hrl @@ -30,3 +30,5 @@ outstanding_reqs/0, get_session_stats/0, get_session_stats/2, wait_for_session/4, reset_session_stats/0]). -endif. + +-define(MSISDN_FOR_IMEI_SV, "AAAAAAAAAAAAAAA").