diff --git a/examples/sys.config b/examples/sys.config index 8814893..8ad9bdf 100644 --- a/examples/sys.config +++ b/examples/sys.config @@ -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"} ]}]. diff --git a/src/server_cb.erl b/src/server_cb.erl index fc8e397..709ef44 100644 --- a/src/server_cb.erl +++ b/src/server_cb.erl @@ -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,