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 extension headers supported
51  *
52  * Used by the ROHCv1 TCP and ROHCv2 profiles. Not used by the other ROHCv1
53  * profiles.
54  *
55  * The limit value was chosen arbitrarily. It should handle most real-life case
56  * without hurting performances nor memory footprint.
57  */
58 #define ROHC_MAX_IP_EXT_HDRS 5U
59 
60 
61 /** The common IPv4/v6 header */
62 struct ip_hdr
63 {
64 #if WORDS_BIGENDIAN == 1
65  uint8_t version:4; /**< The IP version */
66  uint8_t reserved:4; /**< That field depends on IP version */
67 #else
68  uint8_t reserved:4;
69  uint8_t version:4;
70 #endif
71 } __attribute__((packed));
72 
73 
74 #endif
75 
uint8_t version
Definition: protocols/ip.h:69
uint8_t reserved
Definition: protocols/ip.h:68
Definition: protocols/ip.h:62