Skip to content

Commit

Permalink
Add IMEISV to NASREQ
Browse files Browse the repository at this point in the history
  • Loading branch information
Javier M. Torres committed May 27, 2024
1 parent 7a089e6 commit 220e839
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 20 deletions.
2 changes: 2 additions & 0 deletions dia/diameter_3gpp_ts29_061_sgi.dia
Original file line number Diff line number Diff line change
Expand Up @@ -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 ]

Expand Down
2 changes: 1 addition & 1 deletion test/diameter_nasreq_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
44 changes: 25 additions & 19 deletions test/diameter_test_server.erl
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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) ->
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 2 additions & 0 deletions test/ergw_aaa_test_lib.hrl
Original file line number Diff line number Diff line change
Expand Up @@ -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").

0 comments on commit 220e839

Please sign in to comment.