Change in osmo-remsim[master]: rspro_util: Add rspro_comp_id_retrieve()

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

Harald Welte gerrit-no-reply at lists.osmocom.org
Thu Mar 7 17:35:00 UTC 2019


Harald Welte has submitted this change and it was merged. ( https://gerrit.osmocom.org/13106 )

Change subject: rspro_util: Add rspro_comp_id_retrieve()
......................................................................

rspro_util: Add rspro_comp_id_retrieve()

This function can be used to obtain an 'sturct app_comp_id' from
received/decoded asn1c ComponentIdentity_t.

Change-Id: I7c68cee171a65cb83a802285531b677cdf37108b
---
M src/rspro_util.c
M src/rspro_util.h
2 files changed, 28 insertions(+), 0 deletions(-)

Approvals:
  Jenkins Builder: Verified
  Harald Welte: Looks good to me, approved



diff --git a/src/rspro_util.c b/src/rspro_util.c
index 7001db8..efcc848 100644
--- a/src/rspro_util.c
+++ b/src/rspro_util.c
@@ -88,6 +88,32 @@
 		out->fwVersion = OCTET_STRING_new_fromBuf(&asn_DEF_ComponentName, in->fw_version, -1);
 }
 
+void string_fromOCTET_STRING(char *out, size_t out_size, const OCTET_STRING_t *in)
+{
+	if (!in)
+		out[0] = '\0';
+	memcpy(out, in->buf, out_size < in->size ? out_size : in->size);
+	if (in->size < out_size)
+		out[in->size] = '\0';
+	else
+		out[out_size-1] = '\0';
+}
+#define string_fromOCTET_STRING_ARRAY(out, in) string_fromOCTET_STRING(out, ARRAY_SIZE(out), in)
+
+
+void rspro_comp_id_retrieve(struct app_comp_id *out, const ComponentIdentity_t *in)
+{
+	memset(out, 0, sizeof(*out));
+	out->type = in->type;
+	string_fromOCTET_STRING_ARRAY(out->name, &in->name);
+	string_fromOCTET_STRING_ARRAY(out->software, &in->software);
+	string_fromOCTET_STRING_ARRAY(out->sw_version, &in->swVersion);
+	string_fromOCTET_STRING_ARRAY(out->hw_manufacturer, in->hwManufacturer);
+	string_fromOCTET_STRING_ARRAY(out->hw_serial_nr, in->hwSerialNr);
+	string_fromOCTET_STRING_ARRAY(out->hw_version, in->hwVersion);
+	string_fromOCTET_STRING_ARRAY(out->fw_version, in->fwVersion);
+}
+
 static void fill_ip4_port(IpPort_t *out, uint32_t ip, uint16_t port)
 {
 	uint32_t ip_n = htonl(ip);
diff --git a/src/rspro_util.h b/src/rspro_util.h
index 0e9a026..7a0c8ed 100644
--- a/src/rspro_util.h
+++ b/src/rspro_util.h
@@ -36,3 +36,5 @@
 				     const uint8_t *tpdu, unsigned int tpdu_len);
 RsproPDU_t *rspro_gen_TpduCard2Modem(const BankSlot_t *bank, const ClientSlot_t *client,
 				     const uint8_t *tpdu, unsigned int tpdu_len);
+
+void rspro_comp_id_retrieve(struct app_comp_id *out, const ComponentIdentity_t *in);

-- 
To view, visit https://gerrit.osmocom.org/13106
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-remsim
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I7c68cee171a65cb83a802285531b677cdf37108b
Gerrit-Change-Number: 13106
Gerrit-PatchSet: 1
Gerrit-Owner: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder (1000002)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20190307/fe4a1fec/attachment.htm>


More information about the gerrit-log mailing list