blob: e8df5cd1934e2b0aa77f89da07884b4801d52462 [file] [log] [blame]
Maxd4bebbd2017-03-02 12:00:19 +01001/* OsmoHLR generic header */
2
3/* (C) 2017 sysmocom s.f.m.c. GmbH <info@sysmocom.de>
4 * All Rights Reserved
5 *
6 * Author: Max Suraev <msuraev@sysmocom.de>
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>
Harald Welte4956ae12018-06-15 22:04:28 +020026#include <osmocom/core/linuxlist.h>
Neels Hofmeyrb2553eb2019-11-20 02:36:45 +010027#include <osmocom/gsm/ipa.h>
28#include <osmocom/core/tdef.h>
Neels Hofmeyra75d1c22019-11-20 03:35:37 +010029#include <osmocom/core/sockaddr_str.h>
Harald Welte4956ae12018-06-15 22:04:28 +020030
Neels Hofmeyr647c1062019-11-20 03:35:37 +010031#include <osmocom/hlr/dgsm.h>
32
Neels Hofmeyr5857c592019-04-02 04:24:49 +020033#define HLR_DEFAULT_DB_FILE_PATH "hlr.db"
34
Harald Welte4956ae12018-06-15 22:04:28 +020035struct hlr_euse;
Neels Hofmeyrb2553eb2019-11-20 02:36:45 +010036struct osmo_gsup_conn;
37enum osmo_gsup_message_type;
38
39extern struct osmo_tdef g_hlr_tdefs[];
Maxd4bebbd2017-03-02 12:00:19 +010040
41struct hlr {
42 /* GSUP server pointer */
43 struct osmo_gsup_server *gs;
44
45 /* DB context */
Neels Hofmeyr5857c592019-04-02 04:24:49 +020046 char *db_file_path;
Maxd4bebbd2017-03-02 12:00:19 +010047 struct db_context *dbc;
Max372868b2017-03-02 12:12:00 +010048
49 /* Control Interface */
50 struct ctrl_handle *ctrl;
51 const char *ctrl_bind_addr;
Pau Espin Pedrolce9bc402017-05-31 13:19:22 +020052
53 /* Local bind addr */
54 char *gsup_bind_addr;
Neels Hofmeyrb2553eb2019-11-20 02:36:45 +010055 struct ipaccess_unit gsup_unit_name;
Harald Welte4956ae12018-06-15 22:04:28 +020056
57 struct llist_head euse_list;
58 struct hlr_euse *euse_default;
Harald Weltedab544e2018-07-29 16:14:48 +020059
Vadim Yanitskiyd157a562018-12-01 00:03:39 +070060 /* NCSS (call independent) session guard timeout value */
61 int ncss_guard_timeout;
62
Harald Weltedab544e2018-07-29 16:14:48 +020063 struct llist_head ussd_routes;
Harald Weltebb779392018-06-16 20:21:10 +020064
65 struct llist_head ss_sessions;
Oliver Smith851814a2019-01-11 15:30:21 +010066
67 bool store_imei;
Oliver Smithc7f17872019-03-04 15:10:44 +010068
69 bool subscr_create_on_demand;
70 /* Bitmask of DB_SUBSCR_FLAG_* */
71 uint8_t subscr_create_on_demand_flags;
72 unsigned int subscr_create_on_demand_rand_msisdn_len;
Neels Hofmeyr32cc07a2019-11-20 03:35:37 +010073
74 struct {
Neels Hofmeyra75d1c22019-11-20 03:35:37 +010075 bool allow_startup;
Neels Hofmeyr32cc07a2019-11-20 03:35:37 +010076 struct {
Neels Hofmeyra75d1c22019-11-20 03:35:37 +010077 /* Whether the mslookup server should be active in general (all lookup methods) */
78 bool enable;
Neels Hofmeyr32cc07a2019-11-20 03:35:37 +010079 uint32_t local_attach_max_age;
80 struct llist_head local_site_services;
Neels Hofmeyra75d1c22019-11-20 03:35:37 +010081 struct {
82 /* Whether the mDNS method of the mslookup server should be active. */
83 bool enable;
84 /* The mDNS bind address and domain suffix as set by the VTY, not necessarily in use. */
85 struct osmo_sockaddr_str bind_addr;
86 char *domain_suffix;
87 struct osmo_mslookup_server_mdns *running;
88 } mdns;
Neels Hofmeyr32cc07a2019-11-20 03:35:37 +010089 } server;
Neels Hofmeyr647c1062019-11-20 03:35:37 +010090
91 /* The mslookup client in osmo-hlr is used to find out which remote HLRs service a locally unknown IMSI.
92 * (It may also be used to resolve recipients for SMS-over-GSUP in the future.) */
93 struct {
94 /* Whether to proxy/forward to remote HLRs */
95 bool enable;
96
97 /* If this is set, all GSUP for unknown IMSIs is forwarded directly to this GSUP address,
98 * unconditionally. */
99 struct osmo_sockaddr_str gsup_gateway_proxy;
100
101 /* mslookup client request handling */
102 unsigned int result_timeout_milliseconds;
103
104 struct osmo_mslookup_client *client;
105 struct {
106 /* Whether to use mDNS for IMSI MS Lookup */
107 bool enable;
108 struct osmo_sockaddr_str query_addr;
109 char *domain_suffix;
110 struct osmo_mslookup_client_method *running;
111 } mdns;
112 } client;
Neels Hofmeyr32cc07a2019-11-20 03:35:37 +0100113 } mslookup;
Maxd4bebbd2017-03-02 12:00:19 +0100114};
Stefan Sperlingf1622522018-04-09 11:39:16 +0200115
Harald Welted5807b82018-07-29 12:27:41 +0200116extern struct hlr *g_hlr;
117
Stefan Sperlingf1622522018-04-09 11:39:16 +0200118struct hlr_subscriber;
119
120void osmo_hlr_subscriber_update_notify(struct hlr_subscriber *subscr);
Neels Hofmeyrb2553eb2019-11-20 02:36:45 +0100121int hlr_subscr_nam(struct hlr *hlr, struct hlr_subscriber *subscr, bool nam_val, bool is_ps);