[PATCH] openbsc[master]: pcu_sock: reorganize calculation of paging group

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

lynxis lazus gerrit-no-reply at lists.osmocom.org
Tue Mar 14 14:41:40 UTC 2017


Review at  https://gerrit.osmocom.org/2067

pcu_sock: reorganize calculation of paging group

pcu_sock.c:pcu_rx_data_req() needs to calculate the paging group
at two positions, this commit adds a functions for that to avoid
code duplication

Change-Id: Iee8926d5bc017d912912916e4898e968bf4dd29b
---
M openbsc/src/libbsc/pcu_sock.c
1 file changed, 23 insertions(+), 22 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/openbsc refs/changes/67/2067/1

diff --git a/openbsc/src/libbsc/pcu_sock.c b/openbsc/src/libbsc/pcu_sock.c
index 7f9119f..ac14ba2 100644
--- a/openbsc/src/libbsc/pcu_sock.c
+++ b/openbsc/src/libbsc/pcu_sock.c
@@ -353,14 +353,30 @@
 	return rc;
 }
 
+/* Helper function for pcu_rx_data_req() to extract paging group info */
+static uint8_t extract_paging_group(struct gsm_bts *bts, uint8_t *data)
+{
+	char imsi_digit_buf[4];
+	uint8_t pag_grp;
+
+	/* the first three bytes are the last three digits of
+	 * the IMSI, which we need to compute the paging group */
+	imsi_digit_buf[0] = data[0];
+	imsi_digit_buf[1] = data[1];
+	imsi_digit_buf[2] = data[2];
+	imsi_digit_buf[3] = '\0';
+
+	pag_grp = gsm0502_calc_paging_group(&bts->si_common.chan_desc,
+					    str_to_imsi(imsi_digit_buf));
+
+	return pag_grp;
+}
+
+
 static int pcu_rx_data_req(struct gsm_bts *bts, uint8_t msg_type,
 	struct gsm_pcu_if_data *data_req)
 {
-	uint8_t is_ptcch;
-	struct gsm_bts_trx *trx;
-	struct gsm_bts_trx_ts *ts;
 	struct msgb *msg;
-	char imsi_digit_buf[4];
 	uint32_t tlli = -1;
 	uint8_t pag_grp;
 	int rc = 0;
@@ -372,15 +388,7 @@
 
 	switch (data_req->sapi) {
 	case PCU_IF_SAPI_PCH:
-		/* the first three bytes are the last three digits of
-		 * the IMSI, which we need to compute the paging group */
-		imsi_digit_buf[0] = data_req->data[0];
-		imsi_digit_buf[1] = data_req->data[1];
-		imsi_digit_buf[2] = data_req->data[2];
-		imsi_digit_buf[3] = '\0';
-		LOGP(DPCU, LOGL_DEBUG, "SAPI PCH imsi %s\n", imsi_digit_buf);
-		pag_grp = gsm0502_calc_paging_group(&bts->si_common.chan_desc,
-						str_to_imsi(imsi_digit_buf));
+		pag_grp = extract_paging_group(bts,data_req->data);
 		pcu_rx_rr_paging(bts, pag_grp, data_req->data+3);
 		break;
 	case PCU_IF_SAPI_AGCH:
@@ -406,16 +414,9 @@
 					"invalid/small length %d\n", data_req->len);
 			break;
 		}
-		tlli = *((uint32_t *)data_req->data);
 
-		/* the first three bytes are the last three digits of
-		 * the IMSI, which we need to compute the paging group */
-		imsi_digit_buf[0] = data_req->data[4];
-		imsi_digit_buf[1] = data_req->data[5];
-		imsi_digit_buf[2] = data_req->data[6];
-		imsi_digit_buf[3] = '\0';
-		pag_grp = gsm0502_calc_paging_group(&bts->si_common.chan_desc,
-						str_to_imsi(imsi_digit_buf));
+		memcpy(&tlli, data_req->data, sizeof(tlli));
+		pag_grp = extract_paging_group(bts,data_req->data+4);
 
 		msg = msgb_alloc(data_req->len - 7, "pcu_pch");
 		if (!msg) {

-- 
To view, visit https://gerrit.osmocom.org/2067
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Iee8926d5bc017d912912916e4898e968bf4dd29b
Gerrit-PatchSet: 1
Gerrit-Project: openbsc
Gerrit-Branch: master
Gerrit-Owner: lynxis lazus <lynxis at fe80.eu>
Gerrit-Reviewer: dexter <pmaier at sysmocom.de>



More information about the gerrit-log mailing list