2009-12-01 12:34:30 +00:00
|
|
|
/* GSM 04.08 System Information (SI) encoding and decoding
|
|
|
|
* 3GPP TS 04.08 version 7.21.0 Release 1998 / ETSI TS 100 940 V7.21.0 */
|
|
|
|
|
2010-06-15 14:44:12 +00:00
|
|
|
/* (C) 2008-2010 by Harald Welte <laforge@gnumonks.org>
|
2009-12-01 12:34:30 +00:00
|
|
|
*
|
|
|
|
* All Rights Reserved
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
2011-01-01 14:25:50 +00:00
|
|
|
* 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
|
2009-12-01 12:34:30 +00:00
|
|
|
* (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
|
2011-01-01 14:25:50 +00:00
|
|
|
* GNU Affero General Public License for more details.
|
2009-12-01 12:34:30 +00:00
|
|
|
*
|
2011-01-01 14:25:50 +00:00
|
|
|
* 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/>.
|
2009-12-01 12:34:30 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <errno.h>
|
|
|
|
#include <string.h>
|
2009-12-14 21:07:14 +00:00
|
|
|
#include <stdio.h>
|
2009-12-01 12:34:30 +00:00
|
|
|
#include <netinet/in.h>
|
|
|
|
|
2011-05-24 13:02:20 +00:00
|
|
|
#include <osmocom/core/bitvec.h>
|
|
|
|
#include <osmocom/core/utils.h>
|
|
|
|
#include <osmocom/gsm/sysinfo.h>
|
|
|
|
|
|
|
|
#include <openbsc/debug.h>
|
2009-12-01 12:34:30 +00:00
|
|
|
#include <openbsc/gsm_04_08.h>
|
|
|
|
#include <openbsc/gsm_data.h>
|
|
|
|
#include <openbsc/abis_rsl.h>
|
|
|
|
#include <openbsc/rest_octets.h>
|
2010-01-06 05:38:14 +00:00
|
|
|
|
|
|
|
|
2009-12-14 19:25:05 +00:00
|
|
|
/* Frequency Lists as per TS 04.08 10.5.2.13 */
|
|
|
|
|
|
|
|
/* 10.5.2.13.2: Bit map 0 format */
|
2011-04-18 15:04:00 +00:00
|
|
|
static int freq_list_bm0_set_arfcn(uint8_t *chan_list, unsigned int arfcn)
|
2009-12-01 12:34:30 +00:00
|
|
|
{
|
|
|
|
unsigned int byte, bit;
|
|
|
|
|
2009-12-17 22:10:46 +00:00
|
|
|
if (arfcn > 124 || arfcn < 1) {
|
|
|
|
LOGP(DRR, LOGL_ERROR, "Bitmap 0 only supports ARFCN 1...124\n");
|
2009-12-01 12:34:30 +00:00
|
|
|
return -EINVAL;
|
2009-12-17 22:10:46 +00:00
|
|
|
}
|
2009-12-01 12:34:30 +00:00
|
|
|
|
2009-12-14 19:25:05 +00:00
|
|
|
/* the bitmask is from 1..124, not from 0..123 */
|
|
|
|
arfcn--;
|
|
|
|
|
2009-12-01 12:34:30 +00:00
|
|
|
byte = arfcn / 8;
|
|
|
|
bit = arfcn % 8;
|
|
|
|
|
2009-12-14 19:25:05 +00:00
|
|
|
chan_list[GSM48_CELL_CHAN_DESC_SIZE-1-byte] |= (1 << bit);
|
2009-12-01 12:34:30 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-12-14 19:25:05 +00:00
|
|
|
/* 10.5.2.13.7: Variable bit map format */
|
2011-04-18 15:04:00 +00:00
|
|
|
static int freq_list_bmrel_set_arfcn(uint8_t *chan_list, unsigned int arfcn)
|
2009-12-01 12:34:30 +00:00
|
|
|
{
|
|
|
|
unsigned int byte, bit;
|
|
|
|
unsigned int min_arfcn;
|
|
|
|
unsigned int bitno;
|
|
|
|
|
|
|
|
min_arfcn = (chan_list[0] & 1) << 9;
|
|
|
|
min_arfcn |= chan_list[1] << 1;
|
|
|
|
min_arfcn |= (chan_list[2] >> 7) & 1;
|
|
|
|
|
|
|
|
/* The lower end of our bitmaks is always implicitly included */
|
|
|
|
if (arfcn == min_arfcn)
|
|
|
|
return 0;
|
|
|
|
|
Improved generation of SYSTEM INFORMATIONs 2* and 5* for neighbour bands
In addition to SI 2 and SI 5, the SI 2ter and 2bis is generated, if
neighbour cells in other bands exist. Also it is indicated in the rest
octets of SI3, that SI 2ter is used. If no neighbour cell in a different
band exists, the SI 2ter and SI 5ter is omitted.
A special case is P-GSM range (channels 1-124). To be compatible with
older phones, SI 2bis and SI 5bis is used. If the BCCH lays inside the
P-GSM band, only neighbour cells of the P-GSM range are included in
SI 2 and SI 5. If neighbour cells exist in the same band (900), but lay
outside the P-GSM range, the SI 2bis and SI 5bis is used to extend the
list of neighbour cells. The extension is also indicated in SI 2 and
SI 5. If the BCCH lays inside the P-GSM range, but no neighbour cell
exists in the same band outside the P-GSM range, the SI 2bis ans SI 5bis
are omitted.
2012-02-29 08:04:07 +00:00
|
|
|
if (((arfcn - min_arfcn) & 1023) > 111) {
|
2009-12-17 22:10:46 +00:00
|
|
|
LOGP(DRR, LOGL_ERROR, "arfcn(%u) > min(%u) + 111\n", arfcn, min_arfcn);
|
2009-12-01 12:34:30 +00:00
|
|
|
return -EINVAL;
|
2009-12-16 10:57:48 +00:00
|
|
|
}
|
2009-12-01 12:34:30 +00:00
|
|
|
|
Improved generation of SYSTEM INFORMATIONs 2* and 5* for neighbour bands
In addition to SI 2 and SI 5, the SI 2ter and 2bis is generated, if
neighbour cells in other bands exist. Also it is indicated in the rest
octets of SI3, that SI 2ter is used. If no neighbour cell in a different
band exists, the SI 2ter and SI 5ter is omitted.
A special case is P-GSM range (channels 1-124). To be compatible with
older phones, SI 2bis and SI 5bis is used. If the BCCH lays inside the
P-GSM band, only neighbour cells of the P-GSM range are included in
SI 2 and SI 5. If neighbour cells exist in the same band (900), but lay
outside the P-GSM range, the SI 2bis and SI 5bis is used to extend the
list of neighbour cells. The extension is also indicated in SI 2 and
SI 5. If the BCCH lays inside the P-GSM range, but no neighbour cell
exists in the same band outside the P-GSM range, the SI 2bis ans SI 5bis
are omitted.
2012-02-29 08:04:07 +00:00
|
|
|
bitno = (arfcn - min_arfcn) & 1023;
|
2009-12-01 12:34:30 +00:00
|
|
|
byte = bitno / 8;
|
|
|
|
bit = bitno % 8;
|
|
|
|
|
|
|
|
chan_list[2 + byte] |= 1 << (7 - bit);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* generate a cell channel list as per Section 10.5.2.1b of 04.08 */
|
2011-04-18 15:04:00 +00:00
|
|
|
static int bitvec2freq_list(uint8_t *chan_list, struct bitvec *bv,
|
Improved generation of SYSTEM INFORMATIONs 2* and 5* for neighbour bands
In addition to SI 2 and SI 5, the SI 2ter and 2bis is generated, if
neighbour cells in other bands exist. Also it is indicated in the rest
octets of SI3, that SI 2ter is used. If no neighbour cell in a different
band exists, the SI 2ter and SI 5ter is omitted.
A special case is P-GSM range (channels 1-124). To be compatible with
older phones, SI 2bis and SI 5bis is used. If the BCCH lays inside the
P-GSM band, only neighbour cells of the P-GSM range are included in
SI 2 and SI 5. If neighbour cells exist in the same band (900), but lay
outside the P-GSM range, the SI 2bis and SI 5bis is used to extend the
list of neighbour cells. The extension is also indicated in SI 2 and
SI 5. If the BCCH lays inside the P-GSM range, but no neighbour cell
exists in the same band outside the P-GSM range, the SI 2bis ans SI 5bis
are omitted.
2012-02-29 08:04:07 +00:00
|
|
|
const struct gsm_bts *bts, int bis, int ter)
|
2009-12-01 12:34:30 +00:00
|
|
|
{
|
Improved generation of SYSTEM INFORMATIONs 2* and 5* for neighbour bands
In addition to SI 2 and SI 5, the SI 2ter and 2bis is generated, if
neighbour cells in other bands exist. Also it is indicated in the rest
octets of SI3, that SI 2ter is used. If no neighbour cell in a different
band exists, the SI 2ter and SI 5ter is omitted.
A special case is P-GSM range (channels 1-124). To be compatible with
older phones, SI 2bis and SI 5bis is used. If the BCCH lays inside the
P-GSM band, only neighbour cells of the P-GSM range are included in
SI 2 and SI 5. If neighbour cells exist in the same band (900), but lay
outside the P-GSM range, the SI 2bis and SI 5bis is used to extend the
list of neighbour cells. The extension is also indicated in SI 2 and
SI 5. If the BCCH lays inside the P-GSM range, but no neighbour cell
exists in the same band outside the P-GSM range, the SI 2bis ans SI 5bis
are omitted.
2012-02-29 08:04:07 +00:00
|
|
|
int i, rc, min = -1, max = -1, pgsm = 0;
|
2009-12-01 12:34:30 +00:00
|
|
|
|
|
|
|
memset(chan_list, 0, 16);
|
|
|
|
|
2012-02-17 14:58:23 +00:00
|
|
|
if (bts->band == GSM_BAND_900
|
Improved generation of SYSTEM INFORMATIONs 2* and 5* for neighbour bands
In addition to SI 2 and SI 5, the SI 2ter and 2bis is generated, if
neighbour cells in other bands exist. Also it is indicated in the rest
octets of SI3, that SI 2ter is used. If no neighbour cell in a different
band exists, the SI 2ter and SI 5ter is omitted.
A special case is P-GSM range (channels 1-124). To be compatible with
older phones, SI 2bis and SI 5bis is used. If the BCCH lays inside the
P-GSM band, only neighbour cells of the P-GSM range are included in
SI 2 and SI 5. If neighbour cells exist in the same band (900), but lay
outside the P-GSM range, the SI 2bis and SI 5bis is used to extend the
list of neighbour cells. The extension is also indicated in SI 2 and
SI 5. If the BCCH lays inside the P-GSM range, but no neighbour cell
exists in the same band outside the P-GSM range, the SI 2bis ans SI 5bis
are omitted.
2012-02-29 08:04:07 +00:00
|
|
|
&& bts->c0->arfcn >= 1 && bts->c0->arfcn <= 124)
|
|
|
|
pgsm = 1;
|
|
|
|
/* P-GSM-only handsets only support 'bit map 0 format' */
|
|
|
|
if (!bis && !ter && pgsm) {
|
2009-12-01 12:34:30 +00:00
|
|
|
chan_list[0] = 0;
|
2009-12-14 21:07:14 +00:00
|
|
|
|
|
|
|
for (i = 0; i < bv->data_len*8; i++) {
|
Improved generation of SYSTEM INFORMATIONs 2* and 5* for neighbour bands
In addition to SI 2 and SI 5, the SI 2ter and 2bis is generated, if
neighbour cells in other bands exist. Also it is indicated in the rest
octets of SI3, that SI 2ter is used. If no neighbour cell in a different
band exists, the SI 2ter and SI 5ter is omitted.
A special case is P-GSM range (channels 1-124). To be compatible with
older phones, SI 2bis and SI 5bis is used. If the BCCH lays inside the
P-GSM band, only neighbour cells of the P-GSM range are included in
SI 2 and SI 5. If neighbour cells exist in the same band (900), but lay
outside the P-GSM range, the SI 2bis and SI 5bis is used to extend the
list of neighbour cells. The extension is also indicated in SI 2 and
SI 5. If the BCCH lays inside the P-GSM range, but no neighbour cell
exists in the same band outside the P-GSM range, the SI 2bis ans SI 5bis
are omitted.
2012-02-29 08:04:07 +00:00
|
|
|
if (i >= 1 && i <= 124
|
|
|
|
&& bitvec_get_bit_pos(bv, i)) {
|
2009-12-14 21:07:14 +00:00
|
|
|
rc = freq_list_bm0_set_arfcn(chan_list, i);
|
|
|
|
if (rc < 0)
|
|
|
|
return rc;
|
|
|
|
}
|
2009-12-01 12:34:30 +00:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* We currently only support the 'Variable bitmap format' */
|
|
|
|
chan_list[0] = 0x8e;
|
|
|
|
|
2009-12-14 21:07:14 +00:00
|
|
|
for (i = 0; i < bv->data_len*8; i++) {
|
Improved generation of SYSTEM INFORMATIONs 2* and 5* for neighbour bands
In addition to SI 2 and SI 5, the SI 2ter and 2bis is generated, if
neighbour cells in other bands exist. Also it is indicated in the rest
octets of SI3, that SI 2ter is used. If no neighbour cell in a different
band exists, the SI 2ter and SI 5ter is omitted.
A special case is P-GSM range (channels 1-124). To be compatible with
older phones, SI 2bis and SI 5bis is used. If the BCCH lays inside the
P-GSM band, only neighbour cells of the P-GSM range are included in
SI 2 and SI 5. If neighbour cells exist in the same band (900), but lay
outside the P-GSM range, the SI 2bis and SI 5bis is used to extend the
list of neighbour cells. The extension is also indicated in SI 2 and
SI 5. If the BCCH lays inside the P-GSM range, but no neighbour cell
exists in the same band outside the P-GSM range, the SI 2bis ans SI 5bis
are omitted.
2012-02-29 08:04:07 +00:00
|
|
|
/* in case of SI2 or SI5 allow all neighbours in same band
|
|
|
|
* in case of SI*bis, allow neighbours in same band ouside pgsm
|
|
|
|
* in case of SI*ter, allow neighbours in different bands
|
|
|
|
*/
|
|
|
|
if (bitvec_get_bit_pos(bv, i)
|
|
|
|
&& ((!bis && !ter && gsm_arfcn2band(i) == bts->band)
|
|
|
|
|| (bis && pgsm && gsm_arfcn2band(i) == bts->band && (i < 1 || i > 124))
|
|
|
|
|| (ter && gsm_arfcn2band(i) != bts->band))) {
|
|
|
|
/* 955..1023 < 0..885 */
|
|
|
|
if (min < 0)
|
|
|
|
min = i;
|
|
|
|
if (i >= 955 && min < 955)
|
|
|
|
min = i;
|
|
|
|
if (i >= 955 && min >= 955 && i < min)
|
2009-12-14 21:07:14 +00:00
|
|
|
min = i;
|
Improved generation of SYSTEM INFORMATIONs 2* and 5* for neighbour bands
In addition to SI 2 and SI 5, the SI 2ter and 2bis is generated, if
neighbour cells in other bands exist. Also it is indicated in the rest
octets of SI3, that SI 2ter is used. If no neighbour cell in a different
band exists, the SI 2ter and SI 5ter is omitted.
A special case is P-GSM range (channels 1-124). To be compatible with
older phones, SI 2bis and SI 5bis is used. If the BCCH lays inside the
P-GSM band, only neighbour cells of the P-GSM range are included in
SI 2 and SI 5. If neighbour cells exist in the same band (900), but lay
outside the P-GSM range, the SI 2bis and SI 5bis is used to extend the
list of neighbour cells. The extension is also indicated in SI 2 and
SI 5. If the BCCH lays inside the P-GSM range, but no neighbour cell
exists in the same band outside the P-GSM range, the SI 2bis ans SI 5bis
are omitted.
2012-02-29 08:04:07 +00:00
|
|
|
if (i < 955 && min < 955 && i < min)
|
|
|
|
min = i;
|
|
|
|
if (max < 0)
|
|
|
|
max = i;
|
|
|
|
if (i < 955 && max >= 955)
|
|
|
|
max = i;
|
|
|
|
if (i >= 955 && max >= 955 && i > max)
|
|
|
|
max = i;
|
|
|
|
if (i < 955 && max < 955 && i > max)
|
2009-12-14 21:07:14 +00:00
|
|
|
max = i;
|
|
|
|
}
|
2009-12-01 12:34:30 +00:00
|
|
|
}
|
|
|
|
|
2009-12-24 13:20:19 +00:00
|
|
|
if (max == -1) {
|
|
|
|
/* Empty set, use 'bit map 0 format' */
|
|
|
|
chan_list[0] = 0;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
Improved generation of SYSTEM INFORMATIONs 2* and 5* for neighbour bands
In addition to SI 2 and SI 5, the SI 2ter and 2bis is generated, if
neighbour cells in other bands exist. Also it is indicated in the rest
octets of SI3, that SI 2ter is used. If no neighbour cell in a different
band exists, the SI 2ter and SI 5ter is omitted.
A special case is P-GSM range (channels 1-124). To be compatible with
older phones, SI 2bis and SI 5bis is used. If the BCCH lays inside the
P-GSM band, only neighbour cells of the P-GSM range are included in
SI 2 and SI 5. If neighbour cells exist in the same band (900), but lay
outside the P-GSM range, the SI 2bis and SI 5bis is used to extend the
list of neighbour cells. The extension is also indicated in SI 2 and
SI 5. If the BCCH lays inside the P-GSM range, but no neighbour cell
exists in the same band outside the P-GSM range, the SI 2bis ans SI 5bis
are omitted.
2012-02-29 08:04:07 +00:00
|
|
|
if (((max - min) & 1023) > 111) {
|
2009-12-17 22:10:46 +00:00
|
|
|
LOGP(DRR, LOGL_ERROR, "min_arfcn=%u, max_arfcn=%u, "
|
|
|
|
"distance > 111\n", min, max);
|
2009-12-01 12:34:30 +00:00
|
|
|
return -EINVAL;
|
2009-12-16 10:57:48 +00:00
|
|
|
}
|
2009-12-01 12:34:30 +00:00
|
|
|
|
|
|
|
chan_list[0] |= (min >> 9) & 1;
|
|
|
|
chan_list[1] = (min >> 1);
|
|
|
|
chan_list[2] = (min & 1) << 7;
|
|
|
|
|
2009-12-14 21:07:14 +00:00
|
|
|
for (i = 0; i < bv->data_len*8; i++) {
|
Improved generation of SYSTEM INFORMATIONs 2* and 5* for neighbour bands
In addition to SI 2 and SI 5, the SI 2ter and 2bis is generated, if
neighbour cells in other bands exist. Also it is indicated in the rest
octets of SI3, that SI 2ter is used. If no neighbour cell in a different
band exists, the SI 2ter and SI 5ter is omitted.
A special case is P-GSM range (channels 1-124). To be compatible with
older phones, SI 2bis and SI 5bis is used. If the BCCH lays inside the
P-GSM band, only neighbour cells of the P-GSM range are included in
SI 2 and SI 5. If neighbour cells exist in the same band (900), but lay
outside the P-GSM range, the SI 2bis and SI 5bis is used to extend the
list of neighbour cells. The extension is also indicated in SI 2 and
SI 5. If the BCCH lays inside the P-GSM range, but no neighbour cell
exists in the same band outside the P-GSM range, the SI 2bis ans SI 5bis
are omitted.
2012-02-29 08:04:07 +00:00
|
|
|
/* see notes above */
|
|
|
|
if (bitvec_get_bit_pos(bv, i)
|
|
|
|
&& ((!bis && !ter && gsm_arfcn2band(i) == bts->band)
|
|
|
|
|| (bis && pgsm && gsm_arfcn2band(i) == bts->band && (i < 1 || i > 124))
|
|
|
|
|| (ter && gsm_arfcn2band(i) != bts->band))) {
|
2009-12-16 10:57:48 +00:00
|
|
|
rc = freq_list_bmrel_set_arfcn(chan_list, i);
|
|
|
|
if (rc < 0)
|
|
|
|
return rc;
|
|
|
|
}
|
2009-12-01 12:34:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* generate a cell channel list as per Section 10.5.2.1b of 04.08 */
|
2011-07-27 22:01:50 +00:00
|
|
|
/* static*/ int generate_cell_chan_list(uint8_t *chan_list, struct gsm_bts *bts)
|
2009-12-01 12:34:30 +00:00
|
|
|
{
|
|
|
|
struct gsm_bts_trx *trx;
|
2009-12-14 21:07:14 +00:00
|
|
|
struct bitvec *bv = &bts->si_common.cell_alloc;
|
2009-12-01 12:34:30 +00:00
|
|
|
|
2010-06-14 20:26:10 +00:00
|
|
|
/* Zero-initialize the bit-vector */
|
2010-06-16 09:09:18 +00:00
|
|
|
memset(bv->data, 0, bv->data_len);
|
2010-06-14 20:26:10 +00:00
|
|
|
|
2009-12-14 21:07:14 +00:00
|
|
|
/* first we generate a bitvec of all TRX ARFCN's in our BTS */
|
2010-06-14 20:26:10 +00:00
|
|
|
llist_for_each_entry(trx, &bts->trx_list, list) {
|
|
|
|
unsigned int i, j;
|
|
|
|
/* Always add the TRX's ARFCN */
|
2009-12-14 21:07:14 +00:00
|
|
|
bitvec_set_bit_pos(bv, trx->arfcn, 1);
|
2010-06-14 20:26:10 +00:00
|
|
|
for (i = 0; i < ARRAY_SIZE(trx->ts); i++) {
|
|
|
|
struct gsm_bts_trx_ts *ts = &trx->ts[i];
|
|
|
|
/* Add any ARFCNs present in hopping channels */
|
|
|
|
for (j = 0; j < 1024; j++) {
|
|
|
|
if (bitvec_get_bit_pos(&ts->hopping.arfcns, j))
|
|
|
|
bitvec_set_bit_pos(bv, j, 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2009-12-01 12:34:30 +00:00
|
|
|
|
2009-12-14 21:07:14 +00:00
|
|
|
/* then we generate a GSM 04.08 frequency list from the bitvec */
|
Improved generation of SYSTEM INFORMATIONs 2* and 5* for neighbour bands
In addition to SI 2 and SI 5, the SI 2ter and 2bis is generated, if
neighbour cells in other bands exist. Also it is indicated in the rest
octets of SI3, that SI 2ter is used. If no neighbour cell in a different
band exists, the SI 2ter and SI 5ter is omitted.
A special case is P-GSM range (channels 1-124). To be compatible with
older phones, SI 2bis and SI 5bis is used. If the BCCH lays inside the
P-GSM band, only neighbour cells of the P-GSM range are included in
SI 2 and SI 5. If neighbour cells exist in the same band (900), but lay
outside the P-GSM range, the SI 2bis and SI 5bis is used to extend the
list of neighbour cells. The extension is also indicated in SI 2 and
SI 5. If the BCCH lays inside the P-GSM range, but no neighbour cell
exists in the same band outside the P-GSM range, the SI 2bis ans SI 5bis
are omitted.
2012-02-29 08:04:07 +00:00
|
|
|
return bitvec2freq_list(chan_list, bv, bts, 0, 0);
|
2009-12-14 21:07:14 +00:00
|
|
|
}
|
2009-12-01 12:34:30 +00:00
|
|
|
|
2009-12-14 21:07:14 +00:00
|
|
|
/* generate a cell channel list as per Section 10.5.2.1b of 04.08 */
|
Improved generation of SYSTEM INFORMATIONs 2* and 5* for neighbour bands
In addition to SI 2 and SI 5, the SI 2ter and 2bis is generated, if
neighbour cells in other bands exist. Also it is indicated in the rest
octets of SI3, that SI 2ter is used. If no neighbour cell in a different
band exists, the SI 2ter and SI 5ter is omitted.
A special case is P-GSM range (channels 1-124). To be compatible with
older phones, SI 2bis and SI 5bis is used. If the BCCH lays inside the
P-GSM band, only neighbour cells of the P-GSM range are included in
SI 2 and SI 5. If neighbour cells exist in the same band (900), but lay
outside the P-GSM range, the SI 2bis and SI 5bis is used to extend the
list of neighbour cells. The extension is also indicated in SI 2 and
SI 5. If the BCCH lays inside the P-GSM range, but no neighbour cell
exists in the same band outside the P-GSM range, the SI 2bis ans SI 5bis
are omitted.
2012-02-29 08:04:07 +00:00
|
|
|
static int generate_bcch_chan_list(uint8_t *chan_list, struct gsm_bts *bts,
|
|
|
|
int si5, int bis, int ter)
|
2009-12-14 21:07:14 +00:00
|
|
|
{
|
|
|
|
struct gsm_bts *cur_bts;
|
2011-02-15 10:43:27 +00:00
|
|
|
struct bitvec *bv;
|
|
|
|
|
|
|
|
if (si5 && bts->neigh_list_manual_mode == NL_MODE_MANUAL_SI5SEP)
|
|
|
|
bv = &bts->si_common.si5_neigh_list;
|
|
|
|
else
|
|
|
|
bv = &bts->si_common.neigh_list;
|
2009-12-01 12:34:30 +00:00
|
|
|
|
2011-01-11 22:44:56 +00:00
|
|
|
/* Generate list of neighbor cells if we are in automatic mode */
|
2011-02-15 10:43:27 +00:00
|
|
|
if (bts->neigh_list_manual_mode == NL_MODE_AUTOMATIC) {
|
2011-02-19 19:43:37 +00:00
|
|
|
/* Zero-initialize the bit-vector */
|
|
|
|
memset(bv->data, 0, bv->data_len);
|
|
|
|
|
2011-01-11 22:44:56 +00:00
|
|
|
/* first we generate a bitvec of the BCCH ARFCN's in our BSC */
|
|
|
|
llist_for_each_entry(cur_bts, &bts->network->bts_list, list) {
|
|
|
|
if (cur_bts == bts)
|
|
|
|
continue;
|
|
|
|
bitvec_set_bit_pos(bv, cur_bts->c0->arfcn, 1);
|
|
|
|
}
|
2009-12-01 12:34:30 +00:00
|
|
|
}
|
|
|
|
|
2009-12-14 21:07:14 +00:00
|
|
|
/* then we generate a GSM 04.08 frequency list from the bitvec */
|
Improved generation of SYSTEM INFORMATIONs 2* and 5* for neighbour bands
In addition to SI 2 and SI 5, the SI 2ter and 2bis is generated, if
neighbour cells in other bands exist. Also it is indicated in the rest
octets of SI3, that SI 2ter is used. If no neighbour cell in a different
band exists, the SI 2ter and SI 5ter is omitted.
A special case is P-GSM range (channels 1-124). To be compatible with
older phones, SI 2bis and SI 5bis is used. If the BCCH lays inside the
P-GSM band, only neighbour cells of the P-GSM range are included in
SI 2 and SI 5. If neighbour cells exist in the same band (900), but lay
outside the P-GSM range, the SI 2bis and SI 5bis is used to extend the
list of neighbour cells. The extension is also indicated in SI 2 and
SI 5. If the BCCH lays inside the P-GSM range, but no neighbour cell
exists in the same band outside the P-GSM range, the SI 2bis ans SI 5bis
are omitted.
2012-02-29 08:04:07 +00:00
|
|
|
return bitvec2freq_list(chan_list, bv, bts, bis, ter);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int list_arfcn(uint8_t *chan_list, uint8_t mask, char *text)
|
|
|
|
{
|
|
|
|
int n = 0, i;
|
|
|
|
struct gsm_sysinfo_freq freq[1024];
|
|
|
|
|
|
|
|
memset(freq, 0, sizeof(freq));
|
|
|
|
gsm48_decode_freq_list(freq, chan_list, 16, 0xce, 1);
|
|
|
|
for (i = 0; i < 1024; i++) {
|
|
|
|
if (freq[i].mask) {
|
|
|
|
if (!n)
|
|
|
|
LOGP(DRR, LOGL_INFO, "%s", text);
|
|
|
|
LOGPC(DRR, LOGL_INFO, " %d", i);
|
|
|
|
n++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (n)
|
|
|
|
LOGPC(DRR, LOGL_INFO, "\n");
|
|
|
|
|
|
|
|
return n;
|
2009-12-01 12:34:30 +00:00
|
|
|
}
|
|
|
|
|
2011-04-18 15:04:00 +00:00
|
|
|
static int generate_si1(uint8_t *output, struct gsm_bts *bts)
|
2009-12-01 12:34:30 +00:00
|
|
|
{
|
|
|
|
int rc;
|
|
|
|
struct gsm48_system_information_type_1 *si1 =
|
|
|
|
(struct gsm48_system_information_type_1 *) output;
|
|
|
|
|
|
|
|
memset(si1, GSM_MACBLOCK_PADDING, GSM_MACBLOCK_LEN);
|
|
|
|
|
|
|
|
si1->header.l2_plen = (21 << 2) | 1;
|
|
|
|
si1->header.rr_protocol_discriminator = GSM48_PDISC_RR;
|
|
|
|
si1->header.skip_indicator = 0;
|
|
|
|
si1->header.system_information = GSM48_MT_RR_SYSINFO_1;
|
|
|
|
|
|
|
|
rc = generate_cell_chan_list(si1->cell_channel_description, bts);
|
|
|
|
if (rc < 0)
|
|
|
|
return rc;
|
Improved generation of SYSTEM INFORMATIONs 2* and 5* for neighbour bands
In addition to SI 2 and SI 5, the SI 2ter and 2bis is generated, if
neighbour cells in other bands exist. Also it is indicated in the rest
octets of SI3, that SI 2ter is used. If no neighbour cell in a different
band exists, the SI 2ter and SI 5ter is omitted.
A special case is P-GSM range (channels 1-124). To be compatible with
older phones, SI 2bis and SI 5bis is used. If the BCCH lays inside the
P-GSM band, only neighbour cells of the P-GSM range are included in
SI 2 and SI 5. If neighbour cells exist in the same band (900), but lay
outside the P-GSM range, the SI 2bis and SI 5bis is used to extend the
list of neighbour cells. The extension is also indicated in SI 2 and
SI 5. If the BCCH lays inside the P-GSM range, but no neighbour cell
exists in the same band outside the P-GSM range, the SI 2bis ans SI 5bis
are omitted.
2012-02-29 08:04:07 +00:00
|
|
|
list_arfcn(si1->cell_channel_description, 0xce, "Serving cell:");
|
2009-12-01 12:34:30 +00:00
|
|
|
|
|
|
|
si1->rach_control = bts->si_common.rach_control;
|
|
|
|
|
|
|
|
/* SI1 Rest Octets (10.5.2.32), contains NCH position */
|
2010-01-06 06:52:31 +00:00
|
|
|
rc = rest_octets_si1(si1->rest_octets, NULL);
|
2010-06-15 14:44:12 +00:00
|
|
|
|
2010-01-06 06:52:31 +00:00
|
|
|
return sizeof(*si1) + rc;
|
2009-12-01 12:34:30 +00:00
|
|
|
}
|
|
|
|
|
2011-04-18 15:04:00 +00:00
|
|
|
static int generate_si2(uint8_t *output, struct gsm_bts *bts)
|
2009-12-01 12:34:30 +00:00
|
|
|
{
|
|
|
|
int rc;
|
|
|
|
struct gsm48_system_information_type_2 *si2 =
|
|
|
|
(struct gsm48_system_information_type_2 *) output;
|
|
|
|
|
|
|
|
memset(si2, GSM_MACBLOCK_PADDING, GSM_MACBLOCK_LEN);
|
|
|
|
|
|
|
|
si2->header.l2_plen = (22 << 2) | 1;
|
|
|
|
si2->header.rr_protocol_discriminator = GSM48_PDISC_RR;
|
|
|
|
si2->header.skip_indicator = 0;
|
|
|
|
si2->header.system_information = GSM48_MT_RR_SYSINFO_2;
|
|
|
|
|
Improved generation of SYSTEM INFORMATIONs 2* and 5* for neighbour bands
In addition to SI 2 and SI 5, the SI 2ter and 2bis is generated, if
neighbour cells in other bands exist. Also it is indicated in the rest
octets of SI3, that SI 2ter is used. If no neighbour cell in a different
band exists, the SI 2ter and SI 5ter is omitted.
A special case is P-GSM range (channels 1-124). To be compatible with
older phones, SI 2bis and SI 5bis is used. If the BCCH lays inside the
P-GSM band, only neighbour cells of the P-GSM range are included in
SI 2 and SI 5. If neighbour cells exist in the same band (900), but lay
outside the P-GSM range, the SI 2bis and SI 5bis is used to extend the
list of neighbour cells. The extension is also indicated in SI 2 and
SI 5. If the BCCH lays inside the P-GSM range, but no neighbour cell
exists in the same band outside the P-GSM range, the SI 2bis ans SI 5bis
are omitted.
2012-02-29 08:04:07 +00:00
|
|
|
rc = generate_bcch_chan_list(si2->bcch_frequency_list, bts, 0, 0, 0);
|
2009-12-01 12:34:30 +00:00
|
|
|
if (rc < 0)
|
|
|
|
return rc;
|
Improved generation of SYSTEM INFORMATIONs 2* and 5* for neighbour bands
In addition to SI 2 and SI 5, the SI 2ter and 2bis is generated, if
neighbour cells in other bands exist. Also it is indicated in the rest
octets of SI3, that SI 2ter is used. If no neighbour cell in a different
band exists, the SI 2ter and SI 5ter is omitted.
A special case is P-GSM range (channels 1-124). To be compatible with
older phones, SI 2bis and SI 5bis is used. If the BCCH lays inside the
P-GSM band, only neighbour cells of the P-GSM range are included in
SI 2 and SI 5. If neighbour cells exist in the same band (900), but lay
outside the P-GSM range, the SI 2bis and SI 5bis is used to extend the
list of neighbour cells. The extension is also indicated in SI 2 and
SI 5. If the BCCH lays inside the P-GSM range, but no neighbour cell
exists in the same band outside the P-GSM range, the SI 2bis ans SI 5bis
are omitted.
2012-02-29 08:04:07 +00:00
|
|
|
list_arfcn(si2->bcch_frequency_list, 0xce,
|
|
|
|
"Neighbour cells in same band:");
|
2009-12-01 12:34:30 +00:00
|
|
|
|
|
|
|
si2->ncc_permitted = bts->si_common.ncc_permitted;
|
|
|
|
si2->rach_control = bts->si_common.rach_control;
|
|
|
|
|
2010-01-06 06:52:31 +00:00
|
|
|
return sizeof(*si2);
|
2009-12-01 12:34:30 +00:00
|
|
|
}
|
|
|
|
|
Improved generation of SYSTEM INFORMATIONs 2* and 5* for neighbour bands
In addition to SI 2 and SI 5, the SI 2ter and 2bis is generated, if
neighbour cells in other bands exist. Also it is indicated in the rest
octets of SI3, that SI 2ter is used. If no neighbour cell in a different
band exists, the SI 2ter and SI 5ter is omitted.
A special case is P-GSM range (channels 1-124). To be compatible with
older phones, SI 2bis and SI 5bis is used. If the BCCH lays inside the
P-GSM band, only neighbour cells of the P-GSM range are included in
SI 2 and SI 5. If neighbour cells exist in the same band (900), but lay
outside the P-GSM range, the SI 2bis and SI 5bis is used to extend the
list of neighbour cells. The extension is also indicated in SI 2 and
SI 5. If the BCCH lays inside the P-GSM range, but no neighbour cell
exists in the same band outside the P-GSM range, the SI 2bis ans SI 5bis
are omitted.
2012-02-29 08:04:07 +00:00
|
|
|
static int generate_si2bis(uint8_t *output, struct gsm_bts *bts)
|
|
|
|
{
|
|
|
|
int rc;
|
|
|
|
struct gsm48_system_information_type_2bis *si2b =
|
|
|
|
(struct gsm48_system_information_type_2bis *) output;
|
|
|
|
int n;
|
|
|
|
|
|
|
|
memset(si2b, GSM_MACBLOCK_PADDING, GSM_MACBLOCK_LEN);
|
|
|
|
|
|
|
|
si2b->header.l2_plen = (22 << 2) | 1;
|
|
|
|
si2b->header.rr_protocol_discriminator = GSM48_PDISC_RR;
|
|
|
|
si2b->header.skip_indicator = 0;
|
|
|
|
si2b->header.system_information = GSM48_MT_RR_SYSINFO_2bis;
|
|
|
|
|
|
|
|
rc = generate_bcch_chan_list(si2b->bcch_frequency_list, bts, 0, 1, 0);
|
|
|
|
if (rc < 0)
|
|
|
|
return rc;
|
|
|
|
n = list_arfcn(si2b->bcch_frequency_list, 0xce,
|
|
|
|
"Neighbour cells in same band, but outside P-GSM:");
|
|
|
|
if (n) {
|
|
|
|
/* indicate in SI2 and SI2bis: there is an extension */
|
|
|
|
struct gsm48_system_information_type_2 *si2 =
|
|
|
|
(struct gsm48_system_information_type_2 *)
|
|
|
|
bts->si_buf[SYSINFO_TYPE_2];
|
|
|
|
si2->bcch_frequency_list[0] |= 0x20;
|
|
|
|
si2b->bcch_frequency_list[0] |= 0x20;
|
|
|
|
} else
|
|
|
|
bts->si_valid &= ~(1 << SYSINFO_TYPE_2bis);
|
|
|
|
|
|
|
|
si2b->rach_control = bts->si_common.rach_control;
|
|
|
|
|
|
|
|
return sizeof(*si2b);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int generate_si2ter(uint8_t *output, struct gsm_bts *bts)
|
|
|
|
{
|
|
|
|
int rc;
|
|
|
|
struct gsm48_system_information_type_2ter *si2t =
|
|
|
|
(struct gsm48_system_information_type_2ter *) output;
|
|
|
|
int n;
|
|
|
|
|
|
|
|
memset(si2t, GSM_MACBLOCK_PADDING, GSM_MACBLOCK_LEN);
|
|
|
|
|
|
|
|
si2t->header.l2_plen = (22 << 2) | 1;
|
|
|
|
si2t->header.rr_protocol_discriminator = GSM48_PDISC_RR;
|
|
|
|
si2t->header.skip_indicator = 0;
|
|
|
|
si2t->header.system_information = GSM48_MT_RR_SYSINFO_2ter;
|
|
|
|
|
|
|
|
rc = generate_bcch_chan_list(si2t->ext_bcch_frequency_list, bts, 0, 0, 1);
|
|
|
|
if (rc < 0)
|
|
|
|
return rc;
|
|
|
|
n = list_arfcn(si2t->ext_bcch_frequency_list, 0x8e,
|
|
|
|
"Neighbour cells in different band:");
|
|
|
|
if (!n)
|
|
|
|
bts->si_valid &= ~(1 << SYSINFO_TYPE_2ter);
|
|
|
|
|
|
|
|
return sizeof(*si2t);
|
|
|
|
}
|
|
|
|
|
2010-03-14 15:46:48 +00:00
|
|
|
static struct gsm48_si_ro_info si_info = {
|
2009-12-01 12:34:30 +00:00
|
|
|
.selection_params = {
|
|
|
|
.present = 0,
|
|
|
|
},
|
|
|
|
.power_offset = {
|
|
|
|
.present = 0,
|
|
|
|
},
|
|
|
|
.si2ter_indicator = 0,
|
|
|
|
.early_cm_ctrl = 1,
|
|
|
|
.scheduling = {
|
|
|
|
.present = 0,
|
|
|
|
},
|
|
|
|
.gprs_ind = {
|
|
|
|
.si13_position = 0,
|
|
|
|
.ra_colour = 0,
|
2010-03-14 07:37:43 +00:00
|
|
|
.present = 1,
|
2009-12-01 12:34:30 +00:00
|
|
|
},
|
|
|
|
.lsa_params = {
|
|
|
|
.present = 0,
|
|
|
|
},
|
|
|
|
.cell_id = 0, /* FIXME: doesn't the bts have this? */
|
|
|
|
.break_ind = 0,
|
|
|
|
};
|
|
|
|
|
2011-04-18 15:04:00 +00:00
|
|
|
static int generate_si3(uint8_t *output, struct gsm_bts *bts)
|
2009-12-01 12:34:30 +00:00
|
|
|
{
|
2010-01-06 06:52:31 +00:00
|
|
|
int rc;
|
2009-12-01 12:34:30 +00:00
|
|
|
struct gsm48_system_information_type_3 *si3 =
|
|
|
|
(struct gsm48_system_information_type_3 *) output;
|
|
|
|
|
|
|
|
memset(si3, GSM_MACBLOCK_PADDING, GSM_MACBLOCK_LEN);
|
|
|
|
|
|
|
|
si3->header.l2_plen = (18 << 2) | 1;
|
|
|
|
si3->header.rr_protocol_discriminator = GSM48_PDISC_RR;
|
|
|
|
si3->header.skip_indicator = 0;
|
|
|
|
si3->header.system_information = GSM48_MT_RR_SYSINFO_3;
|
|
|
|
|
|
|
|
si3->cell_identity = htons(bts->cell_identity);
|
2010-03-04 09:55:40 +00:00
|
|
|
gsm48_generate_lai(&si3->lai, bts->network->country_code,
|
|
|
|
bts->network->network_code,
|
|
|
|
bts->location_area_code);
|
2009-12-01 12:34:30 +00:00
|
|
|
si3->control_channel_desc = bts->si_common.chan_desc;
|
|
|
|
si3->cell_options = bts->si_common.cell_options;
|
|
|
|
si3->cell_sel_par = bts->si_common.cell_sel_par;
|
|
|
|
si3->rach_control = bts->si_common.rach_control;
|
|
|
|
|
Improved generation of SYSTEM INFORMATIONs 2* and 5* for neighbour bands
In addition to SI 2 and SI 5, the SI 2ter and 2bis is generated, if
neighbour cells in other bands exist. Also it is indicated in the rest
octets of SI3, that SI 2ter is used. If no neighbour cell in a different
band exists, the SI 2ter and SI 5ter is omitted.
A special case is P-GSM range (channels 1-124). To be compatible with
older phones, SI 2bis and SI 5bis is used. If the BCCH lays inside the
P-GSM band, only neighbour cells of the P-GSM range are included in
SI 2 and SI 5. If neighbour cells exist in the same band (900), but lay
outside the P-GSM range, the SI 2bis and SI 5bis is used to extend the
list of neighbour cells. The extension is also indicated in SI 2 and
SI 5. If the BCCH lays inside the P-GSM range, but no neighbour cell
exists in the same band outside the P-GSM range, the SI 2bis ans SI 5bis
are omitted.
2012-02-29 08:04:07 +00:00
|
|
|
if ((bts->si_valid & (1 << SYSINFO_TYPE_2ter))) {
|
|
|
|
LOGP(DRR, LOGL_INFO, "SI 2ter is included.\n");
|
|
|
|
si_info.si2ter_indicator = 1;
|
|
|
|
} else {
|
|
|
|
si_info.si2ter_indicator = 0;
|
|
|
|
}
|
|
|
|
|
2009-12-01 12:34:30 +00:00
|
|
|
/* SI3 Rest Octets (10.5.2.34), containing
|
|
|
|
CBQ, CELL_RESELECT_OFFSET, TEMPORARY_OFFSET, PENALTY_TIME
|
|
|
|
Power Offset, 2ter Indicator, Early Classmark Sending,
|
|
|
|
Scheduling if and WHERE, GPRS Indicator, SI13 position */
|
2010-01-06 06:52:31 +00:00
|
|
|
rc = rest_octets_si3(si3->rest_octets, &si_info);
|
2009-12-01 12:34:30 +00:00
|
|
|
|
2010-01-06 06:52:31 +00:00
|
|
|
return sizeof(*si3) + rc;
|
2009-12-01 12:34:30 +00:00
|
|
|
}
|
|
|
|
|
2011-04-18 15:04:00 +00:00
|
|
|
static int generate_si4(uint8_t *output, struct gsm_bts *bts)
|
2009-12-01 12:34:30 +00:00
|
|
|
{
|
2010-01-06 06:52:31 +00:00
|
|
|
int rc;
|
2009-12-01 12:34:30 +00:00
|
|
|
struct gsm48_system_information_type_4 *si4 =
|
|
|
|
(struct gsm48_system_information_type_4 *) output;
|
|
|
|
|
|
|
|
/* length of all IEs present except SI4 rest octets and l2_plen */
|
|
|
|
int l2_plen = sizeof(*si4) - 1;
|
|
|
|
|
|
|
|
memset(si4, GSM_MACBLOCK_PADDING, GSM_MACBLOCK_LEN);
|
|
|
|
|
|
|
|
si4->header.rr_protocol_discriminator = GSM48_PDISC_RR;
|
|
|
|
si4->header.skip_indicator = 0;
|
|
|
|
si4->header.system_information = GSM48_MT_RR_SYSINFO_4;
|
|
|
|
|
2010-03-04 09:55:40 +00:00
|
|
|
gsm48_generate_lai(&si4->lai, bts->network->country_code,
|
|
|
|
bts->network->network_code,
|
|
|
|
bts->location_area_code);
|
2009-12-01 12:34:30 +00:00
|
|
|
si4->cell_sel_par = bts->si_common.cell_sel_par;
|
|
|
|
si4->rach_control = bts->si_common.rach_control;
|
|
|
|
|
|
|
|
/* Optional: CBCH Channel Description + CBCH Mobile Allocation */
|
|
|
|
|
|
|
|
si4->header.l2_plen = (l2_plen << 2) | 1;
|
|
|
|
|
|
|
|
/* SI4 Rest Octets (10.5.2.35), containing
|
|
|
|
Optional Power offset, GPRS Indicator,
|
|
|
|
Cell Identity, LSA ID, Selection Parameter */
|
2010-01-06 06:52:31 +00:00
|
|
|
rc = rest_octets_si4(si4->data, &si_info);
|
2009-12-01 12:34:30 +00:00
|
|
|
|
2010-01-06 06:52:31 +00:00
|
|
|
return sizeof(*si4) + rc;
|
2009-12-01 12:34:30 +00:00
|
|
|
}
|
|
|
|
|
2011-04-18 15:04:00 +00:00
|
|
|
static int generate_si5(uint8_t *output, struct gsm_bts *bts)
|
2009-12-01 12:34:30 +00:00
|
|
|
{
|
2009-12-19 20:26:54 +00:00
|
|
|
struct gsm48_system_information_type_5 *si5;
|
|
|
|
int rc, l2_plen = 18;
|
|
|
|
|
2010-01-06 06:52:55 +00:00
|
|
|
memset(output, GSM_MACBLOCK_PADDING, GSM_MACBLOCK_LEN);
|
|
|
|
|
2009-12-19 20:26:54 +00:00
|
|
|
/* ip.access nanoBTS needs l2_plen!! */
|
2011-03-04 12:41:31 +00:00
|
|
|
switch (bts->type) {
|
|
|
|
case GSM_BTS_TYPE_NANOBTS:
|
2012-07-02 17:51:55 +00:00
|
|
|
case GSM_BTS_TYPE_OSMO_SYSMO:
|
2011-03-04 12:41:31 +00:00
|
|
|
case GSM_BTS_TYPE_HSL_FEMTO:
|
2009-12-19 20:26:54 +00:00
|
|
|
*output++ = (l2_plen << 2) | 1;
|
|
|
|
l2_plen++;
|
2011-03-04 12:41:31 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
2009-12-19 20:26:54 +00:00
|
|
|
}
|
2009-12-01 12:34:30 +00:00
|
|
|
|
2009-12-19 20:26:54 +00:00
|
|
|
si5 = (struct gsm48_system_information_type_5 *) output;
|
2009-12-01 12:34:30 +00:00
|
|
|
|
|
|
|
/* l2 pseudo length, not part of msg: 18 */
|
|
|
|
si5->rr_protocol_discriminator = GSM48_PDISC_RR;
|
|
|
|
si5->skip_indicator = 0;
|
|
|
|
si5->system_information = GSM48_MT_RR_SYSINFO_5;
|
Improved generation of SYSTEM INFORMATIONs 2* and 5* for neighbour bands
In addition to SI 2 and SI 5, the SI 2ter and 2bis is generated, if
neighbour cells in other bands exist. Also it is indicated in the rest
octets of SI3, that SI 2ter is used. If no neighbour cell in a different
band exists, the SI 2ter and SI 5ter is omitted.
A special case is P-GSM range (channels 1-124). To be compatible with
older phones, SI 2bis and SI 5bis is used. If the BCCH lays inside the
P-GSM band, only neighbour cells of the P-GSM range are included in
SI 2 and SI 5. If neighbour cells exist in the same band (900), but lay
outside the P-GSM range, the SI 2bis and SI 5bis is used to extend the
list of neighbour cells. The extension is also indicated in SI 2 and
SI 5. If the BCCH lays inside the P-GSM range, but no neighbour cell
exists in the same band outside the P-GSM range, the SI 2bis ans SI 5bis
are omitted.
2012-02-29 08:04:07 +00:00
|
|
|
rc = generate_bcch_chan_list(si5->bcch_frequency_list, bts, 1, 0, 0);
|
|
|
|
if (rc < 0)
|
|
|
|
return rc;
|
|
|
|
list_arfcn(si5->bcch_frequency_list, 0xce,
|
|
|
|
"Neighbour cells in same band:");
|
|
|
|
|
|
|
|
/* 04.08 9.1.37: L2 Pseudo Length of 18 */
|
|
|
|
return l2_plen;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int generate_si5bis(uint8_t *output, struct gsm_bts *bts)
|
|
|
|
{
|
|
|
|
struct gsm48_system_information_type_5bis *si5b;
|
|
|
|
int rc, l2_plen = 18;
|
|
|
|
int n;
|
|
|
|
|
|
|
|
memset(output, GSM_MACBLOCK_PADDING, GSM_MACBLOCK_LEN);
|
|
|
|
|
|
|
|
/* ip.access nanoBTS needs l2_plen!! */
|
|
|
|
switch (bts->type) {
|
|
|
|
case GSM_BTS_TYPE_NANOBTS:
|
2012-07-02 17:51:55 +00:00
|
|
|
case GSM_BTS_TYPE_OSMO_SYSMO:
|
Improved generation of SYSTEM INFORMATIONs 2* and 5* for neighbour bands
In addition to SI 2 and SI 5, the SI 2ter and 2bis is generated, if
neighbour cells in other bands exist. Also it is indicated in the rest
octets of SI3, that SI 2ter is used. If no neighbour cell in a different
band exists, the SI 2ter and SI 5ter is omitted.
A special case is P-GSM range (channels 1-124). To be compatible with
older phones, SI 2bis and SI 5bis is used. If the BCCH lays inside the
P-GSM band, only neighbour cells of the P-GSM range are included in
SI 2 and SI 5. If neighbour cells exist in the same band (900), but lay
outside the P-GSM range, the SI 2bis and SI 5bis is used to extend the
list of neighbour cells. The extension is also indicated in SI 2 and
SI 5. If the BCCH lays inside the P-GSM range, but no neighbour cell
exists in the same band outside the P-GSM range, the SI 2bis ans SI 5bis
are omitted.
2012-02-29 08:04:07 +00:00
|
|
|
case GSM_BTS_TYPE_HSL_FEMTO:
|
|
|
|
*output++ = (l2_plen << 2) | 1;
|
|
|
|
l2_plen++;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
si5b = (struct gsm48_system_information_type_5bis *) output;
|
|
|
|
|
|
|
|
/* l2 pseudo length, not part of msg: 18 */
|
|
|
|
si5b->rr_protocol_discriminator = GSM48_PDISC_RR;
|
|
|
|
si5b->skip_indicator = 0;
|
|
|
|
si5b->system_information = GSM48_MT_RR_SYSINFO_5bis;
|
|
|
|
rc = generate_bcch_chan_list(si5b->bcch_frequency_list, bts, 1, 1, 0);
|
|
|
|
if (rc < 0)
|
|
|
|
return rc;
|
|
|
|
n = list_arfcn(si5b->bcch_frequency_list, 0xce,
|
|
|
|
"Neighbour cells in same band, but outside P-GSM:");
|
|
|
|
if (n) {
|
|
|
|
/* indicate in SI5 and SI5bis: there is an extension */
|
|
|
|
struct gsm48_system_information_type_5 *si5 =
|
|
|
|
(struct gsm48_system_information_type_5 *)
|
|
|
|
bts->si_buf[SYSINFO_TYPE_5];
|
|
|
|
si5->bcch_frequency_list[0] |= 0x20;
|
|
|
|
si5b->bcch_frequency_list[0] |= 0x20;
|
|
|
|
} else
|
|
|
|
bts->si_valid &= ~(1 << SYSINFO_TYPE_5bis);
|
|
|
|
|
|
|
|
/* 04.08 9.1.37: L2 Pseudo Length of 18 */
|
|
|
|
return l2_plen;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int generate_si5ter(uint8_t *output, struct gsm_bts *bts)
|
|
|
|
{
|
|
|
|
struct gsm48_system_information_type_5ter *si5t;
|
|
|
|
int rc, l2_plen = 18;
|
|
|
|
int n;
|
|
|
|
|
|
|
|
memset(output, GSM_MACBLOCK_PADDING, GSM_MACBLOCK_LEN);
|
|
|
|
|
|
|
|
/* ip.access nanoBTS needs l2_plen!! */
|
|
|
|
switch (bts->type) {
|
|
|
|
case GSM_BTS_TYPE_NANOBTS:
|
2012-07-02 17:51:55 +00:00
|
|
|
case GSM_BTS_TYPE_OSMO_SYSMO:
|
Improved generation of SYSTEM INFORMATIONs 2* and 5* for neighbour bands
In addition to SI 2 and SI 5, the SI 2ter and 2bis is generated, if
neighbour cells in other bands exist. Also it is indicated in the rest
octets of SI3, that SI 2ter is used. If no neighbour cell in a different
band exists, the SI 2ter and SI 5ter is omitted.
A special case is P-GSM range (channels 1-124). To be compatible with
older phones, SI 2bis and SI 5bis is used. If the BCCH lays inside the
P-GSM band, only neighbour cells of the P-GSM range are included in
SI 2 and SI 5. If neighbour cells exist in the same band (900), but lay
outside the P-GSM range, the SI 2bis and SI 5bis is used to extend the
list of neighbour cells. The extension is also indicated in SI 2 and
SI 5. If the BCCH lays inside the P-GSM range, but no neighbour cell
exists in the same band outside the P-GSM range, the SI 2bis ans SI 5bis
are omitted.
2012-02-29 08:04:07 +00:00
|
|
|
case GSM_BTS_TYPE_HSL_FEMTO:
|
|
|
|
*output++ = (l2_plen << 2) | 1;
|
|
|
|
l2_plen++;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
si5t = (struct gsm48_system_information_type_5ter *) output;
|
|
|
|
|
|
|
|
/* l2 pseudo length, not part of msg: 18 */
|
|
|
|
si5t->rr_protocol_discriminator = GSM48_PDISC_RR;
|
|
|
|
si5t->skip_indicator = 0;
|
|
|
|
si5t->system_information = GSM48_MT_RR_SYSINFO_5ter;
|
|
|
|
rc = generate_bcch_chan_list(si5t->bcch_frequency_list, bts, 1, 0, 1);
|
2009-12-01 12:34:30 +00:00
|
|
|
if (rc < 0)
|
|
|
|
return rc;
|
Improved generation of SYSTEM INFORMATIONs 2* and 5* for neighbour bands
In addition to SI 2 and SI 5, the SI 2ter and 2bis is generated, if
neighbour cells in other bands exist. Also it is indicated in the rest
octets of SI3, that SI 2ter is used. If no neighbour cell in a different
band exists, the SI 2ter and SI 5ter is omitted.
A special case is P-GSM range (channels 1-124). To be compatible with
older phones, SI 2bis and SI 5bis is used. If the BCCH lays inside the
P-GSM band, only neighbour cells of the P-GSM range are included in
SI 2 and SI 5. If neighbour cells exist in the same band (900), but lay
outside the P-GSM range, the SI 2bis and SI 5bis is used to extend the
list of neighbour cells. The extension is also indicated in SI 2 and
SI 5. If the BCCH lays inside the P-GSM range, but no neighbour cell
exists in the same band outside the P-GSM range, the SI 2bis ans SI 5bis
are omitted.
2012-02-29 08:04:07 +00:00
|
|
|
n = list_arfcn(si5t->bcch_frequency_list, 0x8e,
|
|
|
|
"Neighbour cells in different band:");
|
|
|
|
if (!n)
|
|
|
|
bts->si_valid &= ~(1 << SYSINFO_TYPE_5ter);
|
2009-12-01 12:34:30 +00:00
|
|
|
|
|
|
|
/* 04.08 9.1.37: L2 Pseudo Length of 18 */
|
2009-12-19 20:26:54 +00:00
|
|
|
return l2_plen;
|
2009-12-01 12:34:30 +00:00
|
|
|
}
|
|
|
|
|
2011-04-18 15:04:00 +00:00
|
|
|
static int generate_si6(uint8_t *output, struct gsm_bts *bts)
|
2009-12-01 12:34:30 +00:00
|
|
|
{
|
2009-12-19 20:26:54 +00:00
|
|
|
struct gsm48_system_information_type_6 *si6;
|
|
|
|
int l2_plen = 11;
|
|
|
|
|
2010-01-06 06:52:55 +00:00
|
|
|
memset(output, GSM_MACBLOCK_PADDING, GSM_MACBLOCK_LEN);
|
|
|
|
|
2009-12-19 20:26:54 +00:00
|
|
|
/* ip.access nanoBTS needs l2_plen!! */
|
2011-03-04 12:41:31 +00:00
|
|
|
switch (bts->type) {
|
|
|
|
case GSM_BTS_TYPE_NANOBTS:
|
2012-07-02 17:51:55 +00:00
|
|
|
case GSM_BTS_TYPE_OSMO_SYSMO:
|
2011-03-04 12:41:31 +00:00
|
|
|
case GSM_BTS_TYPE_HSL_FEMTO:
|
2009-12-19 20:26:54 +00:00
|
|
|
*output++ = (l2_plen << 2) | 1;
|
|
|
|
l2_plen++;
|
2011-03-04 12:41:31 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
2009-12-19 20:26:54 +00:00
|
|
|
}
|
2009-12-01 12:34:30 +00:00
|
|
|
|
2009-12-19 20:26:54 +00:00
|
|
|
si6 = (struct gsm48_system_information_type_6 *) output;
|
2009-12-01 12:34:30 +00:00
|
|
|
|
|
|
|
/* l2 pseudo length, not part of msg: 11 */
|
|
|
|
si6->rr_protocol_discriminator = GSM48_PDISC_RR;
|
|
|
|
si6->skip_indicator = 0;
|
|
|
|
si6->system_information = GSM48_MT_RR_SYSINFO_6;
|
|
|
|
si6->cell_identity = htons(bts->cell_identity);
|
2010-03-04 09:55:40 +00:00
|
|
|
gsm48_generate_lai(&si6->lai, bts->network->country_code,
|
|
|
|
bts->network->network_code,
|
|
|
|
bts->location_area_code);
|
2009-12-01 12:34:30 +00:00
|
|
|
si6->cell_options = bts->si_common.cell_options;
|
|
|
|
si6->ncc_permitted = bts->si_common.ncc_permitted;
|
|
|
|
|
|
|
|
/* SI6 Rest Octets: 10.5.2.35a: PCH / NCH info, VBS/VGCS options */
|
|
|
|
|
2009-12-19 20:26:54 +00:00
|
|
|
return l2_plen;
|
2009-12-01 12:34:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static struct gsm48_si13_info si13_default = {
|
|
|
|
.cell_opts = {
|
2010-06-02 10:19:21 +00:00
|
|
|
.nmo = GPRS_NMO_II,
|
2010-05-31 10:54:23 +00:00
|
|
|
.t3168 = 2000,
|
|
|
|
.t3192 = 200,
|
2010-03-14 07:37:43 +00:00
|
|
|
.drx_timer_max = 3,
|
2009-12-01 12:34:30 +00:00
|
|
|
.bs_cv_max = 15,
|
2011-10-17 11:56:02 +00:00
|
|
|
.ext_info_present = 0,
|
2010-04-18 12:49:05 +00:00
|
|
|
.ext_info = {
|
|
|
|
/* The values below are just guesses ! */
|
2010-04-18 13:53:40 +00:00
|
|
|
.egprs_supported = 0,
|
2010-04-18 12:49:05 +00:00
|
|
|
.use_egprs_p_ch_req = 1,
|
2010-05-31 10:54:23 +00:00
|
|
|
.bep_period = 5,
|
2010-04-18 12:49:05 +00:00
|
|
|
.pfc_supported = 0,
|
|
|
|
.dtm_supported = 0,
|
|
|
|
.bss_paging_coordination = 0,
|
|
|
|
},
|
2009-12-01 12:34:30 +00:00
|
|
|
},
|
|
|
|
.pwr_ctrl_pars = {
|
|
|
|
.alpha = 10, /* a = 1.0 */
|
2010-05-31 10:54:23 +00:00
|
|
|
.t_avg_w = 16,
|
|
|
|
.t_avg_t = 16,
|
2009-12-01 12:34:30 +00:00
|
|
|
.pc_meas_chan = 0, /* downling measured on CCCH */
|
2010-05-31 10:54:23 +00:00
|
|
|
.n_avg_i = 8,
|
2009-12-01 12:34:30 +00:00
|
|
|
},
|
2010-03-14 07:37:43 +00:00
|
|
|
.bcch_change_mark = 1,
|
2009-12-01 12:34:30 +00:00
|
|
|
.si_change_field = 0,
|
|
|
|
.pbcch_present = 0,
|
|
|
|
{
|
|
|
|
.no_pbcch = {
|
2010-03-14 07:37:43 +00:00
|
|
|
.rac = 0, /* needs to be patched */
|
2009-12-01 12:34:30 +00:00
|
|
|
.spgc_ccch_sup = 0,
|
|
|
|
.net_ctrl_ord = 0,
|
2010-03-14 07:37:43 +00:00
|
|
|
.prio_acc_thr = 6,
|
2009-12-01 12:34:30 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2011-04-18 15:04:00 +00:00
|
|
|
static int generate_si13(uint8_t *output, struct gsm_bts *bts)
|
2009-12-01 12:34:30 +00:00
|
|
|
{
|
|
|
|
struct gsm48_system_information_type_13 *si13 =
|
|
|
|
(struct gsm48_system_information_type_13 *) output;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
memset(si13, GSM_MACBLOCK_PADDING, GSM_MACBLOCK_LEN);
|
|
|
|
|
|
|
|
si13->header.rr_protocol_discriminator = GSM48_PDISC_RR;
|
|
|
|
si13->header.skip_indicator = 0;
|
|
|
|
si13->header.system_information = GSM48_MT_RR_SYSINFO_13;
|
|
|
|
|
2010-03-14 07:37:43 +00:00
|
|
|
si13_default.no_pbcch.rac = bts->gprs.rac;
|
|
|
|
|
2009-12-01 12:34:30 +00:00
|
|
|
ret = rest_octets_si13(si13->rest_octets, &si13_default);
|
|
|
|
if (ret < 0)
|
|
|
|
return ret;
|
|
|
|
|
2010-06-16 04:05:56 +00:00
|
|
|
/* length is coded in bit 2 an up */
|
|
|
|
si13->header.l2_plen = 0x01;
|
2009-12-01 12:34:30 +00:00
|
|
|
|
2010-01-06 06:52:31 +00:00
|
|
|
return sizeof (*si13) + ret;
|
2009-12-01 12:34:30 +00:00
|
|
|
}
|
|
|
|
|
2010-06-15 14:44:12 +00:00
|
|
|
typedef int (*gen_si_fn_t)(uint8_t *output, struct gsm_bts *bts);
|
|
|
|
|
|
|
|
static const gen_si_fn_t gen_si_fn[_MAX_SYSINFO_TYPE] = {
|
|
|
|
[SYSINFO_TYPE_1] = &generate_si1,
|
|
|
|
[SYSINFO_TYPE_2] = &generate_si2,
|
Improved generation of SYSTEM INFORMATIONs 2* and 5* for neighbour bands
In addition to SI 2 and SI 5, the SI 2ter and 2bis is generated, if
neighbour cells in other bands exist. Also it is indicated in the rest
octets of SI3, that SI 2ter is used. If no neighbour cell in a different
band exists, the SI 2ter and SI 5ter is omitted.
A special case is P-GSM range (channels 1-124). To be compatible with
older phones, SI 2bis and SI 5bis is used. If the BCCH lays inside the
P-GSM band, only neighbour cells of the P-GSM range are included in
SI 2 and SI 5. If neighbour cells exist in the same band (900), but lay
outside the P-GSM range, the SI 2bis and SI 5bis is used to extend the
list of neighbour cells. The extension is also indicated in SI 2 and
SI 5. If the BCCH lays inside the P-GSM range, but no neighbour cell
exists in the same band outside the P-GSM range, the SI 2bis ans SI 5bis
are omitted.
2012-02-29 08:04:07 +00:00
|
|
|
[SYSINFO_TYPE_2bis] = &generate_si2bis,
|
|
|
|
[SYSINFO_TYPE_2ter] = &generate_si2ter,
|
2010-06-15 14:44:12 +00:00
|
|
|
[SYSINFO_TYPE_3] = &generate_si3,
|
|
|
|
[SYSINFO_TYPE_4] = &generate_si4,
|
|
|
|
[SYSINFO_TYPE_5] = &generate_si5,
|
Improved generation of SYSTEM INFORMATIONs 2* and 5* for neighbour bands
In addition to SI 2 and SI 5, the SI 2ter and 2bis is generated, if
neighbour cells in other bands exist. Also it is indicated in the rest
octets of SI3, that SI 2ter is used. If no neighbour cell in a different
band exists, the SI 2ter and SI 5ter is omitted.
A special case is P-GSM range (channels 1-124). To be compatible with
older phones, SI 2bis and SI 5bis is used. If the BCCH lays inside the
P-GSM band, only neighbour cells of the P-GSM range are included in
SI 2 and SI 5. If neighbour cells exist in the same band (900), but lay
outside the P-GSM range, the SI 2bis and SI 5bis is used to extend the
list of neighbour cells. The extension is also indicated in SI 2 and
SI 5. If the BCCH lays inside the P-GSM range, but no neighbour cell
exists in the same band outside the P-GSM range, the SI 2bis ans SI 5bis
are omitted.
2012-02-29 08:04:07 +00:00
|
|
|
[SYSINFO_TYPE_5bis] = &generate_si5bis,
|
|
|
|
[SYSINFO_TYPE_5ter] = &generate_si5ter,
|
2010-06-15 14:44:12 +00:00
|
|
|
[SYSINFO_TYPE_6] = &generate_si6,
|
|
|
|
[SYSINFO_TYPE_13] = &generate_si13,
|
|
|
|
};
|
|
|
|
|
|
|
|
int gsm_generate_si(struct gsm_bts *bts, enum osmo_sysinfo_type si_type)
|
|
|
|
{
|
|
|
|
gen_si_fn_t gen_si;
|
|
|
|
|
2010-04-18 13:51:20 +00:00
|
|
|
switch (bts->gprs.mode) {
|
|
|
|
case BTS_GPRS_EGPRS:
|
2010-04-18 13:53:40 +00:00
|
|
|
si13_default.cell_opts.ext_info_present = 1;
|
|
|
|
si13_default.cell_opts.ext_info.egprs_supported = 1;
|
|
|
|
/* fallthrough */
|
2010-04-18 13:51:20 +00:00
|
|
|
case BTS_GPRS_GPRS:
|
|
|
|
si_info.gprs_ind.present = 1;
|
|
|
|
break;
|
|
|
|
case BTS_GPRS_NONE:
|
|
|
|
si_info.gprs_ind.present = 0;
|
|
|
|
break;
|
|
|
|
}
|
2010-03-14 15:46:48 +00:00
|
|
|
|
2010-11-28 17:17:28 +00:00
|
|
|
memcpy(&si_info.selection_params,
|
|
|
|
&bts->si_common.cell_ro_sel_par,
|
|
|
|
sizeof(struct gsm48_si_selection_params));
|
|
|
|
|
2010-06-15 14:44:12 +00:00
|
|
|
gen_si = gen_si_fn[si_type];
|
|
|
|
if (!gen_si)
|
2009-12-01 12:34:30 +00:00
|
|
|
return -EINVAL;
|
|
|
|
|
2010-06-15 14:44:12 +00:00
|
|
|
return gen_si(bts->si_buf[si_type], bts);
|
2009-12-01 12:34:30 +00:00
|
|
|
}
|