Harald Welte | e72cf55 | 2016-04-28 07:18:49 +0200 | [diff] [blame] | 1 | #pragma once |
| 2 | |
| 3 | #include <osmocom/core/linuxlist.h> |
| 4 | #include <osmocom/core/msgb.h> |
| 5 | #include <osmocom/abis/ipa.h> |
| 6 | #include <osmocom/abis/ipaccess.h> |
Stefan Sperling | 93c5b10 | 2018-04-10 19:26:14 +0200 | [diff] [blame] | 7 | #include <osmocom/gsm/gsup.h> |
Neels Hofmeyr | 008ce4b | 2019-12-04 01:04:32 +0100 | [diff] [blame] | 8 | #include <osmocom/gsupclient/gsup_peer_id.h> |
Neels Hofmeyr | f13a8bc | 2019-11-20 02:36:45 +0100 | [diff] [blame] | 9 | #include <osmocom/gsupclient/gsup_req.h> |
Harald Welte | e72cf55 | 2016-04-28 07:18:49 +0200 | [diff] [blame] | 10 | |
Stefan Sperling | f83432c | 2018-05-03 14:26:59 +0200 | [diff] [blame] | 11 | #ifndef OSMO_GSUP_MAX_CALLED_PARTY_BCD_LEN |
| 12 | #define OSMO_GSUP_MAX_CALLED_PARTY_BCD_LEN 43 /* TS 24.008 10.5.4.7 */ |
| 13 | #endif |
| 14 | |
Harald Welte | e72cf55 | 2016-04-28 07:18:49 +0200 | [diff] [blame] | 15 | struct osmo_gsup_conn; |
| 16 | |
| 17 | /* Expects message in msg->l2h */ |
| 18 | typedef int (*osmo_gsup_read_cb_t)(struct osmo_gsup_conn *conn, struct msgb *msg); |
| 19 | |
| 20 | struct osmo_gsup_server { |
Harald Welte | 32acace | 2018-06-16 17:07:28 +0200 | [diff] [blame] | 21 | /* private data of the application/user */ |
| 22 | void *priv; |
| 23 | |
Harald Welte | e72cf55 | 2016-04-28 07:18:49 +0200 | [diff] [blame] | 24 | /* list of osmo_gsup_conn */ |
| 25 | struct llist_head clients; |
| 26 | |
| 27 | struct ipa_server_link *link; |
| 28 | osmo_gsup_read_cb_t read_cb; |
Harald Welte | e687be5 | 2016-05-03 18:49:27 +0200 | [diff] [blame] | 29 | struct llist_head routes; |
Harald Welte | e72cf55 | 2016-04-28 07:18:49 +0200 | [diff] [blame] | 30 | }; |
| 31 | |
| 32 | |
| 33 | /* a single connection to a given client (SGSN, MSC) */ |
| 34 | struct osmo_gsup_conn { |
| 35 | struct llist_head list; |
| 36 | |
| 37 | struct osmo_gsup_server *server; |
| 38 | struct ipa_server_conn *conn; |
| 39 | //struct oap_state oap_state; |
Harald Welte | e687be5 | 2016-05-03 18:49:27 +0200 | [diff] [blame] | 40 | struct tlv_parsed ccm; |
Neels Hofmeyr | cab2fcd | 2017-03-15 00:07:43 +0100 | [diff] [blame] | 41 | |
| 42 | unsigned int auc_3g_ind; /*!< IND index used for UMTS AKA SQN */ |
Stefan Sperling | 93c5b10 | 2018-04-10 19:26:14 +0200 | [diff] [blame] | 43 | |
| 44 | /* Set when Location Update is received: */ |
| 45 | bool supports_cs; /* client supports OSMO_GSUP_CN_DOMAIN_CS */ |
| 46 | bool supports_ps; /* client supports OSMO_GSUP_CN_DOMAIN_PS */ |
Neels Hofmeyr | f13a8bc | 2019-11-20 02:36:45 +0100 | [diff] [blame] | 47 | |
| 48 | /* The IPA unit name received on this link. Routes with more unit names serviced by this link may exist in |
| 49 | * osmo_gsup_server->routes, but this is the name the immediate peer identified as in the IPA handshake. */ |
| 50 | struct osmo_ipa_name peer_name; |
Harald Welte | e72cf55 | 2016-04-28 07:18:49 +0200 | [diff] [blame] | 51 | }; |
| 52 | |
Neels Hofmeyr | a7d0f87 | 2019-10-30 02:08:28 +0100 | [diff] [blame] | 53 | struct msgb *osmo_gsup_msgb_alloc(const char *label); |
Harald Welte | e72cf55 | 2016-04-28 07:18:49 +0200 | [diff] [blame] | 54 | |
Neels Hofmeyr | f13a8bc | 2019-11-20 02:36:45 +0100 | [diff] [blame] | 55 | struct osmo_gsup_req *osmo_gsup_conn_rx(struct osmo_gsup_conn *conn, struct msgb *msg); |
Harald Welte | e72cf55 | 2016-04-28 07:18:49 +0200 | [diff] [blame] | 56 | int osmo_gsup_conn_send(struct osmo_gsup_conn *conn, struct msgb *msg); |
Neels Hofmeyr | 6eed322 | 2016-12-11 01:21:49 +0100 | [diff] [blame] | 57 | int osmo_gsup_conn_ccm_get(const struct osmo_gsup_conn *clnt, uint8_t **addr, |
| 58 | uint8_t tag); |
Harald Welte | e72cf55 | 2016-04-28 07:18:49 +0200 | [diff] [blame] | 59 | |
| 60 | struct osmo_gsup_server *osmo_gsup_server_create(void *ctx, |
Max | 9cacb6f | 2017-02-20 17:22:56 +0100 | [diff] [blame] | 61 | const char *ip_addr, |
| 62 | uint16_t tcp_port, |
| 63 | osmo_gsup_read_cb_t read_cb, |
Harald Welte | 32acace | 2018-06-16 17:07:28 +0200 | [diff] [blame] | 64 | void *priv); |
Harald Welte | e72cf55 | 2016-04-28 07:18:49 +0200 | [diff] [blame] | 65 | |
| 66 | void osmo_gsup_server_destroy(struct osmo_gsup_server *gsups); |
| 67 | |
Neels Hofmeyr | 1b8a1dc | 2018-05-04 16:46:47 +0200 | [diff] [blame] | 68 | int osmo_gsup_configure_wildcard_apn(struct osmo_gsup_message *gsup, |
| 69 | uint8_t *apn_buf, size_t apn_buf_size); |
Stefan Sperling | f83432c | 2018-05-03 14:26:59 +0200 | [diff] [blame] | 70 | int osmo_gsup_create_insert_subscriber_data_msg(struct osmo_gsup_message *gsup, const char *imsi, const char *msisdn, |
| 71 | uint8_t *msisdn_enc, size_t msisdn_enc_size, |
| 72 | uint8_t *apn_buf, size_t apn_buf_size, |
| 73 | enum osmo_gsup_cn_domain cn_domain); |