Change in osmo-sgsn[master]: Drop gprs_msgb_resize_area with libosmocore replacement

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

Pau Espin Pedrol gerrit-no-reply at lists.osmocom.org
Wed Aug 15 12:12:35 UTC 2018


Pau Espin Pedrol has uploaded this change for review. ( https://gerrit.osmocom.org/10462


Change subject: Drop gprs_msgb_resize_area with libosmocore replacement
......................................................................

Drop gprs_msgb_resize_area with libosmocore replacement

gprs_msgb_resize_area was introduced in libosmocore 0.94
(f78ec5ce0d0f6038147d9b9e14d81094309ba5d5) as msgb_resize_area. Let's use
that one to avoid code duplication.

Change-Id: Ib80f7b2b186d87f21d63d9b0bec58175170c905c
---
M include/osmocom/sgsn/gprs_utils.h
M src/gprs/gb_proxy_patch.c
M src/gprs/gprs_utils.c
3 files changed, 2 insertions(+), 40 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-sgsn refs/changes/62/10462/1

diff --git a/include/osmocom/sgsn/gprs_utils.h b/include/osmocom/sgsn/gprs_utils.h
index 8e47e90..eacaec7 100644
--- a/include/osmocom/sgsn/gprs_utils.h
+++ b/include/osmocom/sgsn/gprs_utils.h
@@ -29,8 +29,6 @@
 struct msgb;
 struct gprs_ra_id;
 
-int gprs_msgb_resize_area(struct msgb *msg, uint8_t *area,
-			    size_t old_size, size_t new_size);
 int gprs_str_to_apn(uint8_t *apn_enc, size_t max_len, const char *str);
 
 /* GSM 04.08, 10.5.7.3 GPRS Timer */
diff --git a/src/gprs/gb_proxy_patch.c b/src/gprs/gb_proxy_patch.c
index 496f605..9cca9a8 100644
--- a/src/gprs/gb_proxy_patch.c
+++ b/src/gprs/gb_proxy_patch.c
@@ -112,7 +112,7 @@
 		     osmo_apn_to_str(str1, apn, apn_len));
 
 		*new_apn_ie_len = 0;
-		gprs_msgb_resize_area(msg, apn_ie, apn_ie_len, 0);
+		msgb_resize_area(msg, apn_ie, apn_ie_len, 0);
 	} else {
 		/* Resize the IE */
 		char str1[110];
@@ -129,7 +129,7 @@
 				       peer->cfg->core_apn_size));
 
 		*new_apn_ie_len = peer->cfg->core_apn_size + 2;
-		gprs_msgb_resize_area(msg, apn, apn_len, peer->cfg->core_apn_size);
+		msgb_resize_area(msg, apn, apn_len, peer->cfg->core_apn_size);
 		memcpy(apn, peer->cfg->core_apn, peer->cfg->core_apn_size);
 		hdr->apn_len = peer->cfg->core_apn_size;
 	}
@@ -463,4 +463,3 @@
 
 	return 1;
 }
-
diff --git a/src/gprs/gprs_utils.c b/src/gprs/gprs_utils.c
index c4b66d6..13641c1 100644
--- a/src/gprs/gprs_utils.c
+++ b/src/gprs/gprs_utils.c
@@ -30,41 +30,6 @@
 
 #include <string.h>
 
-/* TODO: Move this to libosmocore/msgb.c */
-int gprs_msgb_resize_area(struct msgb *msg, uint8_t *area,
-			    size_t old_size, size_t new_size)
-{
-	int rc;
-	uint8_t *rest = area + old_size;
-	int rest_len = msg->len - old_size - (area - msg->data);
-	int delta_size = (int)new_size - (int)old_size;
-
-	if (delta_size == 0)
-		return 0;
-
-	if (delta_size > 0) {
-		rc = msgb_trim(msg, msg->len + delta_size);
-		if (rc < 0)
-			return rc;
-	}
-
-	memmove(area + new_size, area + old_size, rest_len);
-
-	if (msg->l1h >= rest)
-		msg->l1h += delta_size;
-	if (msg->l2h >= rest)
-		msg->l2h += delta_size;
-	if (msg->l3h >= rest)
-		msg->l3h += delta_size;
-	if (msg->l4h >= rest)
-		msg->l4h += delta_size;
-
-	if (delta_size < 0)
-		msgb_trim(msg, msg->len + delta_size);
-
-	return 0;
-}
-
 int gprs_str_to_apn(uint8_t *apn_enc, size_t max_len, const char *str)
 {
 	uint8_t *last_len_field;

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

Gerrit-Project: osmo-sgsn
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ib80f7b2b186d87f21d63d9b0bec58175170c905c
Gerrit-Change-Number: 10462
Gerrit-PatchSet: 1
Gerrit-Owner: Pau Espin Pedrol <pespin at sysmocom.de>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20180815/81076f39/attachment.htm>


More information about the gerrit-log mailing list