gsup client, gsup_test_client: move logging to DLGSUP category

Use the DLGSUP logging category for GSUP.

Bump the required version of libosmocore to 0.9.5 to benefit from the DLGSUP
logging category fix in core/logging.[hc].
(Id974c7be158e4d60421a98110f5c807aefd31119)

Todo: we're using a "Library" logging category, which is not really what the
library category was intended for. Instead, the GSUP client should probably be
given a logging category like DVLR or DGPRS in its initialization API.

Related: OS#1592
Change-Id: Id3938267fa062e1a997d3704cd678874306f86ee
This commit is contained in:
Neels Hofmeyr 2016-12-08 21:28:29 +01:00 committed by Harald Welte
parent eaaee92db5
commit ef022783c3
3 changed files with 20 additions and 25 deletions

View File

@ -30,7 +30,7 @@ AC_SEARCH_LIBS([dlopen], [dl dld], [LIBRARY_DL="$LIBS";LIBS=""])
AC_SUBST(LIBRARY_DL) AC_SUBST(LIBRARY_DL)
PKG_CHECK_MODULES(LIBOSMOCORE, libosmocore >= 0.9.4) PKG_CHECK_MODULES(LIBOSMOCORE, libosmocore >= 0.9.5)
PKG_CHECK_MODULES(LIBOSMOVTY, libosmovty >= 0.3.0) PKG_CHECK_MODULES(LIBOSMOVTY, libosmovty >= 0.3.0)
PKG_CHECK_MODULES(LIBOSMOCTRL, libosmoctrl) PKG_CHECK_MODULES(LIBOSMOCTRL, libosmoctrl)
PKG_CHECK_MODULES(LIBOSMOGSM, libosmogsm >= 0.9.4) PKG_CHECK_MODULES(LIBOSMOGSM, libosmogsm >= 0.9.4)

View File

@ -55,29 +55,29 @@ static int gsup_client_connect(struct gsup_client *gsupc)
return 0; return 0;
if (osmo_timer_pending(&gsupc->connect_timer)) { if (osmo_timer_pending(&gsupc->connect_timer)) {
LOGP(DLINP, LOGL_DEBUG, LOGP(DLGSUP, LOGL_DEBUG,
"GSUP connect: connect timer already running\n"); "GSUP connect: connect timer already running\n");
osmo_timer_del(&gsupc->connect_timer); osmo_timer_del(&gsupc->connect_timer);
} }
if (osmo_timer_pending(&gsupc->ping_timer)) { if (osmo_timer_pending(&gsupc->ping_timer)) {
LOGP(DLINP, LOGL_DEBUG, LOGP(DLGSUP, LOGL_DEBUG,
"GSUP connect: ping timer already running\n"); "GSUP connect: ping timer already running\n");
osmo_timer_del(&gsupc->ping_timer); osmo_timer_del(&gsupc->ping_timer);
} }
if (ipa_client_conn_clear_queue(gsupc->link) > 0) if (ipa_client_conn_clear_queue(gsupc->link) > 0)
LOGP(DLINP, LOGL_DEBUG, "GSUP connect: discarded stored messages\n"); LOGP(DLGSUP, LOGL_DEBUG, "GSUP connect: discarded stored messages\n");
rc = ipa_client_conn_open(gsupc->link); rc = ipa_client_conn_open(gsupc->link);
if (rc >= 0) { if (rc >= 0) {
LOGP(DGPRS, LOGL_INFO, "GSUP connecting to %s:%d\n", LOGP(DLGSUP, LOGL_INFO, "GSUP connecting to %s:%d\n",
gsupc->link->addr, gsupc->link->port); gsupc->link->addr, gsupc->link->port);
return 0; return 0;
} }
LOGP(DGPRS, LOGL_INFO, "GSUP failed to connect to %s:%d: %s\n", LOGP(DLGSUP, LOGL_INFO, "GSUP failed to connect to %s:%d: %s\n",
gsupc->link->addr, gsupc->link->port, strerror(-rc)); gsupc->link->addr, gsupc->link->port, strerror(-rc));
if (rc == -EBADF || rc == -ENOTSOCK || rc == -EAFNOSUPPORT || if (rc == -EBADF || rc == -ENOTSOCK || rc == -EAFNOSUPPORT ||
@ -87,7 +87,7 @@ static int gsup_client_connect(struct gsup_client *gsupc)
osmo_timer_schedule(&gsupc->connect_timer, osmo_timer_schedule(&gsupc->connect_timer,
GSUP_CLIENT_RECONNECT_INTERVAL, 0); GSUP_CLIENT_RECONNECT_INTERVAL, 0);
LOGP(DGPRS, 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);
return 0; return 0;
@ -119,7 +119,7 @@ static void gsup_client_oap_register(struct gsup_client *gsupc)
rc = oap_register(&gsupc->oap_state, &msg_tx); rc = oap_register(&gsupc->oap_state, &msg_tx);
if ((rc < 0) || (!msg_tx)) { if ((rc < 0) || (!msg_tx)) {
LOGP(DGPRS, LOGL_ERROR, "GSUP OAP set up, but cannot register.\n"); LOGP(DLGSUP, LOGL_ERROR, "GSUP OAP set up, but cannot register.\n");
return; return;
} }
@ -130,7 +130,7 @@ static void gsup_client_updown_cb(struct ipa_client_conn *link, int up)
{ {
struct gsup_client *gsupc = link->data; struct gsup_client *gsupc = link->data;
LOGP(DGPRS, 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");
gsupc->is_connected = up; gsupc->is_connected = up;
@ -181,7 +181,7 @@ static int gsup_client_read_cb(struct ipa_client_conn *link, struct msgb *msg)
rc = ipaccess_bts_handle_ccm(link, &ipa_dev, msg); rc = ipaccess_bts_handle_ccm(link, &ipa_dev, msg);
if (rc < 0) { if (rc < 0) {
LOGP(DGPRS, LOGL_NOTICE, LOGP(DLGSUP, LOGL_NOTICE,
"GSUP received an invalid IPA/CCM message from %s:%d\n", "GSUP received an invalid IPA/CCM message from %s:%d\n",
link->addr, link->port); link->addr, link->port);
/* Link has been closed */ /* Link has been closed */
@ -194,7 +194,7 @@ static int gsup_client_read_cb(struct ipa_client_conn *link, struct msgb *msg)
uint8_t msg_type = *(msg->l2h); uint8_t msg_type = *(msg->l2h);
/* CCM message */ /* CCM message */
if (msg_type == IPAC_MSGT_PONG) { if (msg_type == IPAC_MSGT_PONG) {
LOGP(DGPRS, LOGL_DEBUG, "GSUP receiving PONG\n"); LOGP(DLGSUP, LOGL_DEBUG, "GSUP receiving PONG\n");
gsupc->got_ipa_pong = 1; gsupc->got_ipa_pong = 1;
} }
@ -223,7 +223,7 @@ static int gsup_client_read_cb(struct ipa_client_conn *link, struct msgb *msg)
return 0; return 0;
invalid: invalid:
LOGP(DGPRS, LOGL_NOTICE, LOGP(DLGSUP, LOGL_NOTICE,
"GSUP received an invalid IPA message from %s:%d, size = %d\n", "GSUP received an invalid IPA message from %s:%d, size = %d\n",
link->addr, link->port, msgb_length(msg)); link->addr, link->port, msgb_length(msg));
@ -235,7 +235,7 @@ static void ping_timer_cb(void *gsupc_)
{ {
struct gsup_client *gsupc = gsupc_; struct gsup_client *gsupc = gsupc_;
LOGP(DGPRS, 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",
gsupc->got_ipa_pong ? "got" : "didn't get"); gsupc->got_ipa_pong ? "got" : "didn't get");
@ -244,7 +244,7 @@ static void ping_timer_cb(void *gsupc_)
return; return;
} }
LOGP(DGPRS, LOGL_NOTICE, "GSUP ping timed out, reconnecting\n"); LOGP(DLGSUP, LOGL_NOTICE, "GSUP ping timed out, reconnecting\n");
ipa_client_conn_close(gsupc->link); ipa_client_conn_close(gsupc->link);
gsupc->is_connected = 0; gsupc->is_connected = 0;
@ -258,7 +258,7 @@ static void start_test_procedure(struct gsup_client *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, GSUP_CLIENT_PING_INTERVAL, 0);
LOGP(DGPRS, LOGL_DEBUG, "GSUP sending PING\n"); LOGP(DLGSUP, LOGL_DEBUG, "GSUP sending PING\n");
gsup_client_send_ping(gsupc); gsup_client_send_ping(gsupc);
} }

View File

@ -260,17 +260,12 @@ static void sig_cb(int sig)
void *tall_bsc_ctx = NULL; void *tall_bsc_ctx = NULL;
/* default categories */ /* default categories */
static struct log_info_cat gprs_categories[] = { static struct log_info_cat default_categories[] = {
[DGPRS] = {
.name = "DGPRS",
.description = "GPRS Packet Service",
.enabled = 1, .loglevel = LOGL_INFO,
},
}; };
static const struct log_info gprs_log_info = { static const struct log_info gsup_test_client_log_info = {
.cat = gprs_categories, .cat = default_categories,
.num_cat = ARRAY_SIZE(gprs_categories), .num_cat = ARRAY_SIZE(default_categories),
}; };
int main(int argc, char **argv) int main(int argc, char **argv)
@ -279,7 +274,7 @@ int main(int argc, char **argv)
char *server_host = "127.0.0.1"; char *server_host = "127.0.0.1";
uint16_t server_port = 2222; uint16_t server_port = 2222;
osmo_init_logging(&gprs_log_info); osmo_init_logging(&gsup_test_client_log_info);
g_gc = gsup_client_create(server_host, server_port, gsupc_read_cb, g_gc = gsup_client_create(server_host, server_port, gsupc_read_cb,
NULL); NULL);