blob: cc07807b15d2a1a4555fbbaca23594a4b723e8e2 [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
29/* See also 3GPP TS 29.118, chapter 4.2.2 States at the VLR */
30enum sgs_ue_fsm_state {
31 SGS_UE_ST_NULL,
32 SGS_UE_ST_ASSOCIATED,
33 SGS_UE_ST_LA_UPD_PRES,
34};
35
36enum vlr_sgs_state_tmr {
37 /* Started when sending the SGsAP-PAGING-REQUEST, implemented in vlr_sgs.c */
38 SGS_STATE_TS5,
39 /* TMSI reallocation, 5.2.3.5, implemented by fsm in vlr_sgs_fsm.c */
40 SGS_STATE_TS6_2,
41 /* Started when SGsAP-ALERT-REQUEST is sent 5.3.2.1, not implemented yet */
42 SGS_STATE_TS7,
43 /* Reset ack timeout, implemnted in sgs_iface.c */
44 SGS_STATE_TS11,
45 /* Started when SGsAP-SERVICE-REQUEST is received 5.15.1, not implemented yet */
46 SGS_STATE_TS14,
47 /* Started when SGsAP-MO-CSFB-INDICATION is received 5.16.3 (UE fallback, not implemented yet) */
48 SGS_STATE_TS15,
49 _NUM_SGS_STATE_TIMERS
50};
51
52enum vlr_sgs_state_ctr {
53 /* Alert request retransmit count */
54 SGS_STATE_NS7,
55 /* Reset repeat count */
56 SGS_STATE_NS11,
57 _NUM_SGS_STATE_COUNTERS
58};
59
60extern const struct value_string sgs_state_timer_names[];
61static inline const char *vlr_sgs_state_timer_name(enum vlr_sgs_state_tmr Ts)
62{
63 return get_value_string(sgs_state_timer_names, Ts);
64}
65
66extern const struct value_string sgs_state_counter_names[];
67static inline const char *vlr_sgs_state_counter_name(enum vlr_sgs_state_ctr Ns)
68{
69 return get_value_string(sgs_state_timer_names, Ns);
70}
71
72/* This callback function is called when an SGs location update is complete */
73struct sgs_lu_response {
74 bool accepted;
75 struct vlr_subscr *vsub;
76};
77typedef void (*vlr_sgs_lu_response_cb_t) (struct sgs_lu_response *response);
78
79/* This callback function is called in cases where a paging request is required
80 * after the LU is completed */
81typedef int (*vlr_sgs_lu_paging_cb_t) (struct vlr_subscr *vsub, enum sgsap_service_ind serv_ind);
82
83/* This callback function is called to send the MM info to the UE. */
84typedef void (*vlr_sgs_lu_mminfo_cb_t) (struct vlr_subscr *vsub);
85
86/* Configuration parameters for the SGs FSM */
87struct vlr_sgs_cfg {
88 unsigned int timer[_NUM_SGS_STATE_TIMERS];
89 unsigned int counter[_NUM_SGS_STATE_COUNTERS];
90};
91
92void vlr_sgs_reset(struct vlr_instance *vlr);
93int vlr_sgs_loc_update(struct vlr_instance *vlr, struct vlr_sgs_cfg *cfg,
94 vlr_sgs_lu_response_cb_t response_cb, vlr_sgs_lu_paging_cb_t paging_cb,
95 vlr_sgs_lu_mminfo_cb_t mminfo_cb, char *mme_name, enum vlr_lu_type type, const char *imsi,
96 struct osmo_location_area_id *new_lai);
97void vlr_sgs_loc_update_acc_sent(struct vlr_subscr *vsub);
98void vlr_sgs_loc_update_rej_sent(struct vlr_subscr *vsub);
99void vlr_sgs_detach(struct vlr_instance *vlr, const char *imsi, bool eps);
100void vlr_sgs_imsi_detach(struct vlr_instance *vlr, const char *imsi, enum sgsap_imsi_det_noneps_type type);
101void vlr_sgs_eps_detach(struct vlr_instance *vlr, const char *imsi, enum sgsap_imsi_det_eps_type type);
102void vlr_sgs_tmsi_reall_compl(struct vlr_instance *vlr, const char *imsi);
103void vlr_sgs_pag_rej(struct vlr_instance *vlr, const char *imsi, enum sgsap_sgs_cause cause);
104void vlr_sgs_pag_ack(struct vlr_instance *vlr, const char *imsi);
105void vlr_sgs_ue_unr(struct vlr_instance *vlr, const char *imsi, enum sgsap_sgs_cause cause);
106void vlr_sgs_pag(struct vlr_subscr *vsub, enum sgsap_service_ind serv_ind);
107bool vlr_sgs_pag_pend(struct vlr_subscr *vsub);