blob: 9133e1b6b0d6b1f9f79d326844ead803ff63d19b [file] [log] [blame]
Philipp Maierfbf66102017-04-09 12:32:51 +02001/* (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 Hofmeyr90843962017-09-04 15:04:35 +020023#include <osmocom/msc/a_reset.h>
Max43b01b02017-09-15 11:22:30 +020024#include <osmocom/msc/transaction.h>
Harald Welte6de46592018-02-09 00:53:17 +010025#include <osmocom/msc/vlr.h>
Neels Hofmeyr703638e2017-12-14 05:30:16 +010026#include <osmocom/gsm/protocol/gsm_08_08.h>
Philipp Maierfbf66102017-04-09 12:32:51 +020027
Harald Welte6de46592018-02-09 00:53:17 +010028#define LOGPCONN(conn, level, fmt, args...) \
29 LOGP(DMSC, level, "(subscr %s, conn_id %d) " fmt, \
30 vlr_subscr_name(conn ? conn->vsub : NULL), conn ? conn->a.conn_id : -1, \
31 ## args)
32
33#define LOGPBSCCONN(conn, level, fmt, args...) \
34 LOGP(DMSC, level, "(conn_id %u) " fmt, conn ? conn->conn_id : (uint32_t)(-1), ## args)
35
Philipp Maierfbf66102017-04-09 12:32:51 +020036/* A struct to keep a context information about the BSCs we are associated with */
37struct 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. */
54 struct a_reset_ctx *reset;
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 */
63int a_init(struct osmo_sccp_instance *sccp, struct gsm_network *network);
64
Philipp Maier4502f5f2017-09-07 11:39:58 +020065/* Send DTAP message via A-interface, take ownership of msg */
Philipp Maierfbf66102017-04-09 12:32:51 +020066int a_iface_tx_dtap(struct msgb *msg);
67
68/* Send Cipher mode command via A-interface */
69int a_iface_tx_cipher_mode(const struct gsm_subscriber_connection *conn,
Neels Hofmeyr703638e2017-12-14 05:30:16 +010070 struct gsm0808_encrypt_info *ei, int include_imeisv);
Philipp Maierfbf66102017-04-09 12:32:51 +020071
72/* Page a subscriber via A-interface */
73int a_iface_tx_paging(const char *imsi, uint32_t tmsi, uint16_t lac);
74
75/* Send assignment request via A-interface */
76int a_iface_tx_assignment(const struct gsm_trans *trans);
77
78/* Send clear command via A-interface */
79int a_iface_tx_clear_cmd(struct gsm_subscriber_connection *conn);
80
81/* Clear all subscriber connections on a specified BSC
82 * (Helper function for a_iface_bssap.c) */
83void a_clear_all(struct osmo_sccp_user *scu, const struct osmo_sccp_addr *bsc_addr);
84
Harald Welte54a10ef2018-02-09 00:09:16 +010085void a_start_reset(struct bsc_context *bsc_ctx, bool already_connected);
86
Philipp Maierfbf66102017-04-09 12:32:51 +020087/* Delete info of a closed connection from the active connection list
88 * (Helper function for a_iface_bssap.c) */
89void a_delete_bsc_con(uint32_t conn_id);