* add trau_mux implementation to relay from one incoming TRAU
  channel to another one (simple voice call switching)
* add a way more generic E1 input layer, abstracting out the misdn
  low-level interface. This also adds infrastructure for multiple TRX
  in one BTS, as well as multiple BTS on one E1 link
* add a E1 subchannel multiplexer for sending multiple 16kbit sub-channels
  one one 64kBps E1 channel
* add TRAU IDLE frame generation
* terminate bsc_hack in case there is a E1 / mISDN init error
* introduce 'e1_config.c' file with static configuration of our
  E1 setup (which TRX/BTS is configured for which TEI/SAPI/E1). This should
  later become a config file rather than a compiled C file.

WARNING: all this compiles but is not tested yet.  Expect fix-up committs over
the next hours or so

diff --git a/src/bsc_hack.c b/src/bsc_hack.c
index 7fa12e7..1ff1075 100644
--- a/src/bsc_hack.c
+++ b/src/bsc_hack.c
@@ -45,6 +45,7 @@
 #include <openbsc/misdn.h>
 #include <openbsc/telnet_interface.h>
 #include <openbsc/paging.h>
+#include <openbsc/e1_input.h>
 
 /* global pointer to the gsm network data structure */
 static struct gsm_network *gsmnet;
@@ -654,17 +655,26 @@
 	set_system_infos(trx);
 }
 
-static void mi_cb(int event, struct gsm_bts *bts)
+void input_event(int event, enum e1inp_sign_type type, struct gsm_bts_trx *trx)
 {
 	switch (event) {
-	case EVT_E1_OML_UP:
-		bootstrap_om(bts);
+	case EVT_E1_TEI_UP:
+		switch (type) {
+		case E1INP_SIGN_OML:
+			bootstrap_om(trx->bts);
+			break;
+		case E1INP_SIGN_RSL:
+			bootstrap_rsl(trx);
+			break;
+		default:
+			break;
+		}
 		break;
-	case EVT_E1_RSL_UP:
-		bootstrap_rsl(bts->c0);
+	case EVT_E1_TEI_DN:
+		fprintf(stderr, "Lost some E1 TEI link\n");
+		/* FIXME: deal with TEI or L1 link loss */
 		break;
 	default:
-		/* FIXME: deal with TEI or L1 link loss */
 		break;
 	}
 }
@@ -697,15 +707,14 @@
 	bts->paging.channel_allocated = bsc_hack_channel_allocated;
 
 	telnet_init(gsmnet, 4242);
-	if (mi_setup(bts, 0, mi_cb) < 0)
-		return -EIO;
 
-	return 0;
+	/* E1 mISDN input setup */
+	return e1_config(bts);
 }
 
-
 static void create_pcap_file(char *file)
 {
+#if 0
 	mode_t mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH;
 	int fd = open(file, O_WRONLY|O_TRUNC|O_CREAT, mode);
 
@@ -715,6 +724,9 @@
 	}
 
 	mi_set_pcap_fd(fd);
+#else
+	fprintf(stderr, "PCAP support currently disabled!!\n");
+#endif
 }
 
 static void print_usage()
@@ -815,6 +827,8 @@
 
 int main(int argc, char **argv)
 {
+	int rc;
+
 	/* parse options */
 	handle_options(argc, argv);
 
@@ -830,7 +844,9 @@
 	}
 	printf("DB: Database prepared.\n");
 
-	bootstrap_network();
+	rc = bootstrap_network();
+	if (rc < 0)
+		exit(1);
 
 	signal(SIGHUP, &signal_handler);
 	signal(SIGABRT, &signal_handler);