aboutsummaryrefslogtreecommitdiffstats
path: root/src/libcommon
diff options
context:
space:
mode:
Diffstat (limited to 'src/libcommon')
-rw-r--r--src/libcommon/debug.c23
-rw-r--r--src/libcommon/gsm_data.c10
-rw-r--r--src/libcommon/gsm_subscriber_base.c141
-rw-r--r--src/libcommon/gsup_client.c8
-rw-r--r--src/libcommon/gsup_test_client.c2
5 files changed, 40 insertions, 144 deletions
diff --git a/src/libcommon/debug.c b/src/libcommon/debug.c
index 088902a6..dc79a843 100644
--- a/src/libcommon/debug.c
+++ b/src/libcommon/debug.c
@@ -32,7 +32,6 @@
#include <osmocom/core/logging.h>
#include <osmocom/gprs/gprs_msgb.h>
#include <openbsc/gsm_data.h>
-#include <openbsc/gsm_subscriber.h>
#include <openbsc/debug.h>
/* default categories */
@@ -189,13 +188,13 @@ static const struct log_info_cat default_categories[] = {
static int filter_fn(const struct log_context *ctx, struct log_target *tar)
{
- const struct gsm_subscriber *subscr = ctx->ctx[LOG_CTX_VLR_SUBSCR];
+ const struct vlr_subscr *vsub = ctx->ctx[LOG_CTX_VLR_SUBSCR];
const struct bsc_subscr *bsub = ctx->ctx[LOG_CTX_BSC_SUBSCR];
const struct gprs_nsvc *nsvc = ctx->ctx[LOG_CTX_GB_NSVC];
const struct gprs_nsvc *bvc = ctx->ctx[LOG_CTX_GB_BVC];
if ((tar->filter_map & (1 << LOG_FLT_VLR_SUBSCR)) != 0
- && subscr && subscr == tar->filter_data[LOG_FLT_VLR_SUBSCR])
+ && vsub && vsub == tar->filter_data[LOG_FLT_VLR_SUBSCR])
return 1;
if ((tar->filter_map & (1 << LOG_FLT_BSC_SUBSCR)) != 0
@@ -220,21 +219,3 @@ const struct log_info log_info = {
.cat = default_categories,
.num_cat = ARRAY_SIZE(default_categories),
};
-
-void log_set_filter_vlr_subscr(struct log_target *target,
- struct gsm_subscriber *vlr_subscr)
-{
- struct gsm_subscriber **fsub = (void*)&target->filter_data[LOG_FLT_VLR_SUBSCR];
-
- /* free the old data */
- if (*fsub) {
- subscr_put(*fsub);
- *fsub = NULL;
- }
-
- if (vlr_subscr) {
- target->filter_map |= (1 << LOG_FLT_VLR_SUBSCR);
- *fsub = subscr_get(vlr_subscr);
- } else
- target->filter_map &= ~(1 << LOG_FLT_VLR_SUBSCR);
-}
diff --git a/src/libcommon/gsm_data.c b/src/libcommon/gsm_data.c
index db7de082..7c717a40 100644
--- a/src/libcommon/gsm_data.c
+++ b/src/libcommon/gsm_data.c
@@ -471,3 +471,13 @@ void gsm_bts_set_radio_link_timeout(struct gsm_bts *bts, int value)
cell_options->radio_link_timeout = (value >> 2) - 1;
}
}
+
+bool classmark_is_r99(struct gsm_classmark *cm)
+{
+ int rev_lev = 0;
+ if (cm->classmark1_set)
+ rev_lev = cm->classmark1.rev_lev;
+ else if (cm->classmark2_len > 0)
+ rev_lev = (cm->classmark2[0] >> 5) & 0x3;
+ return rev_lev >= 2;
+}
diff --git a/src/libcommon/gsm_subscriber_base.c b/src/libcommon/gsm_subscriber_base.c
index 1ecdee5a..018ed210 100644
--- a/src/libcommon/gsm_subscriber_base.c
+++ b/src/libcommon/gsm_subscriber_base.c
@@ -31,133 +31,34 @@
#include <osmocom/core/utils.h>
#include <openbsc/gsm_subscriber.h>
#include <openbsc/debug.h>
+#include <openbsc/vlr.h>
LLIST_HEAD(active_subscribers);
void *tall_subscr_ctx;
-/* for the gsm_subscriber.c */
-struct llist_head *subscr_bsc_active_subscribers(void)
+/* return static buffer with printable name of VLR subscriber */
+const char *vlr_subscr_name(struct vlr_subscr *vsub)
{
- return &active_subscribers;
-}
-
-
-char *subscr_name(struct gsm_subscriber *subscr)
-{
- if (!subscr)
+ static char buf[32];
+ if (!vsub)
return "unknown";
-
- if (strlen(subscr->name))
- return subscr->name;
-
- return subscr->imsi;
-}
-
-struct gsm_subscriber *subscr_alloc(void)
-{
- struct gsm_subscriber *s;
-
- s = talloc_zero(tall_subscr_ctx, struct gsm_subscriber);
- if (!s)
- return NULL;
-
- llist_add_tail(&s->entry, &active_subscribers);
- s->use_count = 1;
- s->tmsi = GSM_RESERVED_TMSI;
-
- INIT_LLIST_HEAD(&s->requests);
-
- return s;
-}
-
-static void subscr_free(struct gsm_subscriber *subscr)
-{
- llist_del(&subscr->entry);
- talloc_free(subscr);
-}
-
-void subscr_direct_free(struct gsm_subscriber *subscr)
-{
- OSMO_ASSERT(subscr->use_count == 1);
- subscr_free(subscr);
-}
-
-struct gsm_subscriber *subscr_get(struct gsm_subscriber *subscr)
-{
- subscr->use_count++;
- DEBUGP(DREF, "subscr %s usage increases usage to: %d\n",
- subscr->extension, subscr->use_count);
- return subscr;
-}
-
-struct gsm_subscriber *subscr_put(struct gsm_subscriber *subscr)
-{
- subscr->use_count--;
- DEBUGP(DREF, "subscr %s usage decreased usage to: %d\n",
- subscr->extension, subscr->use_count);
- if (subscr->use_count <= 0 &&
- !((subscr->group && subscr->group->keep_subscr) ||
- subscr->keep_in_ram))
- subscr_free(subscr);
- return NULL;
-}
-
-struct gsm_subscriber *subscr_get_or_create(struct gsm_subscriber_group *sgrp,
- const char *imsi)
-{
- struct gsm_subscriber *subscr;
-
- llist_for_each_entry(subscr, subscr_bsc_active_subscribers(), entry) {
- if (strcmp(subscr->imsi, imsi) == 0 && subscr->group == sgrp)
- return subscr_get(subscr);
- }
-
- subscr = subscr_alloc();
- if (!subscr)
- return NULL;
-
- osmo_strlcpy(subscr->imsi, imsi, sizeof(subscr->imsi));
- subscr->group = sgrp;
- return subscr;
-}
-
-struct gsm_subscriber *subscr_active_by_tmsi(struct gsm_subscriber_group *sgrp,
- uint32_t tmsi)
-{
- struct gsm_subscriber *subscr;
-
- llist_for_each_entry(subscr, subscr_bsc_active_subscribers(), entry) {
- if (subscr->tmsi == tmsi && subscr->group == sgrp)
- return subscr_get(subscr);
- }
-
- return NULL;
-}
-
-struct gsm_subscriber *subscr_active_by_imsi(struct gsm_subscriber_group *sgrp,
- const char *imsi)
-{
- struct gsm_subscriber *subscr;
-
- llist_for_each_entry(subscr, subscr_bsc_active_subscribers(), entry) {
- if (strcmp(subscr->imsi, imsi) == 0 && subscr->group == sgrp)
- return subscr_get(subscr);
- }
-
- return NULL;
+ if (vsub->msisdn[0])
+ snprintf(buf, sizeof(buf), "MSISDN:%s", vsub->msisdn);
+ else if (vsub->imsi[0])
+ snprintf(buf, sizeof(buf), "IMSI:%s", vsub->imsi);
+ else if (vsub->tmsi != GSM_RESERVED_TMSI)
+ snprintf(buf, sizeof(buf), "TMSI:0x%08x", vsub->tmsi);
+ else if (vsub->tmsi_new != GSM_RESERVED_TMSI)
+ snprintf(buf, sizeof(buf), "TMSI(new):0x%08x", vsub->tmsi_new);
+ else
+ return "unknown";
+ buf[sizeof(buf)-1] = '\0';
+ return buf;
}
-int subscr_purge_inactive(struct gsm_subscriber_group *sgrp)
+const char *vlr_subscr_msisdn_or_name(struct vlr_subscr *vsub)
{
- struct gsm_subscriber *subscr, *tmp;
- int purged = 0;
-
- llist_for_each_entry_safe(subscr, tmp, subscr_bsc_active_subscribers(), entry) {
- if (subscr->group == sgrp && subscr->use_count <= 0) {
- subscr_free(subscr);
- purged += 1;
- }
- }
-
- return purged;
+ if (!vsub || !vsub->msisdn[0])
+ return vlr_subscr_name(vsub);
+ return vsub->msisdn;
}
diff --git a/src/libcommon/gsup_client.c b/src/libcommon/gsup_client.c
index 46f25bb9..258f230c 100644
--- a/src/libcommon/gsup_client.c
+++ b/src/libcommon/gsup_client.c
@@ -72,12 +72,12 @@ static int gsup_client_connect(struct gsup_client *gsupc)
rc = ipa_client_conn_open(gsupc->link);
if (rc >= 0) {
- LOGP(DLGSUP, LOGL_INFO, "GSUP connecting to %s:%d\n",
+ LOGP(DLGSUP, LOGL_NOTICE, "GSUP connecting to %s:%d\n",
gsupc->link->addr, gsupc->link->port);
return 0;
}
- LOGP(DLGSUP, LOGL_INFO, "GSUP failed to connect to %s:%d: %s\n",
+ LOGP(DLGSUP, LOGL_ERROR, "GSUP failed to connect to %s:%d: %s\n",
gsupc->link->addr, gsupc->link->port, strerror(-rc));
if (rc == -EBADF || rc == -ENOTSOCK || rc == -EAFNOSUPPORT ||
@@ -331,11 +331,15 @@ void gsup_client_destroy(struct gsup_client *gsupc)
int gsup_client_send(struct gsup_client *gsupc, struct msgb *msg)
{
if (!gsupc) {
+ LOGP(DGPRS, LOGL_NOTICE, "No GSUP client, unable to "
+ "send %s\n", msgb_hexdump(msg));
msgb_free(msg);
return -ENOTCONN;
}
if (!gsupc->is_connected) {
+ LOGP(DGPRS, LOGL_NOTICE, "GSUP not connected, unable to "
+ "send %s\n", msgb_hexdump(msg));
msgb_free(msg);
return -EAGAIN;
}
diff --git a/src/libcommon/gsup_test_client.c b/src/libcommon/gsup_test_client.c
index 1b39670d..b6a8d6b7 100644
--- a/src/libcommon/gsup_test_client.c
+++ b/src/libcommon/gsup_test_client.c
@@ -271,7 +271,7 @@ int main(int argc, char **argv)
{
unsigned long long i;
char *server_host = "127.0.0.1";
- uint16_t server_port = 2222;
+ uint16_t server_port = OSMO_GSUP_PORT;
osmo_init_logging(&gsup_test_client_log_info);