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