aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNeels Hofmeyr <neels@hofmeyr.de>2020-06-26 15:20:51 +0200
committerNeels Hofmeyr <neels@hofmeyr.de>2020-07-01 23:33:16 +0200
commitb697274daabed2bf7454cc05d3e3689e91665e36 (patch)
tree56cde4f9d6e6c1932328facbbbe5d9508bf061ba
parent1139ca352b314b796649f014d8bdbb145fdcf4ea (diff)
refactor: move RESET Osmux TLV parsing to ran_msg_a.c
ran_peer.c is not the proper place to parse messages, because it should be RAN agnostic. All parsing and encoding belongs in ran_msg_a.c and ran_msg_iu.c. Move the Osmux TLV parsing into the is_reset_msg op: add supports_osmux out-parameter (and add a logging fi pointer). To be able to modify msg->l3h, also make the msgb arg non-const. In ranap_is_reset_msg(), always return non-support for Osmux. In bssmap_is_reset_msg(), return 0 if no TLVs were parsed, 1/-1 if an Osmux TLV was present/not present. Update the osmux support flag directly where the ConnectionLess message is received, so that there is only one place responsible for that. Related: OS#4595 Change-Id: I1ad4a3f9356216dd4bf8c48fba29fd23438810a7
-rw-r--r--include/osmocom/msc/ran_msg_a.h3
-rw-r--r--include/osmocom/msc/ran_msg_iu.h3
-rw-r--r--include/osmocom/msc/sccp_ran.h7
-rw-r--r--src/libmsc/ran_msg_a.c36
-rw-r--r--src/libmsc/ran_msg_iu.c6
-rw-r--r--src/libmsc/ran_peer.c31
6 files changed, 60 insertions, 26 deletions
diff --git a/include/osmocom/msc/ran_msg_a.h b/include/osmocom/msc/ran_msg_a.h
index 3ba081de2..2d045b96e 100644
--- a/include/osmocom/msc/ran_msg_a.h
+++ b/include/osmocom/msc/ran_msg_a.h
@@ -35,7 +35,8 @@ struct gsm_mncc_bearer_cap;
int ran_a_decode_l2(struct ran_dec *ran_a, struct msgb *bssap);
struct msgb *ran_a_encode(struct osmo_fsm_inst *caller_fi, const struct ran_msg *ran_enc_msg);
-enum reset_msg_type bssmap_is_reset_msg(const struct sccp_ran_inst *sri, const struct msgb *l2);
+enum reset_msg_type bssmap_is_reset_msg(const struct sccp_ran_inst *sri, struct osmo_fsm_inst *log_fi,
+ struct msgb *l2, int *supports_osmux);
struct msgb *bssmap_make_reset_msg(const struct sccp_ran_inst *sri, enum reset_msg_type type);
struct msgb *bssmap_make_paging_msg(const struct sccp_ran_inst *sri, const struct gsm0808_cell_id *page_cell_id,
const char *imsi, uint32_t tmsi, enum paging_cause cause);
diff --git a/include/osmocom/msc/ran_msg_iu.h b/include/osmocom/msc/ran_msg_iu.h
index 316a91cdb..3f3d61e4a 100644
--- a/include/osmocom/msc/ran_msg_iu.h
+++ b/include/osmocom/msc/ran_msg_iu.h
@@ -28,7 +28,8 @@
int ran_iu_decode_l2(struct ran_dec *ran_dec_iu, struct msgb *ranap);
struct msgb *ran_iu_encode(struct osmo_fsm_inst *caller_fi, const struct ran_msg *ran_enc_msg);
-enum reset_msg_type ranap_is_reset_msg(const struct sccp_ran_inst *sri, const struct msgb *l2);
+enum reset_msg_type ranap_is_reset_msg(const struct sccp_ran_inst *sri, struct osmo_fsm_inst *log_fi,
+ struct msgb *l2, int *supports_osmux);
struct msgb *ranap_make_reset_msg(const struct sccp_ran_inst *sri, enum reset_msg_type type);
struct msgb *ranap_make_paging_msg(const struct sccp_ran_inst *sri, const struct gsm0808_cell_id *page_cell_id,
const char *imsi, uint32_t tmsi, enum paging_cause cause);
diff --git a/include/osmocom/msc/sccp_ran.h b/include/osmocom/msc/sccp_ran.h
index f84bf614e..a4bd4ca61 100644
--- a/include/osmocom/msc/sccp_ran.h
+++ b/include/osmocom/msc/sccp_ran.h
@@ -233,8 +233,11 @@ struct sccp_ran_ops {
/* Return whether the given l2_cl message is a RESET, RESET ACKNOWLEDGE, or RESET-unrelated message.
* This callback is stored in struct sccp_ran_inst to provide RESET handling to the caller (ran_peer),
- * it is not used in sccp_ran.c. */
- enum reset_msg_type (* is_reset_msg )(const struct sccp_ran_inst *sri, const struct msgb *l2_cl);
+ * it is not used in sccp_ran.c.
+ * In supports_osmux, return 0 for no information, 1 for support detected, -1 for non-support detected.
+ */
+ enum reset_msg_type (* is_reset_msg )(const struct sccp_ran_inst *sri, struct osmo_fsm_inst *log_fi,
+ struct msgb *l2_cl, int *supports_osmux);
/* Return a RESET or RESET ACK message for this RAN type.
* This callback is stored in struct sccp_ran_inst to provide RESET handling to the caller (ran_peer),
diff --git a/src/libmsc/ran_msg_a.c b/src/libmsc/ran_msg_a.c
index ab5852660..1fa8ccbce 100644
--- a/src/libmsc/ran_msg_a.c
+++ b/src/libmsc/ran_msg_a.c
@@ -1275,20 +1275,50 @@ struct msgb *ran_a_encode(struct osmo_fsm_inst *caller_fi, const struct ran_msg
return msg;
}
-/* Return 1 for a RESET, 2 for a RESET ACK message, 0 otherwise */
-enum reset_msg_type bssmap_is_reset_msg(const struct sccp_ran_inst *sri, const struct msgb *l2)
+static void cl_parse_osmux(struct osmo_fsm_inst *log_fi, struct msgb *msg, int *supports_osmux)
+{
+ struct tlv_parsed tp;
+ int rc;
+
+ if (supports_osmux == NULL)
+ return;
+
+ rc = tlv_parse(&tp, gsm0808_att_tlvdef(), msgb_l3(msg) + 1, msgb_l3len(msg) - 1, 0, 0);
+ if (rc < 0) {
+ LOGPFSMSL(log_fi, DBSSAP, LOGL_ERROR, "BSSMAP: Failed parsing TLV looking for Osmux support\n");
+ return;
+ }
+
+ if (TLVP_PRESENT(&tp, GSM0808_IE_OSMO_OSMUX_SUPPORT)) {
+ *supports_osmux = true;
+ } else {
+ *supports_osmux = false;
+ }
+}
+
+/* Return 1 for a RESET, 2 for a RESET ACK message, 0 otherwise.
+ * In supports_osmux, return 0 for no information, 1 for support detected, -1 for non-support detected. */
+enum reset_msg_type bssmap_is_reset_msg(const struct sccp_ran_inst *sri, struct osmo_fsm_inst *log_fi,
+ struct msgb *l2, int *supports_osmux)
{
struct bssmap_header *bs = (struct bssmap_header *)msgb_l2(l2);
+ if (supports_osmux != NULL)
+ *supports_osmux = 0;
+
if (!bs
|| msgb_l2len(l2) < (sizeof(*bs) + 1)
|| bs->type != BSSAP_MSG_BSS_MANAGEMENT)
return SCCP_RAN_MSG_NON_RESET;
- switch (l2->l2h[sizeof(*bs)]) {
+ l2->l3h = l2->l2h + sizeof(struct bssmap_header);
+
+ switch (l2->l3h[0]) {
case BSS_MAP_MSG_RESET:
+ cl_parse_osmux(log_fi, l2, supports_osmux);
return SCCP_RAN_MSG_RESET;
case BSS_MAP_MSG_RESET_ACKNOWLEDGE:
+ cl_parse_osmux(log_fi, l2, supports_osmux);
return SCCP_RAN_MSG_RESET_ACK;
default:
return SCCP_RAN_MSG_NON_RESET;
diff --git a/src/libmsc/ran_msg_iu.c b/src/libmsc/ran_msg_iu.c
index b17aef852..5d134605e 100644
--- a/src/libmsc/ran_msg_iu.c
+++ b/src/libmsc/ran_msg_iu.c
@@ -438,11 +438,15 @@ static void ranap_handle_cl(void *ctx, ranap_message *message)
}
}
-enum reset_msg_type ranap_is_reset_msg(const struct sccp_ran_inst *sri, const struct msgb *l2)
+enum reset_msg_type ranap_is_reset_msg(const struct sccp_ran_inst *sri, struct osmo_fsm_inst *log_fi,
+ struct msgb *l2, int *supports_osmux)
{
int ret = SCCP_RAN_MSG_NON_RESET;
int rc;
+ if (supports_osmux != NULL)
+ *supports_osmux = -1;
+
rc = ranap_cn_rx_cl(ranap_handle_cl, &ret, msgb_l2(l2), msgb_l2len(l2));
if (rc)
return 0;
diff --git a/src/libmsc/ran_peer.c b/src/libmsc/ran_peer.c
index da888730f..80ce5581d 100644
--- a/src/libmsc/ran_peer.c
+++ b/src/libmsc/ran_peer.c
@@ -122,25 +122,19 @@ void ran_peer_discard_all_conns(struct ran_peer *rp)
}
}
-/* TODO: create an sccp_ran_ops.rx_reset(_ack) to handle this differently on 2g and 3G */
-/* We expect RAN peer to provide use with an Osmocom extension TLV in BSSMAP_RESET to
- * announce Osmux support */
-static void ran_peer_update_osmux_support(struct ran_peer *rp, struct msgb *msg)
+static void ran_peer_update_osmux_support(struct ran_peer *rp, int supports_osmux)
{
- struct tlv_parsed tp;
- int rc;
bool old_value = rp->remote_supports_osmux;
- OSMO_ASSERT(msg);
- msg->l3h = msg->l2h + sizeof(struct bssmap_header);
- rc = tlv_parse(&tp, gsm0808_att_tlvdef(), msg->l3h + 1, msgb_l3len(msg) - 1, 0, 0);
- if (rc < 0)
- LOG_RAN_PEER(rp, LOGL_NOTICE, "Failed parsing TLV looking for Osmux support\n");
-
- if (TLVP_PRESENT(&tp, GSM0808_IE_OSMO_OSMUX_SUPPORT)) {
+ switch (supports_osmux) {
+ case 1:
rp->remote_supports_osmux = true;
- } else {
+ break;
+ case -1:
rp->remote_supports_osmux = false;
+ break;
+ default:
+ return;
}
if (old_value != rp->remote_supports_osmux)
@@ -155,8 +149,6 @@ static void ran_peer_rx_reset(struct ran_peer *rp, struct msgb* msg)
ran_peer_discard_all_conns(rp);
- ran_peer_update_osmux_support(rp, msg);
-
reset_ack = rp->sri->ran->sccp_ran_ops.make_reset_msg(rp->sri, SCCP_RAN_MSG_RESET_ACK);
if (!reset_ack) {
@@ -183,7 +175,6 @@ static void ran_peer_rx_reset(struct ran_peer *rp, struct msgb* msg)
static void ran_peer_rx_reset_ack(struct ran_peer *rp, struct msgb* msg)
{
ran_peer_state_chg(rp, RAN_PEER_ST_READY);
- ran_peer_update_osmux_support(rp, msg);
}
void ran_peer_reset(struct ran_peer *rp)
@@ -213,10 +204,14 @@ void ran_peer_allstate_action(struct osmo_fsm_inst *fi, uint32_t event, void *da
struct ran_peer *rp = fi->priv;
struct ran_peer_ev_ctx *ctx = data;
struct msgb *msg = ctx->msg;
+ int rc;
+ int supports_osmux;
switch (event) {
case RAN_PEER_EV_MSG_UP_CL:
- switch (rp->sri->ran->sccp_ran_ops.is_reset_msg(rp->sri, msg)) {
+ rc = rp->sri->ran->sccp_ran_ops.is_reset_msg(rp->sri, fi, msg, &supports_osmux);
+ ran_peer_update_osmux_support(rp, supports_osmux);
+ switch (rc) {
case 1:
osmo_fsm_inst_dispatch(fi, RAN_PEER_EV_RX_RESET, msg);
return;