ROHC compression/decompression library
decomp_list.h
Go to the documentation of this file.
1 /*
2  * Copyright 2013 Didier Barvaux
3  * Copyright 2007,2008 Thales Alenia Space
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18  */
19 
20 /**
21  * @file schemes/decomp_list.h
22  * @brief ROHC generic list decompression
23  * @author Didier Barvaux <didier@barvaux.org>
24  */
25 
26 #ifndef ROHC_DECOMP_LIST_H
27 #define ROHC_DECOMP_LIST_H
28 
29 #include "rohc_list.h"
30 #include "rohc_traces_internal.h"
31 
32 
33 /** Print a warning trace for the given decompression list */
34 #define rd_list_warn(decomp_list, format, ...) \
35  rohc_warning(decomp_list, ROHC_TRACE_DECOMP, (decomp_list)->profile_id, \
36  format, ##__VA_ARGS__)
37 
38 /** Print a debug trace for the given decompression list */
39 #define rd_list_debug(decomp_list, format, ...) \
40  rohc_debug(decomp_list, ROHC_TRACE_DECOMP, (decomp_list)->profile_id, \
41  format, ##__VA_ARGS__)
42 
43 
44 /**
45  * @brief The context for list decompression
46  *
47  * The context contains a translation table that associates IDs and list
48  * items together. The different lists (gen_id ones, reference one, anonymous
49  * one) references the items from the translation table.
50  */
52 {
53  /** The translation table */
55 
56  /** All the possible named lists, indexed by gen_id */
58 
59  /** The temporary packet list (not persistent across packets) */
61 
62 
63  /* Functions for handling the data to decompress */
64 
65  /** The handler used to check if the index corresponds to a valid item */
66  bool (*check_item)(const struct list_decomp *const decomp,
67  const size_t index_table);
68 
69  /** The handler used to get the size of a list item */
70  int (*get_item_size)(const uint8_t *data, const size_t data_len);
71 
72  /** The handler used to compare two items */
74 
75  /** The handler used to create a list item */
76  bool (*create_item)(const uint8_t *const data,
77  const size_t length,
78  const size_t index_table,
79  struct list_decomp *const decomp);
80 
81  /** The handler used to add the extension to IP packet */
82  size_t (*build_uncomp_item)(const struct list_decomp *const decomp,
83  const uint8_t ip_nh_type,
84  uint8_t *const dest);
85 
86 
87  /* Traces */
88 
89  /** The callback function used to manage traces */
91  /** The private context of the callback function used to manage traces */
93  /** The profile ID the decompression list was created for */
95 };
96 
97 
98 
99 /*
100  * Generic list decompression
101  */
102 
103 int rohc_list_decode_maybe(struct list_decomp *const decomp,
104  const uint8_t *const packet,
105  const size_t packet_len)
106  __attribute__((warn_unused_result, nonnull(1, 2)));
107 
108 bool rohc_decomp_list_create_item(struct list_decomp *const decomp,
109  const unsigned int xi_index,
110  const unsigned int xi_index_value,
111  const uint8_t *const rohc_packet,
112  const size_t rohc_max_len,
113  size_t *const item_length)
114  __attribute__((warn_unused_result, nonnull(1, 4, 6)));
115 
116 #endif
117 
int profile_id
Definition: decomp_list.h:94
struct rohc_list_item trans_table[ROHC_LIST_MAX_ITEM]
Definition: decomp_list.h:54
struct rohc_list lists[ROHC_LIST_GEN_ID_MAX+1]
Definition: decomp_list.h:57
size_t(* build_uncomp_item)(const struct list_decomp *const decomp, const uint8_t ip_nh_type, uint8_t *const dest)
Definition: decomp_list.h:82
int(* get_item_size)(const uint8_t *data, const size_t data_len)
Definition: decomp_list.h:70
The context for list decompression.
Definition: decomp_list.h:51
bool rohc_decomp_list_create_item(struct list_decomp *const decomp, const unsigned int xi_index, const unsigned int xi_index_value, const uint8_t *const rohc_packet, const size_t rohc_max_len, size_t *const item_length)
Create a list item from a XI item.
Definition: decomp_list.c:350
void(* rohc_trace_callback2_t)(void *const priv_ctxt, const rohc_trace_level_t level, const rohc_trace_entity_t entity, const int profile, const char *const format,...)
The function prototype for the trace callback.
Definition: rohc_traces.h:118
bool(* check_item)(const struct list_decomp *const decomp, const size_t index_table)
Definition: decomp_list.h:66
bool(* create_item)(const uint8_t *const data, const size_t length, const size_t index_table, struct list_decomp *const decomp)
Definition: decomp_list.h:76
Define list compression with its function.
struct rohc_list pkt_list
Definition: decomp_list.h:60
bool(* rohc_list_item_cmp)(const struct rohc_list_item *const item, const uint8_t ext_type, const uint8_t *const ext_data, const size_t ext_len)
Definition: rohc_list.h:106
#define ROHC_LIST_GEN_ID_MAX
Definition: rohc_list.h:54
#define ROHC_LIST_MAX_ITEM
Definition: rohc_list.h:36
rohc_list_item_cmp cmp_item
Definition: decomp_list.h:73
void * trace_callback_priv
Definition: decomp_list.h:92
A list item.
Definition: rohc_list.h:80
Define a list for compression.
Definition: rohc_list.h:62
rohc_trace_callback2_t trace_callback
Definition: decomp_list.h:90
int rohc_list_decode_maybe(struct list_decomp *const decomp, const uint8_t *const packet, const size_t packet_len)
Decompress the compressed list in given packet if present.
Definition: decomp_list.c:143
Internal ROHC macros and functions for traces.