3ad426d40dbe6d25eb453aed0ca3e96b43ea5f32
[osmocom-bb.git] / src / host / layer23 / src / misc / app_bcch_scan.c
1 /* "Application" code of the layer2/3 stack */
2
3 /* (C) 2010 by Holger Hans Peter Freyther
4  * (C) 2010 by Harald Welte <laforge@gnumonks.org>
5  *
6  * All Rights Reserved
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License along
19  * with this program; if not, write to the Free Software Foundation, Inc.,
20  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21  *
22  */
23
24 #include <osmocom/bb/common/osmocom_data.h>
25 #include <osmocom/bb/common/l1ctl.h>
26 #include <osmocom/bb/common/lapdm.h>
27 #include <osmocom/bb/common/logging.h>
28 #include <osmocom/bb/common/l23_app.h>
29 #include <osmocom/bb/misc/layer3.h>
30
31 #include <osmocom/core/msgb.h>
32 #include <osmocom/core/talloc.h>
33 #include <osmocom/core/select.h>
34 #include <osmocom/core/signal.h>
35
36 static int signal_cb(unsigned int subsys, unsigned int signal,
37                      void *handler_data, void *signal_data)
38 {
39         struct osmocom_ms *ms;
40
41         if (subsys != SS_L1CTL)
42                 return 0;
43
44         switch (signal) {
45         case S_L1CTL_RESET:
46                 ms = signal_data;
47                 return fps_start(ms);
48         }
49         return 0;
50 }
51
52 int l23_app_init(struct osmocom_ms *ms)
53 {
54         /* don't do layer3_init() as we don't want an actualy L3 */
55         fps_init(ms);
56         l1ctl_tx_reset_req(ms, L1CTL_RES_T_FULL);
57         return osmo_signal_register_handler(SS_L1CTL, &signal_cb, NULL);
58 }
59
60 static struct l23_app_info info = {
61         .copyright      = "Copyright (C) 2010 Harald Welte <laforge@gnumonks.org>\n",
62         .contribution   = "Contributions by Holger Hans Peter Freyther\n",
63 };
64
65 struct l23_app_info *l23_app_info()
66 {
67         return &info;
68 }