Harald Welte | 9fe1f9f | 2018-11-29 13:47:39 +0100 | [diff] [blame] | 1 | #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 | ***********************************************************************/ |
| 11 | enum osmo_iuup_tnl_prim_type { |
| 12 | OSMO_IUUP_TNL_UNITDATA, |
| 13 | }; |
| 14 | |
| 15 | struct 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 */ |
| 24 | enum 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 |
| 41 | struct osmo_iuup_rnl_config_timer { |
| 42 | uint32_t t_ms; /* time in ms */ |
| 43 | uint32_t n_max; /* max number of repetitions */ |
| 44 | }; |
| 45 | struct 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 | |
| 69 | struct osmo_iuup_rnl_data { |
| 70 | uint8_t rfci; |
| 71 | uint8_t frame_nr; |
| 72 | uint8_t fqc; |
| 73 | }; |
| 74 | |
| 75 | struct 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 { |
Pau Espin Pedrol | 604eaba | 2022-01-03 16:57:45 +0100 | [diff] [blame] | 83 | uint16_t mode_version; |
| 84 | uint8_t data_pdu_type; |
Harald Welte | 9fe1f9f | 2018-11-29 13:47:39 +0100 | [diff] [blame] | 85 | uint8_t num_rfci; |
Pau Espin Pedrol | 604eaba | 2022-01-03 16:57:45 +0100 | [diff] [blame] | 86 | uint8_t num_subflows; |
Harald Welte | 9fe1f9f | 2018-11-29 13:47:39 +0100 | [diff] [blame] | 87 | uint16_t subflow_sizes[IUUP_MAX_RFCIS][IUUP_MAX_SUBFLOWS]; |
| 88 | bool IPTIs_present; |
| 89 | uint8_t IPTIs[IUUP_MAX_RFCIS]; /* values range 0-15, 4 bits */ |
| 90 | } initialization; |
| 91 | struct { |
| 92 | } rate_control; |
| 93 | struct { |
| 94 | } time_alignment; |
| 95 | } u; |
| 96 | }; |
| 97 | |
| 98 | /* SAP on the upper side of IuUP, towards the user */ |
| 99 | struct osmo_iuup_rnl_prim { |
| 100 | struct osmo_prim_hdr oph; |
| 101 | union { |
| 102 | struct osmo_iuup_rnl_config config; |
| 103 | struct osmo_iuup_rnl_data data; |
| 104 | struct osmo_iuup_rnl_status status; |
| 105 | //struct osmo_iuup_rnl_unitdata unitdata; |
| 106 | } u; |
| 107 | }; |
| 108 | |
| 109 | struct osmo_iuup_instance; |
| 110 | struct osmo_iuup_instance *osmo_iuup_instance_alloc(void *ctx, const char *id); |
| 111 | void osmo_iuup_instance_free(struct osmo_iuup_instance *iui); |
| 112 | |
| 113 | void osmo_iuup_instance_set_user_prim_cb(struct osmo_iuup_instance *iui, osmo_prim_cb func, void *priv); |
| 114 | void osmo_iuup_instance_set_transport_prim_cb(struct osmo_iuup_instance *iui, osmo_prim_cb func, void *priv); |
| 115 | int osmo_iuup_tnl_prim_up(struct osmo_iuup_instance *iui, struct osmo_iuup_tnl_prim *itp); |
| 116 | int osmo_iuup_rnl_prim_down(struct osmo_iuup_instance *inst, struct osmo_iuup_rnl_prim *irp); |
| 117 | |
| 118 | |
| 119 | int osmo_iuup_compute_header_crc(const uint8_t *iuup_pdu, unsigned int pdu_len); |
| 120 | int osmo_iuup_compute_payload_crc(const uint8_t *iuup_pdu, unsigned int pdu_len); |
| 121 | |
| 122 | struct osmo_iuup_rnl_prim *osmo_iuup_rnl_prim_alloc(void *ctx, unsigned int primitive, unsigned int operation, unsigned int size); |
| 123 | struct osmo_iuup_tnl_prim *osmo_iuup_tnl_prim_alloc(void *ctx, unsigned int primitive, unsigned int operation, unsigned int size); |