Change in osmo-bsc[master]: abis_nm_ipaccess_rsl_connect(): use msgb to compose attr

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/.

laforge gerrit-no-reply at lists.osmocom.org
Tue Apr 27 14:04:01 UTC 2021


laforge has submitted this change. ( https://gerrit.osmocom.org/c/osmo-bsc/+/23730 )

Change subject: abis_nm_ipaccess_rsl_connect(): use msgb to compose attr
......................................................................

abis_nm_ipaccess_rsl_connect(): use msgb to compose attr

So far the function uses insane byte array magic numbers to compose the
OML "RSL Connect" message. For VAMOS, I intend to modify that message.
To ensure sanity, first change the attr composition to msgb_put*().

Related: OS#4940
Change-Id: Iba005635cf86aee1fde77d58ef203e28eed92281
---
M src/osmo-bsc/abis_nm.c
1 file changed, 10 insertions(+), 13 deletions(-)

Approvals:
  laforge: Looks good to me, approved
  fixeria: Looks good to me, but someone else must approve
  dexter: Looks good to me, but someone else must approve
  pespin: Looks good to me, but someone else must approve
  Jenkins Builder: Verified



diff --git a/src/osmo-bsc/abis_nm.c b/src/osmo-bsc/abis_nm.c
index ba1075a..4fba55c 100644
--- a/src/osmo-bsc/abis_nm.c
+++ b/src/osmo-bsc/abis_nm.c
@@ -3014,32 +3014,29 @@
 int abis_nm_ipaccess_rsl_connect(struct gsm_bts_trx *trx,
 				 uint32_t ip, uint16_t port, uint8_t stream)
 {
+	struct msgb *attr;
 	struct in_addr ia;
-	uint8_t attr[] = { NM_ATT_IPACC_STREAM_ID, 0,
-			    NM_ATT_IPACC_DST_IP_PORT, 0, 0,
-			    NM_ATT_IPACC_DST_IP, 0, 0, 0, 0 };
-
-	int attr_len = sizeof(attr);
 	int error;
 
 	osmo_timer_setup(&trx->rsl_connect_timeout, rsl_connect_timeout, trx);
 
-	ia.s_addr = htonl(ip);
-	attr[1] = stream;
-	attr[3] = port >> 8;
-	attr[4] = port & 0xff;
-	memcpy(attr + 6, &ia.s_addr, sizeof(uint32_t));
+	attr = msgb_alloc(32, "RSL-connect-attr");
+	msgb_tv_put(attr, NM_ATT_IPACC_STREAM_ID, stream);
+	msgb_tv16_put(attr, NM_ATT_IPACC_DST_IP_PORT, port);
 
 	/* if ip == 0, we use the default IP */
-	if (ip == 0)
-		attr_len -= 5;
+	if (ip != 0) {
+		ia.s_addr = htonl(ip);
+		msgb_tv_fixed_put(attr, NM_ATT_IPACC_DST_IP, 4, (void*)&ia.s_addr);
+	}
 
 	LOG_TRX(trx, DNM, LOGL_INFO, "IPA RSL CONNECT IP=%s PORT=%u STREAM=0x%02x\n",
 		inet_ntoa(ia), port, stream);
 
 	error = abis_nm_ipaccess_msg(trx->bts, NM_MT_IPACC_RSL_CONNECT,
 				     NM_OC_BASEB_TRANSC, trx->bts->bts_nr,
-				     trx->nr, 0xff, attr, attr_len);
+				     trx->nr, 0xff, attr->data, attr->len);
+	msgb_free(attr);
 	if (error == 0)
 		osmo_timer_schedule(&trx->rsl_connect_timeout, 60, 0);
 

-- 
To view, visit https://gerrit.osmocom.org/c/osmo-bsc/+/23730
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-bsc
Gerrit-Branch: master
Gerrit-Change-Id: Iba005635cf86aee1fde77d58ef203e28eed92281
Gerrit-Change-Number: 23730
Gerrit-PatchSet: 4
Gerrit-Owner: neels <nhofmeyr at sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: dexter <pmaier at sysmocom.de>
Gerrit-Reviewer: fixeria <vyanitskiy at sysmocom.de>
Gerrit-Reviewer: laforge <laforge at osmocom.org>
Gerrit-Reviewer: pespin <pespin at sysmocom.de>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20210427/bdbbca85/attachment.htm>


More information about the gerrit-log mailing list