ROHC compression/decompression library
comp_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/comp_list.h
22  * @brief ROHC generic list compression
23  * @author Didier Barvaux <didier@barvaux.org>
24  */
25 
26 #ifndef ROHC_COMP_LIST_H
27 #define ROHC_COMP_LIST_H
28 
29 #include "ip.h"
30 #include "rohc_list.h"
31 #include "rohc_traces_internal.h"
32 
33 /** Print a debug trace for the given compression list */
34 #define rc_list_debug(comp_list, format, ...) \
35  rohc_debug(comp_list, ROHC_TRACE_COMP, (comp_list)->profile_id, \
36  format, ##__VA_ARGS__)
37 
38 
39 /**
40  * @brief The list compressor
41  */
42 struct list_comp
43 {
44  /** The translation table */
46 
47  /* All the possible named lists, indexed by gen_id */
49 
50  /** The ID of the reference list */
51  unsigned int ref_id;
52  /** The ID of the current list */
53  unsigned int cur_id; /* TODO: should not be overwritten until compression
54  is fully OK */
55 
56  /** The number of uncompressed transmissions for list compression (L) */
57  size_t list_trans_nr;
58 
59  /* Functions for handling the data to compress */
60 
61  /// @brief the handler used to get the index of an item
62  int (*get_index_table)(const uint8_t type, const size_t occur_nr)
63  __attribute__((warn_unused_result, const));
64 
65  /// @brief the handler used to get the size of an item
66  unsigned short (*get_size)(const uint8_t *ext);
67 
68  /** The handler used to compare two items */
70 
71  /* Traces */
72 
73  /** The callback function used to manage traces */
75  /** The private context of the callback function used to manage traces */
77  /** The profile ID the compression list was created for */
79 };
80 
81 
82 bool detect_ipv6_ext_changes(struct list_comp *const comp,
83  const struct ip_packet *const ip,
84  bool *const list_struct_changed,
85  bool *const list_content_changed)
86  __attribute__((warn_unused_result, nonnull(1, 2, 3, 4)));
87 
88 int rohc_list_encode(struct list_comp *const comp,
89  uint8_t *const dest,
90  int counter)
91  __attribute__((warn_unused_result, nonnull(1, 2)));
92 
93 void rohc_list_update_context(struct list_comp *const comp)
94  __attribute__((nonnull(1)));
95 
96 #endif
97 
bool detect_ipv6_ext_changes(struct list_comp *const comp, const struct ip_packet *const ip, bool *const list_struct_changed, bool *const list_content_changed)
Detect changes within the list of IPv6 extension headers.
Definition: comp_list.c:133
int rohc_list_encode(struct list_comp *const comp, uint8_t *const dest, int counter)
Generic encoding of compressed list.
Definition: comp_list.c:335
int profile_id
Definition: comp_list.h:78
struct rohc_list lists[ROHC_LIST_GEN_ID_MAX+2]
Definition: comp_list.h:48
unsigned int cur_id
Definition: comp_list.h:53
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
rohc_trace_callback2_t trace_callback
Definition: comp_list.h:74
size_t list_trans_nr
Definition: comp_list.h:57
void * trace_callback_priv
Definition: comp_list.h:76
Define list compression with its function.
int(* get_index_table)(const uint8_t type, const size_t occur_nr)
the handler used to get the index of an item
Definition: comp_list.h:62
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
void rohc_list_update_context(struct list_comp *const comp)
Update the list compression context.
Definition: comp_list.c:403
unsigned int ref_id
Definition: comp_list.h:51
The list compressor.
Definition: comp_list.h:42
A list item.
Definition: rohc_list.h:80
Defines an IP-agnostic packet that can handle an IPv4 or IPv6 packet.
Definition: ip.h:81
size_t counter
Definition: rohc_list.h:73
Define a list for compression.
Definition: rohc_list.h:62
unsigned short(* get_size)(const uint8_t *ext)
the handler used to get the size of an item
Definition: comp_list.h:66
rohc_list_item_cmp cmp_item
Definition: comp_list.h:69
struct rohc_list_item trans_table[ROHC_LIST_MAX_ITEM]
Definition: comp_list.h:45
Internal ROHC macros and functions for traces.