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
This commit is contained in:
Pau Espin 2022-07-27 18:21:44 +02:00
parent ab8b8402a4
commit bc21b3ae81
3 changed files with 35 additions and 33 deletions

View File

@ -39,6 +39,8 @@ struct cbc_cell_id {
} num_compl;
};
const char *cbc_cell_id2str(const struct cbc_cell_id *cid);
/*********************************************************************************
* CBC itself
*********************************************************************************/

View File

@ -35,6 +35,39 @@
#include <osmocom/cbc/rest_it_op.h>
#include <osmocom/cbc/debug.h>
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), "<invalid>");
break;
}
return buf;
}
struct cbc *cbc_alloc(void *ctx)
{
struct cbc *cbc;

View File

@ -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), "<invalid>");
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;