Allow to add APN wildcard via configuration

If the osmo-hlr doesn't send a default APN but it is required.
Set application environment append_default_apn to "true".
See the example sys.config.

Change-Id: I5767cb3c4082809f2ac5a4361a4758b54f24ad48
This commit is contained in:
Alexander Couzens 2023-03-14 18:33:57 +01:00
parent 1b6291e313
commit 3d6f214d2a
2 changed files with 31 additions and 2 deletions

View File

@ -8,5 +8,7 @@
{origin_host, "hss.localdomain"},
{origin_realm, "localdomain"},
{vendor_id, 0}
{vendor_id, 0},
% Append default APN to diameter
{append_default_apn, "false"}
]}].

View File

@ -136,6 +136,22 @@ gsup_pdp2dia(GsupPdpInfo) ->
'Pre-emption-Vulnerability'=1}
}).
-spec gen_default_apn(integer()) -> #'APN-Configuration'{}.
gen_default_apn(ContextIdentifier) ->
#'APN-Configuration'{'Context-Identifier' = ContextIdentifier,
'PDN-Type' = ?PDN_TYPE_DEFAULT,
% The EPS-Subscribed-QoS-Profile AVP and the AMBR AVP shall be present in the
% APN-Configuration AVP when the APN-Configuration AVP is sent in the
% APN-Configuration-Profile AVP and when the APN-Configuration-Profile AVP is
% sent within a ULA (as part of the Subscription-Data AVP).
'EPS-Subscribed-QoS-Profile' = ?EPS_QOS_DEFAULT,
'AMBR' = #'AMBR'{'Max-Requested-Bandwidth-UL' = 100000000,
'Max-Requested-Bandwidth-DL' = 100000000},
% The default APN Configuration shall not contain the Wildcard APN (see 3GPP TS
% 23.003 [3], clause 9.2); the default APN shall always contain an explicit APN
'Service-Selection' = "*"
}.
-spec gsup_pdp2dia_apn('GSUPPdpInfo'()) -> #'APN-Configuration'{}.
gsup_pdp2dia_apn(GsupPdpInfo) ->
#'APN-Configuration'{'Context-Identifier' = maps:get(pdp_context_id, GsupPdpInfo),
@ -275,7 +291,18 @@ handle_request(#diameter_packet{msg = Req, errors = []}, _SvcName, {_, Caps}) wh
'PDP-Context'=PdpContexts},
% build the APN-Configuration-Profile
ApnCfgList = lists:map(fun gsup_pdp2dia_apn/1, PdpInfoList),
ApnCfgList2 = lists:map(fun gsup_pdp2dia_apn/1, PdpInfoList),
% append default apn
AppendDefaultApn = application:get_env(osmo_dia2gsup, append_default_apn, "true"),
case AppendDefaultApn of
"true" ->
LastApn = lists:last(ApnCfgList2),
ApnCfgList = ApnCfgList2 ++ [gen_default_apn(LastApn#'APN-Configuration'.'Context-Identifier' + 1)];
_ ->
ApnCfgList = ApnCfgList2
end,
lager:info("ApnCfgList: ~p~n", [ApnCfgList]),
FirstApn = lists:nth(1, ApnCfgList),
DefaultCtxId = FirstApn#'APN-Configuration'.'Context-Identifier',
ApnCfgProf = #'APN-Configuration-Profile'{'Context-Identifier' = DefaultCtxId,