diff --git a/src/server_cb.erl b/src/server_cb.erl index 482ba9a..26a7ac2 100644 --- a/src/server_cb.erl +++ b/src/server_cb.erl @@ -157,7 +157,10 @@ gsup_pdp2dia_apn(GsupPdpInfo) -> -define(DIAMETER_ERROR_CAMEL_SUBSCRIPTION_PRESENT, 4182). % permanent (only in Experimental-Result-Code) -define(DIAMETER_ERROR_USER_UNKNOWN, 5001). +-define(DIAMETER_AUTHORIZATION_REJECTED, 5003). -define(DIAMETER_ERROR_ROAMING_NOT_ALLOWED, 5004). +-define(DIAMETER_MISSING_AVP, 5005). +-define(DIAMETER_UNABLE_TO_COMPLY, 5012). -define(DIAMETER_ERROR_UNKNOWN_EPS_SUBSCRIPTION, 5420). -define(DIAMETER_ERROR_RAT_NOT_ALLOWED, 5421). -define(DIAMETER_ERROR_EQUIPMENT_UNKNOWN, 5422). @@ -177,15 +180,23 @@ gsup_pdp2dia_apn(GsupPdpInfo) -> -define(GMM_CAUSE_INV_MAND_INFO, 16#60). -define(GMM_CAUSE_PROTO_ERR_UNSPEC, 16#6f). --define(EXP_RES(Foo), #'Experimental-Result'{'Vendor-Id'=fixme, 'Experimental-Result-Code'=Foo}). +-define(EXP_RES(Foo), #'Experimental-Result'{'Vendor-Id'=10415, 'Experimental-Result-Code'=Foo}). +%% see 29.272 Annex A/B -type empty_or_intl() :: [] | [integer()]. -spec gsup_cause2dia(integer()) -> {empty_or_intl(), empty_or_intl()}. gsup_cause2dia(?GMM_CAUSE_IMSI_UNKNOWN) -> {[], [?EXP_RES(?DIAMETER_ERROR_USER_UNKNOWN)]}; -gsup_cause2dia(?GMM_CAUSE_PLMN_NOTALLOWED) -> {[], [?DIAMETER_ERROR_ROAMING_NOT_ALLOWED]}; -gsup_cause2dia(?GMM_CAUSE_GPRS_NOTALLOWED) -> {[], [?DIAMETER_ERROR_RAT_NOT_ALLOWED]}; -%gsup_cause2dia(?GMM_CAUSE_INV_MAND_INFO) -> -%gsup_cause2dia(?GMM_CAUSE_NET_FAIL) -> +gsup_cause2dia(?GMM_CAUSE_ILLEGAL_MS) -> {[], [?EXP_RES(?DIAMETER_ERROR_USER_UNKNOWN)]}; +gsup_cause2dia(?GMM_CAUSE_PLMN_NOTALLOWED) -> {[], [?EXP_RES(?DIAMETER_ERROR_ROAMING_NOT_ALLOWED)]}; +gsup_cause2dia(?GMM_CAUSE_GPRS_NOTALLOWED) -> {[], [?EXP_RES(?DIAMETER_ERROR_UNKNOWN_EPS_SUBSCRIPTION)]}; + +gsup_cause2dia(?GMM_CAUSE_LA_NOTALLOWED) -> {[?DIAMETER_AUTHORIZATION_REJECTED], []}; +gsup_cause2dia(?GMM_CAUSE_ROAMING_NOTALLOWED) -> {[], [?EXP_RES(?DIAMETER_ERROR_ROAMING_NOT_ALLOWED)]}; +gsup_cause2dia(?GMM_CAUSE_NO_SUIT_CELL_IN_LA) -> {[], [?EXP_RES(?DIAMETER_ERROR_UNKNOWN_EPS_SUBSCRIPTION)]}; +gsup_cause2dia(?GMM_CAUSE_NET_FAIL) -> {[?DIAMETER_UNABLE_TO_COMPLY], []}; +gsup_cause2dia(?GMM_CAUSE_CONGESTION) -> {[?DIAMETER_UNABLE_TO_COMPLY], []}; +gsup_cause2dia(?GMM_CAUSE_INV_MAND_INFO) -> {[?DIAMETER_MISSING_AVP], []}; +gsup_cause2dia(?GMM_CAUSE_PROTO_ERR_UNSPEC) -> {[?DIAMETER_UNABLE_TO_COMPLY], []}; % TODO: more values gsup_cause2dia(_) -> {fixme, []}. @@ -229,9 +240,11 @@ handle_request(#diameter_packet{msg = Req, errors = []}, _SvcName, {_, Caps}) wh Resp = #'AIA'{'Session-Id'=SessionId, 'Origin-Host'=OH, 'Origin-Realm'=OR, 'Result-Code'=2001, 'Auth-Session-State'=1, 'Authentication-Info'=AuthInfo}; - #{message_type := send_auth_info_err} -> + #{message_type := send_auth_info_err, cause:=Cause} -> + {Res, ExpRes} = gsup_cause2dia(Cause), Resp = #'AIA'{'Session-Id'=SessionId, 'Origin-Host'=OH, 'Origin-Realm'=OR, - 'Result-Code'=?DIAMETER_ERROR_USER_UNKNOWN, + 'Result-Code'=Res, + 'Experimental-Result'=ExpRes, 'Auth-Session-State'=1}; timeout -> Resp = #'AIA'{'Session-Id'=SessionId, 'Origin-Host'=OH, 'Origin-Realm'=OR,