blob: 053a0253d2b561e23581880bba02b623f4f44132 [file] [log] [blame]
Maxea8b0d42017-02-14 16:53:04 +01001/* OsmoHLR TX/RX lu operations */
2
3/* (C) 2017 sysmocom s.f.m.c. GmbH <info@sysmocom.de>
4 * All Rights Reserved
5 *
6 * Author: Harald Welte <laforge@gnumonks.org>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU Affero General Public License as published by
10 * the Free Software Foundation; either version 3 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU Affero General Public License for more details.
17 *
18 * You should have received a copy of the GNU Affero General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 *
21 */
22
23#pragma once
24
25#include <stdbool.h>
26
27#include <osmocom/core/timer.h>
28#include <osmocom/gsm/gsup.h>
29
30#include "db.h"
31
32#define CANCEL_TIMEOUT_SECS 30
33#define ISD_TIMEOUT_SECS 30
34
35enum lu_state {
36 LU_S_NULL,
37 LU_S_LU_RECEIVED,
38 LU_S_CANCEL_SENT,
39 LU_S_CANCEL_ACK_RECEIVED,
40 LU_S_ISD_SENT,
41 LU_S_ISD_ACK_RECEIVED,
42 LU_S_COMPLETE,
43};
44
45extern const struct value_string lu_state_names[];
46
47struct lu_operation {
48 /*! entry in global list of location update operations */
49 struct llist_head list;
50 /*! to which gsup_server do we belong */
51 struct osmo_gsup_server *gsup_server;
52 /*! state of the location update */
53 enum lu_state state;
54 /*! CS (false) or PS (true) Location Update? */
55 bool is_ps;
56 /*! currently running timer */
57 struct osmo_timer_list timer;
58
59 /*! subscriber related to this operation */
60 struct hlr_subscriber subscr;
61 /*! peer VLR/SGSN starting the request */
62 uint8_t *peer;
63};
64
65int osmo_gsup_addr_send(struct osmo_gsup_server *gs,
66 const uint8_t *addr, size_t addrlen,
67 struct msgb *msg);
68
69struct lu_operation *lu_op_alloc(struct osmo_gsup_server *srv);
70struct lu_operation *lu_op_alloc_conn(struct osmo_gsup_conn *conn);
71void lu_op_statechg(struct lu_operation *luop, enum lu_state new_state);
72bool lu_op_fill_subscr(struct lu_operation *luop, struct db_context *dbc,
73 const char *imsi);
74struct lu_operation *lu_op_by_imsi(const char *imsi,
75 const struct llist_head *lst);
76
77void lu_op_tx_error(struct lu_operation *luop, enum gsm48_gmm_cause cause);
78void lu_op_tx_ack(struct lu_operation *luop);
79void lu_op_tx_cancel_old(struct lu_operation *luop);
80void lu_op_tx_insert_subscr_data(struct lu_operation *luop);
Max9cacb6f2017-02-20 17:22:56 +010081void lu_op_tx_del_subscr_data(struct lu_operation *luop);
Neels Hofmeyr200f56e2017-10-17 01:46:04 +020082
83void lu_op_free(struct lu_operation *luop);