blob: a93fff3ef47ed35966bc1913e91c38fedd0a5bd0 [file] [log] [blame]
Neels Hofmeyraae68b22017-07-05 14:38:52 +02001#pragma once
2
3#include <stdbool.h>
4
5#include <osmocom/core/linuxlist.h>
6#include <osmocom/gsm/gsm48.h>
7#include <osmocom/sigtran/sccp_sap.h>
8
9struct msgb;
10struct osmo_auth_vector;
11
12struct RANAP_RAB_SetupOrModifiedItemIEs_s;
13struct RANAP_Cause;
14
15struct ranap_iu_rnc;
16
17/* Debugging switches from asn1c and osmo-iuh */
18extern int asn_debug;
19extern int asn1_xer_print;
20
21enum ranap_nsap_addr_enc {
22 RANAP_NSAP_ADDR_ENC_X213,
23 RANAP_NSAP_ADDR_ENC_V4RAW,
24};
25
26struct ranap_ue_conn_ctx {
27 struct llist_head list;
28 struct ranap_iu_rnc *rnc;
29 uint32_t conn_id;
30 int integrity_active;
31 struct gprs_ra_id ra_id;
32 enum ranap_nsap_addr_enc rab_assign_addr_enc;
Alexander Couzens8e2a0ee2019-09-10 18:28:49 +020033 bool notification; /* send notification to the upstream user */
Alexander Couzensff796992019-09-10 17:46:54 +020034 /* Will be set when the Iu Release Command has been sent */
35 struct osmo_timer_list release_timeout;
Neels Hofmeyraae68b22017-07-05 14:38:52 +020036};
37
38enum ranap_iu_event_type {
39 RANAP_IU_EVENT_RAB_ASSIGN,
40 RANAP_IU_EVENT_SECURITY_MODE_COMPLETE,
41 RANAP_IU_EVENT_IU_RELEASE, /* An actual Iu Release message was received */
42 RANAP_IU_EVENT_LINK_INVALIDATED, /* A SUA link was lost or closed down */
43};
44
45extern const struct value_string ranap_iu_event_type_names[];
46static inline const char *ranap_iu_event_type_str(enum ranap_iu_event_type e)
47{
48 return get_value_string(ranap_iu_event_type_names, e);
49}
50
51/* Implementations of iu_recv_cb_t shall find the ranap_ue_conn_ctx in msg->dst. */
52typedef int (* ranap_iu_recv_cb_t )(struct msgb *msg, struct gprs_ra_id *ra_id,
53 uint16_t *sai);
54
55typedef int (* ranap_iu_event_cb_t )(struct ranap_ue_conn_ctx *ue_ctx,
56 enum ranap_iu_event_type type, void *data);
57
58typedef int (* ranap_iu_rab_ass_resp_cb_t )(struct ranap_ue_conn_ctx *ue_ctx, uint8_t rab_id,
59 struct RANAP_RAB_SetupOrModifiedItemIEs_s *setup_ies);
60
61int ranap_iu_init(void *ctx, int log_subsystem, const char *sccp_user_name, struct osmo_sccp_instance *sccp,
62 ranap_iu_recv_cb_t iu_recv_cb, ranap_iu_event_cb_t iu_event_cb);
63
64int ranap_iu_tx(struct msgb *msg, uint8_t sapi);
65
66int ranap_iu_page_cs(const char *imsi, const uint32_t *tmsi, uint16_t lac);
67int ranap_iu_page_ps(const char *imsi, const uint32_t *ptmsi, uint16_t lac, uint8_t rac);
68
69int ranap_iu_rab_act(struct ranap_ue_conn_ctx *ue_ctx, struct msgb *msg);
70int ranap_iu_rab_deact(struct ranap_ue_conn_ctx *ue_ctx, uint8_t rab_id);
71int ranap_iu_tx_sec_mode_cmd(struct ranap_ue_conn_ctx *uectx, struct osmo_auth_vector *vec,
72 int send_ck, int new_key);
73int ranap_iu_tx_common_id(struct ranap_ue_conn_ctx *ue_ctx, const char *imsi);
74int ranap_iu_tx_release(struct ranap_ue_conn_ctx *ctx, const struct RANAP_Cause *cause);
75
Alexander Couzensff796992019-09-10 17:46:54 +020076/* transmit a Iu Release Command and free the ctx afterwards.
77 * If a Release Complete is not received within timeout s,
78 * release the SCCP connection. */
79void ranap_iu_tx_release_free(struct ranap_ue_conn_ctx *ctx,
80 const struct RANAP_Cause *cause,
81 int timeout);
82
Alexander Couzens609994d2019-08-12 16:48:56 +020083/* freeing the UE will release all resources
84 * This will close the SCCP connection connected to the UE */
85void ranap_iu_free_ue(struct ranap_ue_conn_ctx *ue_ctx);
86
Neels Hofmeyraae68b22017-07-05 14:38:52 +020087void ranap_iu_vty_init(int iu_parent_node, enum ranap_nsap_addr_enc *rab_assign_addr_enc);
88int ranap_iu_vty_config_write(struct vty *vty, const char *indent);