sgsn: Add SGSN_ERROR_CAUSE_NONE and use it instead of 0
Currently an error_cause of 0 is being used to indicate normal operation. Albeit this is not a defined GMM cause, the value is not explicitly reserved. This commit adds the macro SGSN_ERROR_CAUSE_NONE and uses it for initialisation (instead of relying on talloc_zero) and comparisons. The value is set to -1 to be on the safe side. The VTY code is updated to set the error_cause when using the 'update-subscriber imsi IMSI update-location-result CAUSE' command. Sponsored-by: On-Waves ehf
This commit is contained in:
parent
2585620857
commit
d6267d12d8
|
@ -288,6 +288,8 @@ struct sgsn_subscriber_data {
|
||||||
enum sgsn_subscriber_proc blocked_by;
|
enum sgsn_subscriber_proc blocked_by;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#define SGSN_ERROR_CAUSE_NONE (-1)
|
||||||
|
|
||||||
#define LOGGSUBSCRP(level, subscr, fmt, args...) \
|
#define LOGGSUBSCRP(level, subscr, fmt, args...) \
|
||||||
LOGP(DGPRS, level, "SUBSCR(%s) " fmt, \
|
LOGP(DGPRS, level, "SUBSCR(%s) " fmt, \
|
||||||
(subscr) ? (subscr)->imsi : "---", \
|
(subscr) ? (subscr)->imsi : "---", \
|
||||||
|
|
|
@ -654,7 +654,7 @@ void gsm0408_gprs_access_granted(struct sgsn_mm_ctx *ctx)
|
||||||
|
|
||||||
void gsm0408_gprs_access_denied(struct sgsn_mm_ctx *ctx, int gmm_cause)
|
void gsm0408_gprs_access_denied(struct sgsn_mm_ctx *ctx, int gmm_cause)
|
||||||
{
|
{
|
||||||
if (gmm_cause == 0)
|
if (gmm_cause == SGSN_ERROR_CAUSE_NONE)
|
||||||
gmm_cause = GMM_CAUSE_GPRS_NOTALLOWED;
|
gmm_cause = GMM_CAUSE_GPRS_NOTALLOWED;
|
||||||
|
|
||||||
switch (ctx->mm_state) {
|
switch (ctx->mm_state) {
|
||||||
|
@ -690,7 +690,7 @@ void gsm0408_gprs_access_denied(struct sgsn_mm_ctx *ctx, int gmm_cause)
|
||||||
|
|
||||||
void gsm0408_gprs_access_cancelled(struct sgsn_mm_ctx *ctx, int gmm_cause)
|
void gsm0408_gprs_access_cancelled(struct sgsn_mm_ctx *ctx, int gmm_cause)
|
||||||
{
|
{
|
||||||
if (gmm_cause != 0) {
|
if (gmm_cause != SGSN_ERROR_CAUSE_NONE) {
|
||||||
LOGMMCTXP(LOGL_INFO, ctx,
|
LOGMMCTXP(LOGL_INFO, ctx,
|
||||||
"Cancelled with cause '%s' (%d), deleting context\n",
|
"Cancelled with cause '%s' (%d), deleting context\n",
|
||||||
get_value_string(gsm48_gmm_cause_names, gmm_cause),
|
get_value_string(gsm48_gmm_cause_names, gmm_cause),
|
||||||
|
|
|
@ -167,6 +167,8 @@ static struct sgsn_subscriber_data *sgsn_subscriber_data_alloc(void *ctx)
|
||||||
|
|
||||||
sdata = talloc_zero(ctx, struct sgsn_subscriber_data);
|
sdata = talloc_zero(ctx, struct sgsn_subscriber_data);
|
||||||
|
|
||||||
|
sdata->error_cause = SGSN_ERROR_CAUSE_NONE;
|
||||||
|
|
||||||
for (idx = 0; idx < ARRAY_SIZE(sdata->auth_triplets); idx++)
|
for (idx = 0; idx < ARRAY_SIZE(sdata->auth_triplets); idx++)
|
||||||
sdata->auth_triplets[idx].key_seq = GSM_KEY_SEQ_INVAL;
|
sdata->auth_triplets[idx].key_seq = GSM_KEY_SEQ_INVAL;
|
||||||
|
|
||||||
|
@ -292,7 +294,7 @@ static int gprs_subscr_handle_gsup_auth_res(struct gsm_subscriber *subscr,
|
||||||
}
|
}
|
||||||
|
|
||||||
sdata->auth_triplets_updated = 1;
|
sdata->auth_triplets_updated = 1;
|
||||||
sdata->error_cause = 0;
|
sdata->error_cause = SGSN_ERROR_CAUSE_NONE;
|
||||||
|
|
||||||
gprs_subscr_update_auth_info(subscr);
|
gprs_subscr_update_auth_info(subscr);
|
||||||
|
|
||||||
|
@ -322,7 +324,7 @@ static int gprs_subscr_handle_gsup_upd_loc_res(struct gsm_subscriber *subscr,
|
||||||
}
|
}
|
||||||
|
|
||||||
subscr->authorized = 1;
|
subscr->authorized = 1;
|
||||||
subscr->sgsn_data->error_cause = 0;
|
subscr->sgsn_data->error_cause = SGSN_ERROR_CAUSE_NONE;
|
||||||
|
|
||||||
subscr->flags |= GPRS_SUBSCRIBER_ENABLE_PURGE;
|
subscr->flags |= GPRS_SUBSCRIBER_ENABLE_PURGE;
|
||||||
|
|
||||||
|
@ -451,7 +453,7 @@ static int gprs_subscr_handle_gsup_purge_res(struct gsm_subscriber *subscr,
|
||||||
LOGGSUBSCRP(LOGL_INFO, subscr, "Completing purge MS\n");
|
LOGGSUBSCRP(LOGL_INFO, subscr, "Completing purge MS\n");
|
||||||
|
|
||||||
/* Force silent cancellation */
|
/* Force silent cancellation */
|
||||||
subscr->sgsn_data->error_cause = 0;
|
subscr->sgsn_data->error_cause = SGSN_ERROR_CAUSE_NONE;
|
||||||
gprs_subscr_put_and_cancel(subscr_get(subscr));
|
gprs_subscr_put_and_cancel(subscr_get(subscr));
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -500,7 +502,7 @@ static int gprs_subscr_handle_loc_cancel_req(struct gsm_subscriber *subscr,
|
||||||
gsup_reply.message_type = GPRS_GSUP_MSGT_LOCATION_CANCEL_RESULT;
|
gsup_reply.message_type = GPRS_GSUP_MSGT_LOCATION_CANCEL_RESULT;
|
||||||
gprs_subscr_tx_gsup_message(subscr, &gsup_reply);
|
gprs_subscr_tx_gsup_message(subscr, &gsup_reply);
|
||||||
|
|
||||||
subscr->sgsn_data->error_cause = 0;
|
subscr->sgsn_data->error_cause = SGSN_ERROR_CAUSE_NONE;
|
||||||
gprs_subscr_put_and_cancel(subscr_get(subscr));
|
gprs_subscr_put_and_cancel(subscr_get(subscr));
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -257,7 +257,9 @@ void sgsn_auth_update(struct sgsn_mm_ctx *mmctx)
|
||||||
gsm0408_gprs_access_granted(mmctx);
|
gsm0408_gprs_access_granted(mmctx);
|
||||||
break;
|
break;
|
||||||
case SGSN_AUTH_REJECTED:
|
case SGSN_AUTH_REJECTED:
|
||||||
gmm_cause = subscr ? subscr->sgsn_data->error_cause : 0;
|
gmm_cause =
|
||||||
|
subscr ? subscr->sgsn_data->error_cause :
|
||||||
|
SGSN_ERROR_CAUSE_NONE;
|
||||||
|
|
||||||
if (subscr && (subscr->flags & GPRS_SUBSCRIBER_CANCELLED) != 0)
|
if (subscr && (subscr->flags & GPRS_SUBSCRIBER_CANCELLED) != 0)
|
||||||
gsm0408_gprs_access_cancelled(mmctx, gmm_cause);
|
gsm0408_gprs_access_cancelled(mmctx, gmm_cause);
|
||||||
|
|
|
@ -644,15 +644,29 @@ DEFUN(update_subscr_update_location_result, update_subscr_update_location_result
|
||||||
|
|
||||||
struct gsm_subscriber *subscr;
|
struct gsm_subscriber *subscr;
|
||||||
|
|
||||||
|
const struct value_string cause_mapping[] = {
|
||||||
|
{ GMM_CAUSE_NET_FAIL, "system-failure" },
|
||||||
|
{ GMM_CAUSE_INV_MAND_INFO, "data-missing" },
|
||||||
|
{ GMM_CAUSE_PROTO_ERR_UNSPEC, "unexpected-data-value" },
|
||||||
|
{ GMM_CAUSE_IMSI_UNKNOWN, "unknown-subscriber" },
|
||||||
|
{ GMM_CAUSE_GPRS_NOTALLOWED, "roaming-not-allowed" },
|
||||||
|
{ 0, NULL }
|
||||||
|
};
|
||||||
|
|
||||||
subscr = gprs_subscr_get_by_imsi(imsi);
|
subscr = gprs_subscr_get_by_imsi(imsi);
|
||||||
if (!subscr) {
|
if (!subscr) {
|
||||||
vty_out(vty, "%% unable to get subscriber record for %s\n", imsi);
|
vty_out(vty, "%% unable to get subscriber record for %s\n", imsi);
|
||||||
return CMD_WARNING;
|
return CMD_WARNING;
|
||||||
}
|
}
|
||||||
if (strcmp(ret_code_str, "ok") == 0)
|
|
||||||
|
if (strcmp(ret_code_str, "ok") == 0) {
|
||||||
|
subscr->sgsn_data->error_cause = SGSN_ERROR_CAUSE_NONE;
|
||||||
subscr->authorized = 1;
|
subscr->authorized = 1;
|
||||||
else
|
} else {
|
||||||
|
subscr->sgsn_data->error_cause =
|
||||||
|
get_string_value(cause_mapping, ret_code_str);
|
||||||
subscr->authorized = 0;
|
subscr->authorized = 0;
|
||||||
|
}
|
||||||
|
|
||||||
gprs_subscr_update(subscr);
|
gprs_subscr_update(subscr);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue