blob: f4362df62344ec4dfafcb00d1660a9dff28ab0a6 [file] [log] [blame]
Harald Welteec6915a2018-07-23 14:25:33 +02001/* GPRS Subscriber Update Protocol client */
2
3/* (C) 2014 by Sysmocom s.f.m.c. GmbH
4 * All Rights Reserved
5 *
6 * Author: Jacob Erlbeck
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#pragma once
23
24#include <osmocom/core/timer.h>
25#include <osmocom/gsm/oap_client.h>
26
27/* a loss of GSUP between MSC and HLR is considered quite serious, let's try to recover as quickly as
28 * possible. Even one new connection attempt per second should be quite acceptable until the link is
29 * re-established */
30#define GSUP_CLIENT_RECONNECT_INTERVAL 1
31#define GSUP_CLIENT_PING_INTERVAL 20
32
33struct msgb;
34struct ipa_client_conn;
35struct gsup_client;
36
37/* Expects message in msg->l2h */
38typedef int (*gsup_client_read_cb_t)(struct gsup_client *gsupc,
39 struct msgb *msg);
40
41struct gsup_client {
42 const char *unit_name;
43
44 struct ipa_client_conn *link;
45 gsup_client_read_cb_t read_cb;
46 void *data;
47
48 struct osmo_oap_client_state oap_state;
49
50 struct osmo_timer_list ping_timer;
51 struct osmo_timer_list connect_timer;
52 int is_connected;
53 int got_ipa_pong;
54};
55
56struct gsup_client *gsup_client_create(void *talloc_ctx,
57 const char *unit_name,
58 const char *ip_addr,
59 unsigned int tcp_port,
60 gsup_client_read_cb_t read_cb,
61 struct osmo_oap_client_config *oapc_config);
62
63void gsup_client_destroy(struct gsup_client *gsupc);
64int gsup_client_send(struct gsup_client *gsupc, struct msgb *msg);
65struct msgb *gsup_client_msgb_alloc(void);
66