diff options
author | Harald Welte <laforge@osmocom.org> | 2021-05-11 21:00:51 +0200 |
---|---|---|
committer | Harald Welte <laforge@osmocom.org> | 2021-05-13 22:00:14 +0200 |
commit | 2f8b645ecb6703e1c7d97ca12550272c7a499c30 (patch) | |
tree | a74bdf4f6cdb632e2f38b070886d0dbf0eef076f | |
parent | 3639af549c0315ca2f66e64f7bf19f216a3f857f (diff) |
sccp_scrc: Ensure we have not just SSN but at least OPC+SSN in CallingParty
There are implementations out there which send us traffic, specifically
in this case SCMG (SST) that has only SSN in both Called and Calling
Party. This means the inbound SST message is routed correctly to the
local SCCP user of libosmo-sigtran. But when that local SCCP user
responds with inverting Called/Calling Party, the new destination again
just contains a SSN.
As a result, we don't know where to route the message (we always need a PC).
Change-Id: Id66ae960ebe3cb3b09c6dd5454f9ac9c073f46d7
Closes: OS#5146
-rw-r--r-- | src/sccp_scrc.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/sccp_scrc.c b/src/sccp_scrc.c index b46b4f2..1da3890 100644 --- a/src/sccp_scrc.c +++ b/src/sccp_scrc.c @@ -440,6 +440,26 @@ int sccp_scrc_rx_sclc_msg(struct osmo_sccp_instance *inst, return scrc_local_out_common(inst, xua, &called); } +/* ensure the CallingParty address doesn't just contain SSN, but at least SSN+PC */ +static void ensure_opc_in_calling_ssn(struct osmo_sccp_instance *inst, + struct xua_msg *xua) +{ + struct osmo_sccp_addr calling; + + sua_addr_parse(&calling, xua, SUA_IEI_SRC_ADDR); + + /* if we route on SSN and only have a SSN in the address... */ + if (calling.ri == OSMO_SCCP_RI_SSN_PC && + calling.presence == OSMO_SCCP_ADDR_T_SSN) { + /* add the M3UA OPC to the address to ensure that the recipient + * can actually respond back to the source */ + calling.presence |= OSMO_SCCP_ADDR_T_PC; + calling.pc = xua->mtp.opc; + xua_msg_free_tag(xua, SUA_IEI_SRC_ADDR); + xua_msg_add_sccp_addr(xua, SUA_IEI_SRC_ADDR, &calling); + } +} + /* Figure C.1/Q.714 Sheet 1 of 12, after we converted the * MTP-TRANSFER.ind to SUA. */ int scrc_rx_mtp_xfer_ind_xua(struct osmo_sccp_instance *inst, @@ -461,6 +481,9 @@ int scrc_rx_mtp_xfer_ind_xua(struct osmo_sccp_instance *inst, } /* We only treat connectionless and CR below */ + /* ensure we have at least OPC+SSN and not just SSN in CallingParty (OS#5146) */ + ensure_opc_in_calling_ssn(inst, xua); + sua_addr_parse(&called, xua, SUA_IEI_DEST_ADDR); /* Route on GT? */ |