ROHC compression/decompression library
feedback_create.h
Go to the documentation of this file.
00001 /*
00002  * Copyright 2011,2013,2014 Didier Barvaux
00003  * Copyright 2007,2009,2010,2012 Viveris Technologies
00004  *
00005  * This library is free software; you can redistribute it and/or
00006  * modify it under the terms of the GNU Lesser General Public
00007  * License as published by the Free Software Foundation; either
00008  * version 2.1 of the License, or (at your option) any later version.
00009  *
00010  * This library is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013  * Lesser General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU Lesser General Public
00016  * License along with this library; if not, write to the Free Software
00017  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
00018  */
00019 
00020 /**
00021  * @file   feedback_create.h
00022  * @brief  Functions to create ROHC feedback
00023  * @author Didier Barvaux <didier.barvaux@toulouse.viveris.com>
00024  * @author Didier Barvaux <didier@barvaux.org>
00025  */
00026 
00027 #ifndef ROHC_DECOMP_FEEDBACK_CREATE_H
00028 #define ROHC_DECOMP_FEEDBACK_CREATE_H
00029 
00030 #include <rohc/rohc.h>
00031 #include <rohc/rohc_buf.h>
00032 
00033 #include <stdint.h>
00034 #include <stdlib.h>
00035 #include <stdbool.h>
00036 
00037 #include "dllexport.h"
00038 
00039 
00040 /**
00041  * @brief The different feedback options
00042  */
00043 typedef enum
00044 {
00045         ROHC_FEEDBACK_OPT_CRC          = 1, /**< FEEDBACK-2 CRC option */
00046         ROHC_FEEDBACK_OPT_REJECT       = 2, /**< FEEDBACK-2 Reject option */
00047         ROHC_FEEDBACK_OPT_SN_NOT_VALID = 3, /**< FEEDBACK-2 SN-not-valid option */
00048         ROHC_FEEDBACK_OPT_SN           = 4, /**< FEEDBACK-2 SN option */
00049         ROHC_FEEDBACK_OPT_CLOCK        = 5, /**< FEEDBACK-2 Clock option */
00050         ROHC_FEEDBACK_OPT_JITTER       = 6, /**< FEEDBACK-2 Jitter option */
00051         ROHC_FEEDBACK_OPT_LOSS         = 7, /**< FEEDBACK-2 Loss option */
00052 
00053 } rohc_feedback_opt_t;
00054 
00055 
00056 /**
00057  * @brief The different types of feedback acknowledgements
00058  */
00059 typedef enum
00060 {
00061         ROHC_ACK_TYPE_ACK         = 0, /**< positive ACKnowledgement (ACK) */
00062         ROHC_ACK_TYPE_NACK        = 1, /**< Negative ACKnowledgement (NACK) */
00063         ROHC_ACK_TYPE_STATIC_NACK = 2, /**< static Negative ACK (STATIC-NACK) */
00064 
00065 } rohc_ack_type_t;
00066 
00067 
00068 /**
00069  * @brief Whether the feedback is protected by a CRC or not
00070  */
00071 typedef enum
00072 {
00073         ROHC_FEEDBACK_NO_CRC   = false, /**< No CRC option protects the feedback */
00074         ROHC_FEEDBACK_WITH_CRC = true,  /**< A CRC option protects the feedback */
00075 
00076 } rohc_feedback_crc_t;
00077 
00078 
00079 /// The maximum length (in bytes) of the feedback data
00080 #define FEEDBACK_DATA_MAX_LEN  30
00081 
00082 
00083 /**
00084  * @brief Defines a ROHC feedback.
00085  */
00086 struct d_feedback
00087 {
00088         /// The type of feedback (1 for FEEDBACK-1 and 2 for FEEDBACK-2)
00089         int type;
00090         /// The feedback data
00091         uint8_t data[FEEDBACK_DATA_MAX_LEN];
00092         /// The size of feedback data
00093         int size;
00094 };
00095 
00096 
00097 /*
00098  * Prototypes of public functions.
00099  */
00100 
00101 bool ROHC_EXPORT rohc_decomp_feedback_size(const struct rohc_buf rohc_data,
00102                                            size_t *const feedback_hdr_len,
00103                                            size_t *const feedback_data_len)
00104         __attribute__((warn_unused_result, nonnull(2, 3)));
00105 
00106 void f_feedback1(const uint32_t sn, struct d_feedback *const feedback)
00107         __attribute__((nonnull(2)));
00108 
00109 bool f_feedback2(const rohc_ack_type_t ack_type,
00110                  const rohc_mode_t mode,
00111                  const uint32_t sn,
00112                  struct d_feedback *const feedback)
00113         __attribute__((warn_unused_result, nonnull(4)));
00114 
00115 bool f_add_option(struct d_feedback *const feedback,
00116                   const rohc_feedback_opt_t opt_type,
00117                   const unsigned char *const data,
00118                   const size_t data_len)
00119         __attribute__((warn_unused_result, nonnull(1)));
00120 
00121 uint8_t * f_wrap_feedback(struct d_feedback *feedback,
00122                           const uint16_t cid,
00123                           const rohc_cid_type_t cid_type,
00124                           const rohc_feedback_crc_t protect_with_crc,
00125                           const uint8_t *const crc_table,
00126                           size_t *const final_size)
00127         __attribute__((warn_unused_result, nonnull(1, 5, 6)));
00128 
00129 
00130 #endif
00131