aboutsummaryrefslogtreecommitdiffstats
path: root/include/osmocom/gsm/iuup.h
blob: db3d5e0dacb826eb461e892700251db40d25c592 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
#pragma once

#include <stdint.h>

#include <osmocom/core/prim.h>
#include <osmocom/gsm/protocol/gsm_25_415.h>

/***********************************************************************
 * Primitives towards the lower layers (typically RTP transport)
 ***********************************************************************/
enum osmo_iuup_tnl_prim_type {
	OSMO_IUUP_TNL_UNITDATA,
};

struct osmo_iuup_tnl_prim {
	struct osmo_prim_hdr oph;
};

/***********************************************************************
 * Primitives towards the upper layers at the RNL SAP
 ***********************************************************************/

/* 3GPP TS 25.415 Section 7.2.1 */
enum osmo_iuup_rnl_prim_type {
	OSMO_IUUP_RNL_CONFIG,
	OSMO_IUUP_RNL_DATA,
	OSMO_IUUP_RNL_STATUS,
	OSMO_IUUP_RNL_UNIT_DATA,
};

/* TS 25.413 9.2.1.3*/
#define IUUP_MAX_SUBFLOWS 7
#define IUUP_MAX_RFCIS 64

#define IUUP_TIMER_INIT_T_DEFAULT 1000
#define IUUP_TIMER_TA_T_DEFAULT 500
#define IUUP_TIMER_RC_T_DEFAULT 500
#define IUUP_TIMER_INIT_N_DEFAULT 3
#define IUUP_TIMER_TA_N_DEFAULT 1
#define IUUP_TIMER_RC_N_DEFAULT 1
struct osmo_iuup_rnl_config_timer {
	uint32_t t_ms;	/* time in ms */
	uint32_t n_max;	/* max number of repetitions */
};
struct osmo_iuup_rfci {
	uint8_t used:1,
			spare1:1,
			id:6;
	uint8_t spare2:4,
			IPTI:4; /* values range 0-15, 4 bits */;
	uint16_t subflow_sizes[IUUP_MAX_SUBFLOWS];
};
struct osmo_iuup_rnl_config {
	/* transparent (true) or SMpSDU (false): */
	bool transparent;

	/* should we actively transmit INIT in SmpSDU mode? */
	bool active;

	/* Currently Version 0 or 1: */
	uint8_t data_pdu_type;

	/* Supported mode versions */
	uint16_t supported_versions_mask;
	uint8_t num_rfci;
	uint8_t num_subflows;
	bool IPTIs_present;
	struct osmo_iuup_rfci rfci[IUUP_MAX_RFCIS];

	/* TODO: Indication of delivery of erroneous SDUs*/
	struct osmo_iuup_rnl_config_timer t_init;
	struct osmo_iuup_rnl_config_timer t_ta;
	struct osmo_iuup_rnl_config_timer t_rc;
};

struct osmo_iuup_rnl_data {
	uint8_t rfci;
	uint8_t frame_nr;
	uint8_t fqc;
};

struct osmo_iuup_rnl_status {
	enum iuup_procedure procedure;
	union {
		struct {
			enum iuup_error_cause cause;
			enum iuup_error_distance distance;
		} error_event;
		struct {
			uint16_t mode_version;
			uint8_t data_pdu_type;
			uint8_t num_rfci;
			uint8_t num_subflows;
			bool IPTIs_present;
			struct osmo_iuup_rfci rfci[IUUP_MAX_RFCIS];
		} initialization;
		struct {
		} rate_control;
		struct {
		} time_alignment;
	} u;
};

/* SAP on the upper side of IuUP, towards the user */
struct osmo_iuup_rnl_prim {
	struct osmo_prim_hdr oph;
	union {
		struct osmo_iuup_rnl_config config;
		struct osmo_iuup_rnl_data data;
		struct osmo_iuup_rnl_status status;
		//struct osmo_iuup_rnl_unitdata unitdata;
	} u;
};

struct osmo_iuup_instance;
struct osmo_iuup_instance *osmo_iuup_instance_alloc(void *ctx, const char *id);
void osmo_iuup_instance_free(struct osmo_iuup_instance *iui);

void osmo_iuup_instance_set_user_prim_cb(struct osmo_iuup_instance *iui, osmo_prim_cb func, void *priv);
void osmo_iuup_instance_set_transport_prim_cb(struct osmo_iuup_instance *iui, osmo_prim_cb func, void *priv);
int osmo_iuup_tnl_prim_up(struct osmo_iuup_instance *iui, struct osmo_iuup_tnl_prim *itp);
int osmo_iuup_rnl_prim_down(struct osmo_iuup_instance *inst, struct osmo_iuup_rnl_prim *irp);


int osmo_iuup_compute_header_crc(const uint8_t *iuup_pdu, unsigned int pdu_len);
int osmo_iuup_compute_payload_crc(const uint8_t *iuup_pdu, unsigned int pdu_len);

struct osmo_iuup_rnl_prim *osmo_iuup_rnl_prim_alloc(void *ctx, unsigned int primitive, unsigned int operation, unsigned int size);
struct osmo_iuup_tnl_prim *osmo_iuup_tnl_prim_alloc(void *ctx, unsigned int primitive, unsigned int operation, unsigned int size);