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 "comp_wlsb.h"
31 
32 #include <stdint.h>
33 #include <stddef.h>
34 #include <stdbool.h>
35 
36 
37 struct rohc_comp_ctxt;
38 
39 
40 /* static_or_irreg encoding for 8-bit and 16-bit values */
41 int c_static_or_irreg8(const uint8_t packet_value,
42  const bool is_static,
43  uint8_t *const rohc_data,
44  const size_t rohc_max_len,
45  int *const indicator)
46  __attribute__((warn_unused_result, nonnull(3, 5)));
47 int c_static_or_irreg16(const uint16_t packet_value,
48  const bool is_static,
49  uint8_t *const rohc_data,
50  const size_t rohc_max_len,
51  int *const indicator)
52  __attribute__((warn_unused_result, nonnull(3, 5)));
53 int c_static_or_irreg32(const uint32_t packet_value,
54  const bool is_static,
55  uint8_t *const rohc_data,
56  const size_t rohc_max_len,
57  int *const indicator)
58  __attribute__((warn_unused_result, nonnull(3, 5)));
59 
60 /* zero_or_irreg encoding for 16-bit and 32-bit values */
61 int c_zero_or_irreg16(const uint16_t packet_value,
62  uint8_t *const rohc_data,
63  const size_t rohc_max_len,
64  int *const indicator)
65  __attribute__((warn_unused_result, nonnull(2, 4)));
66 int c_zero_or_irreg32(const uint32_t packet_value,
67  uint8_t *const rohc_data,
68  const size_t rohc_max_len,
69  int *const indicator)
70  __attribute__((warn_unused_result, nonnull(2, 4)));
71 
72 /* variable_length_32_enc encoding method */
73 int variable_length_32_enc(const bool is_unchanged,
74  const uint32_t new_value,
75  const struct c_wlsb *const wlsb,
76  uint8_t *const rohc_data,
77  const size_t rohc_max_len,
78  int *const indicator)
79  __attribute__((nonnull(3, 4, 6), warn_unused_result));
80 
81 /* RFC4996 page 49 */
82 void c_field_scaling(uint32_t *const scaled_value,
83  uint32_t *const residue_field,
84  const uint32_t scaling_factor,
85  const uint32_t unscaled_value)
86  __attribute__((nonnull(1, 2)));
87 
88 // RFC4996 page 71
89 bool rsf_index_enc_possible(const uint8_t rsf_flags)
90  __attribute__((warn_unused_result, const));
91 unsigned int rsf_index_enc(const uint8_t rsf_flags)
92  __attribute__((warn_unused_result, const));
93 
94 /* optional_ip_id_lsb encoding method */
95 int c_optional_ip_id_lsb(const int behavior,
96  const uint16_t ip_id_nbo,
97  const uint16_t ip_id_offset,
98  const struct c_wlsb *const wlsb,
99  const rohc_lsb_shift_t p,
100  uint8_t *const rohc_data,
101  const size_t rohc_max_len,
102  int *const indicator)
103  __attribute__((warn_unused_result, nonnull(4, 6, 8)));
104 
105 // RFC4996 page 75
106 int dscp_encode(const bool is_static,
107  const uint8_t packet_value,
108  uint8_t *const rohc_data,
109  const size_t rohc_max_len,
110  int *const indicator)
111  __attribute__((warn_unused_result, nonnull(3, 5)));
112 
113 /* helper functions related to Scaled ACK and ACK Stride */
114 bool tcp_is_ack_scaled_possible(const uint16_t ack_stride,
115  const uint8_t nr_trans,
116  const uint8_t oa_repetitions_nr)
117  __attribute__((warn_unused_result, const));
118 bool tcp_is_ack_stride_static(const uint16_t ack_stride,
119  const uint8_t nr_trans,
120  const uint8_t oa_repetitions_nr)
121  __attribute__((warn_unused_result, const));
122 
123 #endif /* ROHC_COMP_RFC4996_ENCODING_H */
124 
rohc_lsb_shift_t
the different values of the shift parameter of the LSB algorithm
Definition: interval.h:47
bool tcp_is_ack_scaled_possible(const uint16_t ack_stride, const uint8_t nr_trans, const uint8_t oa_repetitions_nr)
Whether the ACK number may be transmitted scaled or not.
Definition: comp/schemes/rfc4996.c:533
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:342
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
Window-based Least Significant Bits (W-LSB) encoding.
One W-LSB encoding object.
Definition: comp_wlsb.h:68
The ROHC compression context.
Definition: rohc_comp_internals.h:278
bool nonnull(1)))
int variable_length_32_enc(const bool is_unchanged, const uint32_t new_value, const struct c_wlsb *const wlsb, 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:269
int dscp_encode(const bool is_static, 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:487
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:370
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_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
int c_optional_ip_id_lsb(const int behavior, const uint16_t ip_id_nbo, const uint16_t ip_id_offset, const struct c_wlsb *const wlsb, const rohc_lsb_shift_t p, 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:421
unsigned int rsf_index_enc(const uint8_t rsf_flags)
Calculate the rsf_index from the rsf flags.
Definition: comp/schemes/rfc4996.c:386
bool tcp_is_ack_stride_static(const uint16_t ack_stride, const uint8_t nr_trans, const uint8_t oa_repetitions_nr)
Whether the ack_stride scaling factor shall be transmitted or not.
Definition: comp/schemes/rfc4996.c:550