[PATCH] libosmo-sccp[master]: SUA-to-SCCP: Fix use of Called/Calling vs. Src/Dest Address

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
Thu May 4 07:07:41 UTC 2017


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

SUA-to-SCCP: Fix use of Called/Calling vs. Src/Dest Address

SUA uses different semantics (source / destination) address, while SCCP
uses Calling/CalledParty. This leads to some confusion.  At least in the
CR/CORE and CREF/COREF case, the CallingParty equals the SRC_ADDR.

Change-Id: I1c641aac7b53c6de7c4e369aaf3004523bd85936
---
M src/sccp2sua.c
1 file changed, 24 insertions(+), 4 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmo-sccp refs/changes/69/2469/1

diff --git a/src/sccp2sua.c b/src/sccp2sua.c
index 753d9a4..499b55b 100644
--- a/src/sccp2sua.c
+++ b/src/sccp2sua.c
@@ -559,7 +559,7 @@
  *  \param msg caller-provided message buffer to which option is to be appended
  *  \param[in] opt xUA option/IE (messge part) to be converted+added
  *  \returns 0 in case of success; negative on error */
-static int sccp_msg_add_sua_opt(struct msgb *msg, struct xua_msg_part *opt)
+static int sccp_msg_add_sua_opt(enum sccp_message_types type, struct msgb *msg, struct xua_msg_part *opt)
 {
 	uint32_t tmp32;
 	uint8_t pnc, *lenptr;
@@ -575,7 +575,17 @@
 		msgb_put_u24be(msg, xua_msg_part_get_u32(opt));
 		break;
 	case SUA_IEI_DEST_ADDR:
-		msgb_put_u8(msg, SCCP_PNC_CALLED_PARTY_ADDRESS);
+		switch (type) {
+		case SCCP_MSG_TYPE_CC:
+		case SCCP_MSG_TYPE_CREF:
+			/* The Destination of a CC message is the
+			 * originator of the connection: Calling Party */
+			msgb_put_u8(msg, SCCP_PNC_CALLING_PARTY_ADDRESS);
+			break;
+		default:
+			msgb_put_u8(msg, SCCP_PNC_CALLED_PARTY_ADDRESS);
+			break;
+		}
 		lenptr = msgb_put(msg, 1);
 		rc = sua_addr_to_sccp(msg, opt);
 		if (rc < 0)
@@ -583,7 +593,17 @@
 		*lenptr = rc;
 		break;
 	case SUA_IEI_SRC_ADDR:
-		msgb_put_u8(msg, SCCP_PNC_CALLING_PARTY_ADDRESS);
+		switch (type) {
+		case SCCP_MSG_TYPE_CC:
+		case SCCP_MSG_TYPE_CREF:
+			/* The Source of a CC message is the
+			 * responder of the connection: Called Party */
+			msgb_put_u8(msg, SCCP_PNC_CALLED_PARTY_ADDRESS);
+			break;
+		default:
+			msgb_put_u8(msg, SCCP_PNC_CALLING_PARTY_ADDRESS);
+			break;
+		}
 		lenptr = msgb_put(msg, 1);
 		rc = sua_addr_to_sccp(msg, opt);
 		if (rc < 0)
@@ -935,7 +955,7 @@
 		 * that is already present in mandatory fixed or
 		 * mandatory variable parts of the header */
 		if (!sccp_is_mandatory(type, part) && sccp_option_permitted(type, part))
-			sccp_msg_add_sua_opt(msg, part);
+			sccp_msg_add_sua_opt(type, msg, part);
 	}
 	msgb_put_u8(msg, SCCP_PNC_END_OF_OPTIONAL);
 

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I1c641aac7b53c6de7c4e369aaf3004523bd85936
Gerrit-PatchSet: 1
Gerrit-Project: libosmo-sccp
Gerrit-Branch: master
Gerrit-Owner: Harald Welte <laforge at gnumonks.org>



More information about the gerrit-log mailing list