Harald Welte | ec6915a | 2018-07-23 14:25:33 +0200 | [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 | |
| 24 | #include <osmocom/core/timer.h> |
| 25 | #include <osmocom/gsm/oap_client.h> |
| 26 | |
| 27 | /* a loss of GSUP between MSC and HLR is considered quite serious, let's try to recover as quickly as |
| 28 | * possible. Even one new connection attempt per second should be quite acceptable until the link is |
| 29 | * re-established */ |
Harald Welte | 953d27c | 2018-07-23 11:11:22 +0200 | [diff] [blame^] | 30 | #define OSMO_GSUP_CLIENT_RECONNECT_INTERVAL 1 |
| 31 | #define OSMO_GSUP_CLIENT_PING_INTERVAL 20 |
Harald Welte | ec6915a | 2018-07-23 14:25:33 +0200 | [diff] [blame] | 32 | |
| 33 | struct msgb; |
| 34 | struct ipa_client_conn; |
Harald Welte | 953d27c | 2018-07-23 11:11:22 +0200 | [diff] [blame^] | 35 | struct osmo_gsup_client; |
Harald Welte | ec6915a | 2018-07-23 14:25:33 +0200 | [diff] [blame] | 36 | |
| 37 | /* Expects message in msg->l2h */ |
Harald Welte | 953d27c | 2018-07-23 11:11:22 +0200 | [diff] [blame^] | 38 | typedef int (*osmo_gsup_client_read_cb_t)(struct osmo_gsup_client *gsupc, struct msgb *msg); |
Harald Welte | ec6915a | 2018-07-23 14:25:33 +0200 | [diff] [blame] | 39 | |
Harald Welte | 953d27c | 2018-07-23 11:11:22 +0200 | [diff] [blame^] | 40 | struct osmo_gsup_client { |
Harald Welte | ec6915a | 2018-07-23 14:25:33 +0200 | [diff] [blame] | 41 | const char *unit_name; |
| 42 | |
| 43 | struct ipa_client_conn *link; |
Harald Welte | 953d27c | 2018-07-23 11:11:22 +0200 | [diff] [blame^] | 44 | osmo_gsup_client_read_cb_t read_cb; |
Harald Welte | ec6915a | 2018-07-23 14:25:33 +0200 | [diff] [blame] | 45 | void *data; |
| 46 | |
| 47 | struct osmo_oap_client_state oap_state; |
| 48 | |
| 49 | struct osmo_timer_list ping_timer; |
| 50 | struct osmo_timer_list connect_timer; |
| 51 | int is_connected; |
| 52 | int got_ipa_pong; |
| 53 | }; |
| 54 | |
Harald Welte | 953d27c | 2018-07-23 11:11:22 +0200 | [diff] [blame^] | 55 | struct osmo_gsup_client *osmo_gsup_client_create(void *talloc_ctx, |
| 56 | const char *unit_name, |
| 57 | const char *ip_addr, |
| 58 | unsigned int tcp_port, |
| 59 | osmo_gsup_client_read_cb_t read_cb, |
| 60 | struct osmo_oap_client_config *oapc_config); |
Harald Welte | ec6915a | 2018-07-23 14:25:33 +0200 | [diff] [blame] | 61 | |
Harald Welte | 953d27c | 2018-07-23 11:11:22 +0200 | [diff] [blame^] | 62 | void osmo_gsup_client_destroy(struct osmo_gsup_client *gsupc); |
| 63 | int osmo_gsup_client_send(struct osmo_gsup_client *gsupc, struct msgb *msg); |
| 64 | struct msgb *osmo_gsup_client_msgb_alloc(void); |
Harald Welte | ec6915a | 2018-07-23 14:25:33 +0200 | [diff] [blame] | 65 | |