00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #ifndef ROHC_DECOMP_INTERNALS_H
00028 #define ROHC_DECOMP_INTERNALS_H
00029
00030 #include "rohc_internal.h"
00031 #include "rohc_decomp.h"
00032 #include "rohc_traces_internal.h"
00033 #include "feedback_create.h"
00034 #include "crc.h"
00035
00036
00037
00038
00039
00040
00041
00042
00043 #define D_NUM_PROFILES 7U
00044
00045
00046
00047 #define rohc_decomp_warn(context, format, ...) \
00048 rohc_warning((context)->decompressor, ROHC_TRACE_DECOMP, \
00049 (context)->profile->id, \
00050 format, ##__VA_ARGS__)
00051
00052
00053 #define rohc_decomp_debug(context, format, ...) \
00054 rohc_debug((context)->decompressor, ROHC_TRACE_DECOMP, \
00055 (context)->profile->id, \
00056 format, ##__VA_ARGS__)
00057
00058
00059 #define rohc_decomp_dump_buf(context, descr, buf, buf_len) \
00060 do { \
00061 if(((context)->decompressor->features & ROHC_DECOMP_FEATURE_DUMP_PACKETS) != 0) { \
00062 rohc_dump_buf((context)->decompressor->trace_callback, \
00063 (context)->decompressor->trace_callback_priv, \
00064 ROHC_TRACE_DECOMP, ROHC_TRACE_DEBUG, \
00065 descr, buf, buf_len); \
00066 } \
00067 } while(0)
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078 struct d_statistics
00079 {
00080
00081 unsigned long received;
00082
00083 unsigned long failed_crc;
00084
00085 unsigned long failed_no_context;
00086
00087 unsigned long failed_decomp;
00088
00089
00090 unsigned long total_compressed_size;
00091
00092 unsigned long total_uncompressed_size;
00093
00094
00095 unsigned long corrected_crc_failures;
00096
00097
00098 unsigned long corrected_sn_wraparounds;
00099
00100
00101 unsigned long corrected_wrong_sn_updates;
00102 };
00103
00104
00105
00106
00107
00108
00109
00110
00111 struct rohc_ack_rate_limit
00112 {
00113 size_t k;
00114 size_t n;
00115 size_t threshold;
00116 };
00117
00118
00119
00120 struct rohc_ack_rate_limits
00121 {
00122
00123 struct rohc_ack_rate_limit speed;
00124
00125 struct rohc_ack_rate_limit nack;
00126
00127 struct rohc_ack_rate_limit static_nack;
00128 };
00129
00130
00131
00132 struct rohc_ack_stats
00133 {
00134 uint32_t needed;
00135 uint32_t sent;
00136 };
00137
00138
00139
00140
00141
00142 struct rohc_decomp
00143 {
00144
00145 struct rohc_medium medium;
00146
00147
00148 rohc_decomp_features_t features;
00149
00150
00151 bool enabled_profiles[D_NUM_PROFILES];
00152
00153
00154 rohc_mode_t target_mode;
00155
00156
00157 struct rohc_decomp_ctxt **contexts;
00158
00159 size_t num_contexts_used;
00160
00161 struct rohc_decomp_ctxt *last_context;
00162
00163
00164
00165
00166
00167 size_t prtt;
00168
00169 size_t sn_feedback_min_bits;
00170
00171 struct rohc_ack_rate_limits ack_rate_limits;
00172
00173 uint32_t last_pkts_errors;
00174
00175 struct rohc_ack_stats last_pkt_feedbacks[ROHC_FEEDBACK_RESERVED];
00176
00177
00178
00179
00180
00181 #define ROHC_MAX_MRRU 65535
00182
00183 uint8_t rru[ROHC_MAX_MRRU];
00184
00185 size_t rru_len;
00186
00187 size_t mrru;
00188
00189
00190
00191
00192
00193 uint8_t crc_table_3[256];
00194
00195 uint8_t crc_table_7[256];
00196
00197 uint8_t crc_table_8[256];
00198
00199
00200
00201 struct d_statistics stats;
00202
00203
00204 rohc_trace_callback2_t trace_callback;
00205
00206 void *trace_callback_priv;
00207 };
00208
00209
00210
00211
00212
00213 typedef enum
00214 {
00215 ROHC_DECOMP_CRC_CORR_SN_NONE = 0,
00216 ROHC_DECOMP_CRC_CORR_SN_WRAP = 1,
00217 ROHC_DECOMP_CRC_CORR_SN_UPDATES = 2,
00218
00219 } rohc_decomp_crc_corr_t;
00220
00221
00222
00223 struct rohc_decomp_crc_corr_ctxt
00224 {
00225
00226 rohc_decomp_crc_corr_t algo;
00227
00228 size_t counter;
00229
00230 #define ROHC_MAX_ARRIVAL_TIMES 10U
00231
00232 struct rohc_ts arrival_times[ROHC_MAX_ARRIVAL_TIMES];
00233
00234 size_t arrival_times_nr;
00235
00236 size_t arrival_times_index;
00237 };
00238
00239
00240
00241 struct rohc_decomp_crc
00242 {
00243 rohc_crc_type_t type;
00244 uint8_t bits;
00245 size_t bits_nr;
00246 };
00247
00248
00249
00250
00251
00252
00253
00254
00255
00256 struct rohc_decomp_volat_ctxt
00257 {
00258
00259 struct rohc_decomp_crc crc;
00260
00261
00262
00263 void *extr_bits;
00264
00265
00266
00267 void *decoded_values;
00268 };
00269
00270
00271
00272
00273
00274 struct rohc_decomp_ctxt
00275 {
00276
00277 rohc_cid_t cid;
00278
00279
00280 struct rohc_decomp *decompressor;
00281
00282
00283 const struct rohc_decomp_profile *profile;
00284
00285 void *persist_ctxt;
00286
00287 struct rohc_decomp_volat_ctxt volat_ctxt;
00288
00289
00290 rohc_mode_t mode;
00291
00292 rohc_decomp_state_t state;
00293
00294
00295 unsigned int latest_used;
00296
00297 unsigned int first_used;
00298
00299
00300 uint32_t last_pkts_errors;
00301
00302 struct rohc_ack_stats last_pkt_feedbacks[ROHC_FEEDBACK_RESERVED];
00303
00304
00305 struct rohc_decomp_crc_corr_ctxt crc_corr;
00306
00307
00308
00309
00310 rohc_packet_t packet_type;
00311
00312
00313 unsigned long total_uncompressed_size;
00314
00315 unsigned long total_compressed_size;
00316
00317 unsigned long header_uncompressed_size;
00318
00319 unsigned long header_compressed_size;
00320
00321
00322 unsigned long num_recv_packets;
00323
00324 unsigned long corrected_crc_failures;
00325
00326 unsigned long corrected_sn_wraparounds;
00327
00328
00329 unsigned long corrected_wrong_sn_updates;
00330
00331
00332 unsigned long nr_lost_packets;
00333
00334 unsigned long nr_misordered_packets;
00335
00336 bool is_duplicated;
00337 };
00338
00339
00340 typedef bool (*rohc_decomp_new_context_t)(const struct rohc_decomp_ctxt *const context,
00341 void **const persist_ctxt,
00342 struct rohc_decomp_volat_ctxt *const volat_ctxt)
00343 __attribute__((warn_unused_result, nonnull(1, 2, 3)));
00344
00345 typedef void (*rohc_decomp_free_context_t)(void *const persist_ctxt,
00346 const struct rohc_decomp_volat_ctxt *const volat_ctxt)
00347 __attribute__((nonnull(2)));
00348
00349 typedef rohc_packet_t (*rohc_decomp_detect_pkt_type_t) (const struct rohc_decomp_ctxt *const context,
00350 const uint8_t *const rohc_packet,
00351 const size_t rohc_length,
00352 const size_t large_cid_len)
00353 __attribute__((warn_unused_result, nonnull(1, 2)));
00354
00355 typedef bool (*rohc_decomp_parse_pkt_t)(const struct rohc_decomp_ctxt *const context,
00356 const struct rohc_buf rohc_packet,
00357 const size_t large_cid_len,
00358 rohc_packet_t *const packet_type,
00359 struct rohc_decomp_crc *const extr_crc,
00360 void *const extr_bits,
00361 size_t *const rohc_hdr_len)
00362 __attribute__((warn_unused_result, nonnull(1, 4, 5, 6, 7)));
00363
00364 typedef bool (*rohc_decomp_decode_bits_t)(const struct rohc_decomp_ctxt *const context,
00365 const void *const extr_bits,
00366 const size_t payload_len,
00367 void *const decoded_values)
00368 __attribute__((warn_unused_result, nonnull(1, 2, 4)));
00369
00370 typedef rohc_status_t (*rohc_decomp_build_hdrs_t)(const struct rohc_decomp *const decomp,
00371 const struct rohc_decomp_ctxt *const context,
00372 const rohc_packet_t packet_type,
00373 const struct rohc_decomp_crc *const extr_crc,
00374 const void *const decoded_values,
00375 const size_t payload_len,
00376 struct rohc_buf *const uncomp_hdrs,
00377 size_t *const uncomp_hdrs_len)
00378 __attribute__((warn_unused_result, nonnull(1, 2, 4, 5, 7, 8)));
00379
00380 typedef void (*rohc_decomp_update_ctxt_t)(struct rohc_decomp_ctxt *const context,
00381 const void *const decoded_values,
00382 const size_t payload_len,
00383 bool *const do_change_mode)
00384 __attribute__((nonnull(1, 2, 4)));
00385
00386 typedef bool (*rohc_decomp_attempt_repair_t)(const struct rohc_decomp *const decomp,
00387 const struct rohc_decomp_ctxt *const context,
00388 const struct rohc_ts pkt_arrival_time,
00389 struct rohc_decomp_crc_corr_ctxt *const crc_corr,
00390 void *const extr_bits)
00391 __attribute__((warn_unused_result, nonnull(1, 2, 4, 5)));
00392
00393 typedef uint32_t (*rohc_decomp_get_sn_t)(const struct rohc_decomp_ctxt *const context)
00394 __attribute__((warn_unused_result, nonnull(1)));
00395
00396
00397
00398
00399
00400
00401
00402
00403 struct rohc_decomp_profile
00404 {
00405
00406 const rohc_profile_t id;
00407
00408
00409 const size_t msn_max_bits;
00410
00411
00412
00413 rohc_decomp_new_context_t new_context;
00414
00415
00416
00417 rohc_decomp_free_context_t free_context;
00418
00419
00420 rohc_decomp_detect_pkt_type_t detect_pkt_type;
00421
00422
00423 rohc_decomp_parse_pkt_t parse_pkt;
00424
00425
00426 rohc_decomp_decode_bits_t decode_bits;
00427
00428
00429 rohc_decomp_build_hdrs_t build_hdrs;
00430
00431
00432 rohc_decomp_update_ctxt_t update_ctxt;
00433
00434
00435 rohc_decomp_attempt_repair_t attempt_repair;
00436
00437
00438 rohc_decomp_get_sn_t get_sn;
00439 };
00440
00441 #endif
00442