Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 1 | /* (C) 2017 by Sysmocom s.f.m.c. GmbH |
| 2 | * All Rights Reserved |
| 3 | * |
| 4 | * Author: 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 | |
Neels Hofmeyr | 9084396 | 2017-09-04 15:04:35 +0200 | [diff] [blame] | 23 | #include <osmocom/msc/a_reset.h> |
Max | 43b01b0 | 2017-09-15 11:22:30 +0200 | [diff] [blame] | 24 | #include <osmocom/msc/transaction.h> |
Harald Welte | 6de4659 | 2018-02-09 00:53:17 +0100 | [diff] [blame] | 25 | #include <osmocom/msc/vlr.h> |
Neels Hofmeyr | 703638e | 2017-12-14 05:30:16 +0100 | [diff] [blame] | 26 | #include <osmocom/gsm/protocol/gsm_08_08.h> |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 27 | |
Harald Welte | 6de4659 | 2018-02-09 00:53:17 +0100 | [diff] [blame] | 28 | #define LOGPCONN(conn, level, fmt, args...) \ |
Harald Welte | 1f47744 | 2018-02-09 01:49:01 +0100 | [diff] [blame] | 29 | LOGP(DBSSAP, level, "(subscr %s, conn_id %d) " fmt, \ |
Harald Welte | 6de4659 | 2018-02-09 00:53:17 +0100 | [diff] [blame] | 30 | vlr_subscr_name(conn ? conn->vsub : NULL), conn ? conn->a.conn_id : -1, \ |
| 31 | ## args) |
| 32 | |
| 33 | #define LOGPBSCCONN(conn, level, fmt, args...) \ |
Harald Welte | 1f47744 | 2018-02-09 01:49:01 +0100 | [diff] [blame] | 34 | LOGP(DBSSAP, level, "(conn_id %u) " fmt, conn ? conn->conn_id : (uint32_t)(-1), ## args) |
Harald Welte | 6de4659 | 2018-02-09 00:53:17 +0100 | [diff] [blame] | 35 | |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 36 | /* A struct to keep a context information about the BSCs we are associated with */ |
| 37 | struct bsc_context { |
| 38 | struct llist_head list; |
| 39 | |
| 40 | /* Holds a copy of the sccp address of the BSC, |
| 41 | * this address will become known as soon as |
| 42 | * a remote BSC tries to make a connection or |
| 43 | * sends a RESET request via UNIDATA */ |
| 44 | struct osmo_sccp_addr bsc_addr; |
| 45 | |
| 46 | /* Holds a copy of the our local MSC address, |
| 47 | * this will be the sccp-address that is associated |
| 48 | * with the A interface */ |
| 49 | struct osmo_sccp_addr msc_addr; |
| 50 | |
| 51 | /* A pointer to the reset handler FSM, the |
| 52 | * state machine is allocated when the BSC |
| 53 | * is registerd. */ |
Philipp Maier | f913e5f | 2018-05-07 10:15:49 +0200 | [diff] [blame] | 54 | struct osmo_fsm_inst *reset_fsm; |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 55 | |
| 56 | /* A pointer to the sccp_user that is associated |
| 57 | * with the A interface. We need this information |
| 58 | * to send the resets and to send paging requests */ |
| 59 | struct osmo_sccp_user *sccp_user; |
| 60 | }; |
| 61 | |
| 62 | /* Initalize A interface connection between to MSC and BSC */ |
| 63 | int a_init(struct osmo_sccp_instance *sccp, struct gsm_network *network); |
| 64 | |
Philipp Maier | 4502f5f | 2017-09-07 11:39:58 +0200 | [diff] [blame] | 65 | /* Send DTAP message via A-interface, take ownership of msg */ |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 66 | int a_iface_tx_dtap(struct msgb *msg); |
| 67 | |
| 68 | /* Send Cipher mode command via A-interface */ |
Neels Hofmeyr | c036b79 | 2018-11-29 22:37:51 +0100 | [diff] [blame] | 69 | int a_iface_tx_cipher_mode(const struct ran_conn *conn, |
Neels Hofmeyr | 703638e | 2017-12-14 05:30:16 +0100 | [diff] [blame] | 70 | struct gsm0808_encrypt_info *ei, int include_imeisv); |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 71 | |
| 72 | /* Page a subscriber via A-interface */ |
| 73 | int a_iface_tx_paging(const char *imsi, uint32_t tmsi, uint16_t lac); |
| 74 | |
| 75 | /* Send assignment request via A-interface */ |
| 76 | int a_iface_tx_assignment(const struct gsm_trans *trans); |
| 77 | |
| 78 | /* Send clear command via A-interface */ |
Neels Hofmeyr | c036b79 | 2018-11-29 22:37:51 +0100 | [diff] [blame] | 79 | int a_iface_tx_clear_cmd(struct ran_conn *conn); |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 80 | |
Neels Hofmeyr | c036b79 | 2018-11-29 22:37:51 +0100 | [diff] [blame] | 81 | int a_iface_tx_classmark_request(const struct ran_conn *conn); |
Neels Hofmeyr | 3117b70 | 2018-09-13 03:23:07 +0200 | [diff] [blame] | 82 | |
Neels Hofmeyr | c036b79 | 2018-11-29 22:37:51 +0100 | [diff] [blame] | 83 | /* Clear all RAN connections on a specified BSC |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 84 | * (Helper function for a_iface_bssap.c) */ |
| 85 | void a_clear_all(struct osmo_sccp_user *scu, const struct osmo_sccp_addr *bsc_addr); |
| 86 | |
Harald Welte | 54a10ef | 2018-02-09 00:09:16 +0100 | [diff] [blame] | 87 | void a_start_reset(struct bsc_context *bsc_ctx, bool already_connected); |
| 88 | |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 89 | /* Delete info of a closed connection from the active connection list |
| 90 | * (Helper function for a_iface_bssap.c) */ |
| 91 | void a_delete_bsc_con(uint32_t conn_id); |