aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPau Espin Pedrol <pespin@sysmocom.de>2019-11-08 17:30:28 +0100
committerPau Espin Pedrol <pespin@sysmocom.de>2019-11-08 17:30:28 +0100
commitb6e28bf77bfd0db8348c56793b2bfda812496d75 (patch)
tree67af9f2ddfae664684aa42db2e2e9bbe379ed614
parente11afdaa0e9b94bcdb958500196be26b3a16c8e3 (diff)
ipa: Allow setting local addr and port for struct ipa_client_conn
-rw-r--r--TODO-RELEASE2
-rw-r--r--include/osmocom/abis/ipa.h13
-rw-r--r--src/input/ipa.c25
-rw-r--r--src/input/ipaccess.c6
-rw-r--r--src/ipa_proxy.c3
5 files changed, 41 insertions, 8 deletions
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 @@ struct ipa_client_conn {
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 @@ ipa_client_conn_create(void *ctx, struct e1inp_ts *ts, int priv_nr,
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 @@ ipa_client_conn_create(void *ctx, struct e1inp_ts *ts,
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_client_conn_create(void *ctx, struct e1inp_ts *ts,
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 ipa_client_conn_open(struct ipa_client_conn *link)
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 @@ static int ipaccess_line_update(struct e1inp_line *line)
"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 @@ int e1inp_ipa_bts_rsl_connect_n(struct e1inp_line *line,
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 @@ ipa_sock_src_accept_cb(struct ipa_server_link *link, int fd)
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,