summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/osmocom/gsm/abis_nm.h2
-rw-r--r--include/osmocom/gsm/gsm_utils.h26
-rw-r--r--src/gsm/abis_nm.c32
3 files changed, 60 insertions, 0 deletions
diff --git a/include/osmocom/gsm/abis_nm.h b/include/osmocom/gsm/abis_nm.h
index 720b603d..dcc8d4bb 100644
--- a/include/osmocom/gsm/abis_nm.h
+++ b/include/osmocom/gsm/abis_nm.h
@@ -22,4 +22,6 @@ const char *abis_nm_avail_name(uint8_t avail);
const char *abis_nm_test_name(uint8_t test);
void abis_nm_debugp_foh(int ss, struct abis_om_fom_hdr *foh);
+int abis_nm_chcomb4pchan(enum gsm_phys_chan_config pchan);
+enum abis_nm_chan_comb abis_nm_pchan4chcomb(uint8_t chcomb);
#endif /* _OSMO_GSM_ABIS_NM_H */
diff --git a/include/osmocom/gsm/gsm_utils.h b/include/osmocom/gsm/gsm_utils.h
index 19adb70a..a0ef3c4f 100644
--- a/include/osmocom/gsm/gsm_utils.h
+++ b/include/osmocom/gsm/gsm_utils.h
@@ -114,4 +114,30 @@ int gprs_tlli_type(uint32_t tlli);
uint32_t gprs_tmsi2tlli(uint32_t p_tmsi, enum gprs_tlli_type type);
+/* Osmocom internal, not part of any gsm spec */
+enum gsm_phys_chan_config {
+ GSM_PCHAN_NONE,
+ GSM_PCHAN_CCCH,
+ GSM_PCHAN_CCCH_SDCCH4,
+ GSM_PCHAN_TCH_F,
+ GSM_PCHAN_TCH_H,
+ GSM_PCHAN_SDCCH8_SACCH8C,
+ GSM_PCHAN_PDCH, /* GPRS PDCH */
+ GSM_PCHAN_TCH_F_PDCH, /* TCH/F if used, PDCH otherwise */
+ GSM_PCHAN_UNKNOWN,
+ _GSM_PCHAN_MAX
+};
+
+/* Osmocom internal, not part of any gsm spec */
+enum gsm_chan_t {
+ GSM_LCHAN_NONE,
+ GSM_LCHAN_SDCCH,
+ GSM_LCHAN_TCH_F,
+ GSM_LCHAN_TCH_H,
+ GSM_LCHAN_UNKNOWN,
+ GSM_LCHAN_CCCH,
+ _GSM_LCHAN_MAX
+};
+
+
#endif
diff --git a/src/gsm/abis_nm.c b/src/gsm/abis_nm.c
index 109c3bba..a82194fd 100644
--- a/src/gsm/abis_nm.c
+++ b/src/gsm/abis_nm.c
@@ -21,9 +21,12 @@
*/
#include <stdint.h>
+#include <errno.h>
+
#include <osmocom/core/utils.h>
#include <osmocom/core/logging.h>
#include <osmocom/gsm/tlv.h>
+#include <osmocom/gsm/gsm_utils.h>
#include <osmocom/gsm/protocol/gsm_12_21.h>
#include <osmocom/gsm/abis_nm.h>
@@ -394,3 +397,32 @@ void abis_nm_debugp_foh(int ss, struct abis_om_fom_hdr *foh)
foh->obj_class, foh->obj_inst.bts_nr, foh->obj_inst.trx_nr,
foh->obj_inst.ts_nr);
}
+
+static const enum abis_nm_chan_comb chcomb4pchan[] = {
+ [GSM_PCHAN_CCCH] = NM_CHANC_mainBCCH,
+ [GSM_PCHAN_CCCH_SDCCH4] = NM_CHANC_BCCHComb,
+ [GSM_PCHAN_TCH_F] = NM_CHANC_TCHFull,
+ [GSM_PCHAN_TCH_H] = NM_CHANC_TCHHalf,
+ [GSM_PCHAN_SDCCH8_SACCH8C] = NM_CHANC_SDCCH,
+ [GSM_PCHAN_PDCH] = NM_CHANC_IPAC_PDCH,
+ [GSM_PCHAN_TCH_F_PDCH] = NM_CHANC_IPAC_TCHFull_PDCH,
+ /* FIXME: bounds check */
+};
+
+int abis_nm_chcomb4pchan(enum gsm_phys_chan_config pchan)
+{
+ if (pchan < ARRAY_SIZE(chcomb4pchan))
+ return chcomb4pchan[pchan];
+
+ return -EINVAL;
+}
+
+enum abis_nm_chan_comb abis_nm_pchan4chcomb(uint8_t chcomb)
+{
+ int i;
+ for (i = 0; i < ARRAY_SIZE(chcomb4pchan); i++) {
+ if (chcomb4pchan[i] == chcomb)
+ return i;
+ }
+ return GSM_PCHAN_NONE;
+}