Harald Welte | 0df904d | 2018-12-03 11:00:04 +0100 | [diff] [blame] | 1 | /* (C) 2018-2019 by sysmocom s.f.m.c. GmbH |
| 2 | * All Rights Reserved |
| 3 | * |
| 4 | * Author: Harald Welte, Philipp Maier |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU Affero General Public License as published by |
| 8 | * the Free Software Foundation; either version 3 of the License, or |
| 9 | * (at your option) any later version. |
| 10 | * |
| 11 | * This program is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | * GNU Affero General Public License for more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU Affero General Public License |
| 17 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 18 | * |
| 19 | */ |
| 20 | |
| 21 | #pragma once |
| 22 | |
| 23 | #include <osmocom/gsm/gsm29118.h> |
| 24 | |
| 25 | enum vlr_lu_type; |
| 26 | struct vlr_subscr; |
| 27 | struct vlr_instance; |
| 28 | |
Pau Espin Pedrol | 017ba1f | 2021-08-24 14:56:03 +0200 | [diff] [blame] | 29 | #define VSUB_USE_SGS_LU "SGs-lu" |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 30 | #define VSUB_USE_SGS_PAGING_REQ "SGs-paging-req" |
Neels Hofmeyr | 7c5346c | 2019-02-19 02:36:35 +0100 | [diff] [blame] | 31 | |
Harald Welte | 0df904d | 2018-12-03 11:00:04 +0100 | [diff] [blame] | 32 | /* See also 3GPP TS 29.118, chapter 4.2.2 States at the VLR */ |
| 33 | enum sgs_ue_fsm_state { |
| 34 | SGS_UE_ST_NULL, |
Harald Welte | 0df904d | 2018-12-03 11:00:04 +0100 | [diff] [blame] | 35 | SGS_UE_ST_LA_UPD_PRES, |
Pau Espin Pedrol | 13f17c1 | 2021-08-24 11:49:03 +0200 | [diff] [blame] | 36 | SGS_UE_ST_ASSOCIATED, |
Harald Welte | 0df904d | 2018-12-03 11:00:04 +0100 | [diff] [blame] | 37 | }; |
| 38 | |
| 39 | enum vlr_sgs_state_tmr { |
| 40 | /* Started when sending the SGsAP-PAGING-REQUEST, implemented in vlr_sgs.c */ |
| 41 | SGS_STATE_TS5, |
| 42 | /* TMSI reallocation, 5.2.3.5, implemented by fsm in vlr_sgs_fsm.c */ |
| 43 | SGS_STATE_TS6_2, |
| 44 | /* Started when SGsAP-ALERT-REQUEST is sent 5.3.2.1, not implemented yet */ |
| 45 | SGS_STATE_TS7, |
| 46 | /* Reset ack timeout, implemnted in sgs_iface.c */ |
| 47 | SGS_STATE_TS11, |
| 48 | /* Started when SGsAP-SERVICE-REQUEST is received 5.15.1, not implemented yet */ |
| 49 | SGS_STATE_TS14, |
| 50 | /* Started when SGsAP-MO-CSFB-INDICATION is received 5.16.3 (UE fallback, not implemented yet) */ |
| 51 | SGS_STATE_TS15, |
| 52 | _NUM_SGS_STATE_TIMERS |
| 53 | }; |
| 54 | |
| 55 | enum vlr_sgs_state_ctr { |
| 56 | /* Alert request retransmit count */ |
| 57 | SGS_STATE_NS7, |
| 58 | /* Reset repeat count */ |
| 59 | SGS_STATE_NS11, |
| 60 | _NUM_SGS_STATE_COUNTERS |
| 61 | }; |
| 62 | |
| 63 | extern const struct value_string sgs_state_timer_names[]; |
| 64 | static inline const char *vlr_sgs_state_timer_name(enum vlr_sgs_state_tmr Ts) |
| 65 | { |
| 66 | return get_value_string(sgs_state_timer_names, Ts); |
| 67 | } |
| 68 | |
| 69 | extern const struct value_string sgs_state_counter_names[]; |
| 70 | static inline const char *vlr_sgs_state_counter_name(enum vlr_sgs_state_ctr Ns) |
| 71 | { |
Philipp Maier | 656354b | 2023-10-23 17:33:45 +0200 | [diff] [blame] | 72 | return get_value_string(sgs_state_counter_names, Ns); |
Harald Welte | 0df904d | 2018-12-03 11:00:04 +0100 | [diff] [blame] | 73 | } |
| 74 | |
| 75 | /* This callback function is called when an SGs location update is complete */ |
| 76 | struct sgs_lu_response { |
| 77 | bool accepted; |
Philipp Maier | 483cea8 | 2019-04-03 16:23:29 +0200 | [diff] [blame] | 78 | bool error; |
Harald Welte | 0df904d | 2018-12-03 11:00:04 +0100 | [diff] [blame] | 79 | struct vlr_subscr *vsub; |
| 80 | }; |
| 81 | typedef void (*vlr_sgs_lu_response_cb_t) (struct sgs_lu_response *response); |
| 82 | |
| 83 | /* This callback function is called in cases where a paging request is required |
Alexander Couzens | 28e43ff | 2024-09-11 23:49:33 +0200 | [diff] [blame] | 84 | * after the LU is completed or when a paging expired */ |
Harald Welte | 0df904d | 2018-12-03 11:00:04 +0100 | [diff] [blame] | 85 | typedef int (*vlr_sgs_lu_paging_cb_t) (struct vlr_subscr *vsub, enum sgsap_service_ind serv_ind); |
| 86 | |
| 87 | /* This callback function is called to send the MM info to the UE. */ |
| 88 | typedef void (*vlr_sgs_lu_mminfo_cb_t) (struct vlr_subscr *vsub); |
| 89 | |
| 90 | /* Configuration parameters for the SGs FSM */ |
| 91 | struct vlr_sgs_cfg { |
| 92 | unsigned int timer[_NUM_SGS_STATE_TIMERS]; |
| 93 | unsigned int counter[_NUM_SGS_STATE_COUNTERS]; |
| 94 | }; |
| 95 | |
| 96 | void vlr_sgs_reset(struct vlr_instance *vlr); |
| 97 | int vlr_sgs_loc_update(struct vlr_instance *vlr, struct vlr_sgs_cfg *cfg, |
| 98 | vlr_sgs_lu_response_cb_t response_cb, vlr_sgs_lu_paging_cb_t paging_cb, |
| 99 | vlr_sgs_lu_mminfo_cb_t mminfo_cb, char *mme_name, enum vlr_lu_type type, const char *imsi, |
Pau Espin Pedrol | 6710670 | 2021-04-27 18:20:15 +0200 | [diff] [blame] | 100 | struct osmo_location_area_id *new_lai, struct osmo_plmn_id *last_eutran_plmn); |
Harald Welte | 0df904d | 2018-12-03 11:00:04 +0100 | [diff] [blame] | 101 | void vlr_sgs_loc_update_acc_sent(struct vlr_subscr *vsub); |
| 102 | void vlr_sgs_loc_update_rej_sent(struct vlr_subscr *vsub); |
| 103 | void vlr_sgs_detach(struct vlr_instance *vlr, const char *imsi, bool eps); |
| 104 | void vlr_sgs_imsi_detach(struct vlr_instance *vlr, const char *imsi, enum sgsap_imsi_det_noneps_type type); |
| 105 | void vlr_sgs_eps_detach(struct vlr_instance *vlr, const char *imsi, enum sgsap_imsi_det_eps_type type); |
| 106 | void vlr_sgs_tmsi_reall_compl(struct vlr_instance *vlr, const char *imsi); |
| 107 | void vlr_sgs_pag_rej(struct vlr_instance *vlr, const char *imsi, enum sgsap_sgs_cause cause); |
| 108 | void vlr_sgs_pag_ack(struct vlr_instance *vlr, const char *imsi); |
| 109 | void vlr_sgs_ue_unr(struct vlr_instance *vlr, const char *imsi, enum sgsap_sgs_cause cause); |
| 110 | void vlr_sgs_pag(struct vlr_subscr *vsub, enum sgsap_service_ind serv_ind); |
| 111 | bool vlr_sgs_pag_pend(struct vlr_subscr *vsub); |