pespin has submitted this change. ( https://gerrit.osmocom.org/c/libosmo-sigtran/+/41519?usp=email )
Change subject: Split code to sua_gen_cldr() helper function ......................................................................
Split code to sua_gen_cldr() helper function
This will be used to send back UDTS to originator of TCAP msg during TCAP loadshare routing if no ASP serving a given TID is found.
Change-Id: I171381991308e3bb54f76afc92ccad3fcae6dcbb --- M src/sccp_sclc.c M src/sua.c M src/xua_internal.h 3 files changed, 51 insertions(+), 41 deletions(-)
Approvals: daniel: Looks good to me, but someone else must approve pespin: Looks good to me, approved laforge: Looks good to me, but someone else must approve Jenkins Builder: Verified
diff --git a/src/sccp_sclc.c b/src/sccp_sclc.c index 0a47cd9..704c4bb 100644 --- a/src/sccp_sclc.c +++ b/src/sccp_sclc.c @@ -344,47 +344,7 @@ const struct xua_msg *xua_in, uint32_t ret_cause) { - struct xua_msg *xua_out = xua_msg_alloc(); - struct osmo_sccp_addr called; - - xua_out->hdr = XUA_HDR(SUA_MSGC_CL, SUA_CL_CLDR); - xua_msg_add_u32(xua_out, SUA_IEI_ROUTE_CTX, inst->route_ctx); - xua_msg_add_u32(xua_out, SUA_IEI_CAUSE, - SUA_CAUSE_T_RETURN | ret_cause); - /* Swap Calling and Called Party */ - xua_msg_copy_part(xua_out, SUA_IEI_SRC_ADDR, xua_in, SUA_IEI_DEST_ADDR); - xua_msg_copy_part(xua_out, SUA_IEI_DEST_ADDR, xua_in, SUA_IEI_SRC_ADDR); - /* TODO: Optional: Hop Count */ - /* Optional: Importance */ - xua_msg_copy_part(xua_out, SUA_IEI_IMPORTANCE, - xua_in, SUA_IEI_IMPORTANCE); - /* Optional: Message Priority */ - xua_msg_copy_part(xua_out, SUA_IEI_MSG_PRIO, xua_in, SUA_IEI_MSG_PRIO); - /* Optional: Correlation ID */ - xua_msg_copy_part(xua_out, SUA_IEI_CORR_ID, xua_in, SUA_IEI_CORR_ID); - /* Optional: Segmentation */ - xua_msg_copy_part(xua_out, SUA_IEI_SEGMENTATION, - xua_in, SUA_IEI_SEGMENTATION); - /* Optional: Data */ - xua_msg_copy_part(xua_out, SUA_IEI_DATA, xua_in, SUA_IEI_DATA); - - OSMO_ASSERT(sua_addr_parse(&called, xua_out, SUA_IEI_DEST_ADDR) == 0); - - /* Route on PC + SSN ? */ - if (called.ri == OSMO_SCCP_RI_SSN_PC) { - /* if no PC, copy OPC into called addr */ - if (!(called.presence & OSMO_SCCP_ADDR_T_PC)) { - struct osmo_sccp_addr calling; - OSMO_ASSERT(sua_addr_parse(&calling, xua_out, SUA_IEI_SRC_ADDR) == 0); - called.presence |= OSMO_SCCP_ADDR_T_PC; - called.pc = calling.pc; - /* Re-encode / replace called address */ - xua_msg_free_tag(xua_out, SUA_IEI_DEST_ADDR); - xua_msg_add_sccp_addr(xua_out, SUA_IEI_DEST_ADDR, - &called); - } - } - return xua_out; + return sua_gen_cldr(xua_in, inst->route_ctx, ret_cause); }
/*! \brief SCRC -> SCLC (Routing Failure diff --git a/src/sua.c b/src/sua.c index e157f31..e81590d 100644 --- a/src/sua.c +++ b/src/sua.c @@ -262,6 +262,54 @@ return xua; }
+/* generate a return/refusal message (SUA CLDR == SCCP UDTS) based on + * the incoming message. We need to flip all identities between sender + * and receiver */ +struct xua_msg *sua_gen_cldr(const struct xua_msg *xua_in, uint32_t route_ctx, uint32_t ret_cause) +{ + struct xua_msg *xua_out = xua_msg_alloc(); + struct osmo_sccp_addr called; + + xua_out->hdr = XUA_HDR(SUA_MSGC_CL, SUA_CL_CLDR); + xua_msg_add_u32(xua_out, SUA_IEI_ROUTE_CTX, route_ctx); + xua_msg_add_u32(xua_out, SUA_IEI_CAUSE, + SUA_CAUSE_T_RETURN | ret_cause); + /* Swap Calling and Called Party */ + xua_msg_copy_part(xua_out, SUA_IEI_SRC_ADDR, xua_in, SUA_IEI_DEST_ADDR); + xua_msg_copy_part(xua_out, SUA_IEI_DEST_ADDR, xua_in, SUA_IEI_SRC_ADDR); + /* TODO: Optional: Hop Count */ + /* Optional: Importance */ + xua_msg_copy_part(xua_out, SUA_IEI_IMPORTANCE, + xua_in, SUA_IEI_IMPORTANCE); + /* Optional: Message Priority */ + xua_msg_copy_part(xua_out, SUA_IEI_MSG_PRIO, xua_in, SUA_IEI_MSG_PRIO); + /* Optional: Correlation ID */ + xua_msg_copy_part(xua_out, SUA_IEI_CORR_ID, xua_in, SUA_IEI_CORR_ID); + /* Optional: Segmentation */ + xua_msg_copy_part(xua_out, SUA_IEI_SEGMENTATION, + xua_in, SUA_IEI_SEGMENTATION); + /* Optional: Data */ + xua_msg_copy_part(xua_out, SUA_IEI_DATA, xua_in, SUA_IEI_DATA); + + OSMO_ASSERT(sua_addr_parse(&called, xua_out, SUA_IEI_DEST_ADDR) == 0); + + /* Route on PC + SSN ? */ + if (called.ri == OSMO_SCCP_RI_SSN_PC) { + /* if no PC, copy OPC into called addr */ + if (!(called.presence & OSMO_SCCP_ADDR_T_PC)) { + struct osmo_sccp_addr calling; + OSMO_ASSERT(sua_addr_parse(&calling, xua_out, SUA_IEI_SRC_ADDR) == 0); + called.presence |= OSMO_SCCP_ADDR_T_PC; + called.pc = calling.pc; + /* Re-encode / replace called address */ + xua_msg_free_tag(xua_out, SUA_IEI_DEST_ADDR); + xua_msg_add_sccp_addr(xua_out, SUA_IEI_DEST_ADDR, + &called); + } + } + return xua_out; +} + /*********************************************************************** * Transmitting SUA messages to SCTP ***********************************************************************/ diff --git a/src/xua_internal.h b/src/xua_internal.h index a6cb961..54172ff 100644 --- a/src/xua_internal.h +++ b/src/xua_internal.h @@ -37,6 +37,8 @@ void sua_tx_dupu(struct osmo_ss7_asp *asp, const uint32_t *rctx, unsigned int num_rctx, uint32_t dpc, uint16_t user, uint16_t cause, const char *info_str);
+struct xua_msg *sua_gen_cldr(const struct xua_msg *xua_in, uint32_t route_ctx, uint32_t ret_cause); + int m3ua_hmdc_rx_from_l2(struct osmo_ss7_instance *inst, struct xua_msg *xua); struct msgb *m3ua_to_msg(struct xua_msg *xua); int m3ua_tx_xua_as(struct osmo_ss7_as *as, struct xua_msg *xua);