This is merely a historical archive of years 2008-2021, before the migration to mailman3.
A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/baseband-devel@lists.osmocom.org/.
Alex Badea vamposdecampos at gmail.comIf System Information contained CBCH channel description, tune to it and log SMSCB messages with a Geographical Scope of Cell Wide (Immediate) -- these are typically used for "Cell Info Display". The CBCH timeout is set to a generous 8 seconds; this is because we need 4 frames for reassembly, we usually miss the first, and we might hit a burst of Null SMSCB messages. Signed-off-by: Alex Badea <vamposdecampos at gmail.com> --- src/host/layer23/src/misc/cell_log.c | 107 +++++++++++++++++++++++++++++++++- 1 files changed, 105 insertions(+), 2 deletions(-) diff --git a/src/host/layer23/src/misc/cell_log.c b/src/host/layer23/src/misc/cell_log.c index e6c5771..37aa271 100644 --- a/src/host/layer23/src/misc/cell_log.c +++ b/src/host/layer23/src/misc/cell_log.c @@ -26,6 +26,7 @@ #include <stdlib.h> #include <time.h> #include <errno.h> +#include <netinet/in.h> #include <l1ctl_proto.h> @@ -34,7 +35,9 @@ #include <osmocore/signal.h> #include <osmocore/msgb.h> #include <osmocore/gsm_utils.h> +#include <osmocore/protocol/gsm_03_41.h> #include <osmocore/protocol/gsm_04_08.h> +#include <osmocore/protocol/gsm_08_58.h> #include <osmocore/rsl.h> #include <osmocom/bb/common/l1ctl.h> @@ -49,6 +52,7 @@ #define READ_WAIT 2, 0 #define RACH_MAX 2 #define RACH_WAIT 0, 900000 +#define CBCH_WAIT 8, 0 #define MIN_RXLEV -106 #define MAX_DIST 2000 @@ -57,6 +61,7 @@ enum { SCAN_STATE_SYNC, SCAN_STATE_READ, SCAN_STATE_RACH, + SCAN_STATE_CBCH, }; /* ranges of bands */ @@ -114,6 +119,7 @@ struct rach_ref { static void start_sync(void); static void start_rach(void); +static void start_cbch(void); static void start_pm(void); static void log_gps(void) @@ -227,6 +233,11 @@ static void timeout_cb(void *arg) rach_count++; start_rach(); break; + case SCAN_STATE_CBCH: + LOGP(DRR, LOGL_INFO, "Timeout reading CBCH\n"); + l1ctl_tx_dm_rel_req(ms); + start_sync(); + break; } } @@ -244,6 +255,33 @@ static void start_timer(int sec, int micro) bsc_schedule_timer(&timer, sec, micro); } +static void start_cbch(void) +{ + struct gsm48_sysinfo *s = &sysinfo; + int res; + + if (!s->chan_nr) { + LOGP(DRR, LOGL_DEBUG, "No CBCH description in sysinfo\n"); + res = -1; + } else if (s->h) { + res = l1ctl_tx_dm_est_req_h1(ms, + s->maio, s->hsn, s->hopping, s->hopp_len, + s->chan_nr, s->tsc, + GSM48_CMODE_SIGN); + } else { + res = l1ctl_tx_dm_est_req_h0(ms, s->arfcn, + s->chan_nr, s->tsc, GSM48_CMODE_SIGN); + } + + if (res < 0) { + start_sync(); + return; + } + + state = SCAN_STATE_CBCH; + start_timer(CBCH_WAIT); +} + static void start_rach(void) { struct gsm48_sysinfo *s = &sysinfo; @@ -253,7 +291,7 @@ static void start_rach(void) if (rach_count == RACH_MAX) { log_sysinfo(); - start_sync(); + start_cbch(); return; } @@ -426,7 +464,7 @@ static int ta_result(uint8_t ta) } log_sysinfo(); - start_sync(); + start_cbch(); return 0; } @@ -730,6 +768,66 @@ int chan_conf(struct osmocom_ms *ms, struct msgb *msg) return 0; } +static int sms_cb_cmd(struct osmocom_ms *ms, struct msgb *msg) +{ + struct abis_rsl_cchan_hdr *ch = msgb_l2(msg); + struct tlv_parsed tv; + struct rsl_ie_cb_cmd_type *cmd_type; + struct gsm341_ms_message *cbmsg; + unsigned int cbmsglen; + char buf[256], *p; + + rsl_tlv_parse(&tv, ch->data, msgb_l2len(msg) - sizeof(*ch)); + if (!TLVP_PRESENT(&tv, RSL_IE_SMSCB_MSG) || + !TLVP_PRESENT(&tv, RSL_IE_CB_CMD_TYPE)) { + LOGP(DRR, LOGL_ERROR, "SMS_BC_CMD missing mandatory IEs\n"); + return -EINVAL; + } + + cmd_type = (struct rsl_ie_cb_cmd_type *) TLVP_VAL(&tv, RSL_IE_CB_CMD_TYPE); + cbmsg = (struct gsm341_ms_message *) TLVP_VAL(&tv, RSL_IE_SMSCB_MSG); + cbmsglen = TLVP_LEN(&tv, RSL_IE_SMSCB_MSG); + if (cbmsglen < sizeof(*cbmsg)) { + LOGP(DRR, LOGL_ERROR, "RSL_IE_SMSCB_MSG too short\n"); + return -EINVAL; + } + + if (cmd_type->command != RSL_CB_CMD_TYPE_NORMAL) + return 0; + if (cbmsg->serial.gs != GSM341_GS_CELL_WIDE_IMMED) + return 0; + + gsm_7bit_decode(buf, cbmsg->data, cbmsglen - sizeof(*cbmsg)); + if ((p = strchr(buf, '\r'))) + *p = 0; + + LOGP(DSUM, LOGL_INFO, "Cell info: code=%d update=%d id=%d text=\"%s\"\n", + cbmsg->serial.code_lo | (cbmsg->serial.code_hi << 6), + cbmsg->serial.update, + ntohs(cbmsg->msg_id), + buf); + + LOGFILE("[cbch]\n"); + LOGFILE("arfcn %d\n", sysinfo.arfcn); + LOGFILE("gs %d code %d update %d msg_id %d page %d numpages %d\n", + cbmsg->serial.gs, + cbmsg->serial.code_lo | (cbmsg->serial.code_hi << 6), + cbmsg->serial.update, + ntohs(cbmsg->msg_id), + cbmsg->page.current, cbmsg->page.total); + LOGFILE("text \"%s\"\n", buf); + LOGFILE("\n"); + LOGFLUSH(); + + l1ctl_tx_dm_rel_req(ms); + stop_timer(); + + start_sync(); + + return 0; + +} + static int rcv_cch(struct osmocom_ms *ms, struct msgb *msg) { struct abis_rsl_cchan_hdr *ch = msgb_l2(msg); @@ -744,6 +842,11 @@ static int rcv_cch(struct osmocom_ms *ms, struct msgb *msg) msgb_free(msg); return rc; } + if (state == SCAN_STATE_CBCH && msg_type == RSL_MT_SMS_BC_CMD) { + rc = sms_cb_cmd(ms, msg); + msgb_free(msg); + return rc; + } LOGP(DRSL, LOGL_NOTICE, "RSLms message unhandled\n"); msgb_free(msg); -- 1.7.0.4