USSD: add special 'idle' handler to IUSE for testing

Change-Id: I0d566a60e95ce2da951f22ad47c6155c5b6a338c
This commit is contained in:
Vadim Yanitskiy 2020-11-17 04:17:46 +07:00
parent 6a6c7f87ca
commit dac855e5c8
4 changed files with 24 additions and 4 deletions

View File

@ -67,7 +67,9 @@ USSD requests internally. It features a set of simple handlers, which
can be assigned to one or more USSD request prefixes:
* `own-msisdn` returns subscriber's MSISDN (if assigned);
* `own-imsi` returns subscriber's IMSI.
* `own-imsi` returns subscriber's IMSI;
* `test-idle` keeps the session idle until the MS terminates it, or
the guard timer expires (may be useful for testing).
Additional handlers can be added on request.

View File

@ -379,6 +379,19 @@ static int handle_ussd_own_imsi(struct ss_session *ss,
return 0;
}
/* This handler just keeps the session idle unless the guard timer expires. */
static int handle_ussd_test_idle(struct ss_session *ss,
const struct osmo_gsup_message *gsup,
const struct ss_request *req)
{
char buf[GSM0480_USSD_7BIT_STRING_LEN + 1];
snprintf(buf, sizeof(buf), "Keeping your session idle, it will expire "
"at most in %u seconds.", g_hlr->ncss_guard_timeout);
ss->state = OSMO_GSUP_SESSION_STATE_CONTINUE;
ss_tx_to_ms_ussd_7bit(ss, req->invoke_id, buf);
return 0;
}
static const struct hlr_iuse hlr_iuses[] = {
{
@ -389,6 +402,10 @@ static const struct hlr_iuse hlr_iuses[] = {
.name = "own-imsi",
.handle_ussd = handle_ussd_own_imsi,
},
{
.name = "test-idle",
.handle_ussd = handle_ussd_test_idle,
},
};
const struct hlr_iuse *iuse_find(const char *name)

View File

@ -174,10 +174,11 @@ DEFUN(cfg_hlr_gsup_ipa_name,
#define UROUTE_STR "Routing Configuration\n"
#define PREFIX_STR "Prefix-Matching Route\n" "USSD Prefix\n"
#define INT_CHOICE "(own-msisdn|own-imsi)"
#define INT_CHOICE "(own-msisdn|own-imsi|test-idle)"
#define INT_STR "Internal USSD Handler\n" \
"Respond with subscribers' own MSISDN\n" \
"Respond with subscribers' own IMSI\n"
"Respond with subscribers' own IMSI\n" \
"Keep the session idle (useful for testing)\n"
#define EXT_STR "External USSD Handler\n" \
"Name of External USSD Handler (IPA CCM ID)\n"

View File

@ -51,7 +51,7 @@ OsmoHLR(config-hlr)# list
database PATH
euse NAME
no euse NAME
ussd route prefix PREFIX internal (own-msisdn|own-imsi)
ussd route prefix PREFIX internal (own-msisdn|own-imsi|test-idle)
ussd route prefix PREFIX external EUSE
no ussd route prefix PREFIX
ussd default-route external EUSE