Holger Hans Peter Freyther | 3e8e046 | 2010-09-15 22:29:25 +0800 | [diff] [blame] | 1 | /* |
| 2 | * Data for the true BSC |
| 3 | * |
Holger Hans Peter Freyther | 32dd2f3 | 2015-04-01 18:15:48 +0200 | [diff] [blame] | 4 | * (C) 2010-2015 by Holger Hans Peter Freyther <zecke@selfish.org> |
| 5 | * (C) 2010-2015 by On-Waves |
Holger Hans Peter Freyther | 3e8e046 | 2010-09-15 22:29:25 +0800 | [diff] [blame] | 6 | * All Rights Reserved |
| 7 | * |
| 8 | * This program is free software; you can redistribute it and/or modify |
Harald Welte | 9af6ddf | 2011-01-01 15:25:50 +0100 | [diff] [blame] | 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 |
Holger Hans Peter Freyther | 3e8e046 | 2010-09-15 22:29:25 +0800 | [diff] [blame] | 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 |
Harald Welte | 9af6ddf | 2011-01-01 15:25:50 +0100 | [diff] [blame] | 16 | * GNU Affero General Public License for more details. |
Holger Hans Peter Freyther | 3e8e046 | 2010-09-15 22:29:25 +0800 | [diff] [blame] | 17 | * |
Harald Welte | 9af6ddf | 2011-01-01 15:25:50 +0100 | [diff] [blame] | 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/>. |
Holger Hans Peter Freyther | 3e8e046 | 2010-09-15 22:29:25 +0800 | [diff] [blame] | 20 | * |
| 21 | */ |
| 22 | |
Neels Hofmeyr | 9762b4c | 2017-02-23 21:41:20 +0100 | [diff] [blame] | 23 | /* |
| 24 | * NOTE: This is about a *remote* MSC for OsmoBSC and is not part of libmsc. |
| 25 | */ |
| 26 | |
Holger Hans Peter Freyther | 3e8e046 | 2010-09-15 22:29:25 +0800 | [diff] [blame] | 27 | #ifndef _OSMO_MSC_DATA_H |
| 28 | #define _OSMO_MSC_DATA_H |
| 29 | |
| 30 | #include "bsc_msc.h" |
| 31 | |
Pablo Neira Ayuso | 136f453 | 2011-03-22 16:47:59 +0100 | [diff] [blame] | 32 | #include <osmocom/core/timer.h> |
Holger Hans Peter Freyther | 25aa749 | 2011-08-06 07:00:52 +0200 | [diff] [blame] | 33 | #include <osmocom/gsm/protocol/gsm_04_08.h> |
Holger Hans Peter Freyther | 5832b3e | 2010-09-16 02:14:41 +0800 | [diff] [blame] | 34 | |
Philipp Maier | efe85d3 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 35 | |
| 36 | #include <osmocom/sigtran/osmo_ss7.h> |
| 37 | #include <osmocom/sigtran/sccp_sap.h> |
| 38 | #include <osmocom/sigtran/sccp_helpers.h> |
| 39 | #include <osmocom/sigtran/protocol/sua.h> |
| 40 | #include <osmocom/sigtran/protocol/m3ua.h> |
| 41 | #include <osmocom/core/fsm.h> |
| 42 | |
Holger Hans Peter Freyther | 83d2d38 | 2011-06-09 17:37:04 +0200 | [diff] [blame] | 43 | #include <regex.h> |
| 44 | |
Holger Hans Peter Freyther | 9a8b5ae | 2010-09-15 23:53:54 +0800 | [diff] [blame] | 45 | struct osmo_bsc_rf; |
Holger Hans Peter Freyther | 620c2e6 | 2010-11-14 20:38:06 +0100 | [diff] [blame] | 46 | struct gsm_network; |
Holger Hans Peter Freyther | 9a8b5ae | 2010-09-15 23:53:54 +0800 | [diff] [blame] | 47 | |
Holger Hans Peter Freyther | 7bf66c5 | 2010-11-03 13:55:49 +0100 | [diff] [blame] | 48 | struct gsm_audio_support { |
Holger Hans Peter Freyther | 620c2e6 | 2010-11-14 20:38:06 +0100 | [diff] [blame] | 49 | uint8_t hr : 1, |
| 50 | ver : 7; |
Holger Hans Peter Freyther | 7bf66c5 | 2010-11-03 13:55:49 +0100 | [diff] [blame] | 51 | }; |
| 52 | |
Holger Hans Peter Freyther | 210565e | 2011-06-07 20:56:18 +0200 | [diff] [blame] | 53 | enum { |
| 54 | MSC_CON_TYPE_NORMAL, |
| 55 | MSC_CON_TYPE_LOCAL, |
| 56 | }; |
| 57 | |
Neels Hofmeyr | 9762b4c | 2017-02-23 21:41:20 +0100 | [diff] [blame] | 58 | /*! /brief Information on a remote MSC for libbsc. |
| 59 | */ |
Neels Hofmeyr | a369e24 | 2017-02-23 21:57:23 +0100 | [diff] [blame] | 60 | struct bsc_msc_data { |
Holger Hans Peter Freyther | 20fea24 | 2011-06-04 19:58:26 +0200 | [diff] [blame] | 61 | struct llist_head entry; |
| 62 | |
Daniel Willmann | 163f612 | 2011-03-03 13:48:28 +0100 | [diff] [blame] | 63 | /* Back pointer */ |
| 64 | struct gsm_network *network; |
| 65 | |
Holger Hans Peter Freyther | 18fa70a | 2011-06-08 19:25:38 +0200 | [diff] [blame] | 66 | int allow_emerg; |
Holger Hans Peter Freyther | 210565e | 2011-06-07 20:56:18 +0200 | [diff] [blame] | 67 | int type; |
| 68 | |
Holger Hans Peter Freyther | 83d2d38 | 2011-06-09 17:37:04 +0200 | [diff] [blame] | 69 | /* local call routing */ |
| 70 | char *local_pref; |
| 71 | regex_t local_pref_reg; |
| 72 | |
| 73 | |
Holger Hans Peter Freyther | 47b2601 | 2010-09-15 23:28:49 +0800 | [diff] [blame] | 74 | /* Connection data */ |
| 75 | char *bsc_token; |
Holger Hans Peter Freyther | e2ac6b7 | 2015-06-08 18:02:10 +0200 | [diff] [blame] | 76 | uint8_t bsc_key[16]; |
| 77 | uint8_t bsc_key_present; |
| 78 | |
Holger Hans Peter Freyther | 47b2601 | 2010-09-15 23:28:49 +0800 | [diff] [blame] | 79 | int ping_timeout; |
| 80 | int pong_timeout; |
Pablo Neira Ayuso | bf540cb | 2011-05-06 12:11:06 +0200 | [diff] [blame] | 81 | struct osmo_timer_list ping_timer; |
| 82 | struct osmo_timer_list pong_timer; |
Holger Hans Peter Freyther | 56cb729 | 2014-09-02 17:28:40 +0200 | [diff] [blame] | 83 | int advanced_ping; |
Holger Hans Peter Freyther | 3e8e046 | 2010-09-15 22:29:25 +0800 | [diff] [blame] | 84 | struct bsc_msc_connection *msc_con; |
Holger Hans Peter Freyther | 1e36547 | 2015-07-13 11:06:10 +0200 | [diff] [blame] | 85 | int core_mnc; |
Holger Hans Peter Freyther | 2a8675e | 2010-11-05 19:43:07 +0100 | [diff] [blame] | 86 | int core_mcc; |
Holger Hans Peter Freyther | 32dd2f3 | 2015-04-01 18:15:48 +0200 | [diff] [blame] | 87 | int core_lac; |
| 88 | int core_ci; |
Holger Hans Peter Freyther | fe16622 | 2010-11-03 13:32:48 +0100 | [diff] [blame] | 89 | int rtp_base; |
Holger Hans Peter Freyther | 47b2601 | 2010-09-15 23:28:49 +0800 | [diff] [blame] | 90 | |
Holger Hans Peter Freyther | 7bf66c5 | 2010-11-03 13:55:49 +0100 | [diff] [blame] | 91 | /* audio codecs */ |
Holger Hans Peter Freyther | 25aa749 | 2011-08-06 07:00:52 +0200 | [diff] [blame] | 92 | struct gsm48_multi_rate_conf amr_conf; |
Holger Hans Peter Freyther | 7bf66c5 | 2010-11-03 13:55:49 +0100 | [diff] [blame] | 93 | struct gsm_audio_support **audio_support; |
| 94 | int audio_length; |
| 95 | |
Holger Hans Peter Freyther | e188010 | 2011-04-23 23:31:31 +0200 | [diff] [blame] | 96 | /* destinations */ |
| 97 | struct llist_head dests; |
| 98 | |
Holger Hans Peter Freyther | 8ec4952 | 2011-08-15 15:53:00 +0200 | [diff] [blame] | 99 | /* ussd welcome text */ |
| 100 | char *ussd_welcome_txt; |
Holger Hans Peter Freyther | 7bf66c5 | 2010-11-03 13:55:49 +0100 | [diff] [blame] | 101 | |
Holger Hans Peter Freyther | 5832b3e | 2010-09-16 02:14:41 +0800 | [diff] [blame] | 102 | /* mgcp agent */ |
Pablo Neira Ayuso | e1273b1 | 2011-05-06 12:09:47 +0200 | [diff] [blame] | 103 | struct osmo_wqueue mgcp_agent; |
Holger Hans Peter Freyther | 20fea24 | 2011-06-04 19:58:26 +0200 | [diff] [blame] | 104 | |
| 105 | int nr; |
Jacob Erlbeck | 1b89402 | 2013-08-28 10:16:54 +0200 | [diff] [blame] | 106 | |
| 107 | /* ussd msc connection lost text */ |
| 108 | char *ussd_msc_lost_txt; |
Jacob Erlbeck | 56595f8 | 2013-09-11 10:46:55 +0200 | [diff] [blame] | 109 | |
| 110 | /* ussd text when MSC has entered the grace period */ |
| 111 | char *ussd_grace_txt; |
Holger Hans Peter Freyther | d633280 | 2015-04-05 19:46:20 +0200 | [diff] [blame] | 112 | |
| 113 | char *acc_lst_name; |
Philipp Maier | efe85d3 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 114 | |
| 115 | /* Sigtran connection data */ |
| 116 | struct { |
| 117 | uint32_t cs7_instance; |
| 118 | bool cs7_instance_valid; |
| 119 | struct osmo_sccp_instance *sccp; |
| 120 | struct osmo_sccp_user *sccp_user; |
| 121 | |
| 122 | /* Holds a copy of the our local MSC address, |
| 123 | * this will be the sccp-address that is associated |
| 124 | * with the A interface of this particular BSC, |
| 125 | * this address is filled up by the VTY interface */ |
| 126 | struct osmo_sccp_addr bsc_addr; |
| 127 | char *bsc_addr_name; |
| 128 | |
| 129 | /* Holds a copy of the MSC address. This is the |
| 130 | * address of the MSC that handles the calls of |
| 131 | * this BSC. The address is configured via the |
| 132 | * VTY interface */ |
| 133 | struct osmo_sccp_addr msc_addr; |
| 134 | char *msc_addr_name; |
| 135 | |
| 136 | struct a_reset_ctx *reset; |
| 137 | } a; |
Holger Hans Peter Freyther | 8ec4952 | 2011-08-15 15:53:00 +0200 | [diff] [blame] | 138 | }; |
| 139 | |
| 140 | /* |
| 141 | * Per BSC data. |
| 142 | */ |
| 143 | struct osmo_bsc_data { |
| 144 | struct gsm_network *network; |
| 145 | |
| 146 | /* msc configuration */ |
Holger Hans Peter Freyther | 20fea24 | 2011-06-04 19:58:26 +0200 | [diff] [blame] | 147 | struct llist_head mscs; |
Holger Hans Peter Freyther | 5832b3e | 2010-09-16 02:14:41 +0800 | [diff] [blame] | 148 | |
Holger Hans Peter Freyther | 47b2601 | 2010-09-15 23:28:49 +0800 | [diff] [blame] | 149 | /* rf ctl related bits */ |
Holger Hans Peter Freyther | bb62b3f | 2010-11-22 18:30:21 +0100 | [diff] [blame] | 150 | char *mid_call_txt; |
| 151 | int mid_call_timeout; |
Holger Hans Peter Freyther | 55ef5fb | 2011-04-07 23:23:27 +0200 | [diff] [blame] | 152 | char *rf_ctrl_name; |
Holger Hans Peter Freyther | 5e3bbba | 2011-06-04 09:32:35 +0200 | [diff] [blame] | 153 | struct osmo_bsc_rf *rf_ctrl; |
Holger Hans Peter Freyther | 2a89607 | 2011-08-16 19:47:39 +0200 | [diff] [blame] | 154 | int auto_off_timeout; |
Jacob Erlbeck | 56595f8 | 2013-09-11 10:46:55 +0200 | [diff] [blame] | 155 | |
| 156 | /* ussd text when there is no MSC available */ |
| 157 | char *ussd_no_msc_txt; |
Holger Hans Peter Freyther | d633280 | 2015-04-05 19:46:20 +0200 | [diff] [blame] | 158 | |
| 159 | char *acc_lst_name; |
Holger Hans Peter Freyther | 3e8e046 | 2010-09-15 22:29:25 +0800 | [diff] [blame] | 160 | }; |
| 161 | |
Holger Hans Peter Freyther | 8ec4952 | 2011-08-15 15:53:00 +0200 | [diff] [blame] | 162 | |
Neels Hofmeyr | a369e24 | 2017-02-23 21:57:23 +0100 | [diff] [blame] | 163 | int osmo_bsc_msc_init(struct bsc_msc_data *msc); |
Holger Hans Peter Freyther | f3d1ae7 | 2010-11-03 16:40:03 +0100 | [diff] [blame] | 164 | int osmo_bsc_sccp_init(struct gsm_network *gsmnet); |
Holger Hans Peter Freyther | 6098038 | 2010-09-16 02:22:20 +0800 | [diff] [blame] | 165 | int msc_queue_write(struct bsc_msc_connection *conn, struct msgb *msg, int proto); |
Holger Hans Peter Freyther | 56cb729 | 2014-09-02 17:28:40 +0200 | [diff] [blame] | 166 | int msc_queue_write_with_ping(struct bsc_msc_connection *, struct msgb *msg, int proto); |
Holger Hans Peter Freyther | 5832b3e | 2010-09-16 02:14:41 +0800 | [diff] [blame] | 167 | |
Holger Hans Peter Freyther | 620c2e6 | 2010-11-14 20:38:06 +0100 | [diff] [blame] | 168 | int osmo_bsc_audio_init(struct gsm_network *network); |
| 169 | |
Neels Hofmeyr | a369e24 | 2017-02-23 21:57:23 +0100 | [diff] [blame] | 170 | struct bsc_msc_data *osmo_msc_data_find(struct gsm_network *, int); |
| 171 | struct bsc_msc_data *osmo_msc_data_alloc(struct gsm_network *, int); |
Holger Hans Peter Freyther | 20fea24 | 2011-06-04 19:58:26 +0200 | [diff] [blame] | 172 | |
| 173 | |
Holger Hans Peter Freyther | 3e8e046 | 2010-09-15 22:29:25 +0800 | [diff] [blame] | 174 | #endif |