add new 'ipaccess-config' program to set Unit ID and primary OML NVRAM parameters of ip.access BTS

diff --git a/src/e1_config.c b/src/e1_config.c
index 4110d48..02fdb5d 100644
--- a/src/e1_config.c
+++ b/src/e1_config.c
@@ -1,6 +1,8 @@
 #include <string.h>
 #include <errno.h>
 
+#include <netinet/in.h>
+
 #include <openbsc/gsm_data.h>
 #include <openbsc/e1_input.h>
 #include <openbsc/trau_mux.h>
@@ -70,7 +72,7 @@
 }
 
 /* do some compiled-in configuration for our BTS/E1 setup */
-int ia_config(struct gsm_bts *bts)
+static struct e1inp_line *__ia_config(struct gsm_bts *bts)
 {
 	struct e1inp_line *line;
 	struct e1inp_ts *sign_ts, *rsl_ts;
@@ -78,7 +80,7 @@
 
 	line = malloc(sizeof(*line));
 	if (!line)
-		return -ENOMEM;
+		return NULL;
 	memset(line, 0, sizeof(*line));
 
 	/* create E1 timeslots for signalling and TRAU frames */
@@ -97,5 +99,33 @@
 	bts->oml_link = oml_link;
 	bts->c0->rsl_link = rsl_link;
 
+	return line;
+}
+
+/* configure pseudo E1 line in ip.access style and create listening socket */
+int ia_config(struct gsm_bts *bts)
+{
+	struct e1inp_line *line;
+
+	line = __ia_config(bts);
+	if (!line)
+		return -ENOMEM;
+
 	return ipaccess_setup(line);
 }
+
+/* configure pseudo E1 line in ip.access style and connect to BTS */
+int ia_config_connect(struct gsm_bts *bts, struct sockaddr_in *sin)
+{
+	struct e1inp_line *line;
+
+	line = __ia_config(bts);
+	if (!line)
+		return -ENOMEM;
+
+	/* default port at BTS for incoming connections is 3006 */
+	if (sin->sin_port == 0)
+		sin->sin_port = htons(3006);
+
+	return ipaccess_connect(line, sin);
+}