ROHC compression/decompression library
feedback.h
Go to the documentation of this file.
1 /*
2  * Copyright 2015,2016 Didier Barvaux
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17  */
18 
19 /**
20  * @file feedback.h
21  * @brief ROHC feedback definitions and formats
22  * @author Didier Barvaux <didier@barvaux.org>
23  */
24 
25 #ifndef ROHC_FEEDBACK_H
26 #define ROHC_FEEDBACK_H
27 
28 #include "rohc.h"
29 
30 #ifdef __KERNEL__
31 # include <endian.h>
32 #else
33 # include "config.h" /* for WORDS_BIGENDIAN */
34 #endif
35 
36 #include <stdbool.h>
37 #include <stdint.h>
38 #include <stddef.h>
39 
40 
41 /** The type of ROHC feedback */
43 {
44  ROHC_FEEDBACK_1 = 1, /**< ROHC FEEDBACK-1 */
45  ROHC_FEEDBACK_2 = 2, /**< ROHC FEEDBACK-2 */
46 };
47 
48 
49 /** The type of acknowledgement */
51 {
52  ROHC_FEEDBACK_ACK = 0, /**< The classical ACKnowledgement */
53  ROHC_FEEDBACK_NACK = 1, /**< The Negative ACKnowledgement */
54  ROHC_FEEDBACK_STATIC_NACK = 2, /**< The Negative STATIC ACKnowledgement */
55  ROHC_FEEDBACK_RESERVED = 3, /**< reserved (MUST NOT be used for parsability) */
56 };
57 
58 
59 /** The ROHC feedback options */
61 {
62  ROHC_FEEDBACK_OPT_CRC = 1, /**< The Feedback CRC option */
63  ROHC_FEEDBACK_OPT_REJECT = 2, /**< The Feedback REJECT option */
64  ROHC_FEEDBACK_OPT_SN_NOT_VALID = 3, /**< The Feedback SN-NOT-VALID option */
65 /** The Feedback MSN-NOT-VALID option (TCP profile) */
66 #define ROHC_FEEDBACK_OPT_MSN_NOT_VALID ROHC_FEEDBACK_OPT_SN_NOT_VALID
67  ROHC_FEEDBACK_OPT_SN = 4, /**< The Feedback SN option */
68 /** The Feedback MSN option (TCP profile) */
69 #define ROHC_FEEDBACK_OPT_MSN ROHC_FEEDBACK_OPT_SN
70  ROHC_FEEDBACK_OPT_CLOCK = 5, /**< The Feedback CLOCK option */
71  ROHC_FEEDBACK_OPT_JITTER = 6, /**< The Feedback JITTER option */
72  ROHC_FEEDBACK_OPT_LOSS = 7, /**< The Feedback LOSS option */
73  ROHC_FEEDBACK_OPT_CV_REQUEST = 8, /**< The Feedback CV-REQUEST option */
74  ROHC_FEEDBACK_OPT_CONTEXT_MEMORY = 9, /**< The Feedback CONTEXT_MEMORY option */
75  ROHC_FEEDBACK_OPT_UNKNOWN_10 = 10, /**< Unknown option with value 10 */
76  ROHC_FEEDBACK_OPT_UNKNOWN_11 = 11, /**< Unknown option with value 11 */
77  ROHC_FEEDBACK_OPT_UNKNOWN_12 = 12, /**< Unknown option with value 12 */
78  ROHC_FEEDBACK_OPT_UNKNOWN_13 = 13, /**< Unknown option with value 13 */
79  ROHC_FEEDBACK_OPT_UNKNOWN_14 = 14, /**< Unknown option with value 14 */
80  ROHC_FEEDBACK_OPT_UNKNOWN_15 = 15, /**< Unknown option with value 15 */
81  ROHC_FEEDBACK_OPT_MAX /**< The max number of feedback options */
82 };
83 
84 
85 /** The ROHC FEEDBACK-2 format as defined in RFC3095 */
87 {
88 #if WORDS_BIGENDIAN == 1
89  uint8_t ack_type:2; /**< The type of acknowledgement \see rohc_feedback_ack_type */
90  uint8_t mode:2; /**< The decompression context mode */
91  uint8_t sn1:4; /**< The 4 first LSB bits of the SN being acked */
92 #else
93  uint8_t sn1:4;
94  uint8_t mode:2;
95  uint8_t ack_type:2;
96 #endif
97  uint8_t sn2; /**< The 8 next LSB bits of the SN being acked */
98 } __attribute__((packed));
99 
100 
101 /** The ROHC FEEDBACK-2 format as defined in RFC6846 */
103 {
104 #if WORDS_BIGENDIAN == 1
105  uint8_t ack_type:2; /**< The type of acknowledgement \see rohc_feedback_ack_type */
106  uint8_t sn1:6; /**< The 6 first LSB bits of the SN being acked */
107 #else
108  uint8_t sn1:6;
109  uint8_t ack_type:2;
110 #endif
111  uint8_t sn2; /**< The 8 next LSB bits of the SN being acked */
112  uint8_t crc; /**< The feedback CRC */
113 } __attribute__((packed));
114 
115 
116 /** The characteristics of one ROHC feedback option */
118 {
119  const char *const name;
120  bool unknown;
121  bool supported;
122  size_t expected_len;
123  enum {
127  } crc_req;
129 };
130 
131 
132 /**
133  * @brief Max occurrences of a feedback option in one feedback packet
134  *
135  * Even if the standard says that some options may be present multiple times,
136  * don't allow more than a raisonable occurrences. It allows the library to
137  * protect itself against abuses.
138  */
139 #define ROHC_FEEDBACK_OPT_MAX_OCCURS 100U
140 
141 
142 /** Feedback options capacities */
143 static const struct rohc_feedback_opt_charac
145 {
146  [0] = {
147  .name = "unknown option with value 0",
148  .unknown = true,
149  },
151  .name = "CRC",
152  .unknown = false,
153  .supported = true,
154  .expected_len = 2U,
156  .max_occurs = {
157  [ROHC_PROFILE_UNCOMPRESSED] = 0, /* RFC3095 §5.10.4 */
158  [ROHC_PROFILE_RTP] = ROHC_FEEDBACK_OPT_MAX_OCCURS, /* RFC3095 §5.7.6.3 */
159  [ROHC_PROFILE_UDP] = ROHC_FEEDBACK_OPT_MAX_OCCURS, /* same as RTP */
160  [ROHC_PROFILE_ESP] = ROHC_FEEDBACK_OPT_MAX_OCCURS, /* same as UDP */
161  [ROHC_PROFILE_IP] = ROHC_FEEDBACK_OPT_MAX_OCCURS, /* same as UDP */
163  [ROHC_PROFILE_TCP] = 0, /* RFC6846 §8.3.2 */
166  }
167  },
169  .name = "REJECT",
170  .unknown = false,
171  .supported = true,
172  .expected_len = 1U,
173  .crc_req = ROHC_FEEDBACK_OPT_CRC_REQUIRED, /* RFC3095, §5.7.6.4 */
174  .max_occurs = {
175  [ROHC_PROFILE_UNCOMPRESSED] = 0, /* RFC3095 §5.10.4 */
176  [ROHC_PROFILE_RTP] = ROHC_FEEDBACK_OPT_MAX_OCCURS, /* RFC3095 §5.7.6.4 */
177  [ROHC_PROFILE_UDP] = ROHC_FEEDBACK_OPT_MAX_OCCURS, /* same as RTP */
178  [ROHC_PROFILE_ESP] = ROHC_FEEDBACK_OPT_MAX_OCCURS, /* same as UDP */
179  [ROHC_PROFILE_IP] = ROHC_FEEDBACK_OPT_MAX_OCCURS, /* same as UDP */
181  [ROHC_PROFILE_TCP] = 1, /* RFC6846 §8.3.2.1 */
184  }
185  },
187  .name = "(M)SN-NOT-VALID",
188  .unknown = false,
189  .supported = true,
190  .expected_len = 1U,
192  .max_occurs = {
193  [ROHC_PROFILE_UNCOMPRESSED] = 0, /* RFC3095 §5.10.4 */
194  [ROHC_PROFILE_RTP] = ROHC_FEEDBACK_OPT_MAX_OCCURS, /* RFC3095 §5.7.6.5 */
195  [ROHC_PROFILE_UDP] = ROHC_FEEDBACK_OPT_MAX_OCCURS, /* same as RTP */
196  [ROHC_PROFILE_ESP] = ROHC_FEEDBACK_OPT_MAX_OCCURS, /* same as UDP */
197  [ROHC_PROFILE_IP] = ROHC_FEEDBACK_OPT_MAX_OCCURS, /* same as UDP */
199  [ROHC_PROFILE_TCP] = 1, /* RFC6846 §8.3.2.2 */
202  }
203  },
205  .name = "(M)SN",
206  .unknown = false,
207  .supported = true,
208  .expected_len = 2U,
210  .max_occurs = {
211  [ROHC_PROFILE_UNCOMPRESSED] = 0, /* RFC3095 §5.10.4 */
212  [ROHC_PROFILE_RTP] = 1, /* RFC4815 §8.5: 1 option needed for 16-bit SN */
213  [ROHC_PROFILE_UDP] = 1, /* same as RTP */
214  [ROHC_PROFILE_ESP] = 3, /* RFC4815 §8.5: 3 options needed for 32-bit SN */
215  [ROHC_PROFILE_IP] = 1, /* same as UDP */
216  [ROHC_PROFILE_RTP_LLA] = 1, /* same as RTP */
217  [ROHC_PROFILE_TCP] = 1, /* RFC6846 §8.3.2.3 */
218  [ROHC_PROFILE_UDPLITE_RTP] = 1, /* same as RTP */
219  [ROHC_PROFILE_UDPLITE] = 1, /* same as UDP */
220  }
221  },
223  .name = "CLOCK",
224  .unknown = false,
225  .supported = false,
226  .expected_len = 2U,
227  .crc_req = ROHC_FEEDBACK_OPT_CRC_SUGGESTED, /* RFC3095, §5.7.6.7 */
228  .max_occurs = {
229  [ROHC_PROFILE_UNCOMPRESSED] = 0, /* RFC3095 §5.10.4 */
230  [ROHC_PROFILE_RTP] = ROHC_FEEDBACK_OPT_MAX_OCCURS, /* RFC3095 §5.7.6.7 */
231  [ROHC_PROFILE_UDP] = 0, /* RFC3095 §5.11.6 */
232  [ROHC_PROFILE_ESP] = 0, /* same as UDP */
233  [ROHC_PROFILE_IP] = 0, /* same as UDP */
235  [ROHC_PROFILE_TCP] = 0, /* RFC6846 §8.3.2 */
237  [ROHC_PROFILE_UDPLITE] = 0, /* same as UDP */
238  }
239  },
241  .name = "JITTER",
242  .unknown = false,
243  .supported = false,
244  .expected_len = 2U,
245  .crc_req = ROHC_FEEDBACK_OPT_CRC_SUGGESTED, /* RFC3095, §5.7.6.8 */
246  .max_occurs = {
247  [ROHC_PROFILE_UNCOMPRESSED] = 0, /* RFC3095 §5.10.4 */
248  [ROHC_PROFILE_RTP] = ROHC_FEEDBACK_OPT_MAX_OCCURS, /* RFC3095 §5.7.6.8 */
249  [ROHC_PROFILE_UDP] = 0, /* RFC3095 §5.11.6 */
250  [ROHC_PROFILE_ESP] = 0, /* same as UDP */
251  [ROHC_PROFILE_IP] = 0, /* same as UDP */
253  [ROHC_PROFILE_TCP] = 0, /* RFC6846 §8.3.2 */
255  [ROHC_PROFILE_UDPLITE] = 0, /* same as UDP */
256  }
257  },
259  .name = "LOSS",
260  .unknown = false,
261  .supported = false,
262  .expected_len = 2U,
263  .crc_req = ROHC_FEEDBACK_OPT_CRC_SUGGESTED, /* RFC3095, §5.7.6.9 */
264  .max_occurs = {
265  [ROHC_PROFILE_UNCOMPRESSED] = 0, /* RFC3095 §5.10.4 */
266  [ROHC_PROFILE_RTP] = ROHC_FEEDBACK_OPT_MAX_OCCURS, /* RFC3095 §5.7.6.9 */
267  [ROHC_PROFILE_UDP] = ROHC_FEEDBACK_OPT_MAX_OCCURS, /* same as RTP */
268  [ROHC_PROFILE_ESP] = ROHC_FEEDBACK_OPT_MAX_OCCURS, /* same as UDP */
269  [ROHC_PROFILE_IP] = ROHC_FEEDBACK_OPT_MAX_OCCURS, /* same as UDP */
271  [ROHC_PROFILE_TCP] = 0, /* RFC6846 §8.3.2 */
274  }
275  },
277  .name = "CV-REQUEST",
278  .unknown = false,
279  .supported = false,
280  .expected_len = 1U,
282  .max_occurs = {
283  [ROHC_PROFILE_UNCOMPRESSED] = 0, /* RFC3095 §5.10.4 */
284  [ROHC_PROFILE_RTP] = 0, /* RFC3095 §5.7.6.2 */
285  [ROHC_PROFILE_UDP] = 0, /* same as RTP */
286  [ROHC_PROFILE_ESP] = 0, /* same as UDP */
287  [ROHC_PROFILE_IP] = 0, /* same as UDP */
288  [ROHC_PROFILE_RTP_LLA] = ROHC_FEEDBACK_OPT_MAX_OCCURS, /* RFC4362 §4.5 */
289  [ROHC_PROFILE_TCP] = 0, /* RFC6846 §8.3.2 */
290  [ROHC_PROFILE_UDPLITE_RTP] = 0, /* same as RTP */
291  [ROHC_PROFILE_UDPLITE] = 0, /* same as UDP */
292  }
293  },
295  .name = "CONTEXT_MEMORY",
296  .unknown = false,
297  .supported = false,
298  .expected_len = 1U,
300  .max_occurs = {
301  [ROHC_PROFILE_UNCOMPRESSED] = 0, /* RFC3095 §5.10.4 */
302  [ROHC_PROFILE_RTP] = 0, /* RFC3095 §5.7.6.2 */
303  [ROHC_PROFILE_UDP] = 0, /* same as RTP */
304  [ROHC_PROFILE_ESP] = 0, /* same as UDP */
305  [ROHC_PROFILE_IP] = ROHC_FEEDBACK_OPT_MAX_OCCURS, /* RFC3843 §3.7 */
306  [ROHC_PROFILE_RTP_LLA] = 0, /* same as RTP */
307  [ROHC_PROFILE_TCP] = 1, /* RFC6846 §8.3.2.4 */
309  [ROHC_PROFILE_UDPLITE] = ROHC_FEEDBACK_OPT_MAX_OCCURS, /* RFC4019 §5.7 */
310  }
311  },
313  .name = "unknown option with value 10",
314  .unknown = true,
315  },
317  .name = "unknown option with value 11",
318  .unknown = true,
319  },
321  .name = "unknown option with value 12",
322  .unknown = true,
323  },
325  .name = "unknown option with value 13",
326  .unknown = true,
327  },
329  .name = "unknown option with value 14",
330  .unknown = true,
331  },
333  .name = "unknown option with value 15",
334  .unknown = true,
335  },
336 };
337 
338 
339 #endif
340 
uint8_t mode
Definition: feedback.h:94
Definition: feedback.h:78
const char *const name
Definition: feedback.h:119
Definition: feedback.h:77
Definition: feedback.h:71
uint8_t sn1
Definition: feedback.h:93
uint8_t ack_type
Definition: feedback.h:95
rohc_feedback_ack_type
Definition: feedback.h:50
Definition: feedback.h:102
bool supported
Definition: feedback.h:121
Definition: rohc.h:228
Definition: feedback.h:63
rohc_feedback_opt
Definition: feedback.h:60
Definition: rohc.h:217
Definition: feedback.h:74
Definition: feedback.h:73
Definition: feedback.h:52
bool unknown
Definition: feedback.h:120
Definition: feedback.h:76
ROHC common definitions and routines.
Definition: feedback.h:70
Definition: feedback.h:45
size_t expected_len
Definition: feedback.h:122
size_t max_occurs[ROHC_PROFILE_MAX]
Definition: feedback.h:128
Definition: feedback.h:72
Definition: feedback.h:117
Definition: feedback.h:75
Definition: feedback.h:67
Definition: feedback.h:64
Definition: feedback.h:86
Definition: feedback.h:55
Definition: rohc.h:234
Definition: feedback.h:80
enum rohc_feedback_opt_charac::@0 crc_req
Definition: rohc.h:230
Definition: feedback.h:54
Definition: rohc.h:223
Definition: rohc.h:232
Definition: feedback.h:62
uint8_t sn1
Definition: feedback.h:108
Definition: rohc.h:215
uint8_t ack_type
Definition: feedback.h:109
#define ROHC_FEEDBACK_OPT_MAX_OCCURS
Max occurrences of a feedback option in one feedback packet.
Definition: feedback.h:139
Definition: feedback.h:79
uint8_t crc
Definition: feedback.h:112
uint8_t sn2
Definition: feedback.h:111
Definition: feedback.h:81
Definition: feedback.h:53
uint8_t sn2
Definition: feedback.h:97
Definition: rohc.h:226
rohc_feedback_type
Definition: feedback.h:42
Definition: rohc.h:221
Definition: feedback.h:44
Definition: rohc.h:219