blob: 08e4cd06bc910c2cbdcd3023dd1c7063c46640fa [file] [log] [blame]
Neels Hofmeyrbfa88782016-05-20 21:38:32 +02001#pragma once
2
3#include <stdbool.h>
Neels Hofmeyra1756f32016-05-20 21:59:55 +02004#include <stdint.h>
5
6#include <osmocom/core/linuxlist.h>
7#include <osmocom/gsm/gsm48.h>
Philipp Maier4b60d072017-04-09 12:32:51 +02008#include <osmocom/sigtran/sccp_sap.h>
Neels Hofmeyra1756f32016-05-20 21:59:55 +02009
10#include <openbsc/common.h>
Neels Hofmeyrbfa88782016-05-20 21:38:32 +020011
12struct sgsn_pdp_ctx;
13struct msgb;
Neels Hofmeyra1756f32016-05-20 21:59:55 +020014struct gsm_auth_tuple;
Philipp Maier4b60d072017-04-09 12:32:51 +020015struct osmo_sccp_addr;
16struct osmo_ss7_instance;
Neels Hofmeyrbfa88782016-05-20 21:38:32 +020017
18struct RANAP_RAB_SetupOrModifiedItemIEs_s;
19struct RANAP_GlobalRNC_ID;
Neels Hofmeyra1756f32016-05-20 21:59:55 +020020struct RANAP_Cause;
21
22/* Debugging switches from asn1c and osmo-iuh */
23extern int asn_debug;
24extern int asn1_xer_print;
Neels Hofmeyrbfa88782016-05-20 21:38:32 +020025
26struct ue_conn_ctx {
27 struct llist_head list;
Philipp Maier4b60d072017-04-09 12:32:51 +020028 /* TODO: It's not needed to store the full SCCP address for each
29 * UE. Rather than that, a pointer to the RNC should be far
30 * sufficient */
31 struct osmo_sccp_addr sccp_addr;
Neels Hofmeyrbfa88782016-05-20 21:38:32 +020032 uint32_t conn_id;
33 int integrity_active;
34 struct gprs_ra_id ra_id;
Neels Hofmeyra1756f32016-05-20 21:59:55 +020035 enum nsap_addr_enc rab_assign_addr_enc;
Neels Hofmeyrbfa88782016-05-20 21:38:32 +020036};
37
38enum iu_event_type {
39 IU_EVENT_RAB_ASSIGN,
40 IU_EVENT_SECURITY_MODE_COMPLETE,
41 IU_EVENT_IU_RELEASE, /* An actual Iu Release message was received */
42 IU_EVENT_LINK_INVALIDATED, /* A SUA link was lost or closed down */
Neels Hofmeyrbfa88782016-05-20 21:38:32 +020043};
44
45extern const struct value_string iu_event_type_names[];
46static inline const char *iu_event_type_str(enum iu_event_type e)
47{
48 return get_value_string(iu_event_type_names, e);
49}
50
51/* Implementations of iu_recv_cb_t shall find the ue_conn_ctx in msg->dst. */
52typedef int (* iu_recv_cb_t )(struct msgb *msg, struct gprs_ra_id *ra_id,
Neels Hofmeyrbfa88782016-05-20 21:38:32 +020053 uint16_t *sai);
54
55typedef int (* iu_event_cb_t )(struct ue_conn_ctx *ue_ctx,
56 enum iu_event_type type, void *data);
57
58typedef int (* iu_rab_ass_resp_cb_t )(struct ue_conn_ctx *ue_ctx, uint8_t rab_id,
59 struct RANAP_RAB_SetupOrModifiedItemIEs_s *setup_ies);
60
Philipp Maier4b60d072017-04-09 12:32:51 +020061int iu_init(void *ctx, struct osmo_sccp_instance *sccp,
Neels Hofmeyrbfa88782016-05-20 21:38:32 +020062 iu_recv_cb_t iu_recv_cb, iu_event_cb_t iu_event_cb);
63
Neels Hofmeyrbfa88782016-05-20 21:38:32 +020064int iu_tx(struct msgb *msg, uint8_t sapi);
65
66int iu_page_cs(const char *imsi, const uint32_t *tmsi, uint16_t lac);
67int iu_page_ps(const char *imsi, const uint32_t *ptmsi, uint16_t lac, uint8_t rac);
68
69int iu_rab_act(struct ue_conn_ctx *ue_ctx, struct msgb *msg);
70int iu_rab_deact(struct ue_conn_ctx *ue_ctx, uint8_t rab_id);
71int iu_tx_sec_mode_cmd(struct ue_conn_ctx *uectx, struct gsm_auth_tuple *tp,
72 int send_ck, int new_key);
Neels Hofmeyra1756f32016-05-20 21:59:55 +020073int iu_tx_common_id(struct ue_conn_ctx *ue_ctx, const char *imsi);
74int iu_tx_release(struct ue_conn_ctx *ctx, const struct RANAP_Cause *cause);
Neels Hofmeyr9bc42ec2016-08-29 13:02:12 +020075
Neels Hofmeyra1756f32016-05-20 21:59:55 +020076void iu_vty_init(int iu_parent_node, enum nsap_addr_enc *rab_assign_addr_enc);
77int iu_vty_config_write(struct vty *vty, const char *indent);