aboutsummaryrefslogtreecommitdiffstats
path: root/src/common/sysinfo.c
blob: 90141d5b3c3e4e38af496f78e93e548677fd3493 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/* (C) 2011 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 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 <stdint.h>

#include <osmocom/gsm/gsm_utils.h>
#include <osmocom/gsm/sysinfo.h>

#include <osmo-bts/gsm_data.h>

uint8_t *bts_sysinfo_get(struct gsm_bts *bts, struct gsm_time *g_time)
{
	/* Apply the rules from 05.02 6.3.1.3 Mapping of BCCH Data */
	switch (g_time->tc) {
	case 0:
		return GSM_BTS_SI(bts, SYSINFO_TYPE_1);
	case 1:
		return GSM_BTS_SI(bts, SYSINFO_TYPE_2);
	case 2:
		return GSM_BTS_SI(bts, SYSINFO_TYPE_3);
	case 3:
		return GSM_BTS_SI(bts, SYSINFO_TYPE_4);
	case 4:
		/* 2ter, 2quater, 9, 13 */
		break;
	case 5:
		/* 2ter, 2quater */
		break;
	case 6:
		return GSM_BTS_SI(bts, SYSINFO_TYPE_3);
	case 7:
		return GSM_BTS_SI(bts, SYSINFO_TYPE_4);
	}

	return NULL;
}

uint8_t *lchan_sacch_get(struct gsm_lchan *lchan, struct gsm_time *g_time)
{
	uint32_t tmp;

	for (tmp = lchan->si.last + 1; tmp != lchan->si.last; tmp = (tmp + 1) % 32) {
		if (lchan->si.valid & (1 << tmp)) {
			lchan->si.last = tmp;
			printf("returning SACCH SI type %u\n", tmp);
			return lchan->si.buf[tmp];
		}
	}
	return NULL;
}