aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/osmo-bsc/bsc_subscriber.c40
-rw-r--r--tests/subscr/bsc_subscr_test.c1
-rw-r--r--tests/subscr/bsc_subscr_test.err40
3 files changed, 44 insertions, 37 deletions
diff --git a/src/osmo-bsc/bsc_subscriber.c b/src/osmo-bsc/bsc_subscriber.c
index 79d0c8512..4a4829866 100644
--- a/src/osmo-bsc/bsc_subscriber.c
+++ b/src/osmo-bsc/bsc_subscriber.c
@@ -51,7 +51,7 @@ static int bsub_use_cb(struct osmo_use_count_entry *e, int32_t old_use_count, co
else
level = LOGL_DEBUG;
- LOGPSRC(DREF, level, file, line, "BSC subscr %s: %s %s: now used by %s\n",
+ LOGPSRC(DREF, level, file, line, "%s: %s %s: now used by %s\n",
bsc_subscr_name(bsub),
(e->count - old_use_count) > 0? "+" : "-", e->use,
osmo_use_count_to_str_c(OTC_SELECT, &bsub->use_count));
@@ -188,30 +188,36 @@ struct bsc_subscr *bsc_subscr_find_or_create_by_mi(struct llist_head *list, cons
}
}
-const char *bsc_subscr_name(struct bsc_subscr *bsub)
+static int bsc_subscr_name_buf(char *buf, size_t buflen, struct bsc_subscr *bsub)
{
- static char buf[32];
- if (!bsub)
- return "unknown";
+ struct osmo_strbuf sb = { .buf = buf, .len = buflen };
+ OSMO_STRBUF_PRINTF(sb, "subscr");
+ if (!bsub) {
+ OSMO_STRBUF_PRINTF(sb, "-null");
+ return sb.chars_needed;
+ }
if (bsub->imsi[0])
- snprintf(buf, sizeof(buf), "IMSI:%s", bsub->imsi);
- else
- snprintf(buf, sizeof(buf), "TMSI:0x%08x", bsub->tmsi);
- return buf;
+ OSMO_STRBUF_PRINTF(sb, "-IMSI-%s", bsub->imsi);
+ if (bsub->tmsi != GSM_RESERVED_TMSI)
+ OSMO_STRBUF_PRINTF(sb, "-TMSI-0x%08x", bsub->tmsi);
+ return sb.chars_needed;
+}
+
+static char *bsc_subscr_name_c(void *ctx, struct bsc_subscr *bsub)
+{
+ OSMO_NAME_C_IMPL(ctx, 64, "ERROR", bsc_subscr_name_buf, bsub)
+}
+
+const char *bsc_subscr_name(struct bsc_subscr *bsub)
+{
+ return bsc_subscr_name_c(OTC_SELECT, bsub);
}
/* Like bsc_subscr_name() but returns only characters approved by osmo_identifier_valid(), useful for
* osmo_fsm_inst IDs. */
const char *bsc_subscr_id(struct bsc_subscr *bsub)
{
- static char buf[32];
- if (!bsub)
- return "unknown";
- if (bsub->imsi[0])
- snprintf(buf, sizeof(buf), "IMSI%s", bsub->imsi);
- else
- snprintf(buf, sizeof(buf), "TMSI%08x", bsub->tmsi);
- return buf;
+ return bsc_subscr_name(bsub);
}
static void bsc_subscr_free(struct bsc_subscr *bsub)
diff --git a/tests/subscr/bsc_subscr_test.c b/tests/subscr/bsc_subscr_test.c
index fcaea63eb..619d5e6bf 100644
--- a/tests/subscr/bsc_subscr_test.c
+++ b/tests/subscr/bsc_subscr_test.c
@@ -75,6 +75,7 @@ static void test_bsc_subscr(void)
/* Allocate entry 2 */
s2 = bsc_subscr_find_or_create_by_imsi(bsc_subscribers, imsi2, BSUB_USE);
+ s2->tmsi = 0x73517351;
VERBOSE_ASSERT(llist_count(bsc_subscribers), == 2, "%d");
/* Allocate entry 3 */
diff --git a/tests/subscr/bsc_subscr_test.err b/tests/subscr/bsc_subscr_test.err
index a78e7576a..c41d3ca2a 100644
--- a/tests/subscr/bsc_subscr_test.err
+++ b/tests/subscr/bsc_subscr_test.err
@@ -1,20 +1,20 @@
-DREF BSC subscr IMSI:1234567890: + test: now used by 1 (test)
-DREF BSC subscr IMSI:1234567890: + test: now used by 2 (2*test)
-DREF BSC subscr IMSI:1234567890: - test: now used by 1 (test)
-DREF BSC subscr IMSI:9876543210: + test: now used by 1 (test)
-DREF BSC subscr IMSI:5656565656: + test: now used by 1 (test)
-DREF BSC subscr IMSI:1234567890: + test: now used by 2 (2*test)
-DREF BSC subscr IMSI:1234567890: - test: now used by 1 (test)
-DREF BSC subscr IMSI:9876543210: + test: now used by 2 (2*test)
-DREF BSC subscr IMSI:9876543210: - test: now used by 1 (test)
-DREF BSC subscr IMSI:5656565656: + test: now used by 2 (2*test)
-DREF BSC subscr IMSI:5656565656: - test: now used by 1 (test)
-DREF BSC subscr IMSI:1234567890: - test: now used by 0 (-)
-DREF BSC subscr IMSI:9876543210: + test: now used by 2 (2*test)
-DREF BSC subscr IMSI:9876543210: - test: now used by 1 (test)
-DREF BSC subscr IMSI:5656565656: + test: now used by 2 (2*test)
-DREF BSC subscr IMSI:5656565656: - test: now used by 1 (test)
-DREF BSC subscr IMSI:9876543210: - test: now used by 0 (-)
-DREF BSC subscr IMSI:5656565656: + test: now used by 2 (2*test)
-DREF BSC subscr IMSI:5656565656: - test: now used by 1 (test)
-DREF BSC subscr IMSI:5656565656: - test: now used by 0 (-)
+DREF subscr-IMSI-1234567890: + test: now used by 1 (test)
+DREF subscr-IMSI-1234567890: + test: now used by 2 (2*test)
+DREF subscr-IMSI-1234567890: - test: now used by 1 (test)
+DREF subscr-IMSI-9876543210: + test: now used by 1 (test)
+DREF subscr-IMSI-5656565656: + test: now used by 1 (test)
+DREF subscr-IMSI-1234567890: + test: now used by 2 (2*test)
+DREF subscr-IMSI-1234567890: - test: now used by 1 (test)
+DREF subscr-IMSI-9876543210-TMSI-0x73517351: + test: now used by 2 (2*test)
+DREF subscr-IMSI-9876543210-TMSI-0x73517351: - test: now used by 1 (test)
+DREF subscr-IMSI-5656565656: + test: now used by 2 (2*test)
+DREF subscr-IMSI-5656565656: - test: now used by 1 (test)
+DREF subscr-IMSI-1234567890: - test: now used by 0 (-)
+DREF subscr-IMSI-9876543210-TMSI-0x73517351: + test: now used by 2 (2*test)
+DREF subscr-IMSI-9876543210-TMSI-0x73517351: - test: now used by 1 (test)
+DREF subscr-IMSI-5656565656: + test: now used by 2 (2*test)
+DREF subscr-IMSI-5656565656: - test: now used by 1 (test)
+DREF subscr-IMSI-9876543210-TMSI-0x73517351: - test: now used by 0 (-)
+DREF subscr-IMSI-5656565656: + test: now used by 2 (2*test)
+DREF subscr-IMSI-5656565656: - test: now used by 1 (test)
+DREF subscr-IMSI-5656565656: - test: now used by 0 (-)