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/.
Stefan Sperling gerrit-no-reply at lists.osmocom.orgStefan Sperling has submitted this change and it was merged. ( https://gerrit.osmocom.org/12098 )
Change subject: introduce osmo_gsup_client_create2()
......................................................................
introduce osmo_gsup_client_create2()
Add a new API which allows creating a GSUP client connection with
more identification information than just a unit name. Instead of
being selective about which idenfifiers callers may use, allow
callers to pass a full-blown struct ipaccess_unit. This allows
applications to use entirely custom identifiers on GSUP client
connections.
This change is a prerequisite for inter-MSC handover because MSCs
will need to use unique identifiers towards the HLR, which isn't
very easy to do with the old osmo_gsup_client_create() API. While
it's always been possible to pass a unique unit_name, this is not
as flexible as we would like.
The old API remains for backwards compatibility.
struct osmo_gsup_client grows in size but is allocated internally
by the library; old calling code won't notice the difference.
Change-Id: Ief09677e07d6e977247185b72c605f109aa091f5
Related: OS#3355
---
M include/osmocom/gsupclient/gsup_client.h
M src/gsupclient/gsup_client.c
2 files changed, 49 insertions(+), 19 deletions(-)
Approvals:
Harald Welte: Looks good to me, approved
Jenkins Builder: Verified
diff --git a/include/osmocom/gsupclient/gsup_client.h b/include/osmocom/gsupclient/gsup_client.h
index 981751b..95163cd 100644
--- a/include/osmocom/gsupclient/gsup_client.h
+++ b/include/osmocom/gsupclient/gsup_client.h
@@ -23,6 +23,7 @@
#include <osmocom/core/timer.h>
#include <osmocom/gsm/oap_client.h>
+#include <osmocom/gsm/ipa.h>
/* a loss of GSUP between MSC and HLR is considered quite serious, let's try to recover as quickly as
* possible. Even one new connection attempt per second should be quite acceptable until the link is
@@ -38,7 +39,7 @@
typedef int (*osmo_gsup_client_read_cb_t)(struct osmo_gsup_client *gsupc, struct msgb *msg);
struct osmo_gsup_client {
- const char *unit_name;
+ const char *unit_name; /* same as ipa_dev->unit_name, for backwards compat */
struct ipa_client_conn *link;
osmo_gsup_client_read_cb_t read_cb;
@@ -50,8 +51,16 @@
struct osmo_timer_list connect_timer;
int is_connected;
int got_ipa_pong;
+
+ struct ipaccess_unit *ipa_dev; /* identification information sent to IPA server */
};
+struct osmo_gsup_client *osmo_gsup_client_create2(void *talloc_ctx,
+ struct ipaccess_unit *ipa_dev,
+ const char *ip_addr,
+ unsigned int tcp_port,
+ osmo_gsup_client_read_cb_t read_cb,
+ struct osmo_oap_client_config *oapc_config);
struct osmo_gsup_client *osmo_gsup_client_create(void *talloc_ctx,
const char *unit_name,
const char *ip_addr,
diff --git a/src/gsupclient/gsup_client.c b/src/gsupclient/gsup_client.c
index d34a22d..f259bdc 100644
--- a/src/gsupclient/gsup_client.c
+++ b/src/gsupclient/gsup_client.c
@@ -170,16 +170,12 @@
struct ipaccess_head_ext *he = (struct ipaccess_head_ext *) msgb_l2(msg);
struct osmo_gsup_client *gsupc = (struct osmo_gsup_client *)link->data;
int rc;
- struct ipaccess_unit ipa_dev = {
- /* see gsup_client_create() on const vs non-const */
- .unit_name = (char*)gsupc->unit_name,
- };
- OSMO_ASSERT(ipa_dev.unit_name);
+ OSMO_ASSERT(gsupc->unit_name);
msg->l2h = &hh->data[0];
- rc = ipaccess_bts_handle_ccm(link, &ipa_dev, msg);
+ rc = ipaccess_bts_handle_ccm(link, gsupc->ipa_dev, msg);
if (rc < 0) {
LOGP(DLGSUP, LOGL_NOTICE,
@@ -262,24 +258,33 @@
gsup_client_send_ping(gsupc);
}
-struct osmo_gsup_client *osmo_gsup_client_create(void *talloc_ctx,
- const char *unit_name,
- const char *ip_addr,
- unsigned int tcp_port,
- osmo_gsup_client_read_cb_t read_cb,
- struct osmo_oap_client_config *oapc_config)
+/*!
+ * Create a gsup client connecting to the specified IP address and TCP port.
+ * Use the provided ipaccess unit as the client-side identifier; ipa_dev should
+ * be allocated in talloc_ctx talloc_ctx as well.
+ * \param[in] talloc_ctx talloc context.
+ * \param[in] ipa_dev IP access unit which contains client identification information; must be allocated
+ * in talloc_ctx as well to ensure it lives throughout the lifetime of the connection.
+ * \param[in] ip_addr GSUP server IP address.
+ * \param[in] tcp_port GSUP server TCP port.
+ * \param[in] read_cb callback for reading from the GSUP connection.
+ * \param[in] oapc_config OPA client configuration.
+ * \returns a GSUP client connection or NULL on failure.
+ */
+struct osmo_gsup_client *osmo_gsup_client_create2(void *talloc_ctx,
+ struct ipaccess_unit *ipa_dev,
+ const char *ip_addr,
+ unsigned int tcp_port,
+ osmo_gsup_client_read_cb_t read_cb,
+ struct osmo_oap_client_config *oapc_config)
{
struct osmo_gsup_client *gsupc;
int rc;
gsupc = talloc_zero(talloc_ctx, struct osmo_gsup_client);
OSMO_ASSERT(gsupc);
-
- /* struct ipaccess_unit has a non-const unit_name, so let's copy to be
- * able to have a non-const unit_name here as well. To not taint the
- * public gsup_client API, let's store it in a const char* anyway. */
- gsupc->unit_name = talloc_strdup(gsupc, unit_name);
- OSMO_ASSERT(gsupc->unit_name);
+ gsupc->unit_name = (const char *)ipa_dev->unit_name; /* API backwards compat */
+ gsupc->ipa_dev = ipa_dev;
/* a NULL oapc_config will mark oap_state disabled. */
rc = osmo_oap_client_init(oapc_config, &gsupc->oap_state);
@@ -313,6 +318,22 @@
return NULL;
}
+/**
+ * Like osmo_gsup_client_create2() except it expects a unit name instead
+ * of a full-blown ipacess_unit as the client-side identifier.
+ */
+struct osmo_gsup_client *osmo_gsup_client_create(void *talloc_ctx,
+ const char *unit_name,
+ const char *ip_addr,
+ unsigned int tcp_port,
+ osmo_gsup_client_read_cb_t read_cb,
+ struct osmo_oap_client_config *oapc_config)
+{
+ struct ipaccess_unit *ipa_dev = talloc_zero(talloc_ctx, struct ipaccess_unit);
+ ipa_dev->unit_name = talloc_strdup(ipa_dev, unit_name);
+ return osmo_gsup_client_create2(talloc_ctx, ipa_dev, ip_addr, tcp_port, read_cb, oapc_config);
+}
+
void osmo_gsup_client_destroy(struct osmo_gsup_client *gsupc)
{
osmo_timer_del(&gsupc->connect_timer);
--
To view, visit https://gerrit.osmocom.org/12098
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: osmo-hlr
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: Ief09677e07d6e977247185b72c605f109aa091f5
Gerrit-Change-Number: 12098
Gerrit-PatchSet: 5
Gerrit-Owner: Stefan Sperling <stsp at stsp.name>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder (1000002)
Gerrit-Reviewer: Neels Hofmeyr <nhofmeyr at sysmocom.de>
Gerrit-Reviewer: Stefan Sperling <stsp at stsp.name>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20181206/f3abf6c8/attachment.htm>