Harald Welte has submitted this change and it was merged. ( 
https://gerrit.osmocom.org/14039 )

Change subject: bssap: Detect BSC Osmux support on RESET (ACK) recv
......................................................................

bssap: Detect BSC Osmux support on RESET (ACK) recv

Related: OS#2551
Depends: libosmocore.git I28f83e2e32b9533c99e65ccc1562900ac2aec74e
Change-Id: If4f33da9b414ab194098755d2c5be85e1fce5d31
---
M include/osmocom/msc/ran_peer.h
M src/libmsc/ran_peer.c
2 files changed, 45 insertions(+), 6 deletions(-)

Approvals:
  Harald Welte: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/include/osmocom/msc/ran_peer.h b/include/osmocom/msc/ran_peer.h
index e3ff59d..06ab500 100644
--- a/include/osmocom/msc/ran_peer.h
+++ b/include/osmocom/msc/ran_peer.h
@@ -51,6 +51,9 @@

        /* See cell_id_list.h */
        struct llist_head cells_seen;
+
+       /* Whether we detected the BSC supports Osmux (during BSSMAP_RESET) */
+       bool remote_supports_osmux;
 };

 #define ran_peer_for_each_ran_conn(RAN_CONN, RAN_PEER) \
diff --git a/src/libmsc/ran_peer.c b/src/libmsc/ran_peer.c
index 35f2842..ce26794 100644
--- a/src/libmsc/ran_peer.c
+++ b/src/libmsc/ran_peer.c
@@ -122,13 +122,41 @@
        }
 }

+/* 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)
+{
+       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)) {
+               rp->remote_supports_osmux = true;
+       } else {
+               rp->remote_supports_osmux = false;
+       }
+
+       if (old_value != rp->remote_supports_osmux)
+               LOG_RAN_PEER(rp, LOGL_INFO, "BSC detected AoIP Osmux support 
changed: %d->%d\n",
+                    old_value, rp->remote_supports_osmux);
+}
+
 /* Drop all SCCP connections for this ran_peer, respond with RESET ACKNOWLEDGE 
and move to READY state. */
-static void ran_peer_rx_reset(struct ran_peer *rp)
+static void ran_peer_rx_reset(struct ran_peer *rp, struct msgb* msg)
 {
        struct msgb *reset_ack;

        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) {
@@ -152,9 +180,10 @@
        ran_peer_state_chg(rp, RAN_PEER_ST_READY);
 }

-static void ran_peer_rx_reset_ack(struct ran_peer *rp)
+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)
@@ -228,6 +257,7 @@
 {
        struct ran_peer *rp = fi->priv;
        struct ran_peer_ev_ctx *ctx;
+       struct msgb *msg;

        switch (event) {

@@ -257,7 +287,8 @@
                return;

        case RAN_PEER_EV_RX_RESET:
-               ran_peer_rx_reset(rp);
+               msg = (struct msgb*)data;
+               ran_peer_rx_reset(rp, msg);
                return;

        default:
@@ -270,11 +301,13 @@
 {
        struct ran_peer *rp = fi->priv;
        struct ran_peer_ev_ctx *ctx;
+       struct msgb *msg;

        switch (event) {

        case RAN_PEER_EV_RX_RESET_ACK:
-               ran_peer_rx_reset_ack(rp);
+               msg = (struct msgb*)data;
+               ran_peer_rx_reset_ack(rp, msg);
                return;

        case RAN_PEER_EV_MSG_UP_CO:
@@ -289,7 +322,8 @@
                return;

        case RAN_PEER_EV_RX_RESET:
-               ran_peer_rx_reset(rp);
+               msg = (struct msgb*)data;
+               ran_peer_rx_reset(rp, msg);
                return;

        default:
@@ -330,6 +364,7 @@
        struct ran_peer_ev_ctx *ctx;
        struct ran_conn *conn;
        struct an_apdu an_apdu;
+       struct msgb *msg;

        switch (event) {

@@ -397,7 +432,8 @@
                return;

        case RAN_PEER_EV_RX_RESET:
-               ran_peer_rx_reset(rp);
+               msg = (struct msgb*)data;
+               ran_peer_rx_reset(rp, msg);
                return;

        default:

--
To view, visit https://gerrit.osmocom.org/14039
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-msc
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: If4f33da9b414ab194098755d2c5be85e1fce5d31
Gerrit-Change-Number: 14039
Gerrit-PatchSet: 4
Gerrit-Owner: Pau Espin Pedrol <[email protected]>
Gerrit-Reviewer: Harald Welte <[email protected]>
Gerrit-Reviewer: Jenkins Builder (1000002)
Gerrit-Reviewer: Neels Hofmeyr <[email protected]>
Gerrit-Reviewer: Pau Espin Pedrol <[email protected]>
Gerrit-CC: Vadim Yanitskiy <[email protected]>

Reply via email to