falconia has submitted this change. ( https://gerrit.osmocom.org/c/osmo-hlr/+/35383?usp=email ) Change subject: ctrl: add subscriber.by-*.imsi GET-able variable ...................................................................... ctrl: add subscriber.by-*.imsi GET-able variable 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 --- M src/ctrl.c 1 file changed, 33 insertions(+), 0 deletions(-) Approvals: fixeria: Looks good to me, approved Jenkins Builder: Verified pespin: Looks good to me, but someone else must approve diff --git a/src/ctrl.c b/src/ctrl.c index e04195d..9555e28 100644 --- a/src/ctrl.c +++ b/src/ctrl.c @@ -426,6 +426,20 @@ 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 @@ 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); -- To view, visit https://gerrit.osmocom.org/c/osmo-hlr/+/35383?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Change-Id: Icea1a74d0c664047f46758ab4ad75508782f3d12 Gerrit-Change-Number: 35383 Gerrit-PatchSet: 1 Gerrit-Owner: falconia <falcon@freecalypso.org> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: falconia <falcon@freecalypso.org> Gerrit-Reviewer: fixeria <vyanitskiy@sysmocom.de> Gerrit-Reviewer: pespin <pespin@sysmocom.de> Gerrit-MessageType: merged