Change in osmo-sip-connector[master]: mncc: add return code for write/send function

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
Thu Jan 14 20:27:24 UTC 2021


lynxis lazus has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-sip-connector/+/22202 )


Change subject: mncc: add return code for write/send function
......................................................................

mncc: add return code for write/send function

Allow to get errors back for the caller to clean up state.

Change-Id: Ic926d192c238ef84fb3ad2be27e507e010b0e93f
---
M src/mncc.c
1 file changed, 20 insertions(+), 10 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-sip-connector refs/changes/02/22202/1

diff --git a/src/mncc.c b/src/mncc.c
index 5456ac6..d3d218b 100644
--- a/src/mncc.c
+++ b/src/mncc.c
@@ -130,7 +130,7 @@
 	}
 }
 
-static void mncc_write(struct mncc_connection *conn, struct gsm_mncc *mncc)
+static int mncc_write(struct mncc_connection *conn, struct gsm_mncc *mncc)
 {
 	int rc;
 
@@ -144,17 +144,19 @@
 		LOGP(DMNCC, LOGL_ERROR, "Failed to send message for call(%u)\n", mncc->callref);
 		close_connection(conn);
 	}
+
+	return rc;
 }
 
-static void mncc_send(struct mncc_connection *conn, uint32_t msg_type, uint32_t callref)
+static int mncc_send(struct mncc_connection *conn, uint32_t msg_type, uint32_t callref)
 {
 	struct gsm_mncc mncc = { 0, };
 
 	mncc_fill_header(&mncc, msg_type, callref);
-	mncc_write(conn, &mncc);
+	return mncc_write(conn, &mncc);
 }
 
-static void mncc_rtp_send(struct mncc_connection *conn, uint32_t msg_type, uint32_t callref)
+static int mncc_rtp_send(struct mncc_connection *conn, uint32_t msg_type, uint32_t callref)
 {
 	int rc;
 	struct gsm_mncc_rtp mncc = { 0, };
@@ -167,6 +169,8 @@
 		LOGP(DMNCC, LOGL_ERROR, "Failed to send message for call(%u)\n", callref);
 		close_connection(conn);
 	}
+
+	return rc;
 }
 
 /* Send a MNCC_RTP_CONNECT to the MSC for the given call legs */
@@ -393,7 +397,8 @@
 	leg = mncc_find_leg_not_released(rtp->callref);
 	if (!leg) {
 		LOGP(DMNCC, LOGL_ERROR, "leg(%u) can not be found\n", rtp->callref);
-		return mncc_send(conn, MNCC_REJ_REQ, rtp->callref);
+		mncc_send(conn, MNCC_REJ_REQ, rtp->callref);
+		return;
 	}
 
 	/* extract information about where the RTP is */
@@ -426,7 +431,8 @@
 	leg = mncc_find_leg_not_released(rtp->callref);
 	if (!leg) {
 		LOGP(DMNCC, LOGL_ERROR, "call(%u) can not be found\n", rtp->callref);
-		return mncc_send(conn, MNCC_REJ_REQ, rtp->callref);
+		mncc_send(conn, MNCC_REJ_REQ, rtp->callref);
+		return;
 	}
 
 	/* extract information about where the RTP is */
@@ -488,7 +494,8 @@
 			LOGP(DMNCC, LOGL_ERROR,
 				"MNCC leg(%u) without called addr fields(%u)\n",
 				data->callref, data->fields);
-			return mncc_send(conn, MNCC_REJ_REQ, data->callref);
+			mncc_send(conn, MNCC_REJ_REQ, data->callref);
+			return;
 		}
 
 		/* Emergency without a called number present. Use the standard "emergency" number. */
@@ -499,14 +506,16 @@
 		LOGP(DMNCC, LOGL_ERROR,
 			"MNCC leg(%u) without calling addr fields(%u)\n",
 			data->callref, data->fields);
-		return mncc_send(conn, MNCC_REJ_REQ, data->callref);
+		mncc_send(conn, MNCC_REJ_REQ, data->callref);
+		return;
 	}
 
 	/* TODO.. bearer caps and better audio handling */
 	if (!continue_setup(conn, data)) {
 		LOGP(DMNCC, LOGL_ERROR,
 			"MNCC screening parameters failed leg(%u)\n", data->callref);
-		return mncc_send(conn, MNCC_REJ_REQ, data->callref);
+		mncc_send(conn, MNCC_REJ_REQ, data->callref);
+		return;
 	}
 
 	/* Create an RTP port and then allocate a call */
@@ -514,7 +523,8 @@
 	if (!call) {
 		LOGP(DMNCC, LOGL_ERROR,
 			"MNCC leg(%u) failed to allocate call\n", data->callref);
-		return mncc_send(conn, MNCC_REJ_REQ, data->callref);
+		mncc_send(conn, MNCC_REJ_REQ, data->callref);
+		return;
 	}
 
 	leg = (struct mncc_call_leg *) call->initial;

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

Gerrit-Project: osmo-sip-connector
Gerrit-Branch: master
Gerrit-Change-Id: Ic926d192c238ef84fb3ad2be27e507e010b0e93f
Gerrit-Change-Number: 22202
Gerrit-PatchSet: 1
Gerrit-Owner: lynxis lazus <lynxis at fe80.eu>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20210114/991a21f6/attachment.htm>


More information about the gerrit-log mailing list