blob: 7231449324851de7a300458bb267e7fbc2a1c8bf [file] [log] [blame]
Harald Welte0df904d2018-12-03 11:00:04 +01001/* (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
25enum vlr_lu_type;
26struct vlr_subscr;
27struct vlr_instance;
28
Pau Espin Pedrol017ba1f2021-08-24 14:56:03 +020029#define VSUB_USE_SGS_LU "SGs-lu"
Neels Hofmeyrc4628a32018-12-07 14:47:34 +010030#define VSUB_USE_SGS_PAGING_REQ "SGs-paging-req"
Neels Hofmeyr7c5346c2019-02-19 02:36:35 +010031
Harald Welte0df904d2018-12-03 11:00:04 +010032/* See also 3GPP TS 29.118, chapter 4.2.2 States at the VLR */
33enum sgs_ue_fsm_state {
34 SGS_UE_ST_NULL,
Harald Welte0df904d2018-12-03 11:00:04 +010035 SGS_UE_ST_LA_UPD_PRES,
Pau Espin Pedrol13f17c12021-08-24 11:49:03 +020036 SGS_UE_ST_ASSOCIATED,
Harald Welte0df904d2018-12-03 11:00:04 +010037};
38
39enum 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
55enum 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
63extern const struct value_string sgs_state_timer_names[];
64static 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
69extern const struct value_string sgs_state_counter_names[];
70static inline const char *vlr_sgs_state_counter_name(enum vlr_sgs_state_ctr Ns)
71{
72 return get_value_string(sgs_state_timer_names, Ns);
73}
74
75/* This callback function is called when an SGs location update is complete */
76struct sgs_lu_response {
77 bool accepted;
Philipp Maier483cea82019-04-03 16:23:29 +020078 bool error;
Harald Welte0df904d2018-12-03 11:00:04 +010079 struct vlr_subscr *vsub;
80};
81typedef 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
84 * after the LU is completed */
85typedef 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. */
88typedef void (*vlr_sgs_lu_mminfo_cb_t) (struct vlr_subscr *vsub);
89
90/* Configuration parameters for the SGs FSM */
91struct vlr_sgs_cfg {
92 unsigned int timer[_NUM_SGS_STATE_TIMERS];
93 unsigned int counter[_NUM_SGS_STATE_COUNTERS];
94};
95
96void vlr_sgs_reset(struct vlr_instance *vlr);
97int 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 Pedrol67106702021-04-27 18:20:15 +0200100 struct osmo_location_area_id *new_lai, struct osmo_plmn_id *last_eutran_plmn);
Harald Welte0df904d2018-12-03 11:00:04 +0100101void vlr_sgs_loc_update_acc_sent(struct vlr_subscr *vsub);
102void vlr_sgs_loc_update_rej_sent(struct vlr_subscr *vsub);
103void vlr_sgs_detach(struct vlr_instance *vlr, const char *imsi, bool eps);
104void vlr_sgs_imsi_detach(struct vlr_instance *vlr, const char *imsi, enum sgsap_imsi_det_noneps_type type);
105void vlr_sgs_eps_detach(struct vlr_instance *vlr, const char *imsi, enum sgsap_imsi_det_eps_type type);
106void vlr_sgs_tmsi_reall_compl(struct vlr_instance *vlr, const char *imsi);
107void vlr_sgs_pag_rej(struct vlr_instance *vlr, const char *imsi, enum sgsap_sgs_cause cause);
108void vlr_sgs_pag_ack(struct vlr_instance *vlr, const char *imsi);
109void vlr_sgs_ue_unr(struct vlr_instance *vlr, const char *imsi, enum sgsap_sgs_cause cause);
110void vlr_sgs_pag(struct vlr_subscr *vsub, enum sgsap_service_ind serv_ind);
111bool vlr_sgs_pag_pend(struct vlr_subscr *vsub);