diff options
author | Andreas Eversberg <jolly@eversberg.eu> | 2013-12-15 18:32:32 +0100 |
---|---|---|
committer | Harald Welte <laforge@gnumonks.org> | 2019-05-23 13:03:44 +0200 |
commit | 5981c25bc0372c73137ae04d3c26e8caab3a60fa (patch) | |
tree | 17b1bceb1a8a137860609b1f30e11dffa41ec4e4 | |
parent | c4b5b2c808abb659b69a6376be8a1e15e8096652 (diff) |
mobile: Use only sel_si for informations about the current cell
sel_si structure tracks content of SI5* and SI6 messages. The informations
will change after handover, so they do not refer to the origin cell.
The list of scanned cells is not affected. The sel_si structure will be
overwritten with the selected cell after leaving dedicated mode.
Change-Id: Idd6a35c13de56115645e0861d95c256ebf9257f8
-rw-r--r-- | src/host/layer23/src/common/sysinfo.c | 2 | ||||
-rw-r--r-- | src/host/layer23/src/mobile/gsm322.c | 20 | ||||
-rw-r--r-- | src/host/layer23/src/mobile/gsm48_rr.c | 74 | ||||
-rw-r--r-- | src/host/layer23/src/mobile/vty_interface.c | 7 |
4 files changed, 62 insertions, 41 deletions
diff --git a/src/host/layer23/src/common/sysinfo.c b/src/host/layer23/src/common/sysinfo.c index b42bd653..ad73c8db 100644 --- a/src/host/layer23/src/common/sysinfo.c +++ b/src/host/layer23/src/common/sysinfo.c @@ -200,7 +200,7 @@ int gsm48_sysinfo_dump(struct gsm48_sysinfo *s, uint16_t arfcn, sprintf(buffer + 69, " %d", i + 63); print(priv, "%s\n", buffer); } - print(priv, " 'S' = serv. cell 'n' = SI2 (neigh.) 'r' = SI5 (rep.) " + print(priv, " 'S' = serv. cell 'n' = SI2 (neigh.) 'r' = last SI5 (rep.) " "'b' = SI2+SI5\n\n"); /* serving cell */ diff --git a/src/host/layer23/src/mobile/gsm322.c b/src/host/layer23/src/mobile/gsm322.c index 53d36d89..e058a808 100644 --- a/src/host/layer23/src/mobile/gsm322.c +++ b/src/host/layer23/src/mobile/gsm322.c @@ -509,8 +509,6 @@ static void gsm322_unselect_cell(struct gsm322_cellsel *cs) LOGP(DCS, LOGL_INFO, "Unselecting serving cell.\n"); cs->selected = 0; - if (cs->si) - cs->si->si5 = 0; /* unset SI5* */ cs->si = NULL; memset(&cs->sel_si, 0, sizeof(cs->sel_si)); cs->sel_mcc = cs->sel_mnc = cs->sel_lac = cs->sel_id = 0; @@ -4859,8 +4857,12 @@ int gsm322_dump_sorted_plmn(struct osmocom_ms *ms) int gsm322_dump_cs_list(struct gsm322_cellsel *cs, uint8_t flags, void (*print)(void *, const char *, ...), void *priv) { - int i; struct gsm48_sysinfo *s; + char arfcn_str[9]; + int i, arfci = -1; + + if (cs->selected) + arfci = arfcn2index(cs->sel_arfcn); print(priv, "ARFCN |MCC |MNC |LAC |cell ID|forb.LA|prio |" "min-db |max-pwr|rx-lev\n"); @@ -4871,11 +4873,15 @@ int gsm322_dump_cs_list(struct gsm322_cellsel *cs, uint8_t flags, if (!s || !(cs->list[i].flags & flags)) continue; if (i >= 1024) - print(priv, "%4dPCS|", i-1024+512); + sprintf(arfcn_str, "%4dPCS|", i-1024+512); else if (i >= 512 && i <= 885) - print(priv, "%4dDCS|", i); + sprintf(arfcn_str, "%4dDCS|", i); else - print(priv, "%4d |", i); + sprintf(arfcn_str, "%4d |", i); + if (i == arfci) { + arfcn_str[6] = '*'; + print(priv, arfcn_str); + } if (s->mcc) { print(priv, "%s |%s%s |", gsm_print_mcc(s->mcc), gsm_print_mnc(s->mnc), @@ -4906,6 +4912,8 @@ int gsm322_dump_cs_list(struct gsm322_cellsel *cs, uint8_t flags, print(priv, "n/a |n/a |n/a\n"); } print(priv, "\n"); + if (arfci >= 0) + print(priv, "* = Selected cell\n"); return 0; } diff --git a/src/host/layer23/src/mobile/gsm48_rr.c b/src/host/layer23/src/mobile/gsm48_rr.c index a11d3778..6b41bdd2 100644 --- a/src/host/layer23/src/mobile/gsm48_rr.c +++ b/src/host/layer23/src/mobile/gsm48_rr.c @@ -1311,7 +1311,7 @@ static int gsm48_rr_chan_req(struct osmocom_ms *ms, int cause, int paging, struct gsm_settings *set = &ms->settings; struct gsm48_rrlayer *rr = &ms->rrlayer; struct gsm322_cellsel *cs = &ms->cellsel; - struct gsm48_sysinfo *s = cs->si; + struct gsm48_sysinfo *s = &cs->sel_si; struct msgb *nmsg; struct gsm48_rr_hdr *nrrh; uint8_t chan_req_val, chan_req_mask; @@ -1541,7 +1541,7 @@ int gsm48_rr_tx_rand_acc(struct osmocom_ms *ms, struct msgb *msg) uint8_t tx_power; enum gsm_band band; - gsm_arfcn2band_rc(cs->arfcn, &band); + gsm_arfcn2band_rc(cs->sel_arfcn, &band); /* already assigned */ if (rr->wait_assign == 2) @@ -1687,8 +1687,8 @@ fail: } else { tx_power = s->ms_txpwr_max_cch; /* power offset in case of DCS1800 */ - if (s->po && (cs->arfcn & 1023) >= 512 - && (cs->arfcn & 1023) <= 885) { + if (s->po && (cs->sel_arfcn & 1023) >= 512 + && (cs->sel_arfcn & 1023) <= 885) { LOGP(DRR, LOGL_INFO, "Use MS-TXPWR-MAX-CCH power value " "%d (%d dBm) with offset %d dBm\n", tx_power, ms_pwr_dbm(band, tx_power), s->po_value * 2); @@ -1717,14 +1717,14 @@ fail: /* generate list from SI5 and send to L1 to start SB measurement */ static int gsm48_new_si5(struct osmocom_ms *ms) { - struct gsm48_sysinfo *s = ms->cellsel.si; struct gsm322_cellsel *cs = &ms->cellsel; + struct gsm48_sysinfo *s = &cs->sel_si; struct gsm48_rrlayer *rr = &ms->rrlayer; struct gsm48_rr_meas *rrmeas = &rr->meas; int n = 0, i, refer_pcs; rrmeas->nc_num = 0; - refer_pcs = gsm_refer_pcs(cs->arfcn, s); + refer_pcs = gsm_refer_pcs(cs->sel_arfcn, s); /* collect channels from freq list (1..1023,0) */ for (i = 1; i <= 1024; i++) { @@ -1807,13 +1807,13 @@ int gsm48_rr_meas_ind(struct osmocom_ms *ms, uint16_t band_arfcn, /* send sysinfo event to other layers */ static int gsm48_new_sysinfo(struct osmocom_ms *ms, uint8_t type) { - struct gsm48_sysinfo *s = ms->cellsel.si; + struct gsm322_cellsel *cs = &ms->cellsel; + struct gsm48_sysinfo *s = &cs->sel_si; struct msgb *nmsg; struct gsm322_msg *em; /* update list of measurements, if BA(SACCH) is complete and new */ - if (s - && (type == GSM48_MT_RR_SYSINFO_5 + if ((type == GSM48_MT_RR_SYSINFO_5 || type == GSM48_MT_RR_SYSINFO_5bis || type == GSM48_MT_RR_SYSINFO_5ter) && s->si5 @@ -1823,6 +1823,14 @@ static int gsm48_new_sysinfo(struct osmocom_ms *ms, uint8_t type) gsm48_new_si5(ms); } + /* update stuff from SI 6 */ + if (type == GSM48_MT_RR_SYSINFO_6 && s->si6) { + cs->sel_mcc = s->mcc; + cs->sel_mnc = s->mnc; + cs->sel_lac = s->lac; + cs->sel_id = s->cell_id; + } + /* send sysinfo event to other layers */ nmsg = gsm322_msgb_alloc(GSM322_EVENT_SYSINFO); if (!nmsg) @@ -2033,7 +2041,7 @@ static int gsm48_rr_rx_sysinfo4(struct osmocom_ms *ms, struct msgb *msg) static int gsm48_rr_rx_sysinfo5(struct osmocom_ms *ms, struct msgb *msg) { struct gsm48_system_information_type_5 *si = msgb_l3(msg); - struct gsm48_sysinfo *s = ms->cellsel.si; + struct gsm48_sysinfo *s = &ms->cellsel.sel_si; int payload_len = msgb_l3len(msg) - sizeof(*si); if (!s) { @@ -2062,7 +2070,7 @@ static int gsm48_rr_rx_sysinfo5(struct osmocom_ms *ms, struct msgb *msg) static int gsm48_rr_rx_sysinfo5bis(struct osmocom_ms *ms, struct msgb *msg) { struct gsm48_system_information_type_5bis *si = msgb_l3(msg); - struct gsm48_sysinfo *s = ms->cellsel.si; + struct gsm48_sysinfo *s = &ms->cellsel.sel_si; int payload_len = msgb_l3len(msg) - sizeof(*si); if (!s) { @@ -2092,7 +2100,7 @@ static int gsm48_rr_rx_sysinfo5bis(struct osmocom_ms *ms, struct msgb *msg) static int gsm48_rr_rx_sysinfo5ter(struct osmocom_ms *ms, struct msgb *msg) { struct gsm48_system_information_type_5ter *si = msgb_l3(msg); - struct gsm48_sysinfo *s = ms->cellsel.si; + struct gsm48_sysinfo *s = &ms->cellsel.sel_si; int payload_len = msgb_l3len(msg) - sizeof(*si); if (!s) { @@ -2122,7 +2130,7 @@ static int gsm48_rr_rx_sysinfo5ter(struct osmocom_ms *ms, struct msgb *msg) static int gsm48_rr_rx_sysinfo6(struct osmocom_ms *ms, struct msgb *msg) { struct gsm48_system_information_type_6 *si = msgb_l3(msg); - struct gsm48_sysinfo *s = ms->cellsel.si; + struct gsm48_sysinfo *s = &ms->cellsel.sel_si; struct rx_meas_stat *meas = &ms->meas; int payload_len = msgb_l3len(msg) - sizeof(*si); @@ -2465,7 +2473,7 @@ static int gsm48_rr_rx_imm_ass(struct osmocom_ms *ms, struct msgb *msg) struct gsm48_rrlayer *rr = &ms->rrlayer; struct gsm48_imm_ass *ia = msgb_l3(msg); struct gsm322_cellsel *cs = &ms->cellsel; - struct gsm48_sysinfo *s = cs->si; + struct gsm48_sysinfo *s = &cs->sel_si; int ma_len = msgb_l3len(msg) - sizeof(*ia); uint8_t ch_type, ch_subch, ch_ts; struct gsm48_rr_cd cd; @@ -2525,7 +2533,7 @@ static int gsm48_rr_rx_imm_ass(struct osmocom_ms *ms, struct msgb *msg) } else { cd.h = 0; gsm48_decode_chan_h0(&ia->chan_desc, &cd.tsc, &cd.arfcn); - if (gsm_refer_pcs(cs->arfcn, s)) + if (gsm_refer_pcs(cs->sel_arfcn, s)) cd.arfcn |= ARFCN_PCS; LOGP(DRR, LOGL_INFO, " (ta %d/%dm ra 0x%02x chan_nr 0x%02x " "ARFCN %s TS %u SS %u TSC %u)\n", @@ -2572,7 +2580,7 @@ static int gsm48_rr_rx_imm_ass_ext(struct osmocom_ms *ms, struct msgb *msg) { struct gsm48_rrlayer *rr = &ms->rrlayer; struct gsm322_cellsel *cs = &ms->cellsel; - struct gsm48_sysinfo *s = cs->si; + struct gsm48_sysinfo *s = &cs->sel_si; struct gsm48_imm_ass_ext *ia = msgb_l3(msg); int ma_len = msgb_l3len(msg) - sizeof(*ia); uint8_t ch_type, ch_subch, ch_ts; @@ -2639,7 +2647,7 @@ static int gsm48_rr_rx_imm_ass_ext(struct osmocom_ms *ms, struct msgb *msg) } else { cd1.h = 0; gsm48_decode_chan_h0(&ia->chan_desc1, &cd1.tsc, &cd1.arfcn); - if (gsm_refer_pcs(cs->arfcn, s)) + if (gsm_refer_pcs(cs->sel_arfcn, s)) cd1.arfcn |= ARFCN_PCS; LOGP(DRR, LOGL_INFO, " assignment 1 (ta %d/%dm ra 0x%02x " "chan_nr 0x%02x ARFCN %s TS %u SS %u TSC %u)\n", @@ -2663,7 +2671,7 @@ static int gsm48_rr_rx_imm_ass_ext(struct osmocom_ms *ms, struct msgb *msg) } else { cd2.h = 0; gsm48_decode_chan_h0(&ia->chan_desc2, &cd2.tsc, &cd2.arfcn); - if (gsm_refer_pcs(cs->arfcn, s)) + if (gsm_refer_pcs(cs->sel_arfcn, s)) cd2.arfcn |= ARFCN_PCS; LOGP(DRR, LOGL_INFO, " assignment 2 (ta %d/%dm ra 0x%02x " "chan_nr 0x%02x ARFCN %s TS %u SS %u TSC %u)\n", @@ -2797,7 +2805,7 @@ static int gsm48_rr_rx_add_ass(struct osmocom_ms *ms, struct msgb *msg) static int gsm48_rr_tx_meas_rep(struct osmocom_ms *ms) { struct gsm48_rrlayer *rr = &ms->rrlayer; - struct gsm48_sysinfo *s = ms->cellsel.si; + struct gsm48_sysinfo *s = &ms->cellsel.sel_si; struct rx_meas_stat *meas = &rr->ms->meas; struct gsm48_rr_meas *rrmeas = &rr->meas; struct msgb *nmsg; @@ -3063,8 +3071,8 @@ static int gsm48_rr_activate_channel(struct osmocom_ms *ms, struct gsm_subscriber *subscr = &ms->subscr; struct gsm48_rrlayer *rr = &ms->rrlayer; struct gsm_settings *set = &ms->settings; - struct gsm48_sysinfo *s = ms->cellsel.si; - struct rx_meas_stat *meas = &ms->meas; + struct gsm48_sysinfo *s = &ms->cellsel.sel_si; + struct rx_meas_stat *meas = &ms->meas; uint8_t ch_type, ch_subch, ch_ts; uint8_t timeout = 64; int ta = cd->ind_ta; @@ -3162,12 +3170,12 @@ static int gsm48_rr_render_ma(struct osmocom_ms *ms, struct gsm48_rr_cd *cd, uint16_t *ma, uint8_t *ma_len) { struct gsm322_cellsel *cs = &ms->cellsel; - struct gsm48_sysinfo *s = cs->si; + struct gsm48_sysinfo *s = &cs->sel_si; struct gsm_settings *set = &ms->settings; int i, pcs, index; uint16_t arfcn; - pcs = gsm_refer_pcs(cs->arfcn, s) ? ARFCN_PCS : 0; + pcs = gsm_refer_pcs(cs->sel_arfcn, s) ? ARFCN_PCS : 0; /* no hopping (no MA), channel description is valid */ if (!cd->h) { @@ -3573,7 +3581,7 @@ static int gsm48_rr_rx_frq_redef(struct osmocom_ms *ms, struct msgb *msg) { struct gsm48_rrlayer *rr = &ms->rrlayer; struct gsm322_cellsel *cs = &ms->cellsel; - struct gsm48_sysinfo *s = cs->si; + struct gsm48_sysinfo *s = &cs->sel_si; struct gsm48_frq_redef *fr = msgb_l3(msg); int mob_al_len = msgb_l3len(msg) - sizeof(*fr); uint8_t ch_type, ch_subch, ch_ts; @@ -3610,7 +3618,7 @@ static int gsm48_rr_rx_frq_redef(struct osmocom_ms *ms, struct msgb *msg) } else { cd.h = 0; gsm48_decode_chan_h0(&fr->chan_desc, &cd.tsc, &cd.arfcn); - if (gsm_refer_pcs(cs->arfcn, s)) + if (gsm_refer_pcs(cs->sel_arfcn, s)) cd.arfcn |= ARFCN_PCS; LOGP(DRR, LOGL_INFO, " (ARFCN %s TS %u SS %u TSC %u)\n", gsm_print_arfcn(cd.arfcn), ch_ts, ch_subch, cd.tsc); @@ -3683,7 +3691,7 @@ static int gsm48_rr_rx_chan_modify(struct osmocom_ms *ms, struct msgb *msg) { struct gsm48_rrlayer *rr = &ms->rrlayer; struct gsm322_cellsel *cs = &ms->cellsel; - struct gsm48_sysinfo *s = cs->si; + struct gsm48_sysinfo *s = &cs->sel_si; struct gsm48_hdr *gh = msgb_l3(msg); struct gsm48_chan_mode_modify *cm = (struct gsm48_chan_mode_modify *)gh->data; @@ -3715,7 +3723,7 @@ static int gsm48_rr_rx_chan_modify(struct osmocom_ms *ms, struct msgb *msg) } else { cd->h = 0; gsm48_decode_chan_h0(&cm->chan_desc, &cd->tsc, &cd->arfcn); - if (gsm_refer_pcs(cs->arfcn, s)) + if (gsm_refer_pcs(cs->sel_arfcn, s)) cd->arfcn |= ARFCN_PCS; LOGP(DRR, LOGL_INFO, " (chan_nr 0x%02x ARFCN %s TS %u SS %u " "TSC %u mode %u)\n", cm->chan_desc.chan_nr, @@ -3791,7 +3799,7 @@ static int gsm48_rr_rx_ass_cmd(struct osmocom_ms *ms, struct msgb *msg) { struct gsm48_rrlayer *rr = &ms->rrlayer; struct gsm322_cellsel *cs = &ms->cellsel; - struct gsm48_sysinfo *s = cs->si; + struct gsm48_sysinfo *s = &cs->sel_si; struct gsm48_hdr *gh = msgb_l3(msg); struct gsm48_ass_cmd *ac = (struct gsm48_ass_cmd *)gh->data; int payload_len = msgb_l3len(msg) - sizeof(*gh) - sizeof(*ac); @@ -3838,7 +3846,7 @@ static int gsm48_rr_rx_ass_cmd(struct osmocom_ms *ms, struct msgb *msg) } else { cdb->h = 0; gsm48_decode_chan_h0(ccd, &cdb->tsc, &cdb->arfcn); - if (gsm_refer_pcs(cs->arfcn, s)) + if (gsm_refer_pcs(cs->sel_arfcn, s)) cdb->arfcn |= ARFCN_PCS; LOGP(DRR, LOGL_INFO, " before: (chan_nr 0x%02x " "ARFCN %s TS %u SS %u TSC %u)\n", ccd->chan_nr, @@ -3861,7 +3869,7 @@ static int gsm48_rr_rx_ass_cmd(struct osmocom_ms *ms, struct msgb *msg) } else { cda->h = 0; gsm48_decode_chan_h0(&ac->chan_desc, &cda->tsc, &cda->arfcn); - if (gsm_refer_pcs(cs->arfcn, s)) + if (gsm_refer_pcs(cs->sel_arfcn, s)) cda->arfcn |= ARFCN_PCS; LOGP(DRR, LOGL_INFO, " after: (chan_nr 0x%02x ARFCN %s TS %u " "SS %u TSC %u)\n", ac->chan_desc.chan_nr, @@ -4211,7 +4219,7 @@ static int gsm48_rr_rx_hando_cmd(struct osmocom_ms *ms, struct msgb *msg) struct gsm48_rrlayer *rr = &ms->rrlayer; struct gsm48_rr_meas *rrmeas = &rr->meas; struct gsm322_cellsel *cs = &ms->cellsel; - struct gsm48_sysinfo *s = cs->si; + struct gsm48_sysinfo *s = &cs->sel_si; struct gsm48_hdr *gh = msgb_l3(msg); struct gsm48_ho_cmd *ho = (struct gsm48_ho_cmd *)gh->data; int payload_len = msgb_l3len(msg) - sizeof(*gh) - sizeof(*ho); @@ -4294,7 +4302,7 @@ static int gsm48_rr_rx_hando_cmd(struct osmocom_ms *ms, struct msgb *msg) } else { cdb->h = 0; gsm48_decode_chan_h0(ccd, &cdb->tsc, &cdb->arfcn); - if (gsm_refer_pcs(cs->arfcn, s)) + if (gsm_refer_pcs(cs->sel_arfcn, s)) cdb->arfcn |= ARFCN_PCS; LOGP(DRR, LOGL_INFO, " before: (chan_nr 0x%02x " "ARFCN %s TS %u SS %u TSC %u)\n", ccd->chan_nr, @@ -4317,7 +4325,7 @@ static int gsm48_rr_rx_hando_cmd(struct osmocom_ms *ms, struct msgb *msg) } else { cda->h = 0; gsm48_decode_chan_h0(&ho->chan_desc, &cda->tsc, &cda->arfcn); - if (gsm_refer_pcs(cs->arfcn, s)) + if (gsm_refer_pcs(cs->sel_arfcn, s)) cda->arfcn |= ARFCN_PCS; LOGP(DRR, LOGL_INFO, " after: (chan_nr 0x%02x ARFCN %s TS %u " "SS %u TSC %u)\n", ho->chan_desc.chan_nr, diff --git a/src/host/layer23/src/mobile/vty_interface.c b/src/host/layer23/src/mobile/vty_interface.c index 9e097cc3..15eb2415 100644 --- a/src/host/layer23/src/mobile/vty_interface.c +++ b/src/host/layer23/src/mobile/vty_interface.c @@ -329,12 +329,14 @@ DEFUN(show_cell_si, show_cell_si_cmd, "show cell MS_NAME <0-1023> [pcs]", "Given frequency is PCS band (1900) rather than DCS band.") { struct osmocom_ms *ms; + struct gsm322_cellsel *cs; struct gsm48_sysinfo *s; uint16_t arfcn = atoi(argv[1]); ms = get_ms(argv[0], vty); if (!ms) return CMD_WARNING; + cs = &ms->cellsel; if (argc > 2) { if (arfcn < 512 || arfcn > 810) { @@ -345,7 +347,10 @@ DEFUN(show_cell_si, show_cell_si_cmd, "show cell MS_NAME <0-1023> [pcs]", arfcn |= ARFCN_PCS; } - s = ms->cellsel.list[arfcn2index(arfcn)].sysinfo; + if (cs->selected && cs->sel_arfcn == arfcn) + s = &cs->sel_si; + else + s = cs->list[arfcn2index(arfcn)].sysinfo; if (!s) { vty_out(vty, "Given ARFCN '%s' has no sysinfo available%s", argv[1], VTY_NEWLINE); |