blob: 981751bbbff5b5bd121378986516405ab9bc9a39 [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 */
Harald Welte953d27c2018-07-23 11:11:22 +020030#define OSMO_GSUP_CLIENT_RECONNECT_INTERVAL 1
31#define OSMO_GSUP_CLIENT_PING_INTERVAL 20
Harald Welteec6915a2018-07-23 14:25:33 +020032
33struct msgb;
34struct ipa_client_conn;
Harald Welte953d27c2018-07-23 11:11:22 +020035struct osmo_gsup_client;
Harald Welteec6915a2018-07-23 14:25:33 +020036
37/* Expects message in msg->l2h */
Harald Welte953d27c2018-07-23 11:11:22 +020038typedef int (*osmo_gsup_client_read_cb_t)(struct osmo_gsup_client *gsupc, struct msgb *msg);
Harald Welteec6915a2018-07-23 14:25:33 +020039
Harald Welte953d27c2018-07-23 11:11:22 +020040struct osmo_gsup_client {
Harald Welteec6915a2018-07-23 14:25:33 +020041 const char *unit_name;
42
43 struct ipa_client_conn *link;
Harald Welte953d27c2018-07-23 11:11:22 +020044 osmo_gsup_client_read_cb_t read_cb;
Harald Welteec6915a2018-07-23 14:25:33 +020045 void *data;
46
47 struct osmo_oap_client_state oap_state;
48
49 struct osmo_timer_list ping_timer;
50 struct osmo_timer_list connect_timer;
51 int is_connected;
52 int got_ipa_pong;
53};
54
Harald Welte953d27c2018-07-23 11:11:22 +020055struct osmo_gsup_client *osmo_gsup_client_create(void *talloc_ctx,
56 const char *unit_name,
57 const char *ip_addr,
58 unsigned int tcp_port,
59 osmo_gsup_client_read_cb_t read_cb,
60 struct osmo_oap_client_config *oapc_config);
Harald Welteec6915a2018-07-23 14:25:33 +020061
Harald Welte953d27c2018-07-23 11:11:22 +020062void osmo_gsup_client_destroy(struct osmo_gsup_client *gsupc);
63int osmo_gsup_client_send(struct osmo_gsup_client *gsupc, struct msgb *msg);
64struct msgb *osmo_gsup_client_msgb_alloc(void);
Harald Welteec6915a2018-07-23 14:25:33 +020065