blob: 22c9a10f7706fdb9eb30a0db9342600dd6494235 [file] [log] [blame]
Harald Weltee72cf552016-04-28 07:18:49 +02001#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 Sperling93c5b102018-04-10 19:26:14 +02007#include <osmocom/gsm/gsup.h>
Neels Hofmeyr0d28d852019-12-04 01:04:32 +01008#include <osmocom/gsupclient/gsup_peer_id.h>
Neels Hofmeyrb2553eb2019-11-20 02:36:45 +01009#include <osmocom/gsupclient/gsup_req.h>
Harald Weltee72cf552016-04-28 07:18:49 +020010
Stefan Sperlingf83432c2018-05-03 14:26:59 +020011#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 Weltee72cf552016-04-28 07:18:49 +020015struct osmo_gsup_conn;
16
17/* Expects message in msg->l2h */
18typedef int (*osmo_gsup_read_cb_t)(struct osmo_gsup_conn *conn, struct msgb *msg);
19
20struct osmo_gsup_server {
Harald Welte32acace2018-06-16 17:07:28 +020021 /* private data of the application/user */
22 void *priv;
23
Harald Weltee72cf552016-04-28 07:18:49 +020024 /* 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 Weltee687be52016-05-03 18:49:27 +020029 struct llist_head routes;
Neels Hofmeyr647c1062019-11-20 03:35:37 +010030
31 /* Proxy requests from this server's clients to remote GSUP servers. */
32 struct proxy *proxy;
Harald Weltee72cf552016-04-28 07:18:49 +020033};
34
35
36/* a single connection to a given client (SGSN, MSC) */
37struct osmo_gsup_conn {
38 struct llist_head list;
39
40 struct osmo_gsup_server *server;
41 struct ipa_server_conn *conn;
42 //struct oap_state oap_state;
Harald Weltee687be52016-05-03 18:49:27 +020043 struct tlv_parsed ccm;
Neels Hofmeyrcab2fcd2017-03-15 00:07:43 +010044
45 unsigned int auc_3g_ind; /*!< IND index used for UMTS AKA SQN */
Stefan Sperling93c5b102018-04-10 19:26:14 +020046
47 /* Set when Location Update is received: */
48 bool supports_cs; /* client supports OSMO_GSUP_CN_DOMAIN_CS */
49 bool supports_ps; /* client supports OSMO_GSUP_CN_DOMAIN_PS */
Neels Hofmeyrb2553eb2019-11-20 02:36:45 +010050
51 /* The IPA unit name received on this link. Routes with more unit names serviced by this link may exist in
52 * osmo_gsup_server->routes, but this is the name the immediate peer identified as in the IPA handshake. */
53 struct osmo_ipa_name peer_name;
Harald Weltee72cf552016-04-28 07:18:49 +020054};
55
Neels Hofmeyra7d0f872019-10-30 02:08:28 +010056struct msgb *osmo_gsup_msgb_alloc(const char *label);
Harald Weltee72cf552016-04-28 07:18:49 +020057
Neels Hofmeyrb2553eb2019-11-20 02:36:45 +010058struct osmo_gsup_req *osmo_gsup_conn_rx(struct osmo_gsup_conn *conn, struct msgb *msg);
Harald Weltee72cf552016-04-28 07:18:49 +020059int osmo_gsup_conn_send(struct osmo_gsup_conn *conn, struct msgb *msg);
Neels Hofmeyr6eed3222016-12-11 01:21:49 +010060int osmo_gsup_conn_ccm_get(const struct osmo_gsup_conn *clnt, uint8_t **addr,
61 uint8_t tag);
Harald Weltee72cf552016-04-28 07:18:49 +020062
63struct osmo_gsup_server *osmo_gsup_server_create(void *ctx,
Max9cacb6f2017-02-20 17:22:56 +010064 const char *ip_addr,
65 uint16_t tcp_port,
66 osmo_gsup_read_cb_t read_cb,
Harald Welte32acace2018-06-16 17:07:28 +020067 void *priv);
Harald Weltee72cf552016-04-28 07:18:49 +020068
69void osmo_gsup_server_destroy(struct osmo_gsup_server *gsups);
70
Neels Hofmeyr1b8a1dc2018-05-04 16:46:47 +020071int osmo_gsup_configure_wildcard_apn(struct osmo_gsup_message *gsup,
72 uint8_t *apn_buf, size_t apn_buf_size);
Stefan Sperlingf83432c2018-05-03 14:26:59 +020073int osmo_gsup_create_insert_subscriber_data_msg(struct osmo_gsup_message *gsup, const char *imsi, const char *msisdn,
74 uint8_t *msisdn_enc, size_t msisdn_enc_size,
75 uint8_t *apn_buf, size_t apn_buf_size,
76 enum osmo_gsup_cn_domain cn_domain);
Neels Hofmeyr647c1062019-11-20 03:35:37 +010077int osmo_gsup_forward_to_local_peer(struct osmo_gsup_server *server, const struct osmo_gsup_peer_id *to_peer,
78 struct osmo_gsup_req *req, struct osmo_gsup_message *modified_gsup);