<p>osmith has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.osmocom.org/12526">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">Optionally store IMEI in subscriber table<br><br>Add VTY config option "store-imei". When it is set, store the IMEI<br>sent from the VLR with CHECK-IMEI in the database.<br><br>Related: OS#2541<br>Change-Id: I09274ecbed64224f7ae305e09ede773931da2a57<br>---<br>M src/hlr.c<br>M src/hlr.h<br>M src/hlr_vty.c<br>3 files changed, 37 insertions(+), 2 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.osmocom.org:29418/osmo-hlr refs/changes/26/12526/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/src/hlr.c b/src/hlr.c</span><br><span>index ce5618a..b3e2fa8 100644</span><br><span>--- a/src/hlr.c</span><br><span>+++ b/src/hlr.c</span><br><span>@@ -258,6 +258,22 @@</span><br><span>      }</span><br><span> }</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+static void update_imei(const char *imsi, const char *imei)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+    struct hlr_subscriber subscr;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+       /* Check if subscriber is known */</span><br><span style="color: hsl(120, 100%, 40%);">+    if (db_subscr_get_by_imsi(g_hlr->dbc, imsi, &subscr) < 0) {</span><br><span style="color: hsl(120, 100%, 40%);">+         LOGP(DAUC, LOGL_ERROR, "Cannot set IMEI '%s' for unknown IMSI '%s'\n", imei, imsi);</span><br><span style="color: hsl(120, 100%, 40%);">+         return;</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%);">+   LOGP(DAUC, LOGL_DEBUG, "IMSI='%s': storing IMEI = %s\n", imsi, imei);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+     if (db_subscr_update_imei_by_id(g_hlr->dbc, subscr.id, imei))</span><br><span style="color: hsl(120, 100%, 40%);">+              LOGP(DAUC, LOGL_ERROR, "IMSI='%s': Cannot update IMEI in the database\n", imsi);</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> /*! Receive Update Location Request, creates new \ref lu_operation */</span><br><span> static int rx_upd_loc_req(struct osmo_gsup_conn *conn,</span><br><span>                     const struct osmo_gsup_message *gsup)</span><br><span>@@ -420,8 +436,11 @@</span><br><span>               return -1;</span><br><span>   }</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-   /* Only print the IMEI for now, it's planned to store it here (OS#2541) */</span><br><span style="color: hsl(0, 100%, 40%);">-  LOGP(DMAIN, LOGL_INFO, "%s: has IMEI: %s\n", gsup->imsi, imei);</span><br><span style="color: hsl(120, 100%, 40%);">+  /* Save in DB if desired */</span><br><span style="color: hsl(120, 100%, 40%);">+   if (g_hlr->store_imei)</span><br><span style="color: hsl(120, 100%, 40%);">+             update_imei(gsup->imsi, imei);</span><br><span style="color: hsl(120, 100%, 40%);">+     else</span><br><span style="color: hsl(120, 100%, 40%);">+          LOGP(DMAIN, LOGL_INFO, "%s: has IMEI: %s (consider setting 'store-imei 1')\n", gsup->imsi, imei);</span><br><span> </span><br><span>   /* Accept all IMEIs */</span><br><span>       gsup_reply.imei_result = OSMO_GSUP_IMEI_RESULT_ACK;</span><br><span>diff --git a/src/hlr.h b/src/hlr.h</span><br><span>index e9cc747..00fa43c 100644</span><br><span>--- a/src/hlr.h</span><br><span>+++ b/src/hlr.h</span><br><span>@@ -51,6 +51,8 @@</span><br><span>     struct llist_head ussd_routes;</span><br><span> </span><br><span>   struct llist_head ss_sessions;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+      bool store_imei;</span><br><span> };</span><br><span> </span><br><span> extern struct hlr *g_hlr;</span><br><span>diff --git a/src/hlr_vty.c b/src/hlr_vty.c</span><br><span>index 6706aa4..f556565 100644</span><br><span>--- a/src/hlr_vty.c</span><br><span>+++ b/src/hlr_vty.c</span><br><span>@@ -71,6 +71,8 @@</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%);">+ if (g_hlr->store_imei)</span><br><span style="color: hsl(120, 100%, 40%);">+             vty_out(vty, "  store-imei 1%s", VTY_NEWLINE);</span><br><span>     return CMD_SUCCESS;</span><br><span> }</span><br><span> </span><br><span>@@ -305,6 +307,17 @@</span><br><span>  return CMD_SUCCESS;</span><br><span> }</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+DEFUN(cfg_store_imei, cfg_store_imei_cmd,</span><br><span style="color: hsl(120, 100%, 40%);">+       "store-imei (0|1)",</span><br><span style="color: hsl(120, 100%, 40%);">+ "Save the IMEI in the database, when receiving Check IMEI requests. When using OsmoHLR with OsmoMSC, make sure"</span><br><span style="color: hsl(120, 100%, 40%);">+     " to set 'check-imei-rqd 1' in osmo-msc.cfg.\n"</span><br><span style="color: hsl(120, 100%, 40%);">+     "Do not save IMEIs in the subscriber database\n"</span><br><span style="color: hsl(120, 100%, 40%);">+    "Save IMEIs in the subscriber database\n")</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+       g_hlr->store_imei = atoi(argv[0]) ? true : false;</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> /***********************************************************************</span><br><span>  * Common Code</span><br><span>  ***********************************************************************/</span><br><span>@@ -368,6 +381,7 @@</span><br><span>    install_element(HLR_NODE, &cfg_ussd_defaultroute_cmd);</span><br><span>   install_element(HLR_NODE, &cfg_ussd_no_defaultroute_cmd);</span><br><span>        install_element(HLR_NODE, &cfg_ncss_guard_timeout_cmd);</span><br><span style="color: hsl(120, 100%, 40%);">+   install_element(HLR_NODE, &cfg_store_imei_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/12526">change 12526</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/12526"/><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-MessageType: newchange </div>
<div style="display:none"> Gerrit-Change-Id: I09274ecbed64224f7ae305e09ede773931da2a57 </div>
<div style="display:none"> Gerrit-Change-Number: 12526 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: osmith <osmith@sysmocom.de> </div>