[PATCH] ipaccess: bts: don't get OML and RSL links up at the same time

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/OpenBSC@lists.osmocom.org/.

pablo at gnumonks.org pablo at gnumonks.org
Sun Feb 10 20:23:59 UTC 2013


From: Pablo Neira Ayuso <pablo at gnumonks.org>

Harald reported that he needs that the RSL link becomes up
once the OML link has been fully established, not both at the
same time as it is currently happening.

This patch changes the existing behaviour to control when the RSL
link becomes up. Basically, you have to have to call e1inp_line_update
once to get the OML link up. Then, once the OML link has been fully
established, you call e1inp_line_update again to get the RSL link up.

I have updates the examples files as well to adapt them to the
new semantics.
---
 src/input/ipaccess.c       |  141 ++++++++++++++++++++++++++++----------------
 tests/e1inp_ipa_bts_test.c |   22 +++++--
 2 files changed, 107 insertions(+), 56 deletions(-)

diff --git a/src/input/ipaccess.c b/src/input/ipaccess.c
index 5e76a09..b8c1e7a 100644
--- a/src/input/ipaccess.c
+++ b/src/input/ipaccess.c
@@ -894,8 +894,73 @@ err:
 	return ret;
 }
 
+static int ipaccess_bts_oml_link_up(struct e1inp_line *line)
+{
+	struct ipa_client_conn *link;
+
+	link = ipa_client_conn_create(tall_ipa_ctx,
+				      &line->ts[E1INP_SIGN_OML-1],
+				      E1INP_SIGN_OML,
+				      line->ops->cfg.ipa.addr,
+				      IPA_TCP_PORT_OML,
+				      NULL,
+				      ipaccess_bts_cb,
+				      ipaccess_bts_write_cb,
+				      NULL);
+	if (link == NULL) {
+		LOGP(DLINP, LOGL_ERROR, "cannot create OML "
+			"BTS link: %s\n", strerror(errno));
+		return -ENOMEM;
+	}
+	if (ipa_client_conn_open(link) < 0) {
+		LOGP(DLINP, LOGL_ERROR, "cannot open OML BTS link: %s\n",
+			strerror(errno));
+		ipa_client_conn_close(link);
+		ipa_client_conn_destroy(link);
+		return -EIO;
+	}
+
+	return 0;
+}
+
+static int ipaccess_bts_rsl_link_up(struct e1inp_line *line)
+{
+	struct ipa_client_conn *rsl_link;
+
+	rsl_link = ipa_client_conn_create(tall_ipa_ctx,
+					  &line->ts[E1INP_SIGN_RSL-1],
+					  E1INP_SIGN_RSL,
+					  line->ops->cfg.ipa.addr,
+					  IPA_TCP_PORT_RSL,
+					  NULL,
+					  ipaccess_bts_cb,
+					  ipaccess_bts_write_cb,
+					  NULL);
+	if (rsl_link == NULL) {
+		LOGP(DLINP, LOGL_ERROR, "cannot create RSL "
+			"BTS link: %s\n", strerror(errno));
+		return -ENOMEM;
+	}
+	if (ipa_client_conn_open(rsl_link) < 0) {
+		LOGP(DLINP, LOGL_ERROR, "cannot open RSL BTS link: %s\n",
+			strerror(errno));
+		ipa_client_conn_close(rsl_link);
+		ipa_client_conn_destroy(rsl_link);
+		return -EIO;
+	}
+
+	return 0;
+}
+
+enum ipaccess_line_state {
+	NONE,
+	OML_UP,
+	RSL_UP,
+	ALL_UP = RSL_UP,
+};
+
 struct ipaccess_line {
-	int line_already_initialized;
+	enum ipaccess_line_state state;
 };
 
 static int ipaccess_line_update(struct e1inp_line *line)
@@ -913,11 +978,9 @@ static int ipaccess_line_update(struct e1inp_line *line)
 	il = line->driver_data;
 
 	/* We only initialize this line once. */
-	if (il->line_already_initialized)
+	if (il->state == ALL_UP)
 		return 0;
 
-	il->line_already_initialized = 1;
-
 	switch(line->ops->cfg.ipa.role) {
 	case E1INP_LINE_R_BSC: {
 		struct ipa_server_link *oml_link, *rsl_link;
@@ -952,58 +1015,34 @@ static int ipaccess_line_update(struct e1inp_line *line)
 			ipa_server_link_destroy(rsl_link);
 			return -EIO;
 		}
+		il->state = ALL_UP;
 		ret = 0;
 		break;
 	}
 	case E1INP_LINE_R_BTS: {
-		struct ipa_client_conn *link, *rsl_link;
-
-		LOGP(DLINP, LOGL_NOTICE, "enabling ipaccess BTS mode\n");
-
-		link = ipa_client_conn_create(tall_ipa_ctx,
-					      &line->ts[E1INP_SIGN_OML-1],
-					      E1INP_SIGN_OML,
-					      line->ops->cfg.ipa.addr,
-					      IPA_TCP_PORT_OML,
-					      NULL,
-					      ipaccess_bts_cb,
-					      ipaccess_bts_write_cb,
-					      NULL);
-		if (link == NULL) {
-			LOGP(DLINP, LOGL_ERROR, "cannot create OML "
-				"BTS link: %s\n", strerror(errno));
-			return -ENOMEM;
-		}
-		if (ipa_client_conn_open(link) < 0) {
-			LOGP(DLINP, LOGL_ERROR, "cannot open OML BTS link: %s\n",
-				strerror(errno));
-			ipa_client_conn_close(link);
-			ipa_client_conn_destroy(link);
-			return -EIO;
-		}
-		rsl_link = ipa_client_conn_create(tall_ipa_ctx,
-						  &line->ts[E1INP_SIGN_RSL-1],
-						  E1INP_SIGN_RSL,
-						  line->ops->cfg.ipa.addr,
-						  IPA_TCP_PORT_RSL,
-						  NULL,
-						  ipaccess_bts_cb,
-						  ipaccess_bts_write_cb,
-						  NULL);
-		if (rsl_link == NULL) {
-			LOGP(DLINP, LOGL_ERROR, "cannot create RSL "
-				"BTS link: %s\n", strerror(errno));
-			return -ENOMEM;
-		}
-		if (ipa_client_conn_open(rsl_link) < 0) {
-			LOGP(DLINP, LOGL_ERROR, "cannot open RSL BTS link: %s\n",
-				strerror(errno));
-			ipa_client_conn_close(rsl_link);
-			ipa_client_conn_destroy(rsl_link);
-			return -EIO;
-		}
-		ret = 0;
+		/* The first call e1inp_line_update, this gets OML link up.
+		 * Once the OML link has been fully established, you call
+		 * e1inp_line_update again to get the RSL link up.
+		 */
+		switch(il->state) {
+		case NONE:
+			LOGP(DLINP, LOGL_NOTICE, "enabling ipaccess BTS mode\n");
+			LOGP(DLINP, LOGL_NOTICE, "getting up OML link\n");
+			ret = ipaccess_bts_oml_link_up(line);
+			il->state = OML_UP;
+			break;
+		case OML_UP:
+			LOGP(DLINP, LOGL_NOTICE, "getting up RSL link\n");
+			ret = ipaccess_bts_rsl_link_up(line);
+			il->state = ALL_UP;
+			break;
+		default:
+			LOGP(DLINP, LOGL_ERROR, "ipaccess BTS links already "
+						"up and running\n");
+			ret = -EBUSY;
+			break;
 		break;
+		}
 	}
 	default:
 		break;
diff --git a/tests/e1inp_ipa_bts_test.c b/tests/e1inp_ipa_bts_test.c
index 31aac95..112af65 100644
--- a/tests/e1inp_ipa_bts_test.c
+++ b/tests/e1inp_ipa_bts_test.c
@@ -57,8 +57,7 @@ sign_link_up(void *unit, struct e1inp_line *line, enum e1inp_sign_type type)
 		if (!oml_sign_link) {
 			LOGP(DBTSTEST, LOGL_ERROR,
 				"cannot create OML sign link\n");
-		}
-		if (oml_sign_link) {
+		} else {
 			unsigned int event_type = 0;
 
 			/* tell GSM 12.21 that we're ready via our eventfd. */
@@ -69,6 +68,20 @@ sign_link_up(void *unit, struct e1inp_line *line, enum e1inp_sign_type type)
 			}
 			/* Now we can send OML messages to the BSC. */
 			bts_state = BTS_TEST_OML_SIGN_LINK_UP;
+
+			/* Well, way more OML messages actually happen before
+			 * we can say that the OML link is fully established,
+			 * but this is a test after all...
+			 */
+			LOGP(DBTSTEST, LOGL_NOTICE, "OML link is up.\n");
+
+			/* Next stage: get RSL link up. */
+			if (e1inp_line_update(line) < 0) {
+				LOGP(DBTSTEST, LOGL_ERROR, "problem enabling "
+							   "E1 line\n");
+				exit(EXIT_FAILURE);
+			}
+
 		}
 		break;
 	case E1INP_SIGN_RSL:
@@ -82,13 +95,12 @@ sign_link_up(void *unit, struct e1inp_line *line, enum e1inp_sign_type type)
 		if (!rsl_sign_link) {
 			LOGP(DBTSTEST, LOGL_ERROR,
 				"cannot create RSL sign link\n");
-		}
+		} else
+			LOGP(DBTSTEST, LOGL_NOTICE, "RSL link is up.\n");
 		break;
 	default:
 		return NULL;
 	}
-	if (sign_link)
-		LOGP(DBTSTEST, LOGL_NOTICE, "signal link has been set up.\n");
 
 	return sign_link;
 }
-- 
1.7.10.4





More information about the OpenBSC mailing list