ROHC compression/decompression library
feedback_create.h
Go to the documentation of this file.
1 /*
2  * Copyright 2011,2013,2014 Didier Barvaux
3  * Copyright 2007,2009,2010,2012 Viveris Technologies
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 feedback_create.h
22  * @brief Functions to create ROHC feedback
23  * @author Didier Barvaux <didier.barvaux@toulouse.viveris.com>
24  * @author Didier Barvaux <didier@barvaux.org>
25  */
26 
27 #ifndef ROHC_DECOMP_FEEDBACK_CREATE_H
28 #define ROHC_DECOMP_FEEDBACK_CREATE_H
29 
30 #include <rohc/rohc.h>
31 #include <rohc/rohc_buf.h>
32 #include <feedback.h>
33 
34 #include <stdint.h>
35 #include <stdlib.h>
36 #include <stdbool.h>
37 
38 
39 /**
40  * @brief Whether the feedback is protected by a CRC or not
41  */
42 typedef enum
43 {
44  ROHC_FEEDBACK_WITH_NO_CRC = 0, /**< No CRC protects the feedback */
45  ROHC_FEEDBACK_WITH_CRC_OPT = 1, /**< A CRC option protects the feedback */
46  ROHC_FEEDBACK_WITH_CRC_BASE = 2, /**< A base header CRC protects the feedback */
47 
49 
50 
51 /// The maximum length (in bytes) of the feedback data
52 #define FEEDBACK_DATA_MAX_LEN 30
53 
54 
55 /**
56  * @brief Defines a ROHC feedback.
57  */
58 struct d_feedback
59 {
60  /// The type of feedback (1 for FEEDBACK-1 and 2 for FEEDBACK-2)
62  /// The feedback data
64  /// The size of feedback data
65  int size;
66 };
67 
68 
69 /*
70  * Prototypes of public functions.
71  */
72 
73 bool rohc_decomp_feedback_size(const struct rohc_buf rohc_data,
74  size_t *const feedback_hdr_len,
75  size_t *const feedback_data_len)
76  __attribute__((warn_unused_result, nonnull(2, 3)));
77 
78 void f_feedback1(const uint32_t sn_bits, struct d_feedback *const feedback)
79  __attribute__((nonnull(2)));
80 
81 bool f_feedback2(const rohc_profile_t profile_id,
82  const enum rohc_feedback_ack_type ack_type,
83  const rohc_mode_t mode,
84  const uint32_t sn_bits,
85  const size_t sn_bits_nr,
86  struct d_feedback *const feedback)
87  __attribute__((warn_unused_result, nonnull(6)));
88 
89 bool f_add_option(struct d_feedback *const feedback,
90  const enum rohc_feedback_opt opt_type,
91  const uint8_t *const data,
92  const size_t data_len)
93  __attribute__((warn_unused_result, nonnull(1)));
94 
95 uint8_t * f_wrap_feedback(struct d_feedback *feedback,
96  const uint16_t cid,
97  const rohc_cid_type_t cid_type,
98  const rohc_feedback_crc_t protect_with_crc,
99  const uint8_t *const crc_table,
100  size_t *const final_size)
101  __attribute__((warn_unused_result, nonnull(1, 5, 6)));
102 
103 
104 #endif
105 
rohc_feedback_ack_type
Definition: feedback.h:50
rohc_mode_t
ROHC operation modes.
Definition: rohc.h:109
bool rohc_decomp_feedback_size(const struct rohc_buf rohc_data, size_t *const feedback_hdr_len, size_t *const feedback_data_len)
rohc_feedback_opt
Definition: feedback.h:60
Definition: feedback_create.h:45
uint8_t data[FEEDBACK_DATA_MAX_LEN]
The feedback data.
Definition: feedback_create.h:63
rohc_cid_type_t
The different types of Context IDs (CID)
Definition: rohc.h:174
int size
The size of feedback data.
Definition: feedback_create.h:65
Defines a ROHC feedback.
Definition: feedback_create.h:58
enum rohc_feedback_ack_type type
The type of feedback (1 for FEEDBACK-1 and 2 for FEEDBACK-2)
Definition: feedback_create.h:61
Definition: feedback_create.h:46
bool f_add_option(struct d_feedback *const feedback, const enum rohc_feedback_opt opt_type, const uint8_t *const data, const size_t data_len)
Add an option data to the FEEDBACK-2 packet.
Definition: feedback_create.c:236
Definition: feedback_create.h:44
A network buffer for the ROHC library.
Definition: rohc_buf.h:102
uint8_t * f_wrap_feedback(struct d_feedback *feedback, const uint16_t cid, const rohc_cid_type_t cid_type, const rohc_feedback_crc_t protect_with_crc, const uint8_t *const crc_table, size_t *const final_size)
Wrap the feedback packet and add a CRC option if specified.
Definition: feedback_create.c:395
#define FEEDBACK_DATA_MAX_LEN
The maximum length (in bytes) of the feedback data.
Definition: feedback_create.h:52
rohc_feedback_crc_t
Whether the feedback is protected by a CRC or not.
Definition: feedback_create.h:42
void f_feedback1(const uint32_t sn_bits, struct d_feedback *const feedback)
Build a FEEDBACK-1 packet.
Definition: feedback_create.c:58
rohc_profile_t
The different ROHC compression/decompression profiles.
Definition: rohc.h:210
bool f_feedback2(const rohc_profile_t profile_id, const enum rohc_feedback_ack_type ack_type, const rohc_mode_t mode, const uint32_t sn_bits, const size_t sn_bits_nr, struct d_feedback *const feedback)
Build a FEEDBACK-2 packet.
Definition: feedback_create.c:85
ROHC feedback definitions and formats.