diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/libmsc/ran_msg_a.c | 36 | ||||
-rw-r--r-- | src/libmsc/ran_msg_iu.c | 6 | ||||
-rw-r--r-- | src/libmsc/ran_peer.c | 31 |
3 files changed, 51 insertions, 22 deletions
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; |