aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorHarald Welte <laforge@gnumonks.org>2017-05-04 09:06:09 +0200
committerHarald Welte <laforge@gnumonks.org>2017-05-04 09:07:21 +0200
commit872c6b2a8e309ca6739ef295f1fc468c189e4ec9 (patch)
treed998f10f7fb7de31d848f3679e1a012785391a4f /src
parent5527df78adc08b76df07c4b682263b5bdd6181d4 (diff)
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
Diffstat (limited to 'src')
-rw-r--r--src/sccp2sua.c28
1 files changed, 24 insertions, 4 deletions
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 @@ static void msgb_put_sccp_opt(struct msgb *msg, uint8_t pnc, uint8_t len, const
* \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 @@ static int sccp_msg_add_sua_opt(struct msgb *msg, struct xua_msg_part *opt)
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 @@ static int sccp_msg_add_sua_opt(struct msgb *msg, struct xua_msg_part *opt)
*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 @@ static int xua_ies_to_sccp_opts(struct msgb *msg, uint8_t *ptr_opt,
* 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);