ipa: extend ipa_*link_create() to take one generic data pointer
With this patch we can attach generic data to some IPA link. This
will be useful for the IPA proxy support.
diff --git a/include/osmocom/abis/ipa.h b/include/osmocom/abis/ipa.h
index 1a9e5d4..1ed4871 100644
--- a/include/osmocom/abis/ipa.h
+++ b/include/osmocom/abis/ipa.h
@@ -12,9 +12,10 @@
const char *addr;
uint16_t port;
int (*accept_cb)(struct ipa_server_link *link, int fd);
+ void *data;
};
-struct ipa_server_link *ipa_server_link_create(void *ctx, struct e1inp_line *line, const char *addr, uint16_t port, int (*accept_cb)(struct ipa_server_link *link, int fd));
+struct ipa_server_link *ipa_server_link_create(void *ctx, struct e1inp_line *line, const char *addr, uint16_t port, int (*accept_cb)(struct ipa_server_link *link, int fd), void *data);
void ipa_server_link_destroy(struct ipa_server_link *link);
int ipa_server_link_open(struct ipa_server_link *link);
@@ -36,9 +37,10 @@
const char *addr;
uint16_t port;
int (*cb)(struct ipa_client_link *link, struct msgb *msg);
+ void *data;
};
-struct ipa_client_link *ipa_client_link_create(void *ctx, struct e1inp_line *line, const char *addr, uint16_t port, int (*cb)(struct ipa_client_link *link, struct msgb *msgb));
+struct ipa_client_link *ipa_client_link_create(void *ctx, struct e1inp_line *line, const char *addr, uint16_t port, int (*cb)(struct ipa_client_link *link, struct msgb *msgb), void *data);
void ipa_client_link_destroy(struct ipa_client_link *link);
int ipa_client_link_open(struct ipa_client_link *link);
diff --git a/src/input/hsl.c b/src/input/hsl.c
index bc8fdb0..0b6b078 100644
--- a/src/input/hsl.c
+++ b/src/input/hsl.c
@@ -338,7 +338,8 @@
LOGP(DINP, LOGL_NOTICE, "enabling hsl BTS mode\n");
link = ipa_client_link_create(tall_hsl_ctx, line, addr,
- HSL_TCP_PORT, hsl_bts_process);
+ HSL_TCP_PORT, hsl_bts_process,
+ NULL);
if (link == NULL) {
LOGP(DINP, LOGL_ERROR, "cannot create BTS link: %s\n",
strerror(errno));
diff --git a/src/input/ipa.c b/src/input/ipa.c
index d99e310..bb32fe1 100644
--- a/src/input/ipa.c
+++ b/src/input/ipa.c
@@ -179,7 +179,8 @@
struct ipa_client_link *
ipa_client_link_create(void *ctx, struct e1inp_line *line,
const char *addr, uint16_t port,
- int (*cb)(struct ipa_client_link *link, struct msgb *msgb))
+ int (*cb)(struct ipa_client_link *link,
+ struct msgb *msgb), void *data)
{
struct ipa_client_link *ipa_link;
@@ -197,6 +198,7 @@
ipa_link->port = port;
ipa_link->cb = cb;
ipa_link->line = line;
+ ipa_link->data = data;
return ipa_link;
}
@@ -265,7 +267,8 @@
struct ipa_server_link *
ipa_server_link_create(void *ctx, struct e1inp_line *line,
const char *addr, uint16_t port,
- int (*accept_cb)(struct ipa_server_link *link, int fd))
+ int (*accept_cb)(struct ipa_server_link *link, int fd),
+ void *data)
{
struct ipa_server_link *ipa_link;
@@ -280,6 +283,7 @@
ipa_link->port = port;
ipa_link->accept_cb = accept_cb;
ipa_link->line = line;
+ ipa_link->data = data;
return ipa_link;
diff --git a/src/input/ipaccess.c b/src/input/ipaccess.c
index a6d09b3..8ce10ab 100644
--- a/src/input/ipaccess.c
+++ b/src/input/ipaccess.c
@@ -459,7 +459,7 @@
oml_link = ipa_server_link_create(tall_ipa_ctx, line,
"0.0.0.0", IPA_TCP_PORT_OML,
- ipaccess_bsc_oml_cb);
+ ipaccess_bsc_oml_cb, NULL);
if (oml_link == NULL) {
LOGP(DINP, LOGL_ERROR, "cannot create OML "
"BSC link: %s\n", strerror(errno));
@@ -474,7 +474,7 @@
}
rsl_link = ipa_server_link_create(tall_ipa_ctx, line,
"0.0.0.0", IPA_TCP_PORT_RSL,
- ipaccess_bsc_rsl_cb);
+ ipaccess_bsc_rsl_cb, NULL);
if (rsl_link == NULL) {
LOGP(DINP, LOGL_ERROR, "cannot create RSL "
"BSC link: %s\n", strerror(errno));
@@ -497,7 +497,7 @@
link = ipa_client_link_create(tall_ipa_ctx, line,
addr, IPA_TCP_PORT_OML,
- ipaccess_bts_cb);
+ ipaccess_bts_cb, NULL);
if (link == NULL) {
LOGP(DINP, LOGL_ERROR, "cannot create OML "
"BTS link: %s\n", strerror(errno));
@@ -512,7 +512,7 @@
}
rsl_link = ipa_client_link_create(tall_ipa_ctx, line,
addr, IPA_TCP_PORT_RSL,
- ipaccess_bts_cb);
+ ipaccess_bts_cb, NULL);
if (rsl_link == NULL) {
LOGP(DINP, LOGL_ERROR, "cannot create RSL "
"BTS link: %s\n", strerror(errno));