laforge submitted this change.

View Change

Approvals: Jenkins Builder: Verified fixeria: Looks good to me, approved
bsc_nat_fsm: split sccp_sap_get_peer_addr_out

Split this code into an extra function, as it will be used by other
message types in sccp_sap_up too (following patches).

Related: SYS#5560
Change-Id: I6bc59445d65f812ccd46eb33dd6cca6b34dd0867
---
M src/osmo-bsc-nat/bsc_nat_fsm.c
1 file changed, 27 insertions(+), 20 deletions(-)

diff --git a/src/osmo-bsc-nat/bsc_nat_fsm.c b/src/osmo-bsc-nat/bsc_nat_fsm.c
index 48ae6f5..3161de3 100644
--- a/src/osmo-bsc-nat/bsc_nat_fsm.c
+++ b/src/osmo-bsc-nat/bsc_nat_fsm.c
@@ -69,6 +69,31 @@
return g_bsc_nat->cn;
}

+/* Figure out who will receive the message.
+ * For now this is simplified by assuming there is only one MSC, one BSC. */
+static int sccp_sap_get_peer_addr_out(struct bsc_nat_ss7_inst *src, struct osmo_sccp_addr *peer_addr_in,
+ struct osmo_sccp_addr *peer_addr_out)
+{
+ struct bsc_nat_ss7_inst *dest = ss7_inst_dest(src);
+ struct osmo_ss7_instance *dest_ss7 = osmo_ss7_instance_find(dest->ss7_id);
+
+ OSMO_ASSERT(dest_ss7);
+
+ if (src == g_bsc_nat->ran) {
+ if (osmo_sccp_addr_by_name_local(peer_addr_out, "msc", dest_ss7) < 0) {
+ LOG_SCCP(src, peer_addr_in, LOGL_ERROR, "Could not find MSC in address book\n");
+ return -1;
+ }
+ } else {
+ if (osmo_sccp_addr_by_name_local(peer_addr_out, "bsc", dest_ss7) < 0) {
+ LOG_SCCP(src, peer_addr_in, LOGL_ERROR, "Could not find BSC in address book\n");
+ return -2;
+ }
+ }
+
+ return 0;
+}
+
static int sccp_sap_up(struct osmo_prim_hdr *oph, void *scu)
{
struct bsc_nat_ss7_inst *src = osmo_sccp_user_get_priv(scu);
@@ -100,26 +125,8 @@
peer_addr_in = &prim->u.unitdata.calling_addr;
LOG_SCCP(src, peer_addr_in, LOGL_DEBUG, "%s(%s)\n", __func__, osmo_scu_prim_name(oph));

- /* Figure out called party in dest. TODO: build and use a
- * mapping of peer_addr + conn_id <--> dest_ss7. For now, this
- * is simplified by assuming there is only one MSC, one BSC. */
-
- struct osmo_ss7_instance *dest_ss7;
-
- dest_ss7 = osmo_ss7_instance_find(dest->ss7_id);
- OSMO_ASSERT(dest_ss7);
-
- if (src == g_bsc_nat->ran) {
- if (osmo_sccp_addr_by_name_local(&peer_addr_out, "msc", dest_ss7) < 0) {
- LOG_SCCP(src, peer_addr_in, LOGL_ERROR, "Could not find MSC in address book\n");
- goto error;
- }
- } else {
- if (osmo_sccp_addr_by_name_local(&peer_addr_out, "bsc", dest_ss7) < 0) {
- LOG_SCCP(src, peer_addr_in, LOGL_ERROR, "Could not find BSC in address book\n");
- goto error;
- }
- }
+ if (sccp_sap_get_peer_addr_out(src, peer_addr_in, &peer_addr_out) < 0)
+ goto error;

LOG_SCCP(src, peer_addr_in, LOGL_NOTICE, "Forwarding to %s in %s\n",
osmo_sccp_inst_addr_name(NULL, &peer_addr_out),

To view, visit change 27259. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: osmo-bsc-nat
Gerrit-Branch: master
Gerrit-Change-Id: I6bc59445d65f812ccd46eb33dd6cca6b34dd0867
Gerrit-Change-Number: 27259
Gerrit-PatchSet: 2
Gerrit-Owner: osmith <osmith@sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <vyanitskiy@sysmocom.de>
Gerrit-Reviewer: laforge <laforge@osmocom.org>
Gerrit-MessageType: merged