blob: 76f3da659140623edabc1f39929454d445925d1a [file] [log] [blame]
Harald Welte77911b02018-08-14 23:47:30 +02001/* Remote SIM Protocol client */
2
3/* (C) 2018 by Harald Welte <laforge@gnumonks.org>
4 * All Rights Reserved
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU 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 General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 *
19 */
20#pragma once
21
22#include <osmocom/core/timer.h>
23
24/* a loss of RSPRO is considered quite serious, let's try to recover as quickly as
25 * possible. Even one new connection attempt per second should be quite acceptable until the link is
26 * re-established */
27#define OSMO_RSPRO_CLIENT_RECONNECT_INTERVAL 1
28#define OSMO_RSPRO_CLIENT_PING_INTERVAL 20
29
30struct msgb;
31struct ipa_client_conn;
32struct osmo_rspro_client;
33
34/* Expects message in msg->l2h */
35typedef int (*osmo_rspro_client_read_cb_t)(struct osmo_rspro_client *rsproc, struct msgb *msg);
36
37struct osmo_rspro_client {
38 const char *unit_name;
39
40 struct ipa_client_conn *link;
41 osmo_rspro_client_read_cb_t read_cb;
42 void *data;
43
44 struct osmo_timer_list ping_timer;
45 struct osmo_timer_list connect_timer;
46 int is_connected;
47 int got_ipa_pong;
48};
49
50struct osmo_rspro_client *osmo_rspro_client_create(void *talloc_ctx,
51 const char *unit_name,
52 const char *ip_addr,
53 unsigned int tcp_port,
54 osmo_rspro_client_read_cb_t read_cb);
55
56void osmo_rspro_client_destroy(struct osmo_rspro_client *rsproc);
57int osmo_rspro_client_send(struct osmo_rspro_client *rsproc, struct msgb *msg);
58struct msgb *osmo_rspro_client_msgb_alloc(void);
59