ROHC compression/decompression library
rohc_utils.h
Go to the documentation of this file.
1 /*
2  * Copyright 2012,2013 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 rohc_utils.h
21  * @brief Miscellaneous utils for ROHC libraries
22  * @author Didier Barvaux <didier@barvaux.org>
23  */
24 
25 #ifndef ROHC_UTILS_H
26 #define ROHC_UTILS_H
27 
28 #include <stdint.h>
29 #include <stdbool.h>
30 
31 
32 /** TODO */
33 typedef enum
34 {
39 
40 
41 /** Get the max value of the 2 given */
42 #define rohc_max(value1, value2) \
43  ( ((value1) >= (value2)) ? (value1) : (value2) )
44 
45 /** Get the max value of the 2 given */
46 #define rohc_min(value1, value2) \
47  ( ((value1) <= (value2)) ? (value1) : (value2) )
48 
49 
50 static inline unsigned int rohc_b2u(const bool boolean)
51  __attribute__((warn_unused_result, const));
52 
53 uint32_t rohc_ntoh32(const uint32_t net32)
54  __attribute__((warn_unused_result, const));
55 uint16_t rohc_ntoh16(const uint16_t net16)
56  __attribute__((warn_unused_result, const));
57 uint32_t rohc_hton32(const uint32_t host32)
58  __attribute__((warn_unused_result, const));
59 uint16_t rohc_hton16(const uint16_t host16)
60  __attribute__((warn_unused_result, const));
61 
62 
63 /**
64  * @brief Convert the given boolean value to one unsigned integer
65  *
66  * true is converted to 1 ; false is converted to 0
67  *
68  * @param boolean The boolean value to convert
69  * @return The converted unsigned integer value
70  */
71 static inline unsigned int rohc_b2u(const bool boolean)
72 {
73  return (boolean ? 1 : 0);
74 }
75 
76 #endif
77 
static unsigned int rohc_b2u(const bool boolean)
Convert the given boolean value to one unsigned integer.
Definition: rohc_utils.h:71
uint32_t rohc_hton32(const uint32_t host32)
Convert a 32-bit long integer from host to network byte orders.
Definition: rohc_utils.c:88
uint32_t rohc_ntoh32(const uint32_t net32)
Convert a 32-bit long integer from network to host byte orders.
Definition: rohc_utils.c:55
Definition: rohc_utils.h:37
Definition: rohc_utils.h:36
Definition: rohc_utils.h:35
uint16_t rohc_ntoh16(const uint16_t net16)
Convert a 16-bit short integer from network to host byte orders.
Definition: rohc_utils.c:71
rohc_tristate_t
Definition: rohc_utils.h:33
uint16_t rohc_hton16(const uint16_t host16)
Convert a 16-bit short integer from host to network byte orders.
Definition: rohc_utils.c:104