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 packet_value,
40  const bool is_static,
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 int c_static_or_irreg32(const uint32_t packet_value,
52  const bool is_static,
53  uint8_t *const rohc_data,
54  const size_t rohc_max_len,
55  int *const indicator)
56  __attribute__((warn_unused_result, nonnull(3, 5)));
57 
58 /* zero_or_irreg encoding for 16-bit and 32-bit values */
59 int c_zero_or_irreg16(const uint16_t packet_value,
60  uint8_t *const rohc_data,
61  const size_t rohc_max_len,
62  int *const indicator)
63  __attribute__((warn_unused_result, nonnull(2, 4)));
64 int c_zero_or_irreg32(const uint32_t packet_value,
65  uint8_t *const rohc_data,
66  const size_t rohc_max_len,
67  int *const indicator)
68  __attribute__((warn_unused_result, nonnull(2, 4)));
69 
70 /* variable_length_32_enc encoding method */
71 int variable_length_32_enc(const uint32_t old_value,
72  const uint32_t new_value,
73  const size_t nr_bits_63,
74  const size_t nr_bits_16383,
75  uint8_t *const rohc_data,
76  const size_t rohc_max_len,
77  int *const indicator)
78  __attribute__((nonnull(5, 7), warn_unused_result));
79 
80 /* RFC4996 page 49 */
81 void c_field_scaling(uint32_t *const scaled_value,
82  uint32_t *const residue_field,
83  const uint32_t scaling_factor,
84  const uint32_t unscaled_value)
85  __attribute__((nonnull(1, 2)));
86 
87 // RFC4996 page 71
88 bool rsf_index_enc_possible(const uint8_t rsf_flags)
89  __attribute__((warn_unused_result, const));
90 unsigned int rsf_index_enc(const uint8_t rsf_flags)
91  __attribute__((warn_unused_result, const));
92 
93 /* optional_ip_id_lsb encoding method */
94 int c_optional_ip_id_lsb(const int behavior,
95  const uint16_t ip_id_nbo,
96  const uint16_t ip_id_offset,
97  const size_t nr_bits_wlsb,
98  uint8_t *const rohc_data,
99  const size_t rohc_max_len,
100  int *const indicator)
101  __attribute__((warn_unused_result, nonnull(5, 7)));
102 
103 // RFC4996 page 75
104 int dscp_encode(const uint8_t context_value,
105  const uint8_t packet_value,
106  uint8_t *const rohc_data,
107  const size_t rohc_max_len,
108  int *const indicator)
109  __attribute__((warn_unused_result, nonnull(3, 5)));
110 
111 /* helper functions related to Scaled ACK and ACK Stride */
112 bool tcp_is_ack_scaled_possible(const uint16_t ack_stride,
113  const size_t nr_trans)
114  __attribute__((warn_unused_result, const));
115 bool tcp_is_ack_stride_static(const uint16_t ack_stride,
116  const size_t nr_trans)
117  __attribute__((warn_unused_result, const));
118 
119 #endif /* ROHC_COMP_RFC4996_ENCODING_H */
120 
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:272
bool tcp_is_ack_scaled_possible(const uint16_t ack_stride, const size_t nr_trans)
Whether the ACK number may be transmitted scaled or not.
Definition: comp/schemes/rfc4996.c:537
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:492
bool tcp_is_ack_stride_static(const uint16_t ack_stride, const size_t nr_trans)
Whether the ack_stride scaling factor shall be transmitted or not.
Definition: comp/schemes/rfc4996.c:552
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:349
int c_static_or_irreg8(const uint8_t packet_value, const bool is_static, 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:52
The ROHC compression context.
Definition: rohc_comp_internals.h:326
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:377
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:181
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:427
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:223
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:94
int c_static_or_irreg32(const uint32_t packet_value, const bool is_static, uint8_t *const rohc_data, const size_t rohc_max_len, int *const indicator)
Compress the 32 bits given, depending of the context value.
Definition: comp/schemes/rfc4996.c:138
unsigned int rsf_index_enc(const uint8_t rsf_flags)
Calculate the rsf_index from the rsf flags.
Definition: comp/schemes/rfc4996.c:393