osmith has uploaded this change for review. (
https://gerrit.osmocom.org/c/osmo-bsc-nat/+/27257 )
Change subject: bsc_nat_fsm: split sccp_sap_verify_called_addr out
......................................................................
bsc_nat_fsm: split sccp_sap_verify_called_addr out
Make sccp_sap_up a bit shorter before extending it to forward not only
connection-less messages, but also connection-oriented messages.
While at it, change my_addr to called_addr. my_addr is ambiguous, the
bsc-nat has one in CN and one in RAN.
Related: SYS#5560
Change-Id: Id9bfbf38a61ef66a4246f752ef487d8a09fea173
---
M src/osmo-bsc-nat/bsc_nat_fsm.c
1 file changed, 18 insertions(+), 8 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-bsc-nat refs/changes/57/27257/1
diff --git a/src/osmo-bsc-nat/bsc_nat_fsm.c b/src/osmo-bsc-nat/bsc_nat_fsm.c
index e5767b1..b3d061e 100644
--- a/src/osmo-bsc-nat/bsc_nat_fsm.c
+++ b/src/osmo-bsc-nat/bsc_nat_fsm.c
@@ -69,14 +69,29 @@
return g_bsc_nat->cn;
}
+/* For connection-less messages, verify that the called address is the locally
+ * configured address. */
+static int sccp_sap_verify_called_addr(struct bsc_nat_ss7_inst *src, struct
osmo_sccp_addr *called_addr,
+ struct osmo_sccp_addr *peer_addr)
+{
+ char buf[255];
+
+ if (osmo_sccp_addr_ri_cmp(&src->local_sccp_addr, called_addr) == 0)
+ return 0;
+
+ osmo_sccp_addr_to_str_buf(buf, sizeof(buf), NULL, called_addr);
+ LOG_SCCP(src, peer_addr, LOGL_ERROR, "Called address %s is not the locally
configured"
+ " address %s\n", buf, osmo_sccp_inst_addr_name(NULL,
&src->local_sccp_addr));
+
+ return -1;
+}
+
static int sccp_sap_up(struct osmo_prim_hdr *oph, void *scu)
{
struct bsc_nat_ss7_inst *src = osmo_sccp_user_get_priv(scu);
struct bsc_nat_ss7_inst *dest = ss7_inst_dest(src);
struct osmo_scu_prim *prim = (struct osmo_scu_prim *) oph;
- struct osmo_sccp_addr *my_addr;
struct osmo_sccp_addr *peer_addr;
- char buf[255];
int rc = -1;
switch (OSMO_PRIM_HDR(oph)) {
@@ -98,16 +113,11 @@
case OSMO_PRIM(OSMO_SCU_PRIM_N_UNITDATA, PRIM_OP_INDICATION):
/* connection-less data received */
- my_addr = &prim->u.unitdata.called_addr;
peer_addr = &prim->u.unitdata.calling_addr;
LOG_SCCP(src, peer_addr, LOGL_DEBUG, "%s(%s)\n", __func__,
osmo_scu_prim_name(oph));
- if (osmo_sccp_addr_ri_cmp(&src->local_sccp_addr, my_addr)) {
- osmo_sccp_addr_to_str_buf(buf, sizeof(buf), NULL, my_addr);
- LOG_SCCP(src, peer_addr, LOGL_ERROR, "Called address %s is not the locally
configured"
- " address %s\n", buf, osmo_sccp_inst_addr_name(NULL,
&src->local_sccp_addr));
+ if (sccp_sap_verify_called_addr(src, &prim->u.unitdata.called_addr, peer_addr)
< 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
--
To view, visit
https://gerrit.osmocom.org/c/osmo-bsc-nat/+/27257
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: Id9bfbf38a61ef66a4246f752ef487d8a09fea173
Gerrit-Change-Number: 27257
Gerrit-PatchSet: 1
Gerrit-Owner: osmith <osmith(a)sysmocom.de>
Gerrit-MessageType: newchange