blob: 29092ad5b7eb0ff7b235f98c8688f8730774d596 [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 Hofmeyr396f2e62017-09-04 15:13:25 +020026#include <osmocom/sgsn/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 {
Neels Hofmeyr398851f2017-03-04 03:15:53 +010040 const char *unit_name;
41
Neels Hofmeyr814fef02016-12-08 21:19:57 +010042 struct ipa_client_conn *link;
43 gsup_client_read_cb_t read_cb;
44 void *data;
Jacob Erlbeck849d0a82014-12-18 15:00:29 +010045
Neels Hofmeyr49012f12016-12-08 21:30:34 +010046 struct oap_client_state oap_state;
Neels Hofmeyr9c534fd2015-10-12 11:57:37 +020047
Neels Hofmeyr814fef02016-12-08 21:19:57 +010048 struct osmo_timer_list ping_timer;
49 struct osmo_timer_list connect_timer;
50 int is_connected;
51 int got_ipa_pong;
Jacob Erlbeckbb23dc12014-12-18 12:28:21 +010052};
53
Neels Hofmeyr398851f2017-03-04 03:15:53 +010054struct gsup_client *gsup_client_create(const char *unit_name,
55 const char *ip_addr,
Neels Hofmeyr814fef02016-12-08 21:19:57 +010056 unsigned int tcp_port,
57 gsup_client_read_cb_t read_cb,
Neels Hofmeyr398851f2017-03-04 03:15:53 +010058 struct oap_client_config *oapc_config);
Jacob Erlbeckbb23dc12014-12-18 12:28:21 +010059
Neels Hofmeyr814fef02016-12-08 21:19:57 +010060void gsup_client_destroy(struct gsup_client *gsupc);
61int gsup_client_send(struct gsup_client *gsupc, struct msgb *msg);
62struct msgb *gsup_client_msgb_alloc(void);
Jacob Erlbeckbb23dc12014-12-18 12:28:21 +010063