[bsc_hack] Allow to select the cardnr defaulting to number 0

Patch from Andreas Eversberg to allow to select the ISDN
card number. The default remains the same.
diff --git a/include/openbsc/e1_input.h b/include/openbsc/e1_input.h
index 61c3e7a..b717c61 100644
--- a/include/openbsc/e1_input.h
+++ b/include/openbsc/e1_input.h
@@ -145,7 +145,7 @@
 struct subch_mux *e1inp_get_mux(u_int8_t e1_nr, u_int8_t ts_nr);
 
 /* e1_config.c */
-int e1_config(struct gsm_bts *bts);
+int e1_config(struct gsm_bts *bts, int cardnr);
 int ia_config(struct gsm_bts *bts);
 int ipaccess_setup(struct e1inp_line *line);
 
diff --git a/src/bsc_hack.c b/src/bsc_hack.c
index 8b25144..38fa5c4 100644
--- a/src/bsc_hack.c
+++ b/src/bsc_hack.c
@@ -55,6 +55,7 @@
 static int MNC = 1;
 static int LAC = 1;
 static int ARFCN = HARDCODED_ARFCN;
+static int cardnr = 0;
 static enum gsm_bts_type BTS_TYPE = GSM_BTS_TYPE_BS11;
 static const char *database_name = "hlr.sqlite3";
 
@@ -926,7 +927,7 @@
 
 	/* E1 mISDN input setup */
 	if (BTS_TYPE == GSM_BTS_TYPE_BS11)
-		return e1_config(bts);
+		return e1_config(bts, cardnr);
 	else
 		return ia_config(bts);
 }
@@ -963,6 +964,7 @@
 	printf("  -r --reject-cause number The reject cause for LOCATION UPDATING REJECT.\n");
 	printf("  -p --pcap file  The filename of the pcap file\n");
 	printf("  -t --bts-type type The BTS type (bs11, nanobts900, nanobts1800)\n");
+	printf("  -C --cardnr number  For bs11 select E1 card number other than 0\n");
 	printf("  -h --help this text\n");
 }
 
@@ -983,10 +985,11 @@
 			{"pcap", 1, 0, 'p'},
 			{"arfcn", 1, 0, 'f'},
 			{"bts-type", 1, 0, 't'},
+			{"cardnr", 1, 0, 'C'},
 			{0, 0, 0, 0}
 		};
 
-		c = getopt_long(argc, argv, "hc:n:d:sar:p:f:t:L:",
+		c = getopt_long(argc, argv, "hc:n:d:sar:p:f:t:C:L:",
 				long_options, &option_index);
 		if (c == -1)
 			break;
@@ -1029,6 +1032,9 @@
 		case 't':
 			BTS_TYPE = parse_btstype(optarg);
 			break;
+		case 'C':
+			cardnr = atoi(optarg);
+			break;
 		default:
 			/* ignore */
 			break;
diff --git a/src/e1_config.c b/src/e1_config.c
index 0aef19d..080ca4f 100644
--- a/src/e1_config.c
+++ b/src/e1_config.c
@@ -15,7 +15,7 @@
 #define TEI_RSL		1
 
 /* do some compiled-in configuration for our BTS/E1 setup */
-int e1_config(struct gsm_bts *bts)
+int e1_config(struct gsm_bts *bts, int cardnr)
 {
 	struct e1inp_line *line;
 	struct e1inp_ts *sign_ts;
@@ -68,7 +68,7 @@
 	bts->trx[1].rsl_link = rsl_link;
 #endif
 
-	return mi_setup(0, line);
+	return mi_setup(cardnr, line);
 }
 
 /* do some compiled-in configuration for our BTS/E1 setup */