blob: a113225e1481c40d04f3f2074f67828c000c5661 [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 Hofmeyr11ecc932016-12-08 21:29:23 +010026#include <openbsc/oap_client.h>
Neels Hofmeyr9c534fd2015-10-12 11:57:37 +020027
Neels Hofmeyr814fef02016-12-08 21:19:57 +010028#define GSUP_CLIENT_RECONNECT_INTERVAL 10
29#define GSUP_CLIENT_PING_INTERVAL 20
Jacob Erlbeck849d0a82014-12-18 15:00:29 +010030
Jacob Erlbeckbb23dc12014-12-18 12:28:21 +010031struct msgb;
32struct ipa_client_conn;
Neels Hofmeyr814fef02016-12-08 21:19:57 +010033struct gsup_client;
Jacob Erlbeckbb23dc12014-12-18 12:28:21 +010034
35/* Expects message in msg->l2h */
Neels Hofmeyr814fef02016-12-08 21:19:57 +010036typedef int (*gsup_client_read_cb_t)(struct gsup_client *gsupc,
37 struct msgb *msg);
Jacob Erlbeckbb23dc12014-12-18 12:28:21 +010038
Neels Hofmeyr814fef02016-12-08 21:19:57 +010039struct gsup_client {
40 struct ipa_client_conn *link;
41 gsup_client_read_cb_t read_cb;
42 void *data;
Jacob Erlbeck849d0a82014-12-18 15:00:29 +010043
Neels Hofmeyr49012f12016-12-08 21:30:34 +010044 struct oap_client_state oap_state;
Neels Hofmeyr9c534fd2015-10-12 11:57:37 +020045
Neels Hofmeyr814fef02016-12-08 21:19:57 +010046 struct osmo_timer_list ping_timer;
47 struct osmo_timer_list connect_timer;
48 int is_connected;
49 int got_ipa_pong;
Jacob Erlbeckbb23dc12014-12-18 12:28:21 +010050};
51
Neels Hofmeyr814fef02016-12-08 21:19:57 +010052struct gsup_client *gsup_client_create(const char *ip_addr,
53 unsigned int tcp_port,
54 gsup_client_read_cb_t read_cb,
Neels Hofmeyr49012f12016-12-08 21:30:34 +010055 struct oap_client_config *oap_config);
Jacob Erlbeckbb23dc12014-12-18 12:28:21 +010056
Neels Hofmeyr814fef02016-12-08 21:19:57 +010057void gsup_client_destroy(struct gsup_client *gsupc);
58int gsup_client_send(struct gsup_client *gsupc, struct msgb *msg);
59struct msgb *gsup_client_msgb_alloc(void);
Jacob Erlbeckbb23dc12014-12-18 12:28:21 +010060