osmith has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/osmo-bsc-nat/+/27259 )


Change subject: bsc_nat_fsm: split sccp_sap_get_peer_addr_out
......................................................................

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(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-bsc-nat refs/changes/59/27259/1

diff --git a/src/osmo-bsc-nat/bsc_nat_fsm.c b/src/osmo-bsc-nat/bsc_nat_fsm.c
index f91845d..8d6ebe8 100644
--- a/src/osmo-bsc-nat/bsc_nat_fsm.c
+++ b/src/osmo-bsc-nat/bsc_nat_fsm.c
@@ -86,6 +86,31 @@
        return -1;
 }

+/* 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);
@@ -120,26 +145,8 @@
                if (sccp_sap_verify_called_addr(src, 
&prim->u.unitdata.called_addr, peer_addr_in) < 0)
                        goto error;

-               /* 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 https://gerrit.osmocom.org/c/osmo-bsc-nat/+/27259
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-bsc-nat
Gerrit-Branch: master
Gerrit-Change-Id: I6bc59445d65f812ccd46eb33dd6cca6b34dd0867
Gerrit-Change-Number: 27259
Gerrit-PatchSet: 1
Gerrit-Owner: osmith <[email protected]>
Gerrit-MessageType: newchange

Reply via email to