Jacob Erlbeck | bb23dc1 | 2014-12-18 12:28:21 +0100 | [diff] [blame] | 1 | /* 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 Erlbeck | 849d0a8 | 2014-12-18 15:00:29 +0100 | [diff] [blame] | 24 | #include <osmocom/core/timer.h> |
| 25 | |
Neels Hofmeyr | 9084396 | 2017-09-04 15:04:35 +0200 | [diff] [blame] | 26 | #include <osmocom/msc/oap_client.h> |
Neels Hofmeyr | 9c534fd | 2015-10-12 11:57:37 +0200 | [diff] [blame] | 27 | |
Neels Hofmeyr | 814fef0 | 2016-12-08 21:19:57 +0100 | [diff] [blame] | 28 | #define GSUP_CLIENT_RECONNECT_INTERVAL 10 |
| 29 | #define GSUP_CLIENT_PING_INTERVAL 20 |
Jacob Erlbeck | 849d0a8 | 2014-12-18 15:00:29 +0100 | [diff] [blame] | 30 | |
Jacob Erlbeck | bb23dc1 | 2014-12-18 12:28:21 +0100 | [diff] [blame] | 31 | struct msgb; |
| 32 | struct ipa_client_conn; |
Neels Hofmeyr | 814fef0 | 2016-12-08 21:19:57 +0100 | [diff] [blame] | 33 | struct gsup_client; |
Jacob Erlbeck | bb23dc1 | 2014-12-18 12:28:21 +0100 | [diff] [blame] | 34 | |
| 35 | /* Expects message in msg->l2h */ |
Neels Hofmeyr | 814fef0 | 2016-12-08 21:19:57 +0100 | [diff] [blame] | 36 | typedef int (*gsup_client_read_cb_t)(struct gsup_client *gsupc, |
| 37 | struct msgb *msg); |
Jacob Erlbeck | bb23dc1 | 2014-12-18 12:28:21 +0100 | [diff] [blame] | 38 | |
Neels Hofmeyr | 814fef0 | 2016-12-08 21:19:57 +0100 | [diff] [blame] | 39 | struct gsup_client { |
Neels Hofmeyr | f2ba813 | 2017-03-04 03:15:53 +0100 | [diff] [blame] | 40 | const char *unit_name; |
| 41 | |
Neels Hofmeyr | 814fef0 | 2016-12-08 21:19:57 +0100 | [diff] [blame] | 42 | struct ipa_client_conn *link; |
| 43 | gsup_client_read_cb_t read_cb; |
| 44 | void *data; |
Jacob Erlbeck | 849d0a8 | 2014-12-18 15:00:29 +0100 | [diff] [blame] | 45 | |
Neels Hofmeyr | 49012f1 | 2016-12-08 21:30:34 +0100 | [diff] [blame] | 46 | struct oap_client_state oap_state; |
Neels Hofmeyr | 9c534fd | 2015-10-12 11:57:37 +0200 | [diff] [blame] | 47 | |
Neels Hofmeyr | 814fef0 | 2016-12-08 21:19:57 +0100 | [diff] [blame] | 48 | struct osmo_timer_list ping_timer; |
| 49 | struct osmo_timer_list connect_timer; |
| 50 | int is_connected; |
| 51 | int got_ipa_pong; |
Jacob Erlbeck | bb23dc1 | 2014-12-18 12:28:21 +0100 | [diff] [blame] | 52 | }; |
| 53 | |
Neels Hofmeyr | f2ba813 | 2017-03-04 03:15:53 +0100 | [diff] [blame] | 54 | struct gsup_client *gsup_client_create(const char *unit_name, |
| 55 | const char *ip_addr, |
Neels Hofmeyr | 814fef0 | 2016-12-08 21:19:57 +0100 | [diff] [blame] | 56 | unsigned int tcp_port, |
| 57 | gsup_client_read_cb_t read_cb, |
Neels Hofmeyr | f2ba813 | 2017-03-04 03:15:53 +0100 | [diff] [blame] | 58 | struct oap_client_config *oapc_config); |
Jacob Erlbeck | bb23dc1 | 2014-12-18 12:28:21 +0100 | [diff] [blame] | 59 | |
Neels Hofmeyr | 814fef0 | 2016-12-08 21:19:57 +0100 | [diff] [blame] | 60 | void gsup_client_destroy(struct gsup_client *gsupc); |
| 61 | int gsup_client_send(struct gsup_client *gsupc, struct msgb *msg); |
| 62 | struct msgb *gsup_client_msgb_alloc(void); |
Jacob Erlbeck | bb23dc1 | 2014-12-18 12:28:21 +0100 | [diff] [blame] | 63 | |