ROHC compression/decompression library
protocols/ip.h
Go to the documentation of this file.
1 /*
2  * Copyright 2015 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 protocols/ip.h
21  * @brief Defines the common IPv4/v6 header
22  * @author Didier Barvaux <didier@barvaux.org>
23  */
24 
25 #ifndef ROHC_PROTOCOLS_IP_H
26 #define ROHC_PROTOCOLS_IP_H
27 
28 #include <stdint.h>
29 
30 #ifdef __KERNEL__
31 # include <endian.h>
32 #else
33 # include "config.h" /* for WORDS_BIGENDIAN */
34 #endif
35 
36 
37 /**
38  * @brief The maximum number of IP headers supported
39  *
40  * Used by the ROHCv1 TCP and ROHCv2 profiles. Not used by the other ROHCv1
41  * profiles.
42  *
43  * The limit value was chosen arbitrarily. It should handle most real-life case
44  * without hurting performances nor memory footprint.
45  */
46 #define ROHC_MAX_IP_HDRS 2U
47 
48 
49 /**
50  * @brief The maximum number of IP headers supported
51  *
52  * Used by the ROHCv1 profiles, except the TCP profile.
53  *
54  * The limit value was not chosen arbitrarily, those profiles only support
55  * 2 levels of IP headers.
56  */
57 #define ROHC_MAX_IP_HDRS_RFC3095 2U
58 
59 
60 /**
61  * @brief The maximum number of IP extension headers supported
62  *
63  * Used by the ROHCv1 TCP and ROHCv2 profiles. Not used by the other ROHCv1
64  * profiles.
65  *
66  * The limit value was chosen arbitrarily. It should handle most real-life case
67  * without hurting performances nor memory footprint.
68  */
69 #define ROHC_MAX_IP_EXT_HDRS 3U
70 
71 
72 /** The common IPv4/v6 header */
73 struct ip_hdr
74 {
75 #if WORDS_BIGENDIAN == 1
76  uint8_t version:4; /**< The IP version */
77  uint8_t reserved:4; /**< That field depends on IP version */
78 #else
79  uint8_t reserved:4;
80  uint8_t version:4;
81 #endif
82 } __attribute__((packed));
83 
84 
85 #endif
86 
uint8_t version
Definition: protocols/ip.h:80
uint8_t reserved
Definition: protocols/ip.h:79
Definition: protocols/ip.h:73