ipa: Allow setting local addr and port for struct ipa_client_conn
Change-Id: I3133c6b01647506a5b9c67e4699bcad3ff59f843
This commit is contained in:
parent
e11afdaa0e
commit
b6e28bf77b
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -154,6 +154,20 @@ ipa_client_conn_create(void *ctx, struct e1inp_ts *ts,
|
|||
struct msgb *msgb),
|
||||
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;
|
||||
|
||||
|
@ -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;
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in New Issue