diff options
Diffstat (limited to 'src/bts_pch_timer.c')
-rw-r--r-- | src/bts_pch_timer.c | 55 |
1 files changed, 41 insertions, 14 deletions
diff --git a/src/bts_pch_timer.c b/src/bts_pch_timer.c index 20373ac8..4b752398 100644 --- a/src/bts_pch_timer.c +++ b/src/bts_pch_timer.c @@ -3,8 +3,8 @@ * Author: Oliver Smith * * 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 + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, @@ -12,7 +12,7 @@ * 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 + * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * */ @@ -26,8 +26,22 @@ #include <gprs_debug.h> #include <gprs_pcu.h> #include <bts_pch_timer.h> +#include <gprs_ms.h> -static struct bts_pch_timer *bts_pch_timer_get(struct gprs_rlcmac_bts *bts, const char *imsi) +static struct bts_pch_timer *bts_pch_timer_get_by_ptmsi(struct gprs_rlcmac_bts *bts, uint32_t ptmsi) +{ + struct bts_pch_timer *p; + OSMO_ASSERT(ptmsi != GSM_RESERVED_TMSI); + + llist_for_each_entry(p, &bts->pch_timer, entry) { + if (p->ptmsi != GSM_RESERVED_TMSI && p->ptmsi == ptmsi) + return p; + } + + return NULL; +} + +struct bts_pch_timer *bts_pch_timer_get_by_imsi(struct gprs_rlcmac_bts *bts, const char *imsi) { struct bts_pch_timer *p; @@ -57,29 +71,42 @@ static void T3113_callback(void *data) bts_pch_timer_remove(p); } -void bts_pch_timer_start(struct gprs_rlcmac_bts *bts, const char *imsi) +void bts_pch_timer_start(struct gprs_rlcmac_bts *bts, const struct osmo_mobile_identity *mi_paging, + const char *imsi) { - if (bts_pch_timer_get(bts, imsi)) - return; - struct bts_pch_timer *p; + struct osmo_tdef *tdef; + p = talloc_zero(bts, struct bts_pch_timer); llist_add_tail(&p->entry, &bts->pch_timer); - osmo_strlcpy(p->imsi, imsi, sizeof(p->imsi)); p->bts = bts; + OSMO_STRLCPY_ARRAY(p->imsi, imsi); + p->ptmsi = (mi_paging->type == GSM_MI_TYPE_TMSI) ? mi_paging->tmsi : GSM_RESERVED_TMSI; - struct osmo_tdef *tdef = osmo_tdef_get_entry(the_pcu->T_defs, 3113); + tdef = osmo_tdef_get_entry(the_pcu->T_defs, 3113); OSMO_ASSERT(tdef); osmo_timer_setup(&p->T3113, T3113_callback, p); osmo_timer_schedule(&p->T3113, tdef->val, 0); - LOGP(DPCU, LOGL_DEBUG, "PCH paging timer started for IMSI=%s\n", p->imsi); + if (log_check_level(DPCU, LOGL_DEBUG)) { + char str[64]; + osmo_mobile_identity_to_str_buf(str, sizeof(str), mi_paging); + LOGP(DPCU, LOGL_DEBUG, "PCH paging timer started for MI=%s IMSI=%s\n", str, p->imsi); + } } -void bts_pch_timer_stop(struct gprs_rlcmac_bts *bts, const char *imsi) +void bts_pch_timer_stop(struct gprs_rlcmac_bts *bts, const struct GprsMs *ms) { - struct bts_pch_timer *p = bts_pch_timer_get(bts, imsi); - + struct bts_pch_timer *p = NULL; + uint32_t tlli = ms_tlli(ms); + const char *imsi = ms_imsi(ms); + + /* First try matching by TMSI if available in MS */ + if (tlli != GSM_RESERVED_TMSI) + p = bts_pch_timer_get_by_ptmsi(bts, tlli); + /* Otherwise try matching by IMSI if available in MS */ + if (!p && imsi[0] != '\0') + p = bts_pch_timer_get_by_imsi(bts, imsi); if (p) bts_pch_timer_remove(p); } |