blob: 59e650f63eb0f110992282e7aa9c136db76d5f0a [file] [log] [blame]
Jacob Erlbeckbb23dc12014-12-18 12:28:21 +01001/* 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
Jacob Erlbeck849d0a82014-12-18 15:00:29 +010024#include <osmocom/core/timer.h>
25
Neels Hofmeyr90843962017-09-04 15:04:35 +020026#include <osmocom/msc/oap_client.h>
Neels Hofmeyr9c534fd2015-10-12 11:57:37 +020027
Harald Welte327c2f52018-01-27 22:57:38 +010028/* a loss of GSUP between MSC and HLR is considered quite serious, let's try to recover as quickly as
29 * possible. Even one new connection attempt per second should be quite acceptable until the link is
30 * re-established */
31#define GSUP_CLIENT_RECONNECT_INTERVAL 1
Neels Hofmeyr814fef02016-12-08 21:19:57 +010032#define GSUP_CLIENT_PING_INTERVAL 20
Jacob Erlbeck849d0a82014-12-18 15:00:29 +010033
Jacob Erlbeckbb23dc12014-12-18 12:28:21 +010034struct msgb;
35struct ipa_client_conn;
Neels Hofmeyr814fef02016-12-08 21:19:57 +010036struct gsup_client;
Jacob Erlbeckbb23dc12014-12-18 12:28:21 +010037
38/* Expects message in msg->l2h */
Neels Hofmeyr814fef02016-12-08 21:19:57 +010039typedef int (*gsup_client_read_cb_t)(struct gsup_client *gsupc,
40 struct msgb *msg);
Jacob Erlbeckbb23dc12014-12-18 12:28:21 +010041
Neels Hofmeyr814fef02016-12-08 21:19:57 +010042struct gsup_client {
Neels Hofmeyrf2ba8132017-03-04 03:15:53 +010043 const char *unit_name;
44
Neels Hofmeyr814fef02016-12-08 21:19:57 +010045 struct ipa_client_conn *link;
46 gsup_client_read_cb_t read_cb;
47 void *data;
Jacob Erlbeck849d0a82014-12-18 15:00:29 +010048
Neels Hofmeyr49012f12016-12-08 21:30:34 +010049 struct oap_client_state oap_state;
Neels Hofmeyr9c534fd2015-10-12 11:57:37 +020050
Neels Hofmeyr814fef02016-12-08 21:19:57 +010051 struct osmo_timer_list ping_timer;
52 struct osmo_timer_list connect_timer;
53 int is_connected;
54 int got_ipa_pong;
Jacob Erlbeckbb23dc12014-12-18 12:28:21 +010055};
56
Neels Hofmeyrc01e9092018-03-22 15:56:49 +010057struct gsup_client *gsup_client_create(void *talloc_ctx,
58 const char *unit_name,
Neels Hofmeyrf2ba8132017-03-04 03:15:53 +010059 const char *ip_addr,
Neels Hofmeyr814fef02016-12-08 21:19:57 +010060 unsigned int tcp_port,
61 gsup_client_read_cb_t read_cb,
Neels Hofmeyrf2ba8132017-03-04 03:15:53 +010062 struct oap_client_config *oapc_config);
Jacob Erlbeckbb23dc12014-12-18 12:28:21 +010063
Neels Hofmeyr814fef02016-12-08 21:19:57 +010064void gsup_client_destroy(struct gsup_client *gsupc);
65int gsup_client_send(struct gsup_client *gsupc, struct msgb *msg);
66struct msgb *gsup_client_msgb_alloc(void);
Jacob Erlbeckbb23dc12014-12-18 12:28:21 +010067