blob: b1651c5913bc64c9af2abc8b4f7147a2988a2a20 [file] [log] [blame]
Harald Welte9fe1f9f2018-11-29 13:47:39 +01001#pragma once
2
3#include <stdint.h>
4
5#include <osmocom/core/prim.h>
6#include <osmocom/gsm/protocol/gsm_25_415.h>
7
8/***********************************************************************
9 * Primitives towards the lower layers (typically RTP transport)
10 ***********************************************************************/
11enum osmo_iuup_tnl_prim_type {
12 OSMO_IUUP_TNL_UNITDATA,
13};
14
15struct osmo_iuup_tnl_prim {
16 struct osmo_prim_hdr oph;
17};
18
19/***********************************************************************
20 * Primitives towards the upper layers at the RNL SAP
21 ***********************************************************************/
22
23/* 3GPP TS 25.415 Section 7.2.1 */
24enum osmo_iuup_rnl_prim_type {
25 OSMO_IUUP_RNL_CONFIG,
26 OSMO_IUUP_RNL_DATA,
27 OSMO_IUUP_RNL_STATUS,
28 OSMO_IUUP_RNL_UNIT_DATA,
29};
30
31/* TS 25.413 9.2.1.3*/
32#define IUUP_MAX_SUBFLOWS 7
33#define IUUP_MAX_RFCIS 64
34
35#define IUUP_TIMER_INIT_T_DEFAULT 1000
36#define IUUP_TIMER_TA_T_DEFAULT 500
37#define IUUP_TIMER_RC_T_DEFAULT 500
38#define IUUP_TIMER_INIT_N_DEFAULT 3
39#define IUUP_TIMER_TA_N_DEFAULT 1
40#define IUUP_TIMER_RC_N_DEFAULT 1
41struct osmo_iuup_rnl_config_timer {
42 uint32_t t_ms; /* time in ms */
43 uint32_t n_max; /* max number of repetitions */
44};
45struct osmo_iuup_rnl_config {
46 /* transparent (true) or SMpSDU (false): */
47 bool transparent;
48
49 /* should we actively transmit INIT in SmpSDU mode? */
50 bool active;
51
52 /* Currently Version 0 or 1: */
53 uint8_t data_pdu_type;
54
55 /* Supported mode versions */
56 uint16_t supported_versions_mask;
57 uint8_t num_rfci;
58 uint8_t num_subflows;
59 uint16_t subflow_sizes[IUUP_MAX_RFCIS][IUUP_MAX_SUBFLOWS];
60 bool IPTIs_present;
61 uint8_t IPTIs[IUUP_MAX_RFCIS]; /* values range 0-15, 4 bits */
62
63 /* TODO: Indication of delivery of erroneous SDUs*/
64 struct osmo_iuup_rnl_config_timer t_init;
65 struct osmo_iuup_rnl_config_timer t_ta;
66 struct osmo_iuup_rnl_config_timer t_rc;
67};
68
69struct osmo_iuup_rnl_data {
70 uint8_t rfci;
71 uint8_t frame_nr;
72 uint8_t fqc;
73};
74
75struct osmo_iuup_rnl_status {
76 enum iuup_procedure procedure;
77 union {
78 struct {
79 enum iuup_error_cause cause;
80 enum iuup_error_distance distance;
81 } error_event;
82 struct {
83 uint16_t supported_versions_mask;
84 uint8_t num_subflows;
85 uint8_t num_rfci;
86 uint16_t subflow_sizes[IUUP_MAX_RFCIS][IUUP_MAX_SUBFLOWS];
87 bool IPTIs_present;
88 uint8_t IPTIs[IUUP_MAX_RFCIS]; /* values range 0-15, 4 bits */
89 } initialization;
90 struct {
91 } rate_control;
92 struct {
93 } time_alignment;
94 } u;
95};
96
97/* SAP on the upper side of IuUP, towards the user */
98struct osmo_iuup_rnl_prim {
99 struct osmo_prim_hdr oph;
100 union {
101 struct osmo_iuup_rnl_config config;
102 struct osmo_iuup_rnl_data data;
103 struct osmo_iuup_rnl_status status;
104 //struct osmo_iuup_rnl_unitdata unitdata;
105 } u;
106};
107
108struct osmo_iuup_instance;
109struct osmo_iuup_instance *osmo_iuup_instance_alloc(void *ctx, const char *id);
110void osmo_iuup_instance_free(struct osmo_iuup_instance *iui);
111
112void osmo_iuup_instance_set_user_prim_cb(struct osmo_iuup_instance *iui, osmo_prim_cb func, void *priv);
113void osmo_iuup_instance_set_transport_prim_cb(struct osmo_iuup_instance *iui, osmo_prim_cb func, void *priv);
114int osmo_iuup_tnl_prim_up(struct osmo_iuup_instance *iui, struct osmo_iuup_tnl_prim *itp);
115int osmo_iuup_rnl_prim_down(struct osmo_iuup_instance *inst, struct osmo_iuup_rnl_prim *irp);
116
117
118int osmo_iuup_compute_header_crc(const uint8_t *iuup_pdu, unsigned int pdu_len);
119int osmo_iuup_compute_payload_crc(const uint8_t *iuup_pdu, unsigned int pdu_len);
120
121struct osmo_iuup_rnl_prim *osmo_iuup_rnl_prim_alloc(void *ctx, unsigned int primitive, unsigned int operation, unsigned int size);
122struct osmo_iuup_tnl_prim *osmo_iuup_tnl_prim_alloc(void *ctx, unsigned int primitive, unsigned int operation, unsigned int size);