pespin has uploaded this change for review. (
https://gerrit.osmocom.org/c/osmo-hnbgw/+/39989?usp=email )
Change subject: Move UL CO RANAP processing to its proper layer file
......................................................................
Move UL CO RANAP processing to its proper layer file
Change-Id: I0d16f6c1c303aa1275322f12faf332de8d7c3147
---
M include/osmocom/hnbgw/hnbgw_ranap.h
M include/osmocom/hnbgw/hnbgw_rua.h
M src/osmo-hnbgw/context_map_rua.c
M src/osmo-hnbgw/hnbgw_l3.c
M src/osmo-hnbgw/hnbgw_ranap.c
M src/osmo-hnbgw/hnbgw_rua.c
6 files changed, 75 insertions(+), 70 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-hnbgw refs/changes/89/39989/1
diff --git a/include/osmocom/hnbgw/hnbgw_ranap.h b/include/osmocom/hnbgw/hnbgw_ranap.h
index 2e77246..7129187 100644
--- a/include/osmocom/hnbgw/hnbgw_ranap.h
+++ b/include/osmocom/hnbgw/hnbgw_ranap.h
@@ -1,11 +1,16 @@
/* RANAP, 3GPP TS 25.413 */
#pragma once
+#include <osmocom/ranap/ranap_ies_defs.h>
#include <osmocom/hnbgw/hnbgw.h>
struct osmo_scu_unitdata_param;
+ranap_message *hnbgw_decode_ranap_cn_co(struct msgb *ranap_msg);
+
int hnbgw_ranap_rx_udt_ul(struct msgb *msg, uint8_t *data, size_t len);
+int hnbgw_ranap_rx_data_ul(struct hnbgw_context_map *map, struct msgb *ranap_msg);
+
int hnbgw_ranap_rx_udt_dl(struct hnbgw_cnlink *cnlink, const struct
osmo_scu_unitdata_param *unitdata,
const uint8_t *data, unsigned int len);
int hnbgw_ranap_rx_data_dl(struct hnbgw_context_map *map, struct msgb *ranap_msg);
diff --git a/include/osmocom/hnbgw/hnbgw_rua.h b/include/osmocom/hnbgw/hnbgw_rua.h
index 55e90c0..2b74be9 100644
--- a/include/osmocom/hnbgw/hnbgw_rua.h
+++ b/include/osmocom/hnbgw/hnbgw_rua.h
@@ -3,7 +3,6 @@
#include <osmocom/hnbgw/hnbgw.h>
#include <osmocom/rua/RUA_Cause.h>
-#include <osmocom/ranap/ranap_ies_defs.h>
int hnbgw_rua_rx(struct hnb_context *hnb, struct msgb *msg);
@@ -13,4 +12,3 @@
int rua_tx_disc(struct hnb_context *hnb, int is_ps, uint32_t context_id,
const RUA_Cause_t *cause, const uint8_t *data, unsigned int len);
-ranap_message *hnbgw_decode_ranap_cn_co(struct msgb *ranap_msg);
diff --git a/src/osmo-hnbgw/context_map_rua.c b/src/osmo-hnbgw/context_map_rua.c
index f73b8e2..ca1a6ed 100644
--- a/src/osmo-hnbgw/context_map_rua.c
+++ b/src/osmo-hnbgw/context_map_rua.c
@@ -24,19 +24,11 @@
#include <osmocom/core/utils.h>
#include <osmocom/core/fsm.h>
-#include <osmocom/ranap/ranap_common_cn.h>
-
-#if ENABLE_PFCP
-#include <osmocom/pfcp/pfcp_cp_peer.h>
-#endif
-
#include <osmocom/hnbgw/hnbgw.h>
#include <osmocom/hnbgw/context_map.h>
#include <osmocom/hnbgw/tdefs.h>
#include <osmocom/hnbgw/hnbgw_rua.h>
-#include <osmocom/hnbgw/mgw_fsm.h>
-#include <osmocom/hnbgw/ps_rab_ass_fsm.h>
-#include <osmocom/hnbgw/kpi.h>
+#include <osmocom/hnbgw/hnbgw_ranap.h>
enum map_rua_fsm_state {
MAP_RUA_ST_INIT,
@@ -128,32 +120,6 @@
}
}
-static int destruct_ranap_cn_rx_co_ies(ranap_message *ranap_message_p)
-{
- ranap_cn_rx_co_free(ranap_message_p);
- return 0;
-}
-
-/* Decode UL RANAP message with convenient memory freeing: just talloc_free() the
returned pointer..
- * Allocate a ranap_message from OTC_SELECT, decode RANAP msgb into it, attach a talloc
destructor that calls
- * ranap_cn_rx_co_free() upon talloc_free(), and return the decoded ranap_message. */
-ranap_message *hnbgw_decode_ranap_cn_co(struct msgb *ranap_msg)
-{
- int rc;
- ranap_message *message;
-
- if (!msg_has_l2_data(ranap_msg))
- return NULL;
- message = talloc_zero(OTC_SELECT, ranap_message);
- rc = ranap_cn_rx_co_decode2(message, msgb_l2(ranap_msg), msgb_l2len(ranap_msg));
- if (rc != 0) {
- talloc_free(message);
- return NULL;
- }
- talloc_set_destructor(message, destruct_ranap_cn_rx_co_ies);
- return message;
-}
-
/* Dispatch RANAP message to SCCP, if any. */
static int handle_rx_rua(struct osmo_fsm_inst *fi, struct msgb *ranap_msg)
{
@@ -166,37 +132,7 @@
if (!msg_has_l2_data(ranap_msg))
return 0;
- ranap_message *message = hnbgw_decode_ranap_cn_co(ranap_msg);
- if (message) {
- LOGPFSML(fi, LOGL_DEBUG, "rx from RUA: RANAP %s\n",
- get_value_string(ranap_procedure_code_vals, message->procedureCode));
-
- kpi_ranap_process_ul(map, message);
-
- if (!map->is_ps) {
- /* See if it is a RAB Assignment Response message from RUA to SCCP, where we need to
change the user plane
- * information, for RTP mapping via MGW, or GTP mapping via UPF. */
- switch (message->procedureCode) {
- case RANAP_ProcedureCode_id_RAB_Assignment:
- /* mgw_fsm_handle_rab_ass_resp() takes ownership of prim->oph and (ranap) message
*/
- return mgw_fsm_handle_cs_rab_ass_resp(map, ranap_msg, message);
- }
- } else {
-#if ENABLE_PFCP
- if (hnb_gw_is_gtp_mapping_enabled()) {
- /* map->is_ps == true and PFCP is enabled in osmo-hnbgw.cfg */
- switch (message->procedureCode) {
- case RANAP_ProcedureCode_id_RAB_Assignment:
- /* ps_rab_ass_fsm takes ownership of prim->oph and RANAP message */
- return hnbgw_gtpmap_rx_rab_ass_resp(map, ranap_msg, message);
- }
- }
-#endif
- }
- }
-
- /* It was not a RAB Assignment Response that needed to be intercepted. Forward as-is to
SCCP. */
- return map_sccp_dispatch(map, MAP_SCCP_EV_TX_DATA_REQUEST, ranap_msg);
+ return hnbgw_ranap_rx_data_ul(map, ranap_msg);
}
static int forward_ranap_to_rua(struct hnbgw_context_map *map, struct msgb *ranap_msg)
diff --git a/src/osmo-hnbgw/hnbgw_l3.c b/src/osmo-hnbgw/hnbgw_l3.c
index 65d9eff..88587f4 100644
--- a/src/osmo-hnbgw/hnbgw_l3.c
+++ b/src/osmo-hnbgw/hnbgw_l3.c
@@ -28,7 +28,7 @@
#include <osmocom/gsm/protocol/gsm_04_08_gprs.h>
#include <osmocom/hnbgw/hnbgw.h>
-#include <osmocom/hnbgw/hnbgw_rua.h>
+#include <osmocom/hnbgw/hnbgw_ranap.h>
#include <osmocom/hnbgw/context_map.h>
#include <osmocom/ranap/ranap_ies_defs.h>
diff --git a/src/osmo-hnbgw/hnbgw_ranap.c b/src/osmo-hnbgw/hnbgw_ranap.c
index 666560c..3078b7d 100644
--- a/src/osmo-hnbgw/hnbgw_ranap.c
+++ b/src/osmo-hnbgw/hnbgw_ranap.c
@@ -31,6 +31,7 @@
#include <osmocom/ranap/ranap_common.h>
#include <osmocom/ranap/ranap_common_ran.h>
+#include <osmocom/ranap/ranap_common_cn.h>
#include <osmocom/ranap/ranap_ies_defs.h>
#include <osmocom/ranap/ranap_msg_factory.h>
@@ -224,6 +225,72 @@
return rc;
}
+static int destruct_ranap_cn_rx_co_ies(ranap_message *ranap_message_p)
+{
+ ranap_cn_rx_co_free(ranap_message_p);
+ return 0;
+}
+
+/* Decode UL RANAP message with convenient memory freeing: just talloc_free() the
returned pointer..
+ * Allocate a ranap_message from OTC_SELECT, decode RANAP msgb into it, attach a talloc
destructor that calls
+ * ranap_cn_rx_co_free() upon talloc_free(), and return the decoded ranap_message. */
+ranap_message *hnbgw_decode_ranap_cn_co(struct msgb *ranap_msg)
+{
+ int rc;
+ ranap_message *message;
+
+ if (!msg_has_l2_data(ranap_msg))
+ return NULL;
+ message = talloc_zero(OTC_SELECT, ranap_message);
+ rc = ranap_cn_rx_co_decode2(message, msgb_l2(ranap_msg), msgb_l2len(ranap_msg));
+ if (rc != 0) {
+ talloc_free(message);
+ return NULL;
+ }
+ talloc_set_destructor(message, destruct_ranap_cn_rx_co_ies);
+ return message;
+}
+
+/* Process a received RANAP PDU through SCCP DATA.ind coming from CN (MSC/SGSN)
+ * Takes ownership of ranap_msg? */
+int hnbgw_ranap_rx_data_ul(struct hnbgw_context_map *map, struct msgb *ranap_msg)
+{
+ OSMO_ASSERT(map);
+ OSMO_ASSERT(msg_has_l2_data(ranap_msg));
+
+ ranap_message *message = hnbgw_decode_ranap_cn_co(ranap_msg);
+ if (message) {
+ LOG_MAP(map, DHNB, LOGL_DEBUG, "rx from RUA: RANAP %s\n",
+ get_value_string(ranap_procedure_code_vals, message->procedureCode));
+
+ kpi_ranap_process_ul(map, message);
+
+ if (!map->is_ps) {
+ /* See if it is a RAB Assignment Response message from RUA to SCCP, where we need to
change the user plane
+ * information, for RTP mapping via MGW, or GTP mapping via UPF. */
+ switch (message->procedureCode) {
+ case RANAP_ProcedureCode_id_RAB_Assignment:
+ /* mgw_fsm_handle_rab_ass_resp() takes ownership of prim->oph and (ranap) message
*/
+ return mgw_fsm_handle_cs_rab_ass_resp(map, ranap_msg, message);
+ }
+ } else {
+#if ENABLE_PFCP
+ if (hnb_gw_is_gtp_mapping_enabled()) {
+ /* map->is_ps == true and PFCP is enabled in osmo-hnbgw.cfg */
+ switch (message->procedureCode) {
+ case RANAP_ProcedureCode_id_RAB_Assignment:
+ /* ps_rab_ass_fsm takes ownership of prim->oph and RANAP message */
+ return hnbgw_gtpmap_rx_rab_ass_resp(map, ranap_msg, message);
+ }
+ }
+#endif
+ }
+ }
+
+ /* It was not a RAB Assignment Response that needed to be intercepted. Forward as-is to
SCCP. */
+ return map_sccp_dispatch(map, MAP_SCCP_EV_TX_DATA_REQUEST, ranap_msg);
+}
+
/*****************************************************************************
* Processing of RANAP from the endpoint towards CN (MSC/SGSN), acting as RAN
*****************************************************************************/
diff --git a/src/osmo-hnbgw/hnbgw_rua.c b/src/osmo-hnbgw/hnbgw_rua.c
index b3342f9..7cc1b27 100644
--- a/src/osmo-hnbgw/hnbgw_rua.c
+++ b/src/osmo-hnbgw/hnbgw_rua.c
@@ -40,7 +40,6 @@
#include <osmocom/hnbgw/context_map.h>
#include <osmocom/hnbgw/hnbgw_rua.h>
#include <osmocom/hnbap/HNBAP_CN-DomainIndicator.h>
-#include <osmocom/ranap/ranap_ies_defs.h>
static int hnbgw_rua_tx(struct hnb_context *ctx, struct msgb *msg)
{
--
To view, visit
https://gerrit.osmocom.org/c/osmo-hnbgw/+/39989?usp=email
To unsubscribe, or for help writing mail filters, visit
https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: newchange
Gerrit-Project: osmo-hnbgw
Gerrit-Branch: master
Gerrit-Change-Id: I0d16f6c1c303aa1275322f12faf332de8d7c3147
Gerrit-Change-Number: 39989
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <pespin(a)sysmocom.de>