<p>Harald Welte <strong>merged</strong> this change.</p><p><a href="https://gerrit.osmocom.org/13106">View Change</a></p><div style="white-space:pre-wrap">Approvals:
  Jenkins Builder: Verified
  Harald Welte: Looks good to me, approved

</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">rspro_util: Add rspro_comp_id_retrieve()<br><br>This function can be used to obtain an 'sturct app_comp_id' from<br>received/decoded asn1c ComponentIdentity_t.<br><br>Change-Id: I7c68cee171a65cb83a802285531b677cdf37108b<br>---<br>M src/rspro_util.c<br>M src/rspro_util.h<br>2 files changed, 28 insertions(+), 0 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/src/rspro_util.c b/src/rspro_util.c</span><br><span>index 7001db8..efcc848 100644</span><br><span>--- a/src/rspro_util.c</span><br><span>+++ b/src/rspro_util.c</span><br><span>@@ -88,6 +88,32 @@</span><br><span>                 out->fwVersion = OCTET_STRING_new_fromBuf(&asn_DEF_ComponentName, in->fw_version, -1);</span><br><span> }</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+void string_fromOCTET_STRING(char *out, size_t out_size, const OCTET_STRING_t *in)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+      if (!in)</span><br><span style="color: hsl(120, 100%, 40%);">+              out[0] = '\0';</span><br><span style="color: hsl(120, 100%, 40%);">+        memcpy(out, in->buf, out_size < in->size ? out_size : in->size);</span><br><span style="color: hsl(120, 100%, 40%);">+  if (in->size < out_size)</span><br><span style="color: hsl(120, 100%, 40%);">+                out[in->size] = '\0';</span><br><span style="color: hsl(120, 100%, 40%);">+      else</span><br><span style="color: hsl(120, 100%, 40%);">+          out[out_size-1] = '\0';</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+#define string_fromOCTET_STRING_ARRAY(out, in) string_fromOCTET_STRING(out, ARRAY_SIZE(out), in)</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%);">+void rspro_comp_id_retrieve(struct app_comp_id *out, const ComponentIdentity_t *in)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+      memset(out, 0, sizeof(*out));</span><br><span style="color: hsl(120, 100%, 40%);">+ out->type = in->type;</span><br><span style="color: hsl(120, 100%, 40%);">+   string_fromOCTET_STRING_ARRAY(out->name, &in->name);</span><br><span style="color: hsl(120, 100%, 40%);">+        string_fromOCTET_STRING_ARRAY(out->software, &in->software);</span><br><span style="color: hsl(120, 100%, 40%);">+        string_fromOCTET_STRING_ARRAY(out->sw_version, &in->swVersion);</span><br><span style="color: hsl(120, 100%, 40%);">+     string_fromOCTET_STRING_ARRAY(out->hw_manufacturer, in->hwManufacturer);</span><br><span style="color: hsl(120, 100%, 40%);">+        string_fromOCTET_STRING_ARRAY(out->hw_serial_nr, in->hwSerialNr);</span><br><span style="color: hsl(120, 100%, 40%);">+       string_fromOCTET_STRING_ARRAY(out->hw_version, in->hwVersion);</span><br><span style="color: hsl(120, 100%, 40%);">+  string_fromOCTET_STRING_ARRAY(out->fw_version, in->fwVersion);</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> static void fill_ip4_port(IpPort_t *out, uint32_t ip, uint16_t port)</span><br><span> {</span><br><span>       uint32_t ip_n = htonl(ip);</span><br><span>diff --git a/src/rspro_util.h b/src/rspro_util.h</span><br><span>index 0e9a026..7a0c8ed 100644</span><br><span>--- a/src/rspro_util.h</span><br><span>+++ b/src/rspro_util.h</span><br><span>@@ -36,3 +36,5 @@</span><br><span>                               const uint8_t *tpdu, unsigned int tpdu_len);</span><br><span> RsproPDU_t *rspro_gen_TpduCard2Modem(const BankSlot_t *bank, const ClientSlot_t *client,</span><br><span>                                     const uint8_t *tpdu, unsigned int tpdu_len);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+void rspro_comp_id_retrieve(struct app_comp_id *out, const ComponentIdentity_t *in);</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.osmocom.org/13106">change 13106</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/13106"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: osmo-remsim </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-MessageType: merged </div>
<div style="display:none"> Gerrit-Change-Id: I7c68cee171a65cb83a802285531b677cdf37108b </div>
<div style="display:none"> Gerrit-Change-Number: 13106 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Harald Welte <laforge@gnumonks.org> </div>
<div style="display:none"> Gerrit-Reviewer: Harald Welte <laforge@gnumonks.org> </div>
<div style="display:none"> Gerrit-Reviewer: Jenkins Builder (1000002) </div>