pespin has uploaded this change for review. (
https://gerrit.osmocom.org/c/libosmo-sigtran/+/42039?usp=email )
Change subject: xua_rkm: Add checks for ASP role in rx msg path
......................................................................
xua_rkm: Add checks for ASP role in rx msg path
Change-Id: I672060c24571586b37102c7f7f60e4b0e20e07a9
---
M src/m3ua.c
M src/xua_internal.h
M src/xua_rkm.c
3 files changed, 30 insertions(+), 5 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/libosmo-sigtran
refs/changes/39/42039/1
diff --git a/src/m3ua.c b/src/m3ua.c
index e4173bd..cad7889 100644
--- a/src/m3ua.c
+++ b/src/m3ua.c
@@ -266,7 +266,7 @@
static const uint16_t dereg_rsp_ies[] = {
M3UA_IEI_DEREG_RESULT, 0
};
-static const struct value_string m3ua_rkm_msgt_names[] = {
+const struct value_string m3ua_rkm_msgt_names[] = {
{ M3UA_RKM_REG_REQ, "REG-REQ" },
{ M3UA_RKM_REG_RSP, "REG-RESP" },
{ M3UA_RKM_DEREG_REQ, "DEREG-REQ" },
diff --git a/src/xua_internal.h b/src/xua_internal.h
index c5bd009..a2f0af6 100644
--- a/src/xua_internal.h
+++ b/src/xua_internal.h
@@ -135,6 +135,7 @@
extern struct osmo_fsm xua_default_lm_fsm;
extern const struct value_string m3ua_rkm_reg_status_vals[];
extern const struct value_string m3ua_rkm_dereg_status_vals[];
+extern const struct value_string m3ua_rkm_msgt_names[];
int xua_as_transmit_msg(struct osmo_ss7_as *as, struct xua_msg *xua);
diff --git a/src/xua_rkm.c b/src/xua_rkm.c
index 9713e3a..fabe116 100644
--- a/src/xua_rkm.c
+++ b/src/xua_rkm.c
@@ -561,6 +561,30 @@
return 0;
}
+#define ENSURE_ASP_OR_IPSP(asp, xua)
\
+ do {
\
+ if (asp->cfg.role != OSMO_SS7_ASP_ROLE_ASP &&
\
+ asp->cfg.role != OSMO_SS7_ASP_ROLE_IPSP) {
\
+ LOGPASP(asp, DLSS7, LOGL_ERROR, "Rx %s not permitted in
role %s\n", \
+ get_value_string(m3ua_rkm_msgt_names,
xua->hdr.msg_type), \
+ get_value_string(osmo_ss7_asp_role_names,
asp->cfg.role)); \
+ xua_msg_free(xua);
\
+ return -1;
\
+ }
\
+ } while (0)
+
+#define ENSURE_SG_OR_IPSP(asp, xua)
\
+ do {
\
+ if (asp->cfg.role != OSMO_SS7_ASP_ROLE_SG &&
\
+ asp->cfg.role != OSMO_SS7_ASP_ROLE_IPSP) {
\
+ LOGPASP(asp, DLSS7, LOGL_ERROR, "Rx %s not permitted
in role %s\n", \
+ get_value_string(m3ua_rkm_msgt_names,
xua->hdr.msg_type), \
+ get_value_string(osmo_ss7_asp_role_names,
asp->cfg.role)); \
+ xua_msg_free(xua);
\
+ return -1;
\
+ }
\
+ } while (0)
+
/* process an incoming RKM message in xua format
* This function takes ownership of xua msg passed to it. */
int m3ua_rx_rkm(struct osmo_ss7_asp *asp, struct xua_msg *xua)
@@ -570,20 +594,20 @@
switch (xua->hdr.msg_type) {
/* SG Side */
case M3UA_RKM_REG_REQ:
- /* TOOD: ensure we are role SG */
+ ENSURE_SG_OR_IPSP(asp, xua);
rc = m3ua_rx_rkm_reg_req(asp, xua);
break;
case M3UA_RKM_DEREG_REQ:
- /* TOOD: ensure we are role SG */
+ ENSURE_SG_OR_IPSP(asp, xua);
rc = m3ua_rx_rkm_dereg_req(asp, xua);
break;
/* ASP Side */
case M3UA_RKM_REG_RSP:
- /* TOOD: ensure we are role ASP */
+ ENSURE_ASP_OR_IPSP(asp, xua);
rc = m3ua_rx_rkm_reg_rsp(asp, xua);
break;
case M3UA_RKM_DEREG_RSP:
- /* TOOD: ensure we are role ASP */
+ ENSURE_ASP_OR_IPSP(asp, xua);
rc = m3ua_rx_rkm_dereg_rsp(asp, xua);
break;
default:
--
To view, visit https://gerrit.osmocom.org/c/libosmo-sigtran/+/42039?usp=email
To unsubscribe, or for help writing mail filters, visit
https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: newchange
Gerrit-Project: libosmo-sigtran
Gerrit-Branch: master
Gerrit-Change-Id: I672060c24571586b37102c7f7f60e4b0e20e07a9
Gerrit-Change-Number: 42039
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <[email protected]>