aboutsummaryrefslogtreecommitdiffstats
path: root/openbsc/src/bsc/meas_proc.c
diff options
context:
space:
mode:
authorHarald Welte <laforge@gnumonks.org>2011-03-03 23:29:05 +0100
committerHarald Welte <laforge@gnumonks.org>2011-03-03 23:29:05 +0100
commit31c00f7d6fa63937f2c973157d196a427f6eef95 (patch)
tree6b7c81d92b6a8b83d0588b2b59d47fd0cca7a052 /openbsc/src/bsc/meas_proc.c
parent9349d7ff7c5866110a1f2421ccc68a487e4030be (diff)
re-structure the OpenBSC directory layout
The new structure divides the code into a number of libraries for the BSC core functionality, MSC core functionality, Abis transport, TRAU and other bits. This doesn't introduce any functional code change but simply moves around files and alters Makefile.am accordingly. Next step would be to disentangle a lot of the inter-library dependencies and make the individual bits of code more independent.
Diffstat (limited to 'openbsc/src/bsc/meas_proc.c')
-rw-r--r--openbsc/src/bsc/meas_proc.c84
1 files changed, 84 insertions, 0 deletions
diff --git a/openbsc/src/bsc/meas_proc.c b/openbsc/src/bsc/meas_proc.c
new file mode 100644
index 000000000..ade1f2e0c
--- /dev/null
+++ b/openbsc/src/bsc/meas_proc.c
@@ -0,0 +1,84 @@
+/* Measurement Processing */
+
+/* (C) 2009 by Harald Welte <laforge@gnumonks.org>
+ *
+ * All Rights Reserved
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include <stdlib.h>
+#include <errno.h>
+
+#include <osmocore/talloc.h>
+#include <osmocore/msgb.h>
+#include <openbsc/debug.h>
+#include <openbsc/gsm_data.h>
+#include <openbsc/meas_rep.h>
+#include <openbsc/signal.h>
+
+/* process an already parsed measurement report */
+static int process_meas_rep(struct gsm_meas_rep *mr)
+{
+ struct gsm_meas_rep_cell *mr_cell = NULL;
+ unsigned int best_better_db;
+ int i;
+
+ /* FIXME: implement actual averaging over multiple measurement
+ * reports */
+
+ /* find the best cell in this report that is at least RXLEV_HYST
+ * better than the current serving cell */
+ for (i = 0; i < mr->num_cell; i++) {
+ unsigned int better;
+ if (mr->cell[i].rxlev < mr->dl.full.rx_lev + RXLEV_HYST)
+ continue;
+
+ better = mr->cell[i].rxlev - mr->dl.full.rx_lev;
+ if (better > best_better_db) {
+ mr_cell = &mr->cell[i];
+ best_better_db = better;
+ }
+ }
+
+ if (mr_cell)
+ return handover_to_arfcn_bsic(mr->lchan, mr_cell->arfcn,
+ mr_cell->bsic);
+ return 0;
+}
+
+static int meas_proc_sig_cb(unsigned int subsys, unsigned int signal,
+ void *handler_data, void *signal_data)
+{
+ struct gsm_lchan *lchan;
+ struct gsm_meas_rep *mr;
+
+ if (subsys != SS_LCHAN)
+ return 0;
+
+ switch (signal) {
+ case S_LCHAN_MEAS_REP:
+ mr = signal_data;
+ process_meas_rep(mr);
+ break;
+ }
+
+ return 0;
+}
+
+static __attribute__((constructor)) void on_dso_load_meas(void)
+{
+ register_signal_handler(SS_LCHAN, meas_proc_sig_cb, NULL);
+}