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

neels gerrit-no-reply at lists.osmocom.org
Mon Apr 12 12:48:53 UTC 2021


neels has uploaded this change for review. ( 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, 9 insertions(+), 13 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-bsc refs/changes/30/23730/1

diff --git a/src/osmo-bsc/abis_nm.c b/src/osmo-bsc/abis_nm.c
index ba1075a..a5407ed 100644
--- a/src/osmo-bsc/abis_nm.c
+++ b/src/osmo-bsc/abis_nm.c
@@ -3014,32 +3014,28 @@
 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_c(OTC_SELECT, 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);
 	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: 1
Gerrit-Owner: neels <nhofmeyr at sysmocom.de>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20210412/1d92a506/attachment.htm>


More information about the gerrit-log mailing list