diff options
author | Mychaela N. Falconia <falcon@freecalypso.org> | 2023-12-17 20:25:41 +0000 |
---|---|---|
committer | Mychaela N. Falconia <falcon@freecalypso.org> | 2023-12-17 20:25:41 +0000 |
commit | 1244c3d54955657a541b836a6c4c52def7b33b44 (patch) | |
tree | c4d8b1cff735eaa4790939859c8cf543a3de11c4 | |
parent | 5b5a9ff4069c0714aebb1c44ae473d5cc519d328 (diff) |
ctrl: add subscriber.by-*.imsi GET-able variablefalconia/production
There may be a need in various OsmoCNI-attached entities (for example,
external SMSC implementations) to perform a mapping from known MSISDN
to unknown IMSI, querying OsmoHLR subscriber db for it. Querying for
subscriber.by-msisdn-*.imsi will be much more efficient (and easier on
client-side implementors) than querying for subscriber.by-msisdn-*.info
and fishing the IMSI out of the long multiline response, discarding all
other irrelevant info.
Related: OS#6312
Change-Id: Icea1a74d0c664047f46758ab4ad75508782f3d12
-rw-r--r-- | src/ctrl.c | 15 |
1 files changed, 15 insertions, 0 deletions
@@ -426,6 +426,20 @@ static int set_subscr_cs_enabled(struct ctrl_cmd *cmd, void *data) return set_subscr_cs_ps_enabled(cmd, data, false); } +CTRL_CMD_DEFINE_RO(subscr_imsi, "imsi"); +static int get_subscr_imsi(struct ctrl_cmd *cmd, void *data) +{ + struct hlr_subscriber subscr; + struct hlr *hlr = data; + const char *by_selector = cmd->node; + + if (!get_subscriber(hlr->dbc, by_selector, &subscr, cmd)) + return CTRL_CMD_ERROR; + + cmd->reply = talloc_strdup(cmd, subscr.imsi); + return CTRL_CMD_REPLY; +} + CTRL_CMD_DEFINE(subscr_msisdn, "msisdn"); static int verify_subscr_msisdn(struct ctrl_cmd *cmd, const char *value, void *data) { @@ -761,6 +775,7 @@ static int hlr_ctrl_cmds_install(void) rc |= ctrl_cmd_install(CTRL_NODE_SUBSCR_BY, &cmd_subscr_info_all); rc |= ctrl_cmd_install(CTRL_NODE_SUBSCR_BY, &cmd_subscr_ps_enabled); rc |= ctrl_cmd_install(CTRL_NODE_SUBSCR_BY, &cmd_subscr_cs_enabled); + rc |= ctrl_cmd_install(CTRL_NODE_SUBSCR_BY, &cmd_subscr_imsi); rc |= ctrl_cmd_install(CTRL_NODE_SUBSCR_BY, &cmd_subscr_msisdn); rc |= ctrl_cmd_install(CTRL_NODE_SUBSCR_BY, &cmd_subscr_aud2g); rc |= ctrl_cmd_install(CTRL_NODE_SUBSCR_BY, &cmd_subscr_aud3g); |