# HG changeset patch # User Mychaela Falconia # Date 1495348676 0 # Node ID e2db512abbeee83ed41424d8b09abb8f7f1092e3 # Parent 698602bbd1203674d4bd577d85bbcd7c04f2dd31 fc-cmu200d: band and ARFCN tables implemented diff -r 698602bbd120 -r e2db512abbee cmu200/Makefile --- a/cmu200/Makefile Sat May 20 18:58:44 2017 +0000 +++ b/cmu200/Makefile Sun May 21 06:37:56 2017 +0000 @@ -3,7 +3,8 @@ PROGS= fc-cmu200d fc-serscpi INSTBIN=/opt/freecalypso/bin -CMU200D_OBJS= dispatch.o init.o main.o openport.o sercmd.o session.o socket.o +CMU200D_OBJS= band.o dispatch.o init.o main.o openport.o sercmd.o session.o \ + socket.o SERSCPI_OBJS= openport.o sertool.o all: ${PROGS} diff -r 698602bbd120 -r e2db512abbee cmu200/band.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cmu200/band.c Sun May 21 06:37:56 2017 +0000 @@ -0,0 +1,65 @@ +/* + * Our band and ARFCN tables and lookup code live here. + */ + +#include +#include +#include "band.h" +#include "secaddr.h" + +struct arfcn_range band850_arfcn_range = {128, 251, 824200, 869200}; +struct arfcn_range band900_arfcn_range = { 0, 124, 890000, 935000}; +struct arfcn_range band900_arfcn_range_ext = {975, 1023, 880200, 925200}; +struct arfcn_range band1800_arfcn_range = {512, 885, 1710200, 1805200}; +struct arfcn_range band1900_arfcn_range = {512, 810, 1850200, 1930200}; + +struct band supported_bands[] = { + {"850", SECADDR_GSM850MS_NSIG, &band850_arfcn_range, 0}, + {"900", SECADDR_GSM900MS_NSIG, &band900_arfcn_range, + &band900_arfcn_range_ext}, + {"1800", SECADDR_GSM1800MS_NSIG, &band1800_arfcn_range, 0}, + {"1900", SECADDR_GSM1900MS_NSIG, &band1900_arfcn_range, 0}, + {0, 0, 0, 0} +}; + +struct band *current_band; + +find_named_band(srchname) + char *srchname; +{ + struct band *band; + + for (band = supported_bands; band->name; band++) + if (!strcmp(band->name, srchname)) + break; + if (!band->name) + return(-1); + current_band = band; + return(0); +} + +check_arfcn_range(range, arfcn, ulp, dlp) + struct arfcn_range *range; + unsigned arfcn, *ulp, *dlp; +{ + if (arfcn < range->min) + return(-1); + if (arfcn > range->max) + return(-1); + if (ulp) + *ulp = range->ul_khz + (arfcn - range->min) * 200; + if (dlp) + *dlp = range->dl_khz + (arfcn - range->min) * 200; + return(0); +} + +verify_arfcn(arfcn, ulp, dlp) + unsigned arfcn, *ulp, *dlp; +{ + if (!check_arfcn_range(current_band->arfcn_range, arfcn, ulp, dlp)) + return(0); + if (current_band->arfcn_range_ext && + !check_arfcn_range(current_band->arfcn_range_ext, arfcn, ulp, dlp)) + return(0); + return(-1); +} diff -r 698602bbd120 -r e2db512abbee cmu200/band.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cmu200/band.h Sun May 21 06:37:56 2017 +0000 @@ -0,0 +1,18 @@ +/* + * In this header file we are going to define structures which contain + * our knowledge about GSM frequency bands we work with. + */ + +struct arfcn_range { + unsigned min; + unsigned max; + unsigned ul_khz; + unsigned dl_khz; +}; + +struct band { + char *name; + int secaddr; + struct arfcn_range *arfcn_range; + struct arfcn_range *arfcn_range_ext; +};