From bc21b3ae8146c07ae47365e65e934e5f7488dd63 Mon Sep 17 00:00:00 2001 From: Pau Espin Pedrol Date: Wed, 27 Jul 2022 18:21:44 +0200 Subject: [PATCH] Move cbc_cell_id2str() and make it public It will be used later on to log whenever new cell ids are added to a message_peer. Change-Id: I74ccbbc810a2fa76fb2999a7588b3f67d4d21e03 --- include/osmocom/cbc/cbc_data.h | 2 ++ src/cbc_data.c | 33 +++++++++++++++++++++++++++++++++ src/cbc_vty.c | 33 --------------------------------- 3 files changed, 35 insertions(+), 33 deletions(-) diff --git a/include/osmocom/cbc/cbc_data.h b/include/osmocom/cbc/cbc_data.h index d3a8319..890da67 100644 --- a/include/osmocom/cbc/cbc_data.h +++ b/include/osmocom/cbc/cbc_data.h @@ -39,6 +39,8 @@ struct cbc_cell_id { } num_compl; }; +const char *cbc_cell_id2str(const struct cbc_cell_id *cid); + /********************************************************************************* * CBC itself *********************************************************************************/ diff --git a/src/cbc_data.c b/src/cbc_data.c index 2e350e9..68dc024 100644 --- a/src/cbc_data.c +++ b/src/cbc_data.c @@ -35,6 +35,39 @@ #include #include +const char *cbc_cell_id2str(const struct cbc_cell_id *cid) +{ + static char buf[256]; + + switch (cid->id_discr) { + case CBC_CELL_ID_NONE: + snprintf(buf, sizeof(buf), "NONE"); + break; + case CBC_CELL_ID_BSS: + snprintf(buf, sizeof(buf), "BSS"); + break; + case CBC_CELL_ID_CGI: + snprintf(buf, sizeof(buf), "CGI %s", osmo_cgi_name(&cid->u.cgi)); + break; + case CBC_CELL_ID_LAC_CI: + snprintf(buf, sizeof(buf), "LAC %u CI %u", cid->u.lac_and_ci.lac, cid->u.lac_and_ci.ci); + break; + case CBC_CELL_ID_LAI: + snprintf(buf, sizeof(buf), "LAI %s", osmo_lai_name(&cid->u.lai)); + break; + case CBC_CELL_ID_LAC: + snprintf(buf, sizeof(buf), "LAC %u", cid->u.lac); + break; + case CBC_CELL_ID_CI: + snprintf(buf, sizeof(buf), "CI %u", cid->u.ci); + break; + default: + snprintf(buf, sizeof(buf), ""); + break; + } + return buf; +} + struct cbc *cbc_alloc(void *ctx) { struct cbc *cbc; diff --git a/src/cbc_vty.c b/src/cbc_vty.c index 1f19878..631ef96 100644 --- a/src/cbc_vty.c +++ b/src/cbc_vty.c @@ -174,39 +174,6 @@ DEFUN(delete_message_expired, delete_message_expired_cmd, return CMD_SUCCESS; } -static const char *cbc_cell_id2str(const struct cbc_cell_id *cid) -{ - static char buf[256]; - - switch (cid->id_discr) { - case CBC_CELL_ID_NONE: - snprintf(buf, sizeof(buf), "NONE"); - break; - case CBC_CELL_ID_BSS: - snprintf(buf, sizeof(buf), "BSS"); - break; - case CBC_CELL_ID_CGI: - snprintf(buf, sizeof(buf), "CGI %s", osmo_cgi_name(&cid->u.cgi)); - break; - case CBC_CELL_ID_LAC_CI: - snprintf(buf, sizeof(buf), "LAC %u CI %u", cid->u.lac_and_ci.lac, cid->u.lac_and_ci.ci); - break; - case CBC_CELL_ID_LAI: - snprintf(buf, sizeof(buf), "LAI %s", osmo_lai_name(&cid->u.lai)); - break; - case CBC_CELL_ID_LAC: - snprintf(buf, sizeof(buf), "LAC %u", cid->u.lac); - break; - case CBC_CELL_ID_CI: - snprintf(buf, sizeof(buf), "CI %u", cid->u.ci); - break; - default: - snprintf(buf, sizeof(buf), ""); - break; - } - return buf; -} - static void dump_one_msg_peer(struct vty *vty, const struct cbc_message_peer *msg_peer, const char *pfx) { struct cbc_cell_id *cid;