blob: 6a4e8a14333a390305363399c936ca5f5130919e [file] [log] [blame]
Neels Hofmeyr647c1062019-11-20 03:35:37 +01001/* Copyright 2019 by sysmocom s.f.m.c. GmbH <info@sysmocom.de>
2 *
3 * All Rights Reserved
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU Affero General Public License as published by
7 * the Free Software Foundation; either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU Affero General Public License for more details.
14 *
15 * You should have received a copy of the GNU Affero General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 *
18 */
19
20#pragma once
21
22#include <stdbool.h>
23#include <osmocom/core/linuxlist.h>
24#include <osmocom/core/sockaddr_str.h>
25
26struct osmo_gsup_client;
27struct osmo_gsup_message;
28struct osmo_gsup_req;
29struct msgb;
30
31#define LOG_REMOTE_HLR(remote_hlr, level, fmt, args...) \
32 LOGP(DDGSM, level, "(Proxy HLR-" OSMO_SOCKADDR_STR_FMT ") " fmt, \
33 OSMO_SOCKADDR_STR_FMT_ARGS((remote_hlr) ? &(remote_hlr)->addr : NULL), ##args)
34
35#define LOG_REMOTE_HLR_MSG(remote_hlr, gsup_msg, level, fmt, args...) \
36 LOG_REMOTE_HLR(remote_hlr, level, "%s: " fmt, osmo_gsup_message_type_name((gsup_msg)->message_type), ##args)
37
38/* GSUP client link for proxying to a remote HLR. */
39struct remote_hlr {
40 struct llist_head entry;
41 struct osmo_sockaddr_str addr;
42 struct osmo_gsup_client *gsupc;
43 struct llist_head pending_up_callbacks;
44};
45
46/*! Receive a remote_hlr address when connecting succeeded, or remote_hlr == NULL on error.
47 * \param addr GSUP IP address and port for which the connection was requested.
48 * \param remote_hlr The connected remote_hlr ready for sending, or NULL if connecting failed.
49 * \param data Same a passed to remote_hlr_get_or_connect(). */
50typedef void (*remote_hlr_connect_result_cb_t)(const struct osmo_sockaddr_str *addr, struct remote_hlr *remote_hlr, void *data);
51
52struct remote_hlr *remote_hlr_get_or_connect(const struct osmo_sockaddr_str *addr, bool connect,
53 remote_hlr_connect_result_cb_t connect_result_cb, void *data);
54void remote_hlr_destroy(struct remote_hlr *remote_hlr);
55int remote_hlr_msgb_send(struct remote_hlr *remote_hlr, struct msgb *msg);
56void remote_hlr_gsup_forward_to_remote_hlr(struct remote_hlr *remote_hlr, struct osmo_gsup_req *req,
57 struct osmo_gsup_message *modified_gsup);
58
59bool remote_hlr_is_up(struct remote_hlr *remote_hlr);