Change in libosmo-abis[master]: ipa: Allow setting local addr and port for struct ipa_client_conn

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

pespin gerrit-no-reply at lists.osmocom.org
Tue Nov 12 15:56:29 UTC 2019


pespin has submitted this change. ( https://gerrit.osmocom.org/c/libosmo-abis/+/16014 )

Change subject: ipa: Allow setting local addr and port for struct ipa_client_conn
......................................................................

ipa: Allow setting local addr and port for struct ipa_client_conn

Change-Id: I3133c6b01647506a5b9c67e4699bcad3ff59f843
---
M TODO-RELEASE
M include/osmocom/abis/ipa.h
M src/input/ipa.c
M src/input/ipaccess.c
M src/ipa_proxy.c
5 files changed, 41 insertions(+), 8 deletions(-)

Approvals:
  Jenkins Builder: Verified
  laforge: Looks good to me, but someone else must approve
  osmith: Looks good to me, approved



diff --git a/TODO-RELEASE b/TODO-RELEASE
index d0852fc..4fe42c6 100644
--- a/TODO-RELEASE
+++ b/TODO-RELEASE
@@ -7,3 +7,5 @@
 # If any interfaces have been added since the last public release: c:r:a + 1.
 # If any interfaces have been removed or changed since the last public release: c:r:0.
 #library	what		description / commit summary line
+libosmo-abis	struct ipa_client_conn		Fields added at the end (no ABI break because instance is created through API func)
+libosmo-abis	ipa_client_conn_create2()	New API added
diff --git a/include/osmocom/abis/ipa.h b/include/osmocom/abis/ipa.h
index ff00697..4764a95 100644
--- a/include/osmocom/abis/ipa.h
+++ b/include/osmocom/abis/ipa.h
@@ -78,6 +78,8 @@
 	int (*write_cb)(struct ipa_client_conn *link);
 	void				*data;
 	struct msgb			*pending_msg;
+	const char			*local_addr;
+	uint16_t			local_port;
 };
 
 struct ipa_client_conn *
@@ -86,7 +88,16 @@
 			void (*updown)(struct ipa_client_conn *link, int),
 			int (*read_cb)(struct ipa_client_conn *link, struct msgb *msgb),
 			int (*write_cb)(struct ipa_client_conn *link),
-			void *data);
+			void *data) OSMO_DEPRECATED("Use ipa_client_conn_create2() instead");
+struct ipa_client_conn *
+ipa_client_conn_create2(void *ctx, struct e1inp_ts *ts,
+		       int priv_nr, const char *loc_addr, uint16_t loc_port,
+		       const char *rem_addr, uint16_t rem_port,
+		       void (*updown_cb)(struct ipa_client_conn *link, int up),
+		       int (*read_cb)(struct ipa_client_conn *link,
+				      struct msgb *msgb),
+		       int (*write_cb)(struct ipa_client_conn *link),
+		       void *data);
 void ipa_client_conn_destroy(struct ipa_client_conn *link);
 
 int ipa_client_conn_open(struct ipa_client_conn *link);
diff --git a/src/input/ipa.c b/src/input/ipa.c
index b4dbcb0..0f67dca 100644
--- a/src/input/ipa.c
+++ b/src/input/ipa.c
@@ -155,6 +155,20 @@
 		       int (*write_cb)(struct ipa_client_conn *link),
 		       void *data)
 {
+	return ipa_client_conn_create2(ctx, ts, priv_nr, NULL, 0, addr, port,
+				       updown_cb, read_cb, write_cb, data);
+}
+
+struct ipa_client_conn *
+ipa_client_conn_create2(void *ctx, struct e1inp_ts *ts,
+		       int priv_nr, const char *loc_addr, uint16_t loc_port,
+		       const char *rem_addr, uint16_t rem_port,
+		       void (*updown_cb)(struct ipa_client_conn *link, int up),
+		       int (*read_cb)(struct ipa_client_conn *link,
+				      struct msgb *msgb),
+		       int (*write_cb)(struct ipa_client_conn *link),
+		       void *data)
+{
 	struct ipa_client_conn *ipa_link;
 
 	ipa_link = talloc_zero(ctx, struct ipa_client_conn);
@@ -181,8 +195,10 @@
 	ipa_link->ofd->data = ipa_link;
 	ipa_link->ofd->fd = -1;
 	ipa_link->state = IPA_CLIENT_LINK_STATE_CONNECTING;
-	ipa_link->addr = talloc_strdup(ipa_link, addr);
-	ipa_link->port = port;
+	ipa_link->local_addr = talloc_strdup(ipa_link, loc_addr);
+	ipa_link->local_port = loc_port;
+	ipa_link->addr = talloc_strdup(ipa_link, rem_addr);
+	ipa_link->port = rem_port;
 	ipa_link->updown_cb = updown_cb;
 	ipa_link->read_cb = read_cb;
 	/* default to generic write callback if not set. */
@@ -209,9 +225,10 @@
 	int ret;
 
 	link->state = IPA_CLIENT_LINK_STATE_CONNECTING;
-	ret = osmo_sock_init(AF_INET, SOCK_STREAM, IPPROTO_TCP,
+	ret = osmo_sock_init2(AF_INET, SOCK_STREAM, IPPROTO_TCP,
+			     link->local_addr, link->local_port,
 			     link->addr, link->port,
-			     OSMO_SOCK_F_CONNECT|OSMO_SOCK_F_NONBLOCK);
+			     OSMO_SOCK_F_BIND|OSMO_SOCK_F_CONNECT|OSMO_SOCK_F_NONBLOCK);
 	if (ret < 0)
 		return ret;
 	link->ofd->fd = ret;
diff --git a/src/input/ipaccess.c b/src/input/ipaccess.c
index 474bfb4..0f8e2d5 100644
--- a/src/input/ipaccess.c
+++ b/src/input/ipaccess.c
@@ -896,9 +896,10 @@
 		     "OML connecting to %s:%u\n", line->ops->cfg.ipa.addr,
 		     IPA_TCP_PORT_OML);
 
-		link = ipa_client_conn_create(tall_ipa_ctx,
+		link = ipa_client_conn_create2(tall_ipa_ctx,
 					      e1inp_line_ipa_oml_ts(line),
 					      E1INP_SIGN_OML,
+					      NULL, 0,
 					      line->ops->cfg.ipa.addr,
 					      IPA_TCP_PORT_OML,
 					      ipaccess_bts_updown_cb,
@@ -946,9 +947,10 @@
 		return -EINVAL;
 	}
 
-	rsl_link = ipa_client_conn_create(tall_ipa_ctx,
+	rsl_link = ipa_client_conn_create2(tall_ipa_ctx,
 					  e1inp_line_ipa_rsl_ts(line, trx_nr),
 					  E1INP_SIGN_RSL+trx_nr,
+					  NULL, 0,
 					  rem_addr, rem_port,
 					  ipaccess_bts_updown_cb,
 					  ipaccess_bts_read_cb,
diff --git a/src/ipa_proxy.c b/src/ipa_proxy.c
index 44f5baf..980add7 100644
--- a/src/ipa_proxy.c
+++ b/src/ipa_proxy.c
@@ -184,7 +184,8 @@
 
 	LOGP(DLINP, LOGL_NOTICE, "now trying to connect to destination\n");
 
-	conn->dst = ipa_client_conn_create(NULL, NULL, 0,
+	conn->dst = ipa_client_conn_create2(NULL, NULL, 0,
+					   NULL, 0,
 					   route->shared->dst.inst->net.addr,
 					   route->shared->dst.inst->net.port,
 					   NULL,

-- 
To view, visit https://gerrit.osmocom.org/c/libosmo-abis/+/16014
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: libosmo-abis
Gerrit-Branch: master
Gerrit-Change-Id: I3133c6b01647506a5b9c67e4699bcad3ff59f843
Gerrit-Change-Number: 16014
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <pespin at sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge at osmocom.org>
Gerrit-Reviewer: osmith <osmith at sysmocom.de>
Gerrit-Reviewer: pespin <pespin at sysmocom.de>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20191112/9b319228/attachment.htm>


More information about the gerrit-log mailing list