INPUT: Allow for a per-TRX OML link

So far, all BTS we have interfaced had one OML link per BTS, independent of the
number of TRX.  In Ericsson RBS 2000, there is an OML link for the DXU/IXU,
and one additional OML link for each TRX/TRU.
diff --git a/openbsc/src/e1_config.c b/openbsc/src/e1_config.c
index db290cb..9e191ba 100644
--- a/openbsc/src/e1_config.c
+++ b/openbsc/src/e1_config.c
@@ -100,10 +100,19 @@
 	}
 	sign_ts = &line->ts[e1_link->e1_ts-1];
 	e1inp_ts_config(sign_ts, line, E1INP_TS_TYPE_SIGN);
+	/* Ericsson RBS have a per-TRX OML link in parallel to RSL */
 	if (trx->bts->type == GSM_BTS_TYPE_RBS2000) {
-		/* FIXME: where to put the reference of the per-TRX OML? */
-		e1inp_sign_link_create(sign_ts, E1INP_SIGN_OML, trx,
-					trx->rsl_tei, SAPI_OML);
+		struct e1inp_sign_link *oml_link;
+		oml_link = e1inp_sign_link_create(sign_ts, E1INP_SIGN_OML, trx,
+						  trx->rsl_tei, SAPI_OML);
+		if (!oml_link) {
+			LOGP(DINP, LOGL_ERROR, "TRX (%u/$u) OML link creation "
+				"failed\n", trx->bts->nr, trx->nr);
+			return -ENOMEM;
+		}
+		if (trx->oml_link)
+			e1inp_sign_link_destroy(trx->oml_link);
+		trx->oml_link = oml_link;
 	}
 	rsl_link = e1inp_sign_link_create(sign_ts, E1INP_SIGN_RSL,
 					  trx, trx->rsl_tei, SAPI_RSL);
diff --git a/openbsc/src/e1_input.c b/openbsc/src/e1_input.c
index 79c3a5a..b55fe2e 100644
--- a/openbsc/src/e1_input.c
+++ b/openbsc/src/e1_input.c
@@ -268,7 +268,12 @@
 		return -EINVAL;
 	}
 
-	sign_link = msg->trx->bts->oml_link;
+	/* Check for TRX-specific OML link first */
+	if (msg->trx->oml_link)
+		sign_link = msg->trx->oml_link;
+	else
+		sign_link = msg->trx->bts->oml_link;
+
 	e1i_ts = sign_link->ts;
 	if (!bsc_timer_pending(&e1i_ts->sign.tx_timer)) {
 		/* notify the driver we have something to write */