aboutsummaryrefslogtreecommitdiffstats
path: root/openbsc/src/libcommon
diff options
context:
space:
mode:
Diffstat (limited to 'openbsc/src/libcommon')
-rw-r--r--openbsc/src/libcommon/common_vty.c19
-rw-r--r--openbsc/src/libcommon/gsm_data.c40
2 files changed, 59 insertions, 0 deletions
diff --git a/openbsc/src/libcommon/common_vty.c b/openbsc/src/libcommon/common_vty.c
index a0674f0f1..66a82d8bc 100644
--- a/openbsc/src/libcommon/common_vty.c
+++ b/openbsc/src/libcommon/common_vty.c
@@ -42,6 +42,15 @@ int bsc_vty_go_parent(struct vty *vty)
vty->node = CONFIG_NODE;
vty->index = NULL;
break;
+ case VIRT_NET_NODE:
+ vty->node = GSMNET_NODE;
+ {
+ /* set vty->index correctly ! */
+ struct gsm_virt_network *virt_net = vty->index;
+ vty->index = virt_net->network;
+ vty->index_sub = NULL;
+ }
+ break;
case BTS_NODE:
vty->node = GSMNET_NODE;
{
@@ -141,3 +150,13 @@ void bsc_replace_string(void *ctx, char **dst, const char *newstr)
talloc_free(*dst);
*dst = talloc_strdup(ctx, newstr);
}
+
+int osmo_is_digits(const char *str)
+{
+ int i;
+ for (i = 0; i < strlen(str); i++) {
+ if (!isdigit(str[i]))
+ return 0;
+ }
+ return 1;
+}
diff --git a/openbsc/src/libcommon/gsm_data.c b/openbsc/src/libcommon/gsm_data.c
index 16035edcc..d75e7afef 100644
--- a/openbsc/src/libcommon/gsm_data.c
+++ b/openbsc/src/libcommon/gsm_data.c
@@ -192,6 +192,46 @@ const char *rrlp_mode_name(enum rrlp_mode mode)
return get_value_string(rrlp_mode_names, mode);
}
+struct gsm_virt_network *gsm_virt_net_alloc(void *ctx)
+{
+ struct gsm_virt_network *virt_net = talloc_zero(ctx, struct gsm_virt_network);
+ if (!virt_net)
+ return NULL;
+ return virt_net;
+}
+
+struct gsm_virt_network *gsm_virt_net_alloc_register(struct gsm_network *net)
+{
+ struct gsm_virt_network *virt_net;
+
+ virt_net = gsm_virt_net_alloc(net);
+ if (!virt_net)
+ return NULL;
+
+ virt_net->nr = net->num_virt_net++;
+ virt_net->network = net;
+ virt_net->name_short = talloc_strdup(net, "OpenBSC");
+ virt_net->name_long = talloc_strdup(net, "OpenBSC");
+
+ llist_add_tail(&virt_net->list, &net->virt_net_list);
+ return virt_net;
+}
+
+struct gsm_virt_network *gsm_virt_net_num(struct gsm_network *net, int num)
+{
+ struct gsm_virt_network *virt_net;
+
+ if (num >= net->num_virt_net)
+ return NULL;
+
+ llist_for_each_entry(virt_net, &net->virt_net_list, list) {
+ if (virt_net->nr == num)
+ return virt_net;
+ }
+
+ return NULL;
+}
+
static const struct value_string bts_gprs_mode_names[] = {
{ BTS_GPRS_NONE, "none" },
{ BTS_GPRS_GPRS, "gprs" },