<p>lynxis lazus has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.osmocom.org/c/osmo-hlr/+/16808">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">Add vty `imsi unknown cause` to set the reject cause<br><br>Allow to set the reject cause when an IMSI is unknown to the HLR.<br>Most common on reject causes are GMM_CAUSE_IMSI_UNKNOWN (2) or<br>CAUSE_ROAMING_NOTALLOWED (11).<br><br>Change-Id: Icea39020c23fbbea9e92847df76af8986fdbf48a<br>---<br>M doc/examples/osmo-hlr.cfg<br>M include/osmocom/hlr/hlr.h<br>M src/hlr.c<br>M src/hlr_vty.c<br>4 files changed, 33 insertions(+), 1 deletion(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.osmocom.org:29418/osmo-hlr refs/changes/08/16808/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/doc/examples/osmo-hlr.cfg b/doc/examples/osmo-hlr.cfg</span><br><span>index a685858..cf78e74 100644</span><br><span>--- a/doc/examples/osmo-hlr.cfg</span><br><span>+++ b/doc/examples/osmo-hlr.cfg</span><br><span>@@ -24,3 +24,4 @@</span><br><span>   bind ip 127.0.0.1</span><br><span>  ussd route prefix *#100# internal own-msisdn</span><br><span>  ussd route prefix *#101# internal own-imsi</span><br><span style="color: hsl(120, 100%, 40%);">+ imsi unknown cause 2</span><br><span>diff --git a/include/osmocom/hlr/hlr.h b/include/osmocom/hlr/hlr.h</span><br><span>index 0564518..ae3ce39 100644</span><br><span>--- a/include/osmocom/hlr/hlr.h</span><br><span>+++ b/include/osmocom/hlr/hlr.h</span><br><span>@@ -23,6 +23,7 @@</span><br><span> #pragma once</span><br><span> </span><br><span> #include <stdbool.h></span><br><span style="color: hsl(120, 100%, 40%);">+#include <osmocom/gsm/protocol/gsm_04_08_gprs.h></span><br><span> #include <osmocom/core/linuxlist.h></span><br><span> </span><br><span> #define HLR_DEFAULT_DB_FILE_PATH "hlr.db"</span><br><span>@@ -46,6 +47,7 @@</span><br><span> </span><br><span>   struct llist_head euse_list;</span><br><span>         struct hlr_euse *euse_default;</span><br><span style="color: hsl(120, 100%, 40%);">+        enum gsm48_gmm_cause imsi_unknown_cause;</span><br><span> </span><br><span>         /* NCSS (call independent) session guard timeout value */</span><br><span>    int ncss_guard_timeout;</span><br><span>diff --git a/src/hlr.c b/src/hlr.c</span><br><span>index 656f0a4..966267b 100644</span><br><span>--- a/src/hlr.c</span><br><span>+++ b/src/hlr.c</span><br><span>@@ -268,7 +268,7 @@</span><br><span>                       break;</span><br><span>               case -ENOENT:</span><br><span>                        LOGP(DAUC, LOGL_NOTICE, "%s: IMSI not known\n", gsup->imsi);</span><br><span style="color: hsl(0, 100%, 40%);">-                       gsup_out.cause = GMM_CAUSE_IMSI_UNKNOWN;</span><br><span style="color: hsl(120, 100%, 40%);">+                      gsup_out.cause = g_hlr->imsi_unknown_cause;</span><br><span>                       break;</span><br><span>               default:</span><br><span>                     LOGP(DAUC, LOGL_ERROR, "%s: failure to look up IMSI in db\n", gsup->imsi);</span><br><span>@@ -849,6 +849,7 @@</span><br><span>        INIT_LLIST_HEAD(&g_hlr->ss_sessions);</span><br><span>         INIT_LLIST_HEAD(&g_hlr->ussd_routes);</span><br><span>         g_hlr->db_file_path = talloc_strdup(g_hlr, HLR_DEFAULT_DB_FILE_PATH);</span><br><span style="color: hsl(120, 100%, 40%);">+      g_hlr->imsi_unknown_cause = GMM_CAUSE_IMSI_UNKNOWN;</span><br><span> </span><br><span>   /* Init default (call independent) SS session guard timeout value */</span><br><span>         g_hlr->ncss_guard_timeout = NCSS_GUARD_TIMEOUT_DEFAULT;</span><br><span>diff --git a/src/hlr_vty.c b/src/hlr_vty.c</span><br><span>index 6701cd9..9b1dac3 100644</span><br><span>--- a/src/hlr_vty.c</span><br><span>+++ b/src/hlr_vty.c</span><br><span>@@ -25,7 +25,10 @@</span><br><span>  *</span><br><span>  */</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+#include <errno.h></span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> #include <osmocom/core/talloc.h></span><br><span style="color: hsl(120, 100%, 40%);">+#include <osmocom/gsm/protocol/gsm_04_08_gprs.h></span><br><span> #include <osmocom/vty/vty.h></span><br><span> #include <osmocom/vty/stats.h></span><br><span> #include <osmocom/vty/command.h></span><br><span>@@ -73,6 +76,7 @@</span><br><span> static int config_write_hlr(struct vty *vty)</span><br><span> {</span><br><span>     vty_out(vty, "hlr%s", VTY_NEWLINE);</span><br><span style="color: hsl(120, 100%, 40%);">+ vty_out(vty, " imsi unknown cause %d%s", g_hlr->imsi_unknown_cause, VTY_NEWLINE);</span><br><span>       if (g_hlr->store_imei)</span><br><span>            vty_out(vty, " store-imei%s", VTY_NEWLINE);</span><br><span>        if (g_hlr->db_file_path && strcmp(g_hlr->db_file_path, HLR_DEFAULT_DB_FILE_PATH))</span><br><span>@@ -337,6 +341,29 @@</span><br><span>       return CMD_SUCCESS;</span><br><span> }</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+DEFUN(cfg_imsi_not_found_cause, cfg_imsi_not_found_cause_cmd,</span><br><span style="color: hsl(120, 100%, 40%);">+      "imsi unknown cause CAUSE",</span><br><span style="color: hsl(120, 100%, 40%);">+      "Define the GSUP cause to be send in case the IMSI could not found in the database."</span><br><span style="color: hsl(120, 100%, 40%);">+      "Default is 2 (GMM_CAUSE_IMSI_UNKNOWN). A good alternative is 13 (GMM_CAUSE_ROAMING_NOTALLOWED)."</span><br><span style="color: hsl(120, 100%, 40%);">+      )</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+ long int cause = 0;</span><br><span style="color: hsl(120, 100%, 40%);">+   char *endptr = NULL;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+        errno = 0;</span><br><span style="color: hsl(120, 100%, 40%);">+    cause = strtol(argv[0], &endptr, 0);</span><br><span style="color: hsl(120, 100%, 40%);">+      if (errno)</span><br><span style="color: hsl(120, 100%, 40%);">+            return -errno;</span><br><span style="color: hsl(120, 100%, 40%);">+        else if (*endptr)</span><br><span style="color: hsl(120, 100%, 40%);">+             return -EINVAL;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+     if (get_value_string_or_null(gsm48_gmm_cause_names, (uint32_t) cause) == NULL)</span><br><span style="color: hsl(120, 100%, 40%);">+                return -EINVAL;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+     g_hlr->imsi_unknown_cause = (enum gsm48_gmm_cause) cause;</span><br><span style="color: hsl(120, 100%, 40%);">+  return CMD_SUCCESS;</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> DEFUN(cfg_store_imei, cfg_store_imei_cmd,</span><br><span>        "store-imei",</span><br><span>      "Save the IMEI in the database when receiving Check IMEI requests. Note that an MSC does not necessarily send"</span><br><span>@@ -460,6 +487,7 @@</span><br><span>       install_element(HLR_NODE, &cfg_no_store_imei_cmd);</span><br><span>       install_element(HLR_NODE, &cfg_subscr_create_on_demand_cmd);</span><br><span>     install_element(HLR_NODE, &cfg_no_subscr_create_on_demand_cmd);</span><br><span style="color: hsl(120, 100%, 40%);">+   install_element(HLR_NODE, &cfg_imsi_not_found_cause_cmd);</span><br><span> </span><br><span>    hlr_vty_subscriber_init();</span><br><span> }</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.osmocom.org/c/osmo-hlr/+/16808">change 16808</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.osmocom.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.osmocom.org/c/osmo-hlr/+/16808"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: osmo-hlr </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-Change-Id: Icea39020c23fbbea9e92847df76af8986fdbf48a </div>
<div style="display:none"> Gerrit-Change-Number: 16808 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: lynxis lazus <lynxis@fe80.eu> </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>