Added "show ba 1" to view BA lists via VTY interface.
authorAndreas.Eversberg <jolly@eversberg.eu>
Sun, 9 May 2010 17:31:49 +0000 (17:31 +0000)
committerAndreas.Eversberg <jolly@eversberg.eu>
Sun, 9 May 2010 17:31:49 +0000 (17:31 +0000)
src/host/layer23/include/osmocom/gsm322.h
src/host/layer23/src/gsm322.c
src/host/layer23/src/vty_interface.c

index c6828be..4a9c88b 100755 (executable)
@@ -187,6 +187,8 @@ int gsm322_dump_sorted_plmn(struct osmocom_ms *ms);
 int gsm322_dump_cs_list(struct gsm322_cellsel *cs, uint8_t flags,
                        void (*print)(void *, const char *, ...), void *priv);
 int gsm322_dump_forbidden_la(struct osmocom_ms *ms);
+int gsm322_dump_ba_list(struct gsm322_cellsel *cs, uint16_t mcc, uint16_t mnc,
+                       void (*print)(void *, const char *, ...), void *priv);
 void start_cs_timer(struct gsm322_cellsel *cs, int sec, int micro);
 void start_loss_timer(struct gsm322_cellsel *cs, int sec, int micro);
 
index 7101f13..41ec30b 100755 (executable)
@@ -3055,7 +3055,7 @@ int gsm322_dump_cs_list(struct gsm322_cellsel *cs, uint8_t flags,
                s = cs->list[i].sysinfo;
                if (!s || !(cs->list[i].flags & flags))
                        continue;
-               print(priv, "%04d   |%4d   |", i, cs->list[i].rxlev_db);
+               print(priv, "%4d   |%4d   |", i, cs->list[i].rxlev_db);
                if ((cs->list[i].flags & GSM322_CS_FLAG_SYSINFO)) {
                        print(priv, "%03d    |%02d     |", s->mcc, s->mnc);
                        if ((cs->list[i].flags & GSM322_CS_FLAG_FORBIDD))
@@ -3101,6 +3101,28 @@ int gsm322_dump_forbidden_la(struct osmocom_ms *ms)
        return 0;
 }
 
+int gsm322_dump_ba_list(struct gsm322_cellsel *cs, uint16_t mcc, uint16_t mnc,
+                       void (*print)(void *, const char *, ...), void *priv)
+{
+       struct gsm322_ba_list *ba;
+       int i;
+
+       llist_for_each_entry(ba, &cs->ba_list, entry) {
+               if (mcc && mnc && (mcc != ba->mcc || mnc != ba->mnc))
+                       continue;
+               print(priv, "Band Allocation of network: MCC %03d MNC %02d "
+                       "(%s, %s)\n", ba->mcc, ba->mnc, gsm_get_mcc(ba->mcc),
+                       gsm_get_mnc(ba->mcc, ba->mnc));
+               for (i = 0; i <= 1023; i++) {
+                       if ((ba->freq[i >> 3] & (1 << (i & 7))))
+                               print(priv, " %d", i);
+               }
+               print(priv, "\n");
+       }
+
+       return 0;
+}
+
 /*
  * initialization
  */
index e9cfbd2..3f508da 100644 (file)
@@ -162,6 +162,26 @@ DEFUN(show_cell_si, show_cell_si_cmd, "show cell MS_NAME <0-1023>",
        return CMD_SUCCESS;
 }
 
+DEFUN(show_ba, show_ba_cmd, "show ba MS_NAME [mcc] [mnc]",
+       SHOW_STR "Display information about band allocations\n")
+{
+       struct osmocom_ms *ms;
+       uint16_t mcc = 0, mnc = 0;
+
+       ms = get_ms(argv[0], vty);
+       if (!ms)
+               return CMD_WARNING;
+
+       if (argc >= 3) {
+               mcc = atoi(argv[1]);
+               mnc = atoi(argv[2]);
+       }
+
+       gsm322_dump_ba_list(&ms->cellsel, mcc, mnc, print_vty, vty);
+
+       return CMD_SUCCESS;
+}
+
 DEFUN(insert_test, insert_test_cmd, "insert testcard MS_NAME [mcc] [mnc]",
        SHOW_STR "Insert test card\n")
 {
@@ -180,7 +200,7 @@ DEFUN(insert_test, insert_test_cmd, "insert testcard MS_NAME [mcc] [mnc]",
 
        if (argc >= 3) {
                mcc = atoi(argv[1]);
-               mnc = atoi(argv[1]);
+               mnc = atoi(argv[2]);
        }
 
        gsm_subscr_testcard(ms, mcc, mnc, "0000000000");
@@ -217,6 +237,7 @@ int ms_vty_init(void)
        install_element(VIEW_NODE, &show_subscr_cmd);
        install_element(VIEW_NODE, &show_cell_cmd);
        install_element(VIEW_NODE, &show_cell_si_cmd);
+       install_element(VIEW_NODE, &show_ba_cmd);
 
        install_element(VIEW_NODE, &insert_test_cmd);
        install_element(VIEW_NODE, &remove_sim_cmd);