sms: Introduce VTY-configurable minimum SMS validity period

This is meant as a safeguard against users or user equipment which
doesn't set a reasonable validity period.  Using this setting, the
SMSC administrator can set a minimum SMS validity period. Any SMS
submitted with lower validity period will be extended to that minimum.

Change-Id: I192528a6f9059d158fa12876a247d61bd7edaec8
Related: OS#5567
changes/38/28138/5
Harald Welte 4 months ago committed by laforge
parent 2765a18450
commit a3c639ff5f
  1. 1
      include/osmocom/msc/sms_queue.h
  2. 6
      src/libmsc/gsm_04_11.c
  3. 7
      src/libmsc/smpp_openbsc.c
  4. 1
      src/libmsc/sms_queue.c
  5. 11
      src/libmsc/smsc_vty.c
  6. 1
      tests/test_nodes.vty

@ -13,6 +13,7 @@ struct sms_queue_config {
int max_pending; /* maximum number of gsm_sms_pending in RAM */
bool delete_delivered; /* delete delivered SMS from DB? */
bool delete_expired; /* delete expired SMS from DB? */
unsigned int minimum_validity_mins; /* minimum validity period in minutes */
unsigned int default_validity_mins; /* default validity period in minutes */
};

@ -626,6 +626,12 @@ static int gsm340_rx_tpdu(struct gsm_trans *trans, struct msgb *msg,
osmo_hexdump(gsms->user_data, gsms->user_data_len));
gsms->validity_minutes = gsm340_validity_period(sms_vpf, sms_vp);
if (gsms->validity_minutes < net->sms_queue_cfg->minimum_validity_mins) {
LOG_TRANS(trans, LOGL_INFO, "Overriding user-provided validity period (%lu) "
"with minimum SMSC validity period (%u) minutes\n", gsms->validity_minutes,
net->sms_queue_cfg->minimum_validity_mins);
gsms->validity_minutes = net->sms_queue_cfg->minimum_validity_mins;
}
rc = sms_route_mt_sms(trans, gsms);

@ -267,6 +267,13 @@ static int submit_to_sms(struct gsm_sms **psms, struct gsm_network *net,
else
sms->validity_minutes = (t_validity_absolute - t_now) / 60;
if (sms->validity_minutes < net->sms_queue_cfg->minimum_validity_mins) {
LOGP(DLSMS, LOGL_INFO, "SMS to %s: Overriding ESME-provided validity period (%lu) "
"with minimum SMSC validity period (%u) minutes\n", submit->destination_addr,
sms->validity_minutes, net->sms_queue_cfg->minimum_validity_mins);
sms->validity_minutes = net->sms_queue_cfg->minimum_validity_mins;
}
*psms = sms;
return ESME_ROK;
}

@ -475,6 +475,7 @@ struct sms_queue_config *sms_queue_cfg_alloc(void *ctx)
sqcfg->delete_delivered = true;
sqcfg->delete_expired = true;
sqcfg->default_validity_mins = 7 * 24 * 60; /* 7 days */
sqcfg->minimum_validity_mins = 1;
sqcfg->db_file_path = talloc_strdup(ctx, SMS_DEFAULT_DB_FILE_PATH);
return sqcfg;

@ -99,12 +99,16 @@ DEFUN(cfg_sms_db_del_expired, cfg_sms_db_del_expired_cmd,
}
DEFUN(cfg_sms_def_val_per, cfg_sms_def_val_per_cmd,
"validity-period default <1-5256000>",
"validity-period (minimum|default) <1-5256000>",
"Configure validity period for SMS\n"
"Minimum SMS validity period in minutes\n"
"Default SMS validity period in minutes\n"
"Default SMS validity period in minutes\n")
"Validity period in minutes\n")
{
smqcfg->default_validity_mins = atoi(argv[0]);
if (!strcmp(argv[0], "minimum"))
smqcfg->minimum_validity_mins = atoi(argv[1]);
else
smqcfg->default_validity_mins = atoi(argv[1]);
return CMD_SUCCESS;
}
@ -177,6 +181,7 @@ static int config_write_smsc(struct vty *vty)
vty_out(vty, " database delete-delivered %u%s", smqcfg->delete_delivered, VTY_NEWLINE);
vty_out(vty, " database delete-expired %u%s", smqcfg->delete_expired, VTY_NEWLINE);
vty_out(vty, " validity-period minimum %u%s", smqcfg->minimum_validity_mins, VTY_NEWLINE);
vty_out(vty, " validity-period default %u%s", smqcfg->default_validity_mins, VTY_NEWLINE);
return 0;

@ -183,6 +183,7 @@ smsc
queue max-failure 1
database delete-delivered 1
database delete-expired 1
validity-period minimum 1
validity-period default 10080
end

Loading…
Cancel
Save