Max | d4bebbd | 2017-03-02 12:00:19 +0100 | [diff] [blame] | 1 | /* 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 Welte | 4956ae1 | 2018-06-15 22:04:28 +0200 | [diff] [blame] | 26 | #include <osmocom/core/linuxlist.h> |
Neels Hofmeyr | f13a8bc | 2019-11-20 02:36:45 +0100 | [diff] [blame] | 27 | #include <osmocom/gsm/ipa.h> |
| 28 | #include <osmocom/core/tdef.h> |
Neels Hofmeyr | 3ad481a | 2019-11-20 03:35:37 +0100 | [diff] [blame] | 29 | #include <osmocom/core/sockaddr_str.h> |
Harald Welte | 4956ae1 | 2018-06-15 22:04:28 +0200 | [diff] [blame] | 30 | |
Neels Hofmeyr | 62d916f | 2019-11-20 03:35:37 +0100 | [diff] [blame] | 31 | #include <osmocom/hlr/dgsm.h> |
| 32 | |
Neels Hofmeyr | 5857c59 | 2019-04-02 04:24:49 +0200 | [diff] [blame] | 33 | #define HLR_DEFAULT_DB_FILE_PATH "hlr.db" |
| 34 | |
Harald Welte | 4956ae1 | 2018-06-15 22:04:28 +0200 | [diff] [blame] | 35 | struct hlr_euse; |
Neels Hofmeyr | f13a8bc | 2019-11-20 02:36:45 +0100 | [diff] [blame] | 36 | struct osmo_gsup_conn; |
| 37 | enum osmo_gsup_message_type; |
| 38 | |
| 39 | extern struct osmo_tdef g_hlr_tdefs[]; |
Max | d4bebbd | 2017-03-02 12:00:19 +0100 | [diff] [blame] | 40 | |
| 41 | struct hlr { |
| 42 | /* GSUP server pointer */ |
| 43 | struct osmo_gsup_server *gs; |
| 44 | |
| 45 | /* DB context */ |
Neels Hofmeyr | 5857c59 | 2019-04-02 04:24:49 +0200 | [diff] [blame] | 46 | char *db_file_path; |
Max | d4bebbd | 2017-03-02 12:00:19 +0100 | [diff] [blame] | 47 | struct db_context *dbc; |
Max | 372868b | 2017-03-02 12:12:00 +0100 | [diff] [blame] | 48 | |
| 49 | /* Control Interface */ |
| 50 | struct ctrl_handle *ctrl; |
| 51 | const char *ctrl_bind_addr; |
Pau Espin Pedrol | ce9bc40 | 2017-05-31 13:19:22 +0200 | [diff] [blame] | 52 | |
| 53 | /* Local bind addr */ |
| 54 | char *gsup_bind_addr; |
Neels Hofmeyr | f13a8bc | 2019-11-20 02:36:45 +0100 | [diff] [blame] | 55 | struct ipaccess_unit gsup_unit_name; |
Harald Welte | 4956ae1 | 2018-06-15 22:04:28 +0200 | [diff] [blame] | 56 | |
| 57 | struct llist_head euse_list; |
| 58 | struct hlr_euse *euse_default; |
Harald Welte | dab544e | 2018-07-29 16:14:48 +0200 | [diff] [blame] | 59 | struct llist_head iuse_list; |
| 60 | |
Vadim Yanitskiy | d157a56 | 2018-12-01 00:03:39 +0700 | [diff] [blame] | 61 | /* NCSS (call independent) session guard timeout value */ |
| 62 | int ncss_guard_timeout; |
| 63 | |
Harald Welte | dab544e | 2018-07-29 16:14:48 +0200 | [diff] [blame] | 64 | struct llist_head ussd_routes; |
Harald Welte | bb77939 | 2018-06-16 20:21:10 +0200 | [diff] [blame] | 65 | |
| 66 | struct llist_head ss_sessions; |
Oliver Smith | 851814a | 2019-01-11 15:30:21 +0100 | [diff] [blame] | 67 | |
| 68 | bool store_imei; |
Oliver Smith | c7f1787 | 2019-03-04 15:10:44 +0100 | [diff] [blame] | 69 | |
| 70 | bool subscr_create_on_demand; |
| 71 | /* Bitmask of DB_SUBSCR_FLAG_* */ |
| 72 | uint8_t subscr_create_on_demand_flags; |
| 73 | unsigned int subscr_create_on_demand_rand_msisdn_len; |
Neels Hofmeyr | 6aa871d | 2019-11-20 03:35:37 +0100 | [diff] [blame] | 74 | |
| 75 | struct { |
Neels Hofmeyr | 3ad481a | 2019-11-20 03:35:37 +0100 | [diff] [blame] | 76 | bool allow_startup; |
Neels Hofmeyr | 6aa871d | 2019-11-20 03:35:37 +0100 | [diff] [blame] | 77 | struct { |
Neels Hofmeyr | 3ad481a | 2019-11-20 03:35:37 +0100 | [diff] [blame] | 78 | /* Whether the mslookup server should be active in general (all lookup methods) */ |
| 79 | bool enable; |
Neels Hofmeyr | 6aa871d | 2019-11-20 03:35:37 +0100 | [diff] [blame] | 80 | uint32_t local_attach_max_age; |
| 81 | struct llist_head local_site_services; |
Neels Hofmeyr | 3ad481a | 2019-11-20 03:35:37 +0100 | [diff] [blame] | 82 | struct { |
| 83 | /* Whether the mDNS method of the mslookup server should be active. */ |
| 84 | bool enable; |
| 85 | /* The mDNS bind address and domain suffix as set by the VTY, not necessarily in use. */ |
| 86 | struct osmo_sockaddr_str bind_addr; |
| 87 | char *domain_suffix; |
| 88 | struct osmo_mslookup_server_mdns *running; |
| 89 | } mdns; |
Neels Hofmeyr | 6aa871d | 2019-11-20 03:35:37 +0100 | [diff] [blame] | 90 | } server; |
Neels Hofmeyr | 62d916f | 2019-11-20 03:35:37 +0100 | [diff] [blame] | 91 | |
| 92 | /* The mslookup client in osmo-hlr is used to find out which remote HLRs service a locally unknown IMSI. |
| 93 | * (It may also be used to resolve recipients for SMS-over-GSUP in the future.) */ |
| 94 | struct { |
| 95 | /* Whether to proxy/forward to remote HLRs */ |
| 96 | bool enable; |
| 97 | |
| 98 | /* If this is set, all GSUP for unknown IMSIs is forwarded directly to this GSUP address, |
| 99 | * unconditionally. */ |
| 100 | struct osmo_sockaddr_str gsup_gateway_proxy; |
| 101 | |
| 102 | /* mslookup client request handling */ |
| 103 | unsigned int result_timeout_milliseconds; |
| 104 | |
| 105 | struct osmo_mslookup_client *client; |
| 106 | struct { |
| 107 | /* Whether to use mDNS for IMSI MS Lookup */ |
| 108 | bool enable; |
| 109 | struct osmo_sockaddr_str query_addr; |
| 110 | char *domain_suffix; |
| 111 | struct osmo_mslookup_client_method *running; |
| 112 | } mdns; |
| 113 | } client; |
Neels Hofmeyr | 6aa871d | 2019-11-20 03:35:37 +0100 | [diff] [blame] | 114 | } mslookup; |
Neels Hofmeyr | fd08e4d | 2019-12-16 17:15:40 +0100 | [diff] [blame^] | 115 | |
| 116 | struct { |
| 117 | /* FIXME actually use branch fixeria/sms for SMSC routing. completely unimplemented */ |
| 118 | struct osmo_gsup_peer_id smsc; |
| 119 | |
| 120 | /* If no SMSC is present / responsible, try punching the SMS through directly when this is true. */ |
| 121 | bool try_direct_delivery; |
| 122 | } sms_over_gsup; |
Max | d4bebbd | 2017-03-02 12:00:19 +0100 | [diff] [blame] | 123 | }; |
Stefan Sperling | f162252 | 2018-04-09 11:39:16 +0200 | [diff] [blame] | 124 | |
Harald Welte | d5807b8 | 2018-07-29 12:27:41 +0200 | [diff] [blame] | 125 | extern struct hlr *g_hlr; |
| 126 | |
Stefan Sperling | f162252 | 2018-04-09 11:39:16 +0200 | [diff] [blame] | 127 | struct hlr_subscriber; |
| 128 | |
| 129 | void osmo_hlr_subscriber_update_notify(struct hlr_subscriber *subscr); |
Neels Hofmeyr | f13a8bc | 2019-11-20 02:36:45 +0100 | [diff] [blame] | 130 | int hlr_subscr_nam(struct hlr *hlr, struct hlr_subscriber *subscr, bool nam_val, bool is_ps); |