aboutsummaryrefslogtreecommitdiffstats
path: root/openbsc
diff options
context:
space:
mode:
authorHarald Welte <laforge@gnumonks.org>2009-11-12 14:48:42 +0100
committerHarald Welte <laforge@gnumonks.org>2009-11-12 14:48:42 +0100
commit0f255857d406223a85bae12d69c028274ecd66b2 (patch)
treecf7ab831cb19ffb0294ac52cc5f5e116b2bd67f3 /openbsc
parentccda96517c7f2f5aa10166eebe105f2f45342ad4 (diff)
ip.access: Introduce parser function for BCCH Info test result
Diffstat (limited to 'openbsc')
-rw-r--r--openbsc/include/openbsc/abis_nm.h45
-rwxr-xr-xopenbsc/src/abis_nm.c102
2 files changed, 147 insertions, 0 deletions
diff --git a/openbsc/include/openbsc/abis_nm.h b/openbsc/include/openbsc/abis_nm.h
index 8765a7a00..a9bfceee0 100644
--- a/openbsc/include/openbsc/abis_nm.h
+++ b/openbsc/include/openbsc/abis_nm.h
@@ -660,6 +660,49 @@ enum abis_nm_ipacc_testres_ie {
NM_IPACC_TR_IE_FREQ_ERR = 18,
};
+enum ipac_eie {
+ NM_IPAC_EIE_ARFCN_WHITE = 0x01,
+ NM_IPAC_EIE_ARFCH_BLACK = 0x02,
+ NM_IPAC_EIE_FREQ_ERR_LIST = 0x03,
+ NM_IPAC_EIE_CHAN_USE_LIST = 0x04,
+ NM_IPAC_EIE_BCCH_INFO_TYPE = 0x05,
+ NM_IPAC_EIE_BCCH_INFO = 0x06,
+ /* FIXME */
+};
+
+enum ipac_bcch_info_type {
+ IPAC_BINF_RXLEV = (1 << 8),
+ IPAC_BINF_RXQUAL = (1 << 9),
+ IPAC_BINF_FREQ_ERR_QUAL = (1 << 10),
+ IPAC_BINF_FRAME_OFFSET = (1 << 11),
+ IPAC_BINF_FRAME_NR_OFFSET = (1 << 12),
+ IPAC_BINF_BSIC = (1 << 13),
+ IPAC_BINF_CGI = (1 << 14),
+ IPAC_BINF_NEIGH_BA_SI2 = (1 << 15),
+ IPAC_BINF_NEIGH_BA_SI2bis = (1 << 0),
+ IPAC_BINF_NEIGH_BA_SI2ter = (1 << 1),
+ IPAC_BINF_CELL_ALLOC = (1 << 2),
+};
+
+/* The BCCH info from an ip.access test, in host byte order
+ * and already parsed... */
+struct ipac_bcch_info {
+ u_int16_t info_type;
+ u_int8_t freq_qual;
+ u_int16_t arfcn;
+ u_int8_t rx_lev;
+ u_int8_t rx_qual;
+ u_int16_t freq_err;
+ u_int16_t frame_offset;
+ u_int32_t frame_nr_offset;
+ u_int8_t bsic;
+ u_int8_t cgi[7];
+ u_int8_t ba_list_si2[16];
+ u_int8_t ba_list_si2bis[16];
+ u_int8_t ba_list_si2ter[16];
+ u_int8_t ca_list_si1[16];
+};
+
/* PUBLIC */
struct msgb;
@@ -754,6 +797,8 @@ int abis_nm_ipaccess_set_attr(struct gsm_bts *bts, u_int8_t obj_class,
u_int8_t *attr, u_int8_t attr_len);
int abis_nm_ipaccess_rsl_connect(struct gsm_bts_trx *trx,
u_int32_t ip, u_int16_t port, u_int8_t stream);
+int ipac_parse_bcch_info(struct ipac_bcch_info *binf, u_int8_t *buf);
+const char *ipacc_testres_name(u_int8_t res);
/* Functions calling into other code parts */
enum nm_evt {
diff --git a/openbsc/src/abis_nm.c b/openbsc/src/abis_nm.c
index 05dec2201..3f4fabb4a 100755
--- a/openbsc/src/abis_nm.c
+++ b/openbsc/src/abis_nm.c
@@ -572,6 +572,18 @@ const char *nm_avail_name(u_int8_t avail)
return avail_names[avail];
}
+static struct value_string test_names[] = {
+ /* FIXME: standard test names */
+ { NM_IPACC_TESTNO_CHAN_USAGE, "Channel Usage" },
+ { NM_IPACC_TESTNO_BCCH_CHAN_USAGE, "BCCH Channel Usage" },
+ { NM_IPACC_TESTNO_FREQ_SYNC, "Frequency Synchronization" },
+ { NM_IPACC_TESTNO_BCCH_INFO, "BCCH Info" },
+ { NM_IPACC_TESTNO_TX_BEACON, "Transmit Beacon" },
+ { NM_IPACC_TESTNO_SYSINFO_MONITOR, "System Info Monitor" },
+ { NM_IPACC_TESTNO_BCCCH_MONITOR, "BCCH Monitor" },
+ { 0, NULL }
+};
+
const char *nm_adm_name(u_int8_t adm)
{
switch (adm) {
@@ -2672,3 +2684,93 @@ int abis_nm_ipaccess_set_attr(struct gsm_bts *bts, u_int8_t obj_class,
obj_class, bts_nr, trx_nr, ts_nr,
attr, attr_len);
}
+
+static const char *ipacc_testres_names[] = {
+ [NM_IPACC_TESTRES_SUCCESS] = "SUCCESS",
+ [NM_IPACC_TESTRES_TIMEOUT] = "TIMEOUT",
+ [NM_IPACC_TESTRES_NO_CHANS] = "NO CHANNELS",
+ [NM_IPACC_TESTRES_PARTIAL] = "PARTIAL",
+ [NM_IPACC_TESTRES_STOPPED] = "STOPPED",
+};
+
+const char *ipacc_testres_name(u_int8_t res)
+{
+ if (res < ARRAY_SIZE(ipacc_testres_names) &&
+ ipacc_testres_names[res])
+ return ipacc_testres_names[res];
+
+ return "unknown";
+}
+
+/* parse BCCH information IEI from wire format to struct ipac_bcch_info */
+int ipac_parse_bcch_info(struct ipac_bcch_info *binf, u_int8_t *buf)
+{
+ u_int8_t *cur = buf;
+ u_int16_t len;
+
+ memset(binf, 0, sizeof(binf));
+
+ if (cur[0] != NM_IPAC_EIE_BCCH_INFO)
+ return -EINVAL;
+ cur++;
+
+ len = ntohs(*(u_int16_t *)cur);
+ cur += 2;
+
+ binf->info_type = ntohs(*(u_int16_t *)cur);
+ cur += 2;
+
+ if (binf->info_type & IPAC_BINF_FREQ_ERR_QUAL)
+ binf->freq_qual = *cur >> 2;
+
+ binf->arfcn = *cur++ & 3 << 8;
+ binf->arfcn |= *cur++;
+
+ if (binf->info_type & IPAC_BINF_RXLEV)
+ binf->rx_lev = *cur & 0x3f;
+ cur++;
+
+ if (binf->info_type & IPAC_BINF_RXQUAL)
+ binf->rx_qual = *cur & 0x7;
+ cur++;
+
+ if (binf->info_type & IPAC_BINF_FREQ_ERR_QUAL)
+ binf->freq_err = ntohs(*(u_int16_t *)cur);
+ cur += 2;
+
+ if (binf->info_type & IPAC_BINF_FRAME_OFFSET)
+ binf->frame_offset = ntohs(*(u_int16_t *)cur);
+ cur += 2;
+
+ if (binf->info_type & IPAC_BINF_FRAME_NR_OFFSET)
+ binf->frame_nr_offset = ntohl(*(u_int32_t *)cur);
+ cur += 4;
+
+ if (binf->info_type & IPAC_BINF_BSIC)
+ binf->bsic = *cur++ & 0x3f;
+ cur++;
+
+ memcpy(binf->cgi, cur, sizeof(binf->cgi));
+ cur += sizeof(binf->cgi);
+
+ if (binf->info_type & IPAC_BINF_NEIGH_BA_SI2) {
+ memcpy(binf->ba_list_si2, cur, sizeof(binf->ba_list_si2));
+ cur += sizeof(binf->ba_list_si2);
+ }
+
+ if (binf->info_type & IPAC_BINF_NEIGH_BA_SI2bis) {
+ memcpy(binf->ba_list_si2bis, cur,
+ sizeof(binf->ba_list_si2bis));
+ cur += sizeof(binf->ba_list_si2bis);
+ }
+
+ if (binf->info_type & IPAC_BINF_NEIGH_BA_SI2ter) {
+ memcpy(binf->ba_list_si2ter, cur,
+ sizeof(binf->ba_list_si2ter));
+ cur += sizeof(binf->ba_list_si2ter);
+ }
+
+ return 0;
+}
+
+