blob: 24a5af9076760f606307df4d6cd4e02079e083ce [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 Couzens32fc82a2019-09-10 19:09:30 +020034 /* if true the ue_ctx will be free on Iu release complete */
35 bool free_on_release;
Alexander Couzensff796992019-09-10 17:46:54 +020036 /* Will be set when the Iu Release Command has been sent */
37 struct osmo_timer_list release_timeout;
Neels Hofmeyraae68b22017-07-05 14:38:52 +020038};
39
40enum ranap_iu_event_type {
41 RANAP_IU_EVENT_RAB_ASSIGN,
42 RANAP_IU_EVENT_SECURITY_MODE_COMPLETE,
43 RANAP_IU_EVENT_IU_RELEASE, /* An actual Iu Release message was received */
44 RANAP_IU_EVENT_LINK_INVALIDATED, /* A SUA link was lost or closed down */
45};
46
47extern const struct value_string ranap_iu_event_type_names[];
48static inline const char *ranap_iu_event_type_str(enum ranap_iu_event_type e)
49{
50 return get_value_string(ranap_iu_event_type_names, e);
51}
52
53/* Implementations of iu_recv_cb_t shall find the ranap_ue_conn_ctx in msg->dst. */
54typedef int (* ranap_iu_recv_cb_t )(struct msgb *msg, struct gprs_ra_id *ra_id,
55 uint16_t *sai);
56
57typedef int (* ranap_iu_event_cb_t )(struct ranap_ue_conn_ctx *ue_ctx,
58 enum ranap_iu_event_type type, void *data);
59
60typedef int (* ranap_iu_rab_ass_resp_cb_t )(struct ranap_ue_conn_ctx *ue_ctx, uint8_t rab_id,
61 struct RANAP_RAB_SetupOrModifiedItemIEs_s *setup_ies);
62
63int ranap_iu_init(void *ctx, int log_subsystem, const char *sccp_user_name, struct osmo_sccp_instance *sccp,
64 ranap_iu_recv_cb_t iu_recv_cb, ranap_iu_event_cb_t iu_event_cb);
65
66int ranap_iu_tx(struct msgb *msg, uint8_t sapi);
67
68int ranap_iu_page_cs(const char *imsi, const uint32_t *tmsi, uint16_t lac);
69int ranap_iu_page_ps(const char *imsi, const uint32_t *ptmsi, uint16_t lac, uint8_t rac);
70
71int ranap_iu_rab_act(struct ranap_ue_conn_ctx *ue_ctx, struct msgb *msg);
72int ranap_iu_rab_deact(struct ranap_ue_conn_ctx *ue_ctx, uint8_t rab_id);
73int ranap_iu_tx_sec_mode_cmd(struct ranap_ue_conn_ctx *uectx, struct osmo_auth_vector *vec,
74 int send_ck, int new_key);
75int ranap_iu_tx_common_id(struct ranap_ue_conn_ctx *ue_ctx, const char *imsi);
76int ranap_iu_tx_release(struct ranap_ue_conn_ctx *ctx, const struct RANAP_Cause *cause);
77
Alexander Couzensff796992019-09-10 17:46:54 +020078/* transmit a Iu Release Command and free the ctx afterwards.
79 * If a Release Complete is not received within timeout s,
80 * release the SCCP connection. */
81void ranap_iu_tx_release_free(struct ranap_ue_conn_ctx *ctx,
82 const struct RANAP_Cause *cause,
83 int timeout);
84
Alexander Couzens609994d2019-08-12 16:48:56 +020085/* freeing the UE will release all resources
86 * This will close the SCCP connection connected to the UE */
87void ranap_iu_free_ue(struct ranap_ue_conn_ctx *ue_ctx);
88
Neels Hofmeyraae68b22017-07-05 14:38:52 +020089void ranap_iu_vty_init(int iu_parent_node, enum ranap_nsap_addr_enc *rab_assign_addr_enc);
90int ranap_iu_vty_config_write(struct vty *vty, const char *indent);