gsup_client: rename gsup_client_* to osmo_gsup_client_*

As we're moving this to a common/shared library now, we need to use
the osmo_ namespace prefix for symbol names, struct/type names and
constants.

Change-Id: I294f8f96af4c5daa2b128962534426e04909290e
This commit is contained in:
Harald Welte 2018-07-23 11:11:22 +02:00
parent ec6915a771
commit 953d27ce8f
3 changed files with 49 additions and 50 deletions

View File

@ -27,22 +27,21 @@
/* a loss of GSUP between MSC and HLR is considered quite serious, let's try to recover as quickly as /* 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 * possible. Even one new connection attempt per second should be quite acceptable until the link is
* re-established */ * re-established */
#define GSUP_CLIENT_RECONNECT_INTERVAL 1 #define OSMO_GSUP_CLIENT_RECONNECT_INTERVAL 1
#define GSUP_CLIENT_PING_INTERVAL 20 #define OSMO_GSUP_CLIENT_PING_INTERVAL 20
struct msgb; struct msgb;
struct ipa_client_conn; struct ipa_client_conn;
struct gsup_client; struct osmo_gsup_client;
/* Expects message in msg->l2h */ /* Expects message in msg->l2h */
typedef int (*gsup_client_read_cb_t)(struct gsup_client *gsupc, typedef int (*osmo_gsup_client_read_cb_t)(struct osmo_gsup_client *gsupc, struct msgb *msg);
struct msgb *msg);
struct gsup_client { struct osmo_gsup_client {
const char *unit_name; const char *unit_name;
struct ipa_client_conn *link; struct ipa_client_conn *link;
gsup_client_read_cb_t read_cb; osmo_gsup_client_read_cb_t read_cb;
void *data; void *data;
struct osmo_oap_client_state oap_state; struct osmo_oap_client_state oap_state;
@ -53,14 +52,14 @@ struct gsup_client {
int got_ipa_pong; int got_ipa_pong;
}; };
struct gsup_client *gsup_client_create(void *talloc_ctx, struct osmo_gsup_client *osmo_gsup_client_create(void *talloc_ctx,
const char *unit_name, const char *unit_name,
const char *ip_addr, const char *ip_addr,
unsigned int tcp_port, unsigned int tcp_port,
gsup_client_read_cb_t read_cb, osmo_gsup_client_read_cb_t read_cb,
struct osmo_oap_client_config *oapc_config); struct osmo_oap_client_config *oapc_config);
void gsup_client_destroy(struct gsup_client *gsupc); void osmo_gsup_client_destroy(struct osmo_gsup_client *gsupc);
int gsup_client_send(struct gsup_client *gsupc, struct msgb *msg); int osmo_gsup_client_send(struct osmo_gsup_client *gsupc, struct msgb *msg);
struct msgb *gsup_client_msgb_alloc(void); struct msgb *osmo_gsup_client_msgb_alloc(void);

View File

@ -32,11 +32,11 @@
#include <errno.h> #include <errno.h>
#include <string.h> #include <string.h>
static void start_test_procedure(struct gsup_client *gsupc); static void start_test_procedure(struct osmo_gsup_client *gsupc);
static void gsup_client_send_ping(struct gsup_client *gsupc) static void gsup_client_send_ping(struct osmo_gsup_client *gsupc)
{ {
struct msgb *msg = gsup_client_msgb_alloc(); struct msgb *msg = osmo_gsup_client_msgb_alloc();
msg->l2h = msgb_put(msg, 1); msg->l2h = msgb_put(msg, 1);
msg->l2h[0] = IPAC_MSGT_PING; msg->l2h[0] = IPAC_MSGT_PING;
@ -44,7 +44,7 @@ static void gsup_client_send_ping(struct gsup_client *gsupc)
ipa_client_conn_send(gsupc->link, msg); ipa_client_conn_send(gsupc->link, msg);
} }
static int gsup_client_connect(struct gsup_client *gsupc) static int gsup_client_connect(struct osmo_gsup_client *gsupc)
{ {
int rc; int rc;
@ -82,7 +82,7 @@ static int gsup_client_connect(struct gsup_client *gsupc)
return rc; return rc;
osmo_timer_schedule(&gsupc->connect_timer, osmo_timer_schedule(&gsupc->connect_timer,
GSUP_CLIENT_RECONNECT_INTERVAL, 0); OSMO_GSUP_CLIENT_RECONNECT_INTERVAL, 0);
LOGP(DLGSUP, LOGL_INFO, "Scheduled timer to retry GSUP connect to %s:%d\n", LOGP(DLGSUP, LOGL_INFO, "Scheduled timer to retry GSUP connect to %s:%d\n",
gsupc->link->addr, gsupc->link->port); gsupc->link->addr, gsupc->link->port);
@ -92,7 +92,7 @@ static int gsup_client_connect(struct gsup_client *gsupc)
static void connect_timer_cb(void *gsupc_) static void connect_timer_cb(void *gsupc_)
{ {
struct gsup_client *gsupc = gsupc_; struct osmo_gsup_client *gsupc = gsupc_;
if (gsupc->is_connected) if (gsupc->is_connected)
return; return;
@ -100,7 +100,7 @@ static void connect_timer_cb(void *gsupc_)
gsup_client_connect(gsupc); gsup_client_connect(gsupc);
} }
static void client_send(struct gsup_client *gsupc, int proto_ext, static void client_send(struct osmo_gsup_client *gsupc, int proto_ext,
struct msgb *msg_tx) struct msgb *msg_tx)
{ {
ipa_prepend_header_ext(msg_tx, proto_ext); ipa_prepend_header_ext(msg_tx, proto_ext);
@ -109,7 +109,7 @@ static void client_send(struct gsup_client *gsupc, int proto_ext,
/* msg_tx is now queued and will be freed. */ /* msg_tx is now queued and will be freed. */
} }
static void gsup_client_oap_register(struct gsup_client *gsupc) static void gsup_client_oap_register(struct osmo_gsup_client *gsupc)
{ {
struct msgb *msg_tx; struct msgb *msg_tx;
int rc; int rc;
@ -125,7 +125,7 @@ static void gsup_client_oap_register(struct gsup_client *gsupc)
static void gsup_client_updown_cb(struct ipa_client_conn *link, int up) static void gsup_client_updown_cb(struct ipa_client_conn *link, int up)
{ {
struct gsup_client *gsupc = link->data; struct osmo_gsup_client *gsupc = link->data;
LOGP(DLGSUP, LOGL_INFO, "GSUP link to %s:%d %s\n", LOGP(DLGSUP, LOGL_INFO, "GSUP link to %s:%d %s\n",
link->addr, link->port, up ? "UP" : "DOWN"); link->addr, link->port, up ? "UP" : "DOWN");
@ -143,11 +143,11 @@ static void gsup_client_updown_cb(struct ipa_client_conn *link, int up)
osmo_timer_del(&gsupc->ping_timer); osmo_timer_del(&gsupc->ping_timer);
osmo_timer_schedule(&gsupc->connect_timer, osmo_timer_schedule(&gsupc->connect_timer,
GSUP_CLIENT_RECONNECT_INTERVAL, 0); OSMO_GSUP_CLIENT_RECONNECT_INTERVAL, 0);
} }
} }
static int gsup_client_oap_handle(struct gsup_client *gsupc, struct msgb *msg_rx) static int gsup_client_oap_handle(struct osmo_gsup_client *gsupc, struct msgb *msg_rx)
{ {
int rc; int rc;
struct msgb *msg_tx; struct msgb *msg_tx;
@ -168,7 +168,7 @@ 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 *hh = (struct ipaccess_head *) msg->data;
struct ipaccess_head_ext *he = (struct ipaccess_head_ext *) msgb_l2(msg); struct ipaccess_head_ext *he = (struct ipaccess_head_ext *) msgb_l2(msg);
struct gsup_client *gsupc = (struct gsup_client *)link->data; struct osmo_gsup_client *gsupc = (struct osmo_gsup_client *)link->data;
int rc; int rc;
struct ipaccess_unit ipa_dev = { struct ipaccess_unit ipa_dev = {
/* see gsup_client_create() on const vs non-const */ /* see gsup_client_create() on const vs non-const */
@ -234,7 +234,7 @@ invalid:
static void ping_timer_cb(void *gsupc_) static void ping_timer_cb(void *gsupc_)
{ {
struct gsup_client *gsupc = gsupc_; struct osmo_gsup_client *gsupc = gsupc_;
LOGP(DLGSUP, LOGL_INFO, "GSUP ping callback (%s, %s PONG)\n", LOGP(DLGSUP, LOGL_INFO, "GSUP ping callback (%s, %s PONG)\n",
gsupc->is_connected ? "connected" : "not connected", gsupc->is_connected ? "connected" : "not connected",
@ -252,27 +252,27 @@ static void ping_timer_cb(void *gsupc_)
gsup_client_connect(gsupc); gsup_client_connect(gsupc);
} }
static void start_test_procedure(struct gsup_client *gsupc) static void start_test_procedure(struct osmo_gsup_client *gsupc)
{ {
osmo_timer_setup(&gsupc->ping_timer, ping_timer_cb, gsupc); osmo_timer_setup(&gsupc->ping_timer, ping_timer_cb, gsupc);
gsupc->got_ipa_pong = 0; gsupc->got_ipa_pong = 0;
osmo_timer_schedule(&gsupc->ping_timer, GSUP_CLIENT_PING_INTERVAL, 0); osmo_timer_schedule(&gsupc->ping_timer, OSMO_GSUP_CLIENT_PING_INTERVAL, 0);
LOGP(DLGSUP, LOGL_DEBUG, "GSUP sending PING\n"); LOGP(DLGSUP, LOGL_DEBUG, "GSUP sending PING\n");
gsup_client_send_ping(gsupc); gsup_client_send_ping(gsupc);
} }
struct gsup_client *gsup_client_create(void *talloc_ctx, struct osmo_gsup_client *osmo_gsup_client_create(void *talloc_ctx,
const char *unit_name, const char *unit_name,
const char *ip_addr, const char *ip_addr,
unsigned int tcp_port, unsigned int tcp_port,
gsup_client_read_cb_t read_cb, osmo_gsup_client_read_cb_t read_cb,
struct osmo_oap_client_config *oapc_config) struct osmo_oap_client_config *oapc_config)
{ {
struct gsup_client *gsupc; struct osmo_gsup_client *gsupc;
int rc; int rc;
gsupc = talloc_zero(talloc_ctx, struct gsup_client); gsupc = talloc_zero(talloc_ctx, struct osmo_gsup_client);
OSMO_ASSERT(gsupc); OSMO_ASSERT(gsupc);
/* struct ipaccess_unit has a non-const unit_name, so let's copy to be /* struct ipaccess_unit has a non-const unit_name, so let's copy to be
@ -309,11 +309,11 @@ struct gsup_client *gsup_client_create(void *talloc_ctx,
return gsupc; return gsupc;
failed: failed:
gsup_client_destroy(gsupc); osmo_gsup_client_destroy(gsupc);
return NULL; return NULL;
} }
void gsup_client_destroy(struct gsup_client *gsupc) void osmo_gsup_client_destroy(struct osmo_gsup_client *gsupc)
{ {
osmo_timer_del(&gsupc->connect_timer); osmo_timer_del(&gsupc->connect_timer);
osmo_timer_del(&gsupc->ping_timer); osmo_timer_del(&gsupc->ping_timer);
@ -326,7 +326,7 @@ void gsup_client_destroy(struct gsup_client *gsupc)
talloc_free(gsupc); talloc_free(gsupc);
} }
int gsup_client_send(struct gsup_client *gsupc, struct msgb *msg) int osmo_gsup_client_send(struct osmo_gsup_client *gsupc, struct msgb *msg)
{ {
if (!gsupc || !gsupc->is_connected) { if (!gsupc || !gsupc->is_connected) {
LOGP(DLGSUP, LOGL_ERROR, "GSUP not connected, unable to send %s\n", msgb_hexdump(msg)); LOGP(DLGSUP, LOGL_ERROR, "GSUP not connected, unable to send %s\n", msgb_hexdump(msg));
@ -339,7 +339,7 @@ int gsup_client_send(struct gsup_client *gsupc, struct msgb *msg)
return 0; return 0;
} }
struct msgb *gsup_client_msgb_alloc(void) struct msgb *osmo_gsup_client_msgb_alloc(void)
{ {
return msgb_alloc_headroom(4000, 64, __func__); return msgb_alloc_headroom(4000, 64, __func__);
} }

View File

@ -13,7 +13,7 @@
#include <osmocom/gsupclient/gsup_client.h> #include <osmocom/gsupclient/gsup_client.h>
static struct gsup_client *g_gc; static struct osmo_gsup_client *g_gc;
/*********************************************************************** /***********************************************************************
@ -117,7 +117,7 @@ static int req_auth_info(const char *imsi)
return rc; return rc;
} }
return gsup_client_send(g_gc, msg); return osmo_gsup_client_send(g_gc, msg);
} }
/* allocate + generate + send Send-Auth-Info */ /* allocate + generate + send Send-Auth-Info */
@ -137,7 +137,7 @@ static int req_loc_upd(const char *imsi)
return rc; return rc;
} }
return gsup_client_send(g_gc, msg); return osmo_gsup_client_send(g_gc, msg);
} }
static int resp_isd(struct imsi_op *io) static int resp_isd(struct imsi_op *io)
@ -157,7 +157,7 @@ static int resp_isd(struct imsi_op *io)
imsi_op_release(io); imsi_op_release(io);
return gsup_client_send(g_gc, msg); return osmo_gsup_client_send(g_gc, msg);
} }
/* receive an incoming GSUP message */ /* receive an incoming GSUP message */
@ -214,7 +214,7 @@ static int op_type_by_gsup_msgt(enum osmo_gsup_message_type msg_type)
} }
} }
static int gsupc_read_cb(struct gsup_client *gsupc, struct msgb *msg) static int gsupc_read_cb(struct osmo_gsup_client *gsupc, struct msgb *msg)
{ {
struct osmo_gsup_message gsup_msg = {0}; struct osmo_gsup_message gsup_msg = {0};
struct imsi_op *io = NULL; struct imsi_op *io = NULL;
@ -293,8 +293,8 @@ int main(int argc, char **argv)
osmo_init_logging2(ctx, &gsup_test_client_log_info); osmo_init_logging2(ctx, &gsup_test_client_log_info);
g_gc = gsup_client_create(ctx, "GSUPTEST", server_host, server_port, g_gc = osmo_gsup_client_create(ctx, "GSUPTEST", server_host, server_port,
gsupc_read_cb, NULL); gsupc_read_cb, NULL);
signal(SIGINT, sig_cb); signal(SIGINT, sig_cb);