[MERGED] libosmo-sccp[master]: sua.c: Replace sua_msgb_alloc() with new sccp_msgb_alloc()

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
Mon Apr 10 11:03:01 UTC 2017


Harald Welte has submitted this change and it was merged.

Change subject: sua.c: Replace sua_msgb_alloc() with new sccp_msgb_alloc()
......................................................................


sua.c: Replace sua_msgb_alloc() with new sccp_msgb_alloc()

Change-Id: I7067a85dcc5dda66f4b17b0fe08da8cb3efe79ef
---
M src/Makefile.am
A src/sccp_internal.h
M src/sua.c
3 files changed, 24 insertions(+), 15 deletions(-)

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



diff --git a/src/Makefile.am b/src/Makefile.am
index f7f4ccc..ec3fe99 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1,7 +1,7 @@
 AM_CPPFLAGS = $(all_includes) -I$(top_srcdir)/include -I$(top_builddir)
 AM_CFLAGS=-Wall $(LIBOSMOCORE_CFLAGS) $(LIBOSMONETIF_CFLAGS)
 
-noinst_HEADERS = xua_asp_fsm.h xua_as_fsm.h xua_internal.h
+noinst_HEADERS = sccp_internal.h xua_asp_fsm.h xua_as_fsm.h xua_internal.h
 
 # Legacy static libs
 
diff --git a/src/sccp_internal.h b/src/sccp_internal.h
new file mode 100644
index 0000000..7287a82
--- /dev/null
+++ b/src/sccp_internal.h
@@ -0,0 +1,5 @@
+#pragma once
+
+#include <osmocom/core/msgb.h>
+
+struct msgb *sccp_msgb_alloc(const char *name);
diff --git a/src/sua.c b/src/sua.c
index 0be5467..0f42d63 100644
--- a/src/sua.c
+++ b/src/sua.c
@@ -51,6 +51,17 @@
 #define GUARD_TIMER		(23 * 60 * 100)
 #define RESET_TIMER		(     10 * 100)
 
+#define SCCP_MSG_SIZE 2048
+#define SCCP_MSG_HEADROOM 512
+
+struct msgb *sccp_msgb_alloc(const char *name)
+{
+	if (!name)
+		name = "SCCP";
+	return msgb_alloc_headroom(SCCP_MSG_SIZE+SCCP_MSG_HEADROOM,
+				   SCCP_MSG_HEADROOM, name);
+}
+
 /***********************************************************************
  * Protocol Definition (string tables, mandatory IE checking)
  ***********************************************************************/
@@ -431,13 +442,6 @@
 	conn_restart_tx_inact_timer(conn);
 	conn_restart_rx_inact_timer(conn);
 }
-
-
-static struct msgb *sua_msgb_alloc(void)
-{
-	return msgb_alloc(SUA_MSGB_SIZE, "SUA Primitive");
-}
-
 
 /***********************************************************************
  * Handling of messages from the User SAP
@@ -871,7 +875,7 @@
 	struct osmo_scu_prim *prim;
 	struct osmo_scu_unitdata_param *param;
 	struct xua_msg_part *data_ie = xua_msg_find_tag(xua, SUA_IEI_DATA);
-	struct msgb *upmsg = sua_msgb_alloc();
+	struct msgb *upmsg = sccp_msgb_alloc(__func__);
 	uint32_t protocol_class;
 
 	/* fill primitive */
@@ -932,7 +936,7 @@
 	conn->remote_ref = xua_msg_get_u32(xua, SUA_IEI_SRC_REF);
 
 	/* fill primitive */
-	upmsg = sua_msgb_alloc();
+	upmsg = sccp_msgb_alloc(__func__);
 	prim = (struct osmo_scu_prim *) msgb_put(upmsg, sizeof(*prim));
 	param = &prim->u.connect;
 	osmo_prim_init(&prim->oph, SCCP_SAP_USER,
@@ -992,7 +996,7 @@
 	conn->remote_ref = xua_msg_get_u32(xua, SUA_IEI_SRC_REF);
 
 	/* fill primitive */
-	upmsg = sua_msgb_alloc();
+	upmsg = sccp_msgb_alloc(__func__);
 	prim = (struct osmo_scu_prim *) msgb_put(upmsg, sizeof(*prim));
 	param = &prim->u.connect;
 	osmo_prim_init(&prim->oph, SCCP_SAP_USER,
@@ -1044,7 +1048,7 @@
 	conn_restart_rx_inact_timer(conn);
 
 	/* fill primitive */
-	upmsg = sua_msgb_alloc();
+	upmsg = sccp_msgb_alloc(__func__);
 	prim = (struct osmo_scu_prim *) msgb_put(upmsg, sizeof(*prim));
 	param = &prim->u.disconnect;
 	osmo_prim_init(&prim->oph, SCCP_SAP_USER,
@@ -1095,7 +1099,7 @@
 	}
 
 	/* fill primitive */
-	upmsg = sua_msgb_alloc();
+	upmsg = sccp_msgb_alloc(__func__);
 	prim = (struct osmo_scu_prim *) msgb_put(upmsg, sizeof(*prim));
 	param = &prim->u.disconnect;
 	osmo_prim_init(&prim->oph, SCCP_SAP_USER,
@@ -1144,7 +1148,7 @@
 	conn_restart_rx_inact_timer(conn);
 
 	/* fill primitive */
-	upmsg = sua_msgb_alloc();
+	upmsg = sccp_msgb_alloc(__func__);
 	prim = (struct osmo_scu_prim *) msgb_put(upmsg, sizeof(*prim));
 	param = &prim->u.disconnect;
 	osmo_prim_init(&prim->oph, SCCP_SAP_USER,
@@ -1196,7 +1200,7 @@
 	conn_restart_rx_inact_timer(conn);
 
 	/* fill primitive */
-	upmsg = sua_msgb_alloc();
+	upmsg = sccp_msgb_alloc(__func__);
 	prim = (struct osmo_scu_prim *) msgb_put(upmsg, sizeof(*prim));
 	param = &prim->u.data;
 	osmo_prim_init(&prim->oph, SCCP_SAP_USER,

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I7067a85dcc5dda66f4b17b0fe08da8cb3efe79ef
Gerrit-PatchSet: 6
Gerrit-Project: libosmo-sccp
Gerrit-Branch: master
Gerrit-Owner: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder



More information about the gerrit-log mailing list