ROHC compression/decompression library
|
00001 /* 00002 * Copyright 2011,2012,2013 Didier Barvaux 00003 * Copyright 2009,2010 Thales Communications 00004 * Copyright 2010,2012 Viveris Technologies 00005 * 00006 * This library is free software; you can redistribute it and/or 00007 * modify it under the terms of the GNU Lesser General Public 00008 * License as published by the Free Software Foundation; either 00009 * version 2.1 of the License, or (at your option) any later version. 00010 * 00011 * This library is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00014 * Lesser General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU Lesser General Public 00017 * License along with this library; if not, write to the Free Software 00018 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 00019 */ 00020 00021 /** 00022 * @file rohc_traces_internal.h 00023 * @brief Internal ROHC macros and functions for traces 00024 * @author Julien Bernard <julien.bernard@toulouse.viveris.com> 00025 * @author Audric Schiltknecht <audric.schiltknecht@toulouse.viveris.com> 00026 * @author Didier Barvaux <didier.barvaux@toulouse.viveris.com> 00027 * @author Didier Barvaux <didier@barvaux.org> 00028 */ 00029 00030 #ifndef ROHC_TRACES_INTERNAL_H 00031 #define ROHC_TRACES_INTERNAL_H 00032 00033 #include "rohc_traces.h" 00034 #include "rohc_buf.h" 00035 00036 #include "config.h" /* for ROHC_ENABLE_DEPRECATED_API */ 00037 00038 #include <stdlib.h> 00039 #include <assert.h> 00040 00041 #include "dllexport.h" 00042 00043 00044 #if !defined(ROHC_ENABLE_DEPRECATED_API) || ROHC_ENABLE_DEPRECATED_API == 1 00045 /** Print information depending on the debug level (internal usage) */ 00046 #define __rohc_print(trace_cb, trace_cb2, trace_cb_priv, \ 00047 level, entity, profile, format, ...) \ 00048 do { \ 00049 if(trace_cb2 != NULL) { \ 00050 trace_cb2(trace_cb_priv, level, entity, profile, \ 00051 "[%s:%d %s()] " format "\n", \ 00052 __FILE__, __LINE__, __FUNCTION__, ##__VA_ARGS__); \ 00053 } else if(trace_cb != NULL) { \ 00054 trace_cb(level, entity, profile, \ 00055 "[%s:%d %s()] " format "\n", \ 00056 __FILE__, __LINE__, __FUNCTION__, ##__VA_ARGS__); \ 00057 } \ 00058 } while(0) 00059 #else 00060 /** Print information depending on the debug level (internal usage) */ 00061 #define __rohc_print(trace_cb, trace_cb_priv, \ 00062 level, entity, profile, format, ...) \ 00063 do { \ 00064 if(trace_cb != NULL) { \ 00065 trace_cb(trace_cb_priv, level, entity, profile, \ 00066 "[%s:%d %s()] " format "\n", \ 00067 __FILE__, __LINE__, __FUNCTION__, ##__VA_ARGS__); \ 00068 } \ 00069 } while(0) 00070 #endif 00071 00072 #if !defined(ROHC_ENABLE_DEPRECATED_API) || ROHC_ENABLE_DEPRECATED_API == 1 00073 /** Print information depending on the debug level */ 00074 #define rohc_print(entity_struct, level, entity, profile, format, ...) \ 00075 do { \ 00076 assert((entity_struct) != NULL); \ 00077 __rohc_print((entity_struct)->trace_callback, \ 00078 (entity_struct)->trace_callback2, \ 00079 (entity_struct)->trace_callback_priv, \ 00080 level, entity, profile, \ 00081 format, ##__VA_ARGS__); \ 00082 } while(0) 00083 #else 00084 /** Print information depending on the debug level */ 00085 #define rohc_print(entity_struct, level, entity, profile, format, ...) \ 00086 do { \ 00087 assert((entity_struct) != NULL); \ 00088 __rohc_print((entity_struct)->trace_callback2, \ 00089 (entity_struct)->trace_callback_priv, \ 00090 level, entity, profile, \ 00091 format, ##__VA_ARGS__); \ 00092 } while(0) 00093 #endif 00094 00095 /** Print debug messages prefixed with the function name */ 00096 #define rohc_debug(entity_struct, entity, profile, format, ...) \ 00097 rohc_print(entity_struct, ROHC_TRACE_DEBUG, entity, profile, \ 00098 format, ##__VA_ARGS__) 00099 00100 /** Print information prefixed with the function name */ 00101 #define rohc_info(entity_struct, entity, profile, format, ...) \ 00102 rohc_print(entity_struct, ROHC_TRACE_INFO, entity, profile, \ 00103 format, ##__VA_ARGS__) 00104 00105 /** Print warning messages prefixed with the function name */ 00106 #define rohc_warning(entity_struct, entity, profile, format, ...) \ 00107 rohc_print(entity_struct, ROHC_TRACE_WARNING, entity, profile, \ 00108 format, ##__VA_ARGS__) 00109 00110 /** Print error messages prefixed with the function name */ 00111 #define rohc_error(entity_struct, entity, profile, format, ...) \ 00112 rohc_print(entity_struct, ROHC_TRACE_ERROR, entity, profile, \ 00113 format, ##__VA_ARGS__) 00114 00115 /** 00116 * @brief Stop processing if the given condition is false 00117 * 00118 * In non-debug mode (ie. NDEBUG set): if the given condition fails, prints 00119 * the given message then jump to the given label. 00120 * 00121 * In debug mode (ie. NDEBUG not set): if the given condition fails, prints 00122 * the given message then asserts. 00123 */ 00124 #define rohc_assert(entity_struct, entity, profile, \ 00125 condition, label, format, ...) \ 00126 do { \ 00127 if(!(condition)) { \ 00128 rohc_error(entity_struct, entity, profile, \ 00129 format, ##__VA_ARGS__); \ 00130 assert(condition); \ 00131 goto label; \ 00132 } \ 00133 } while(0) 00134 00135 00136 void ROHC_EXPORT rohc_dump_packet( 00137 #if !defined(ROHC_ENABLE_DEPRECATED_API) || ROHC_ENABLE_DEPRECATED_API == 1 00138 const rohc_trace_callback_t trace_cb, 00139 #endif 00140 const rohc_trace_callback2_t trace_cb2, 00141 void *const trace_cb_priv, 00142 const rohc_trace_entity_t trace_entity, 00143 const rohc_trace_level_t trace_level, 00144 const char *const descr, 00145 const struct rohc_buf packet); 00146 00147 void ROHC_EXPORT rohc_dump_buf( 00148 #if !defined(ROHC_ENABLE_DEPRECATED_API) || ROHC_ENABLE_DEPRECATED_API == 1 00149 const rohc_trace_callback_t trace_cb, 00150 #endif 00151 const rohc_trace_callback2_t trace_cb2, 00152 void *const trace_cb_priv, 00153 const rohc_trace_entity_t trace_entity, 00154 const rohc_trace_level_t trace_level, 00155 const char *const descr, 00156 const unsigned char *const packet, 00157 const size_t length); 00158 00159 #endif 00160