aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHarald Welte <laforge@gnumonks.org>2018-07-31 19:40:52 +0200
committerHarald Welte <laforge@gnumonks.org>2018-07-31 19:40:52 +0200
commit5b5ecfbcfa5caa12ca1ed2f332bc1c8e7a90aa0e (patch)
tree7bd1c497370e88b62867725768608c889b2d600b
parenta44b97059221f62056b3608abd7cfba3d9cf214c (diff)
Remove local libgsupclient; Use libosmo-gsup-client from osmo-hlrlaforge/gsup
osmo-hlr has recently (as of Change-Id Iad227bb477d64da30dd6bfbbe1bd0c0a55be9474) a working shared library implementation of libosmo-gsup-client. We can remove the local implementation in osmo-msc and use the system-installed shared library instead. Change-Id: I6f542945403cf2e3ddac419186b09ec0e2d43b69
-rw-r--r--configure.ac2
-rw-r--r--include/osmocom/msc/Makefile.am1
-rw-r--r--include/osmocom/msc/gsup_client.h67
-rw-r--r--include/osmocom/msc/vlr.h3
-rw-r--r--src/Makefile.am1
-rw-r--r--src/libgsupclient/Makefile.am38
-rw-r--r--src/libgsupclient/gsup_client.c347
-rw-r--r--src/libgsupclient/gsup_test_client.c321
-rw-r--r--src/libmsc/gsm_09_11.c6
-rw-r--r--src/libvlr/vlr.c16
-rw-r--r--src/osmo-msc/Makefile.am3
-rw-r--r--tests/msc_vlr/Makefile.am7
-rw-r--r--tests/msc_vlr/msc_vlr_tests.c26
-rw-r--r--tests/sms_queue/Makefile.am3
14 files changed, 35 insertions, 806 deletions
diff --git a/configure.ac b/configure.ac
index be66d51a7..03acc0ccf 100644
--- a/configure.ac
+++ b/configure.ac
@@ -44,6 +44,7 @@ PKG_CHECK_MODULES(LIBOSMONETIF, libosmo-netif >= 0.2.0)
PKG_CHECK_MODULES(LIBOSMOSIGTRAN, libosmo-sigtran >= 0.9.0)
PKG_CHECK_MODULES(LIBOSMOSCCP, libosmo-sccp >= 0.9.0)
PKG_CHECK_MODULES(LIBOSMOMGCPCLIENT, libosmo-mgcp-client >= 1.3.0)
+PKG_CHECK_MODULES(LIBOSMOGSUPCLIENT, libosmo-gsup-client >= 0.2.1)
AC_ARG_ENABLE(sanitize,
[AS_HELP_STRING(
@@ -193,7 +194,6 @@ AC_OUTPUT(
src/Makefile
src/libmsc/Makefile
src/libvlr/Makefile
- src/libgsupclient/Makefile
src/osmo-msc/Makefile
src/utils/Makefile
tests/Makefile
diff --git a/include/osmocom/msc/Makefile.am b/include/osmocom/msc/Makefile.am
index b1a4810df..ebc946a30 100644
--- a/include/osmocom/msc/Makefile.am
+++ b/include/osmocom/msc/Makefile.am
@@ -13,7 +13,6 @@ noinst_HEADERS = \
gsm_data.h \
gsm_data_shared.h \
gsm_subscriber.h \
- gsup_client.h \
iucs.h \
iucs_ranap.h \
iu_dummy.h \
diff --git a/include/osmocom/msc/gsup_client.h b/include/osmocom/msc/gsup_client.h
deleted file mode 100644
index 2f6170b63..000000000
--- a/include/osmocom/msc/gsup_client.h
+++ /dev/null
@@ -1,67 +0,0 @@
-/* GPRS Subscriber Update Protocol client */
-
-/* (C) 2014 by Sysmocom s.f.m.c. GmbH
- * All Rights Reserved
- *
- * Author: Jacob Erlbeck
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-#pragma once
-
-#include <osmocom/core/timer.h>
-
-#include <osmocom/gsm/oap_client.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
- * re-established */
-#define GSUP_CLIENT_RECONNECT_INTERVAL 1
-#define GSUP_CLIENT_PING_INTERVAL 20
-
-struct msgb;
-struct ipa_client_conn;
-struct gsup_client;
-
-/* Expects message in msg->l2h */
-typedef int (*gsup_client_read_cb_t)(struct gsup_client *gsupc,
- struct msgb *msg);
-
-struct gsup_client {
- const char *unit_name;
-
- struct ipa_client_conn *link;
- gsup_client_read_cb_t read_cb;
- void *data;
-
- struct osmo_oap_client_state oap_state;
-
- struct osmo_timer_list ping_timer;
- struct osmo_timer_list connect_timer;
- int is_connected;
- int got_ipa_pong;
-};
-
-struct gsup_client *gsup_client_create(void *talloc_ctx,
- const char *unit_name,
- const char *ip_addr,
- unsigned int tcp_port,
- gsup_client_read_cb_t read_cb,
- struct osmo_oap_client_config *oapc_config);
-
-void gsup_client_destroy(struct gsup_client *gsupc);
-int gsup_client_send(struct gsup_client *gsupc, struct msgb *msg);
-struct msgb *gsup_client_msgb_alloc(void);
-
diff --git a/include/osmocom/msc/vlr.h b/include/osmocom/msc/vlr.h
index b54aa553d..91c28dbd8 100644
--- a/include/osmocom/msc/vlr.h
+++ b/include/osmocom/msc/vlr.h
@@ -12,6 +12,7 @@
#include <osmocom/msc/gsm_data.h>
// for GSM_NAME_LENGTH
#include <osmocom/msc/gsm_subscriber.h>
+#include <osmocom/gsupclient/gsup_client.h>
#define LOGGSUPP(level, gsup, fmt, args...) \
LOGP(DVLR, level, "GSUP(%s) " fmt, (gsup)->imsi, ## args)
@@ -243,7 +244,7 @@ enum vlr_timer {
struct vlr_instance {
struct llist_head subscribers;
struct llist_head operations;
- struct gsup_client *gsup_client;
+ struct osmo_gsup_client *gsup_client;
struct vlr_ops ops;
struct osmo_timer_list lu_expire_timer;
struct {
diff --git a/src/Makefile.am b/src/Makefile.am
index 2322adea4..4e7cea19b 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -21,7 +21,6 @@ AM_LDFLAGS = \
# Libraries
SUBDIRS = \
- libgsupclient \
libvlr \
libmsc \
$(NULL)
diff --git a/src/libgsupclient/Makefile.am b/src/libgsupclient/Makefile.am
deleted file mode 100644
index 6381687e4..000000000
--- a/src/libgsupclient/Makefile.am
+++ /dev/null
@@ -1,38 +0,0 @@
-AM_CPPFLAGS = \
- $(all_includes) \
- -I$(top_srcdir)/include \
- -I$(top_builddir) \
- $(NULL)
-
-AM_CFLAGS = \
- -Wall \
- $(LIBOSMOCORE_CFLAGS) \
- $(LIBOSMOGSM_CFLAGS) \
- $(LIBOSMOVTY_CFLAGS) \
- $(LIBOSMOABIS_CFLAGS) \
- $(COVERAGE_CFLAGS) \
- $(NULL)
-
-noinst_LIBRARIES = \
- libgsupclient.a \
- $(NULL)
-
-libgsupclient_a_SOURCES = \
- gsup_client.c \
- $(NULL)
-
-noinst_PROGRAMS = \
- gsup_test_client \
- $(NULL)
-
-gsup_test_client_SOURCES = \
- gsup_test_client.c \
- $(NULL)
-gsup_test_client_LDADD = \
- libgsupclient.a \
- $(LIBOSMOCORE_LIBS) \
- $(LIBOSMOGSM_LIBS) \
- $(LIBOSMOVTY_LIBS) \
- $(LIBOSMOABIS_LIBS) \
- -lrt \
- $(NULL)
diff --git a/src/libgsupclient/gsup_client.c b/src/libgsupclient/gsup_client.c
deleted file mode 100644
index 39dc181b4..000000000
--- a/src/libgsupclient/gsup_client.c
+++ /dev/null
@@ -1,347 +0,0 @@
-/* Generic Subscriber Update Protocol client */
-
-/* (C) 2014-2016 by Sysmocom s.f.m.c. GmbH
- * All Rights Reserved
- *
- * Author: Jacob Erlbeck
- * Author: Neels Hofmeyr
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#include <osmocom/msc/gsup_client.h>
-
-#include <osmocom/abis/ipa.h>
-#include <osmocom/gsm/protocol/ipaccess.h>
-#include <osmocom/gsm/oap_client.h>
-#include <osmocom/core/msgb.h>
-#include <osmocom/core/logging.h>
-
-#include <osmocom/msc/debug.h>
-
-#include <errno.h>
-#include <string.h>
-
-static void start_test_procedure(struct gsup_client *gsupc);
-
-static void gsup_client_send_ping(struct gsup_client *gsupc)
-{
- struct msgb *msg = gsup_client_msgb_alloc();
-
- msg->l2h = msgb_put(msg, 1);
- msg->l2h[0] = IPAC_MSGT_PING;
- ipa_msg_push_header(msg, IPAC_PROTO_IPACCESS);
- ipa_client_conn_send(gsupc->link, msg);
-}
-
-static int gsup_client_connect(struct gsup_client *gsupc)
-{
- int rc;
-
- if (gsupc->is_connected)
- return 0;
-
- if (osmo_timer_pending(&gsupc->connect_timer)) {
- LOGP(DLGSUP, LOGL_DEBUG,
- "GSUP connect: connect timer already running\n");
- osmo_timer_del(&gsupc->connect_timer);
- }
-
- if (osmo_timer_pending(&gsupc->ping_timer)) {
- LOGP(DLGSUP, LOGL_DEBUG,
- "GSUP connect: ping timer already running\n");
- osmo_timer_del(&gsupc->ping_timer);
- }
-
- if (ipa_client_conn_clear_queue(gsupc->link) > 0)
- LOGP(DLGSUP, LOGL_DEBUG, "GSUP connect: discarded stored messages\n");
-
- rc = ipa_client_conn_open(gsupc->link);
-
- if (rc >= 0) {
- LOGP(DLGSUP, LOGL_NOTICE, "GSUP connecting to %s:%d\n",
- gsupc->link->addr, gsupc->link->port);
- return 0;
- }
-
- LOGP(DLGSUP, LOGL_ERROR, "GSUP failed to connect to %s:%d: %s\n",
- gsupc->link->addr, gsupc->link->port, strerror(-rc));
-
- if (rc == -EBADF || rc == -ENOTSOCK || rc == -EAFNOSUPPORT ||
- rc == -EINVAL)
- return rc;
-
- osmo_timer_schedule(&gsupc->connect_timer,
- GSUP_CLIENT_RECONNECT_INTERVAL, 0);
-
- LOGP(DLGSUP, LOGL_INFO, "Scheduled timer to retry GSUP connect to %s:%d\n",
- gsupc->link->addr, gsupc->link->port);
-
- return 0;
-}
-
-static void connect_timer_cb(void *gsupc_)
-{
- struct gsup_client *gsupc = gsupc_;
-
- if (gsupc->is_connected)
- return;
-
- gsup_client_connect(gsupc);
-}
-
-static void client_send(struct gsup_client *gsupc, int proto_ext,
- struct msgb *msg_tx)
-{
- ipa_prepend_header_ext(msg_tx, proto_ext);
- ipa_msg_push_header(msg_tx, IPAC_PROTO_OSMO);
- ipa_client_conn_send(gsupc->link, msg_tx);
- /* msg_tx is now queued and will be freed. */
-}
-
-static void gsup_client_oap_register(struct gsup_client *gsupc)
-{
- struct msgb *msg_tx;
- int rc;
- rc = osmo_oap_client_register(&gsupc->oap_state, &msg_tx);
-
- if ((rc < 0) || (!msg_tx)) {
- LOGP(DLGSUP, LOGL_ERROR, "GSUP OAP set up, but cannot register.\n");
- return;
- }
-
- client_send(gsupc, IPAC_PROTO_EXT_OAP, msg_tx);
-}
-
-static void gsup_client_updown_cb(struct ipa_client_conn *link, int up)
-{
- struct gsup_client *gsupc = link->data;
-
- LOGP(DLGSUP, LOGL_INFO, "GSUP link to %s:%d %s\n",
- link->addr, link->port, up ? "UP" : "DOWN");
-
- gsupc->is_connected = up;
-
- if (up) {
- start_test_procedure(gsupc);
-
- if (gsupc->oap_state.state == OSMO_OAP_INITIALIZED)
- gsup_client_oap_register(gsupc);
-
- osmo_timer_del(&gsupc->connect_timer);
- } else {
- osmo_timer_del(&gsupc->ping_timer);
-
- osmo_timer_schedule(&gsupc->connect_timer,
- GSUP_CLIENT_RECONNECT_INTERVAL, 0);
- }
-}
-
-static int gsup_client_oap_handle(struct gsup_client *gsupc, struct msgb *msg_rx)
-{
- int rc;
- struct msgb *msg_tx;
-
- /* If the oap_state is disabled, this will reject the messages. */
- rc = osmo_oap_client_handle(&gsupc->oap_state, msg_rx, &msg_tx);
- msgb_free(msg_rx);
- if (rc < 0)
- return rc;
-
- if (msg_tx)
- client_send(gsupc, IPAC_PROTO_EXT_OAP, msg_tx);
-
- return 0;
-}
-
-static int gsup_client_read_cb(struct ipa_client_conn *link, struct msgb *msg)
-{
- struct ipaccess_head *hh = (struct ipaccess_head *) msg->data;
- struct ipaccess_head_ext *he = (struct ipaccess_head_ext *) msgb_l2(msg);
- struct gsup_client *gsupc = (struct 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);
-
- msg->l2h = &hh->data[0];
-
- rc = ipaccess_bts_handle_ccm(link, &ipa_dev, msg);
-
- if (rc < 0) {
- LOGP(DLGSUP, LOGL_NOTICE,
- "GSUP received an invalid IPA/CCM message from %s:%d\n",
- link->addr, link->port);
- /* Link has been closed */
- gsupc->is_connected = 0;
- msgb_free(msg);
- return -1;
- }
-
- if (rc == 1) {
- uint8_t msg_type = *(msg->l2h);
- /* CCM message */
- if (msg_type == IPAC_MSGT_PONG) {
- LOGP(DLGSUP, LOGL_DEBUG, "GSUP receiving PONG\n");
- gsupc->got_ipa_pong = 1;
- }
-
- msgb_free(msg);
- return 0;
- }
-
- if (hh->proto != IPAC_PROTO_OSMO)
- goto invalid;
-
- if (!he || msgb_l2len(msg) < sizeof(*he))
- goto invalid;
-
- msg->l2h = &he->data[0];
-
- if (he->proto == IPAC_PROTO_EXT_GSUP) {
- OSMO_ASSERT(gsupc->read_cb != NULL);
- gsupc->read_cb(gsupc, msg);
- /* expecting read_cb() to free msg */
- } else if (he->proto == IPAC_PROTO_EXT_OAP) {
- return gsup_client_oap_handle(gsupc, msg);
- /* gsup_client_oap_handle frees msg */
- } else
- goto invalid;
-
- return 0;
-
-invalid:
- LOGP(DLGSUP, LOGL_NOTICE,
- "GSUP received an invalid IPA message from %s:%d, size = %d\n",
- link->addr, link->port, msgb_length(msg));
-
- msgb_free(msg);
- return -1;
-}
-
-static void ping_timer_cb(void *gsupc_)
-{
- struct gsup_client *gsupc = gsupc_;
-
- LOGP(DLGSUP, LOGL_INFO, "GSUP ping callback (%s, %s PONG)\n",
- gsupc->is_connected ? "connected" : "not connected",
- gsupc->got_ipa_pong ? "got" : "didn't get");
-
- if (gsupc->got_ipa_pong) {
- start_test_procedure(gsupc);
- return;
- }
-
- LOGP(DLGSUP, LOGL_NOTICE, "GSUP ping timed out, reconnecting\n");
- ipa_client_conn_close(gsupc->link);
- gsupc->is_connected = 0;
-
- gsup_client_connect(gsupc);
-}
-
-static void start_test_procedure(struct gsup_client *gsupc)
-{
- osmo_timer_setup(&gsupc->ping_timer, ping_timer_cb, gsupc);
-
- gsupc->got_ipa_pong = 0;
- osmo_timer_schedule(&gsupc->ping_timer, GSUP_CLIENT_PING_INTERVAL, 0);
- LOGP(DLGSUP, LOGL_DEBUG, "GSUP sending PING\n");
- gsup_client_send_ping(gsupc);
-}
-
-struct gsup_client *gsup_client_create(void *talloc_ctx,
- const char *unit_name,
- const char *ip_addr,
- unsigned int tcp_port,
- gsup_client_read_cb_t read_cb,
- struct osmo_oap_client_config *oapc_config)
-{
- struct gsup_client *gsupc;
- int rc;
-
- gsupc = talloc_zero(talloc_ctx, struct 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);
-
- /* a NULL oapc_config will mark oap_state disabled. */
- rc = osmo_oap_client_init(oapc_config, &gsupc->oap_state);
- if (rc != 0)
- goto failed;
-
- gsupc->link = ipa_client_conn_create(gsupc,
- /* no e1inp */ NULL,
- 0,
- ip_addr, tcp_port,
- gsup_client_updown_cb,
- gsup_client_read_cb,
- /* default write_cb */ NULL,
- gsupc);
- if (!gsupc->link)
- goto failed;
-
- osmo_timer_setup(&gsupc->connect_timer, connect_timer_cb, gsupc);
-
- rc = gsup_client_connect(gsupc);
-
- if (rc < 0)
- goto failed;
-
- gsupc->read_cb = read_cb;
-
- return gsupc;
-
-failed:
- gsup_client_destroy(gsupc);
- return NULL;
-}
-
-void gsup_client_destroy(struct gsup_client *gsupc)
-{
- osmo_timer_del(&gsupc->connect_timer);
- osmo_timer_del(&gsupc->ping_timer);
-
- if (gsupc->link) {
- ipa_client_conn_close(gsupc->link);
- ipa_client_conn_destroy(gsupc->link);
- gsupc->link = NULL;
- }
- talloc_free(gsupc);
-}
-
-int gsup_client_send(struct gsup_client *gsupc, struct msgb *msg)
-{
- if (!gsupc || !gsupc->is_connected) {
- LOGP(DLGSUP, LOGL_ERROR, "GSUP not connected, unable to send %s\n", msgb_hexdump(msg));
- msgb_free(msg);
- return -ENOTCONN;
- }
-
- client_send(gsupc, IPAC_PROTO_EXT_GSUP, msg);
-
- return 0;
-}
-
-struct msgb *gsup_client_msgb_alloc(void)
-{
- return msgb_alloc_headroom(4000, 64, __func__);
-}
diff --git a/src/libgsupclient/gsup_test_client.c b/src/libgsupclient/gsup_test_client.c
deleted file mode 100644
index 0ebcd4a3c..000000000
--- a/src/libgsupclient/gsup_test_client.c
+++ /dev/null
@@ -1,321 +0,0 @@
-#include <string.h>
-#include <stdio.h>
-#include <errno.h>
-#include <signal.h>
-
-#include <osmocom/core/linuxlist.h>
-#include <osmocom/core/msgb.h>
-#include <osmocom/core/select.h>
-#include <osmocom/core/application.h>
-#include <osmocom/core/utils.h>
-#include <osmocom/core/logging.h>
-#include <osmocom/gsm/gsup.h>
-
-#include <osmocom/msc/gsup_client.h>
-
-static struct gsup_client *g_gc;
-
-
-/***********************************************************************
- * IMSI Operation
- ***********************************************************************/
-static LLIST_HEAD(g_imsi_ops);
-
-struct imsi_op_stats {
- uint32_t num_alloc;
- uint32_t num_released;
- uint32_t num_rx_success;
- uint32_t num_rx_error;
- uint32_t num_timeout;
-};
-
-enum imsi_op_type {
- IMSI_OP_SAI,
- IMSI_OP_LU,
- IMSI_OP_ISD,
- _NUM_IMSI_OP
-};
-
-static const struct value_string imsi_op_names[] = {
- { IMSI_OP_SAI, "SAI" },
- { IMSI_OP_LU, "LU" },
- { IMSI_OP_ISD, "ISD" },
- { 0, NULL }
-};
-
-static struct imsi_op_stats imsi_op_stats[_NUM_IMSI_OP];
-
-struct imsi_op {
- struct llist_head list;
- char imsi[17];
- enum imsi_op_type type;
- struct osmo_timer_list timer;
-};
-
-static struct imsi_op *imsi_op_find(const char *imsi,
- enum imsi_op_type type)
-{
- struct imsi_op *io;
-
- llist_for_each_entry(io, &g_imsi_ops, list) {
- if (!strcmp(io->imsi, imsi) && io->type == type)
- return io;
- }
- return NULL;
-}
-
-static void imsi_op_timer_cb(void *data);
-
-static struct imsi_op *imsi_op_alloc(void *ctx, const char *imsi,
- enum imsi_op_type type)
-{
- struct imsi_op *io;
-
- if (imsi_op_find(imsi, type))
- return NULL;
-
- io = talloc_zero(ctx, struct imsi_op);
- OSMO_STRLCPY_ARRAY(io->imsi, imsi);
- io->type = type;
- osmo_timer_setup(&io->timer, imsi_op_timer_cb, io);
- llist_add(&io->list, &g_imsi_ops);
- imsi_op_stats[type].num_alloc++;
-
- return io;
-}
-
-static void imsi_op_release(struct imsi_op *io)
-{
- osmo_timer_del(&io->timer);
- llist_del(&io->list);
- imsi_op_stats[io->type].num_released++;
- talloc_free(io);
-}
-
-static void imsi_op_timer_cb(void *data)
-{
- struct imsi_op *io = data;
- printf("%s: Timer expiration\n", io->imsi);
- imsi_op_stats[io->type].num_timeout++;
- imsi_op_release(io);
-}
-
-/* allocate + generate + send Send-Auth-Info */
-static int req_auth_info(const char *imsi)
-{
- struct imsi_op *io = imsi_op_alloc(g_gc, imsi, IMSI_OP_SAI);
- struct osmo_gsup_message gsup = {0};
- struct msgb *msg = msgb_alloc_headroom(1200, 200, __func__);
- int rc;
-
- OSMO_STRLCPY_ARRAY(gsup.imsi, io->imsi);
- gsup.message_type = OSMO_GSUP_MSGT_SEND_AUTH_INFO_REQUEST;
-
- rc = osmo_gsup_encode(msg, &gsup);
- if (rc < 0) {
- printf("%s: encoding failure (%s)\n", imsi, strerror(-rc));
- return rc;
- }
-
- return gsup_client_send(g_gc, msg);
-}
-
-/* allocate + generate + send Send-Auth-Info */
-static int req_loc_upd(const char *imsi)
-{
- struct imsi_op *io = imsi_op_alloc(g_gc, imsi, IMSI_OP_LU);
- struct osmo_gsup_message gsup = {0};
- struct msgb *msg = msgb_alloc_headroom(1200, 200, __func__);
- int rc;
-
- OSMO_STRLCPY_ARRAY(gsup.imsi, io->imsi);
- gsup.message_type = OSMO_GSUP_MSGT_UPDATE_LOCATION_REQUEST;
-
- rc = osmo_gsup_encode(msg, &gsup);
- if (rc < 0) {
- printf("%s: encoding failure (%s)\n", imsi, strerror(-rc));
- return rc;
- }
-
- return gsup_client_send(g_gc, msg);
-}
-
-static int resp_isd(struct imsi_op *io)
-{
- struct osmo_gsup_message gsup = {0};
- struct msgb *msg = msgb_alloc_headroom(1200, 200, __func__);
- int rc;
-
- OSMO_STRLCPY_ARRAY(gsup.imsi, io->imsi);
- gsup.message_type = OSMO_GSUP_MSGT_INSERT_DATA_RESULT;
-
- rc = osmo_gsup_encode(msg, &gsup);
- if (rc < 0) {
- printf("%s: encoding failure (%s)\n", io->imsi, strerror(-rc));
- return rc;
- }
-
- imsi_op_release(io);
-
- return gsup_client_send(g_gc, msg);
-}
-
-/* receive an incoming GSUP message */
-static void imsi_op_rx_gsup(struct imsi_op *io, const struct osmo_gsup_message *gsup)
-{
- int is_error = 0, rc;
-
- if (OSMO_GSUP_IS_MSGT_ERROR(gsup->message_type)) {
- imsi_op_stats[io->type].num_rx_error++;
- is_error = 1;
- } else
- imsi_op_stats[io->type].num_rx_success++;
-
- switch (io->type) {
- case IMSI_OP_SAI:
- printf("%s; SAI Response%s\n", io->imsi, is_error ? ": ERROR" : "");
- /* now that we have auth tuples, request LU */
- rc = req_loc_upd(io->imsi);
- if (rc < 0)
- printf("Failed to request Location Update for %s\n", io->imsi);
- imsi_op_release(io);
- break;
- case IMSI_OP_LU:
- printf("%s; LU Response%s\n", io->imsi, is_error ? ": ERROR" : "");
- imsi_op_release(io);
- break;
- case IMSI_OP_ISD:
- printf("%s; ISD Request%s\n", io->imsi, is_error ? ": ERROR" : "");
- rc = resp_isd(io);
- if (rc < 0)
- printf("Failed to insert subscriber data for %s\n", io->imsi);
- break;
- default:
- printf("%s: Unknown\n", io->imsi);
- imsi_op_release(io);
- break;
- }
-}
-
-static int op_type_by_gsup_msgt(enum osmo_gsup_message_type msg_type)
-{
- switch (msg_type) {
- case OSMO_GSUP_MSGT_SEND_AUTH_INFO_RESULT:
- case OSMO_GSUP_MSGT_SEND_AUTH_INFO_ERROR:
- return IMSI_OP_SAI;
- case OSMO_GSUP_MSGT_UPDATE_LOCATION_RESULT:
- case OSMO_GSUP_MSGT_UPDATE_LOCATION_ERROR:
- return IMSI_OP_LU;
- case OSMO_GSUP_MSGT_INSERT_DATA_REQUEST:
- return IMSI_OP_ISD;
- default:
- printf("Unknown GSUP msg_type %u\n", msg_type);
- return -1;
- }
-}
-
-static int gsupc_read_cb(struct gsup_client *gsupc, struct msgb *msg)
-{
- struct osmo_gsup_message gsup_msg = {0};
- struct imsi_op *io = NULL;
- int rc;
-
- DEBUGP(DLGSUP, "Rx GSUP %s\n", msgb_hexdump(msg));
-
- rc = osmo_gsup_decode(msgb_l2(msg), msgb_l2len(msg), &gsup_msg);
- if (rc < 0)
- return rc;
-
- if (!gsup_msg.imsi[0])
- return -1;
-
- rc = op_type_by_gsup_msgt(gsup_msg.message_type);
- if (rc < 0)
- return rc;
-
- switch (rc) {
- case IMSI_OP_SAI:
- case IMSI_OP_LU:
- io = imsi_op_find(gsup_msg.imsi, rc);
- break;
- case IMSI_OP_ISD:
- /* ISD is an inbound transaction */
- io = imsi_op_alloc(g_gc, gsup_msg.imsi, IMSI_OP_ISD);
- break;
- }
- if (!io)
- return -1;
-
- imsi_op_rx_gsup(io, &gsup_msg);
- msgb_free(msg);
-
- return 0;
-}
-
-static void print_report(void)
-{
- unsigned int i;
-
- for (i = 0; i < ARRAY_SIZE(imsi_op_stats); i++) {
- struct imsi_op_stats *st = &imsi_op_stats[i];
- const char *name = get_value_string(imsi_op_names, i);
- printf("%s: %u alloc, %u released, %u success, %u error , %u tout\n",
- name, st->num_alloc, st->num_released, st->num_rx_success,
- st->num_rx_error, st->num_timeout);
- }
-}
-
-static void sig_cb(int sig)
-{
- switch (sig) {
- case SIGINT:
- print_report();
- exit(0);
- break;
- }
-}
-
-/* default categories */
-static struct log_info_cat default_categories[] = {
-};
-
-static const struct log_info gsup_test_client_log_info = {
- .cat = default_categories,
- .num_cat = ARRAY_SIZE(default_categories),
-};
-
-int main(int argc, char **argv)
-{
- unsigned long long i;
- char *server_host = "127.0.0.1";
- uint16_t server_port = OSMO_GSUP_PORT;
- void *ctx = talloc_named_const(NULL, 0, "gsup_test_client");
-
- osmo_init_logging2(ctx, &gsup_test_client_log_info);
-
- g_gc = gsup_client_create(ctx, "GSUPTEST", server_host, server_port,
- gsupc_read_cb, NULL);
-
-
- signal(SIGINT, sig_cb);
-
- for (i = 0; i < 10000; i++) {
- unsigned long long imsi = 901790000000000 + i;
- char imsi_buf[17] = { 0 };
- int rc;
-
- snprintf(imsi_buf, sizeof(imsi_buf), "%015llu", imsi);
- rc = req_auth_info(imsi_buf);
- if (rc < 0)
- printf("Failed to request Auth Info for %s\n", imsi_buf);
-
- osmo_select_main(0);
- }
-
- while (1) {
- osmo_select_main(0);
- }
-
- print_report();
- exit(0);
-}
diff --git a/src/libmsc/gsm_09_11.c b/src/libmsc/gsm_09_11.c
index 9b0a9e446..342fd2bf8 100644
--- a/src/libmsc/gsm_09_11.c
+++ b/src/libmsc/gsm_09_11.c
@@ -43,7 +43,7 @@
#include <osmocom/msc/vlr.h>
#include <osmocom/msc/gsm_04_08.h>
#include <osmocom/msc/transaction.h>
-#include <osmocom/msc/gsup_client.h>
+#include <osmocom/gsupclient/gsup_client.h>
#include <osmocom/msc/msc_ifaces.h>
/* FIXME: choose a proper range */
@@ -165,7 +165,7 @@ int gsm0911_rcv_nc_ss(struct gsm_subscriber_connection *conn, struct msgb *msg)
OSMO_STRLCPY_ARRAY(gsup_msg.imsi, conn->vsub->imsi);
/* Allocate GSUP message buffer */
- gsup_msgb = gsup_client_msgb_alloc();
+ gsup_msgb = osmo_gsup_client_msgb_alloc();
if (!gsup_msgb) {
LOGP(DMM, LOGL_ERROR, "Couldn't allocate GSUP message\n");
rc = -ENOMEM;
@@ -180,7 +180,7 @@ int gsm0911_rcv_nc_ss(struct gsm_subscriber_connection *conn, struct msgb *msg)
}
/* Finally send */
- rc = gsup_client_send(conn->network->vlr->gsup_client, gsup_msgb);
+ rc = osmo_gsup_client_send(conn->network->vlr->gsup_client, gsup_msgb);
if (rc) {
LOGP(DMM, LOGL_ERROR, "Couldn't send GSUP message\n");
goto error;
diff --git a/src/libvlr/vlr.c b/src/libvlr/vlr.c
index 2f7dc3052..bfaf3339c 100644
--- a/src/libvlr/vlr.c
+++ b/src/libvlr/vlr.c
@@ -28,7 +28,7 @@
#include <osmocom/gsm/apn.h>
#include <osmocom/gsm/gsm48.h>
#include <osmocom/msc/gsm_subscriber.h>
-#include <osmocom/msc/gsup_client.h>
+#include <osmocom/gsupclient/gsup_client.h>
#include <osmocom/msc/vlr.h>
#include <osmocom/msc/debug.h>
@@ -156,7 +156,7 @@ struct vlr_subscr *_vlr_subscr_find_by_msisdn(struct vlr_instance *vlr,
static int vlr_tx_gsup_message(const struct vlr_instance *vlr,
const struct osmo_gsup_message *gsup_msg)
{
- struct msgb *msg = gsup_client_msgb_alloc();
+ struct msgb *msg = osmo_gsup_client_msgb_alloc();
int rc = osmo_gsup_encode(msg, gsup_msg);
if (rc < 0) {
@@ -174,7 +174,7 @@ static int vlr_tx_gsup_message(const struct vlr_instance *vlr,
LOGP(DVLR, LOGL_DEBUG, "GSUP tx: %s\n",
osmo_hexdump_nospc(msg->data, msg->len));
- return gsup_client_send(vlr->gsup_client, msg);
+ return osmo_gsup_client_send(vlr->gsup_client, msg);
}
/* Transmit GSUP message for subscriber to HLR, using IMSI from subscriber */
@@ -974,7 +974,7 @@ static int vlr_subscr_handle_cancel_req(struct vlr_subscr *vsub,
/* Incoming handler for GSUP from HLR.
* Keep this function non-static for direct invocation by unit tests. */
-int vlr_gsupc_read_cb(struct gsup_client *gsupc, struct msgb *msg)
+int vlr_gsupc_read_cb(struct osmo_gsup_client *gsupc, struct msgb *msg)
{
struct vlr_instance *vlr = (struct vlr_instance *) gsupc->data;
struct vlr_subscr *vsub;
@@ -1214,10 +1214,10 @@ int vlr_start(const char *gsup_unit_name, struct vlr_instance *vlr,
{
OSMO_ASSERT(vlr);
- vlr->gsup_client = gsup_client_create(vlr, gsup_unit_name,
- gsup_server_addr_str,
- gsup_server_port,
- &vlr_gsupc_read_cb, NULL);
+ vlr->gsup_client = osmo_gsup_client_create(vlr, gsup_unit_name,
+ gsup_server_addr_str,
+ gsup_server_port,
+ &vlr_gsupc_read_cb, NULL);
if (!vlr->gsup_client)
return -ENOMEM;
vlr->gsup_client->data = vlr;
diff --git a/src/osmo-msc/Makefile.am b/src/osmo-msc/Makefile.am
index 42bc69fe0..bcc4ada01 100644
--- a/src/osmo-msc/Makefile.am
+++ b/src/osmo-msc/Makefile.am
@@ -17,6 +17,7 @@ AM_CFLAGS = \
$(LIBASN1C_CFLAGS) \
$(LIBOSMOSIGTRAN_CFLAGS) \
$(LIBOSMOMGCPCLIENT_CFLAGS) \
+ $(LIBOSMOGSUPCLIENT_CFLAGS) \
$(NULL)
AM_LDFLAGS = \
@@ -34,7 +35,6 @@ osmo_msc_SOURCES = \
osmo_msc_LDADD = \
$(top_builddir)/src/libmsc/libmsc.a \
$(top_builddir)/src/libvlr/libvlr.a \
- $(top_builddir)/src/libgsupclient/libgsupclient.a \
$(LIBOSMOGSM_LIBS) \
$(LIBOSMOVTY_LIBS) \
$(LIBOSMOCORE_LIBS) \
@@ -43,6 +43,7 @@ osmo_msc_LDADD = \
$(LIBSMPP34_LIBS) \
$(LIBOSMOSIGTRAN_LIBS) \
$(LIBOSMOMGCPCLIENT_LIBS) \
+ $(LIBOSMOGSUPCLIENT_LIBS) \
-ldbi \
$(NULL)
if BUILD_IU
diff --git a/tests/msc_vlr/Makefile.am b/tests/msc_vlr/Makefile.am
index 8b29f7917..e6b20e629 100644
--- a/tests/msc_vlr/Makefile.am
+++ b/tests/msc_vlr/Makefile.am
@@ -15,11 +15,12 @@ AM_CFLAGS = \
$(LIBOSMORANAP_CFLAGS) \
$(LIBASN1C_CFLAGS) \
$(LIBOSMOMGCPCLIENT_CFLAGS) \
+ $(LIBOSMOGSUPCLIENT_CFLAGS) \
$(NULL)
AM_LDFLAGS = \
- -Wl,--wrap=gsup_client_create \
- -Wl,--wrap=gsup_client_send \
+ -Wl,--wrap=osmo_gsup_client_create \
+ -Wl,--wrap=osmo_gsup_client_send \
-Wl,--wrap=a_iface_tx_dtap \
-Wl,--wrap=a_iface_tx_clear_cmd \
-Wl,--wrap=a_iface_tx_paging \
@@ -39,7 +40,6 @@ AM_LDFLAGS = \
LDADD = \
$(top_builddir)/src/libmsc/libmsc.a \
$(top_builddir)/src/libvlr/libvlr.a \
- $(top_builddir)/src/libgsupclient/libgsupclient.a \
$(LIBSMPP34_LIBS) \
$(LIBOSMOCORE_LIBS) \
$(LIBOSMOGSM_LIBS) \
@@ -48,6 +48,7 @@ LDADD = \
$(LIBOSMOSIGTRAN_LIBS) \
$(LIBOSMORANAP_LIBS) \
$(LIBOSMOMGCPCLIENT_LIBS) \
+ $(LIBOSMOGSUPCLIENT_LIBS) \
$(LIBRARY_GSM) \
-ldbi \
-lrt \
diff --git a/tests/msc_vlr/msc_vlr_tests.c b/tests/msc_vlr/msc_vlr_tests.c
index 14881096e..f8551dde7 100644
--- a/tests/msc_vlr/msc_vlr_tests.c
+++ b/tests/msc_vlr/msc_vlr_tests.c
@@ -30,7 +30,7 @@
#include <osmocom/core/application.h>
#include <osmocom/gsm/protocol/gsm_04_11.h>
#include <osmocom/gsm/gsup.h>
-#include <osmocom/msc/gsup_client.h>
+#include <osmocom/gsupclient/gsup_client.h>
#include <osmocom/msc/gsm_04_11.h>
#include <osmocom/msc/debug.h>
#include <osmocom/msc/gsm_04_08.h>
@@ -138,7 +138,7 @@ void dtap_expect_tx(const char *hex)
dtap_tx_confirmed = false;
}
-int vlr_gsupc_read_cb(struct gsup_client *gsupc, struct msgb *msg);
+int vlr_gsupc_read_cb(struct osmo_gsup_client *gsupc, struct msgb *msg);
void gsup_rx(const char *rx_hex, const char *expect_tx_hex)
{
@@ -494,24 +494,24 @@ int mncc_recv(struct gsm_network *net, struct msgb *msg)
}
/* override, requires '-Wl,--wrap=gsup_client_create' */
-struct gsup_client *
-__real_gsup_client_create(const char *ip_addr, unsigned int tcp_port,
- gsup_client_read_cb_t read_cb,
+struct osmo_gsup_client *
+__real_osmo_gsup_client_create(const char *ip_addr, unsigned int tcp_port,
+ osmo_gsup_client_read_cb_t read_cb,
struct osmo_oap_client_config *oap_config);
-struct gsup_client *
-__wrap_gsup_client_create(const char *ip_addr, unsigned int tcp_port,
- gsup_client_read_cb_t read_cb,
+struct osmo_gsup_client *
+__wrap_osmo_gsup_client_create(const char *ip_addr, unsigned int tcp_port,
+ osmo_gsup_client_read_cb_t read_cb,
struct osmo_oap_client_config *oap_config)
{
- struct gsup_client *gsupc;
- gsupc = talloc_zero(msc_vlr_tests_ctx, struct gsup_client);
+ struct osmo_gsup_client *gsupc;
+ gsupc = talloc_zero(msc_vlr_tests_ctx, struct osmo_gsup_client);
OSMO_ASSERT(gsupc);
return gsupc;
}
/* override, requires '-Wl,--wrap=gsup_client_send' */
-int __real_gsup_client_send(struct gsup_client *gsupc, struct msgb *msg);
-int __wrap_gsup_client_send(struct gsup_client *gsupc, struct msgb *msg)
+int __real_osmo_gsup_client_send(struct osmo_gsup_client *gsupc, struct msgb *msg);
+int __wrap_osmo_gsup_client_send(struct osmo_gsup_client *gsupc, struct msgb *msg)
{
const char *is = osmo_hexdump_nospc(msg->data, msg->len);
fprintf(stderr, "GSUP --> HLR: %s: %s\n",
@@ -831,7 +831,7 @@ static void check_talloc(void *msgb_ctx, void *msc_vlr_tests_ctx)
/* Expecting these to stick around in msc_vlr_tests_ctx:
* talloc_total_blocks(tall_bsc_ctx) == 12
* full talloc report on 'msc_vlr_tests_ctx' (total 3636 bytes in 12 blocks)
- * struct gsup_client contains 248 bytes in 1 blocks (ref 0) 0x563a489c05f0
+ * struct osmo_gsup_client contains 248 bytes in 1 blocks (ref 0) 0x563a489c05f0
* struct gsm_network contains 2031 bytes in 4 blocks (ref 0) 0x563a489bfbb0
* struct vlr_instance contains 168 bytes in 1 blocks (ref 0) 0x563a489c04e0
* no_gsup_server contains 15 bytes in 1 blocks (ref 0) 0x563a489c0460
diff --git a/tests/sms_queue/Makefile.am b/tests/sms_queue/Makefile.am
index 61b8515d8..1ffbe1c44 100644
--- a/tests/sms_queue/Makefile.am
+++ b/tests/sms_queue/Makefile.am
@@ -14,6 +14,7 @@ AM_CFLAGS = \
$(LIBOSMORANAP_CFLAGS) \
$(LIBASN1C_CFLAGS) \
$(LIBOSMOMGCPCLIENT_CFLAGS) \
+ $(LIBOSMOGSUPCLIENT_CFLAGS) \
$(NULL)
EXTRA_DIST = \
@@ -32,7 +33,6 @@ sms_queue_test_SOURCES = \
sms_queue_test_LDADD = \
$(top_builddir)/src/libmsc/libmsc.a \
$(top_builddir)/src/libvlr/libvlr.a \
- $(top_builddir)/src/libgsupclient/libgsupclient.a \
$(LIBSMPP34_LIBS) \
$(LIBOSMOCORE_LIBS) \
$(LIBOSMOGSM_LIBS) \
@@ -41,6 +41,7 @@ sms_queue_test_LDADD = \
$(LIBOSMOSIGTRAN_LIBS) \
$(LIBOSMORANAP_LIBS) \
$(LIBOSMOMGCPCLIENT_LIBS) \
+ $(LIBOSMOGSUPCLIENT_LIBS) \
$(LIBRARY_GSM) \
-ldbi \
-lrt \