ROHC compression/decompression library
comp/schemes/rfc4996.h
Go to the documentation of this file.
1 /*
2  * Copyright 2012,2013,2014 Didier Barvaux
3  * Copyright 2012 WBX
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 src/comp/schemes/rfc4996.h
22  * @brief Library of encoding methods from RFC4997 and RFC4996
23  * @author FWX <rohc_team@dialine.fr>
24  * @author Didier Barvaux <didier@barvaux.org>
25  */
26 
27 #ifndef ROHC_COMP_SCHEMES_RFC4996_H
28 #define ROHC_COMP_SCHEMES_RFC4996_H
29 
30 #include <stdint.h>
31 #include <stddef.h>
32 #include <stdbool.h>
33 
34 
35 struct rohc_comp_ctxt;
36 
37 
38 /* static_or_irreg encoding for 8-bit and 16-bit values */
39 int c_static_or_irreg8(const uint8_t context_value,
40  const uint8_t packet_value,
41  uint8_t *const rohc_data,
42  const size_t rohc_max_len,
43  int *const indicator)
44  __attribute__((warn_unused_result, nonnull(3, 5)));
45 int c_static_or_irreg16(const uint16_t packet_value,
46  const bool is_static,
47  uint8_t *const rohc_data,
48  const size_t rohc_max_len,
49  int *const indicator)
50  __attribute__((warn_unused_result, nonnull(3, 5)));
51 
52 /* zero_or_irreg encoding for 16-bit and 32-bit values */
53 int c_zero_or_irreg16(const uint16_t packet_value,
54  uint8_t *const rohc_data,
55  const size_t rohc_max_len,
56  int *const indicator)
57  __attribute__((warn_unused_result, nonnull(2, 4)));
58 int c_zero_or_irreg32(const uint32_t packet_value,
59  uint8_t *const rohc_data,
60  const size_t rohc_max_len,
61  int *const indicator)
62  __attribute__((warn_unused_result, nonnull(2, 4)));
63 
64 /* variable_length_32_enc encoding method */
65 int variable_length_32_enc(const uint32_t old_value,
66  const uint32_t new_value,
67  const size_t nr_bits_63,
68  const size_t nr_bits_16383,
69  uint8_t *const rohc_data,
70  const size_t rohc_max_len,
71  int *const indicator)
72  __attribute__((nonnull(5, 7), warn_unused_result));
73 
74 /* RFC4996 page 49 */
75 void c_field_scaling(uint32_t *const scaled_value,
76  uint32_t *const residue_field,
77  const uint32_t scaling_factor,
78  const uint32_t unscaled_value)
79  __attribute__((nonnull(1, 2)));
80 
81 // RFC4996 page 71
82 bool rsf_index_enc_possible(const uint8_t rsf_flags)
83  __attribute__((warn_unused_result, const));
84 unsigned int rsf_index_enc(const uint8_t rsf_flags)
85  __attribute__((warn_unused_result, const));
86 
87 /* optional_ip_id_lsb encoding method */
88 int c_optional_ip_id_lsb(const int behavior,
89  const uint16_t ip_id_nbo,
90  const uint16_t ip_id_offset,
91  const size_t nr_bits_wlsb,
92  uint8_t *const rohc_data,
93  const size_t rohc_max_len,
94  int *const indicator)
95  __attribute__((warn_unused_result, nonnull(5, 7)));
96 
97 // RFC4996 page 75
98 int dscp_encode(const uint8_t context_value,
99  const uint8_t packet_value,
100  uint8_t *const rohc_data,
101  const size_t rohc_max_len,
102  int *const indicator)
103  __attribute__((warn_unused_result, nonnull(3, 5)));
104 
105 #endif /* ROHC_COMP_RFC4996_ENCODING_H */
106 
int c_static_or_irreg8(const uint8_t context_value, const uint8_t packet_value, uint8_t *const rohc_data, const size_t rohc_max_len, int *const indicator)
Compress the 8 bits given, depending of the context value.
Definition: comp/schemes/rfc4996.c:51
int variable_length_32_enc(const uint32_t old_value, const uint32_t new_value, const size_t nr_bits_63, const size_t nr_bits_16383, uint8_t *const rohc_data, const size_t rohc_max_len, int *const indicator)
Compress the given 32-bit value.
Definition: comp/schemes/rfc4996.c:227
int dscp_encode(const uint8_t context_value, const uint8_t packet_value, uint8_t *const rohc_data, const size_t rohc_max_len, int *const indicator)
Encode the DSCP field.
Definition: comp/schemes/rfc4996.c:449
void c_field_scaling(uint32_t *const scaled_value, uint32_t *const residue_field, const uint32_t scaling_factor, const uint32_t unscaled_value)
Calculate the scaled and residue values from unscaled value and scaling factor.
Definition: comp/schemes/rfc4996.c:304
The ROHC compression context.
Definition: rohc_comp_internals.h:306
bool rsf_index_enc_possible(const uint8_t rsf_flags)
Is is possible to use the rsf_index_enc encoding?
Definition: comp/schemes/rfc4996.c:332
int c_zero_or_irreg16(const uint16_t packet_value, uint8_t *const rohc_data, const size_t rohc_max_len, int *const indicator)
Compress the 16 bits value, regarding if null or not.
Definition: comp/schemes/rfc4996.c:136
int c_optional_ip_id_lsb(const int behavior, const uint16_t ip_id_nbo, const uint16_t ip_id_offset, const size_t nr_bits_wlsb, uint8_t *const rohc_data, const size_t rohc_max_len, int *const indicator)
Compress or not the IP-ID.
Definition: comp/schemes/rfc4996.c:382
int c_zero_or_irreg32(const uint32_t packet_value, uint8_t *const rohc_data, const size_t rohc_max_len, int *const indicator)
Compress the 32 bits value, regarding if null or not.
Definition: comp/schemes/rfc4996.c:178
int c_static_or_irreg16(const uint16_t packet_value, const bool is_static, uint8_t *const rohc_data, const size_t rohc_max_len, int *const indicator)
Compress the 16 bits given, depending of the context value.
Definition: comp/schemes/rfc4996.c:93
unsigned int rsf_index_enc(const uint8_t rsf_flags)
Calculate the rsf_index from the rsf flags.
Definition: comp/schemes/rfc4996.c:348