e1input: add address as parameter to e1inp_line_update(...)

This patch adds a new parameter to e1inp_line_update that allows to
specific the address for A-bis over IP BSC/BTS.
diff --git a/include/osmocom/abis/e1_input.h b/include/osmocom/abis/e1_input.h
index c401baa..c52e441 100644
--- a/include/osmocom/abis/e1_input.h
+++ b/include/osmocom/abis/e1_input.h
@@ -115,7 +115,7 @@
 	struct llist_head list;
 	const char *name;
 	int (*want_write)(struct e1inp_ts *ts);
-	int (*line_update)(struct e1inp_line *line, enum e1inp_line_role role);
+	int (*line_update)(struct e1inp_line *line, enum e1inp_line_role role, const char *addr);
 	int default_delay;
 };
 
@@ -206,7 +206,7 @@
 struct subch_mux *e1inp_get_mux(uint8_t e1_nr, uint8_t ts_nr);
 
 void e1inp_sign_link_destroy(struct e1inp_sign_link *link);
-int e1inp_line_update(struct e1inp_line *line, enum e1inp_line_role role);
+int e1inp_line_update(struct e1inp_line *line, enum e1inp_line_role role, const char *addr);
 
 struct gsm_network;
 int ipaccess_setup(struct gsm_network *gsmnet);
diff --git a/include/osmocom/abis/ipa.h b/include/osmocom/abis/ipa.h
index de1d70f..83e4472 100644
--- a/include/osmocom/abis/ipa.h
+++ b/include/osmocom/abis/ipa.h
@@ -17,11 +17,11 @@
 	struct llist_head	tx_queue;
 	struct osmo_timer_list	timer;
 	enum ipa_link_state	state;
-	struct sockaddr_in	addr;
+	const char		*addr;
 	int (*process)(struct ipa_link *link, struct msgb *msg);
 };
 
-struct ipa_link *ipa_client_link_create(void *ctx);
+struct ipa_link *ipa_client_link_create(void *ctx, const char *addr);
 void ipa_client_link_destroy(struct ipa_link *link);
 
 int ipa_client_link_open(struct ipa_link *link);
diff --git a/src/e1_input.c b/src/e1_input.c
index 3453ad0..1781f18 100644
--- a/src/e1_input.c
+++ b/src/e1_input.c
@@ -560,7 +560,8 @@
 	return NULL;
 }
 
-int e1inp_line_update(struct e1inp_line *line, enum e1inp_line_role role)
+int e1inp_line_update(struct e1inp_line *line,
+		      enum e1inp_line_role role, const char *addr)
 {
 	struct input_signal_data isd;
 	int rc;
@@ -570,7 +571,7 @@
 		return 0;
 
 	if (line->driver && line->driver->line_update)
-		rc = line->driver->line_update(line, role);
+		rc = line->driver->line_update(line, role, addr);
 	else
 		rc = 0;
 
diff --git a/src/input/dahdi.c b/src/input/dahdi.c
index 8e5e635..bf73f97 100644
--- a/src/input/dahdi.c
+++ b/src/input/dahdi.c
@@ -367,8 +367,8 @@
 	return rc;
 }
 
-static int
-dahdi_e1_line_update(struct e1inp_line *line, enum e1inp_line_role role);
+static int dahdi_e1_line_update(struct e1inp_line *line,
+				enum e1inp_line_role role, const char *addr);
 
 struct e1inp_driver dahdi_driver = {
 	.name = "dahdi",
@@ -477,8 +477,8 @@
 	return 0;
 }
 
-static int
-dahdi_e1_line_update(struct e1inp_line *line, enum e1inp_line_role role)
+static int dahdi_e1_line_update(struct e1inp_line *line,
+				enum e1inp_line_role role, void *data)
 {
 	if (line->driver != &dahdi_driver)
 		return -EINVAL;
diff --git a/src/input/hsl.c b/src/input/hsl.c
index f00338f..3854b06 100644
--- a/src/input/hsl.c
+++ b/src/input/hsl.c
@@ -242,7 +242,8 @@
 	return rc;
 }
 
-static int hsl_line_update(struct e1inp_line *line, enum e1inp_line_role role);
+static int hsl_line_update(struct e1inp_line *line,
+			   enum e1inp_line_role role, const char *addr);
 
 struct e1inp_driver hsl_driver = {
 	.name = "hsl",
@@ -300,8 +301,8 @@
         return ret;
 }
 
-static int
-hsl_line_update(struct e1inp_line *line, enum e1inp_line_role role)
+static int hsl_line_update(struct e1inp_line *line,
+			   enum e1inp_line_role role, const char *addr)
 {
 	int ret = -ENOENT;
 
diff --git a/src/input/ipa.c b/src/input/ipa.c
index 6f9639f..3f37d47 100644
--- a/src/input/ipa.c
+++ b/src/input/ipa.c
@@ -176,7 +176,7 @@
 
 static void ipa_link_timer_cb(void *data);
 
-struct ipa_link *ipa_client_link_create(void *ctx)
+struct ipa_link *ipa_client_link_create(void *ctx, const char *addr)
 {
 	struct ipa_link *ipa_link;
 
@@ -190,6 +190,7 @@
 	ipa_link->state = IPA_LINK_STATE_CONNECTING;
 	ipa_link->timer.cb = ipa_link_timer_cb;
 	ipa_link->timer.data = ipa_link;
+	ipa_link->addr = talloc_strdup(ipa_link, addr);
 
 	return ipa_link;
 }
@@ -204,7 +205,7 @@
 	int ret;
 
 	ret = osmo_sock_init(AF_INET, SOCK_STREAM, IPPROTO_TCP,
-			     "127.0.0.1", IPA_TCP_PORT_OML,
+			     link->addr, IPA_TCP_PORT_OML,
 			     OSMO_SOCK_F_CONNECT|OSMO_SOCK_F_NONBLOCK);
 	if (ret < 0) {
 		if (errno != EINPROGRESS)
diff --git a/src/input/ipaccess.c b/src/input/ipaccess.c
index 4a86300..18e30dc 100644
--- a/src/input/ipaccess.c
+++ b/src/input/ipaccess.c
@@ -378,8 +378,8 @@
 	return rc;
 }
 
-static int
-ipaccess_line_update(struct e1inp_line *line, enum e1inp_line_role role);
+static int ipaccess_line_update(struct e1inp_line *line,
+				enum e1inp_line_role role, const char *addr);
 
 struct e1inp_driver ipaccess_driver = {
 	.name = "ipa",
@@ -479,8 +479,8 @@
 	return 0;
 }
 
-static int
-ipaccess_line_update(struct e1inp_line *line, enum e1inp_line_role role)
+static int ipaccess_line_update(struct e1inp_line *line,
+				enum e1inp_line_role role, const char *addr)
 {
 	int ret = -ENOENT;
 
@@ -490,8 +490,7 @@
 
 		/* Listen for OML connections */
 		ret = osmo_sock_init(AF_INET, SOCK_STREAM, IPPROTO_TCP,
-				     "0.0.0.0", IPA_TCP_PORT_OML,
-				     OSMO_SOCK_F_BIND);
+				     addr, IPA_TCP_PORT_OML, OSMO_SOCK_F_BIND);
 		if (ret < 0)
 			return ret;
 
@@ -506,8 +505,7 @@
 		}
 		/* Listen for RSL connections */
 		ret = osmo_sock_init(AF_INET, SOCK_STREAM, IPPROTO_TCP,
-				     "0.0.0.0", IPA_TCP_PORT_RSL,
-				     OSMO_SOCK_F_BIND);
+				     addr, IPA_TCP_PORT_RSL, OSMO_SOCK_F_BIND);
 		if (ret < 0)
 			return ret;
 
@@ -526,7 +524,7 @@
 
 		LOGP(DINP, LOGL_NOTICE, "enabling ipaccess BTS mode\n");
 
-		link = ipa_client_link_create(tall_ipa_ctx);
+		link = ipa_client_link_create(tall_ipa_ctx, addr);
 		if (link == NULL) {
 			perror("ipa_client_link_create: ");
 			return -ENOMEM;
diff --git a/src/input/misdn.c b/src/input/misdn.c
index 4bc2e4b..3ccfc4d 100644
--- a/src/input/misdn.c
+++ b/src/input/misdn.c
@@ -384,8 +384,8 @@
 	return ret;
 }
 
-static int
-mi_e1_line_update(struct e1inp_line *line, enum e1inp_line_role role);
+static int mi_e1_line_update(struct e1inp_line *line,
+			     enum e1inp_line_role role, const char *addr);
 
 struct e1inp_driver misdn_driver = {
 	.name = "misdn",
@@ -483,8 +483,8 @@
 	return 0;
 }
 
-static int
-mi_e1_line_update(struct e1inp_line *line, enum e1inp_line_role role)
+static int mi_e1_line_update(struct e1inp_line *line,
+			     enum e1inp_line_role role, const char *addr)
 {
 	struct mISDN_devinfo devinfo;
 	int sk, ret, cnt;
diff --git a/tests/e1inp_ipa_bsc_test.c b/tests/e1inp_ipa_bsc_test.c
index 6c1cacc..3dfbc54 100644
--- a/tests/e1inp_ipa_bsc_test.c
+++ b/tests/e1inp_ipa_bsc_test.c
@@ -76,7 +76,7 @@
 	 * it explains how this is done with ISDN.
 	 */
 
-	if (e1inp_line_update(line, E1INP_LINE_R_BSC) < 0) {
+	if (e1inp_line_update(line, E1INP_LINE_R_BSC, "0.0.0.0") < 0) {
 		LOGP(DBSCTEST, LOGL_ERROR, "problem creating E1 line\n");
 		exit(EXIT_FAILURE);
 	}
diff --git a/tests/e1inp_ipa_bts_test.c b/tests/e1inp_ipa_bts_test.c
index bf6cf16..6f4ceaa 100644
--- a/tests/e1inp_ipa_bts_test.c
+++ b/tests/e1inp_ipa_bts_test.c
@@ -76,7 +76,7 @@
 	 * it explains how this is done with ISDN.
 	 */
 
-	if (e1inp_line_update(line, E1INP_LINE_R_BTS) < 0) {
+	if (e1inp_line_update(line, E1INP_LINE_R_BTS, "127.0.0.1") < 0) {
 		LOGP(DBTSTEST, LOGL_ERROR, "problem enabling E1 line\n");
 		exit(EXIT_FAILURE);
 	}