ROHC compression/decompression library
decomp/schemes/ip_ctxt.h
Go to the documentation of this file.
1 /*
2  * Copyright 2012,2013,2014 Didier Barvaux
3  * Copyright 2013,2014,2018 Viveris Technologies
4  * Copyright 2012 WBX
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19  */
20 
21 /**
22  * @file decomp/schemes/ip_ctxt.h
23  * @brief The decompression context for IP headers
24  * @author FWX <rohc_team@dialine.fr>
25  * @author Didier Barvaux <didier@barvaux.org>
26  * @author Didier Barvaux <didier.barvaux@toulouse.viveris.com>
27  */
28 
29 #ifndef ROHC_DECOMP_SCHEMES_IP_CTXT_H
30 #define ROHC_DECOMP_SCHEMES_IP_CTXT_H
31 
32 #include "protocols/ip.h"
33 #include "protocols/tcp.h"
34 
35 
36 /**
37  * @brief Define the IPv6 option context for Destination, Hop-by-Hop
38  * and Routing option
39  */
40 typedef struct
41 {
42  uint8_t data[IPV6_OPT_CTXT_LEN_MAX];
43  uint16_t data_len; /* max length = (0xff + 1) * 8 = 2048 bytes */
44 
46 
47 /* compiler sanity check for C11-compliant compilers and GCC >= 4.6 */
48 #if ((defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L) || \
49  (defined(__GNUC__) && defined(__GNUC_MINOR__) && \
50  (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6))))
51 _Static_assert((sizeof(ipv6_generic_option_context_t) % 8) == 0,
52  "ipv6_generic_option_context_t length should be multiple of 8 bytes");
53 #endif
54 
55 
56 /** The decompression context for one IP extension header */
57 typedef struct
58 {
59  uint16_t len; /**< The length (in bytes) of the extension header */
60 
61  uint8_t proto; /**< The protocol of the extension header */
62  uint8_t nh_proto; /**< The protocol of the next header */
63  uint8_t unused[4];
64 
65  ipv6_generic_option_context_t generic; /**< IPv6 generic extension header */
66 
68 
69 /* compiler sanity check for C11-compliant compilers and GCC >= 4.6 */
70 #if ((defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L) || \
71  (defined(__GNUC__) && defined(__GNUC_MINOR__) && \
72  (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6))))
73 _Static_assert((offsetof(ip_option_context_t, generic) % 8) == 0,
74  "generic in ip_option_context_t should be aligned on 8 bytes");
75 _Static_assert((sizeof(ip_option_context_t) % 8) == 0,
76  "ip_option_context_t length should be multiple of 8 bytes");
77 #endif
78 
79 
80 /**
81  * @brief The TCP decompression context for one IPv4 or IPv6 header
82  */
83 typedef struct
84 {
85  uint32_t flow_label:20; /**< IPv6 Flow Label */
86  union
87  {
88  struct
89  {
90  uint32_t dscp:6;
91  uint32_t ip_ecn_flags:2;
92  };
93  uint32_t tos_tc:8;
94  };
95  uint32_t df:1;
96  uint32_t unused:3;
97 
98  uint16_t ip_id;
99  uint8_t next_header;
100  uint8_t ttl_hopl;
101 
102  uint32_t saddr[4];
103  uint32_t daddr[4];
104 
106  uint16_t opts_len; /* no more than the max IPv6 length, ie. 65535 */
107  uint8_t opts_nr;
108 
109  uint8_t version:4;
110  uint8_t ip_id_behavior:2;
111  uint8_t unused2:2;
112  uint8_t unused3[4];
113 
114 } ip_context_t;
115 
116 /* compiler sanity check for C11-compliant compilers and GCC >= 4.6 */
117 #if ((defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L) || \
118  (defined(__GNUC__) && defined(__GNUC_MINOR__) && \
119  (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6))))
120 _Static_assert((offsetof(ip_context_t, saddr) % 8) == 0,
121  "saddr in ip_context_t should be aligned on 8 bytes");
122 _Static_assert((offsetof(ip_context_t, daddr) % 8) == 0,
123  "daddr in ip_context_t should be aligned on 8 bytes");
124 _Static_assert((offsetof(ip_context_t, opts_len) % 8) == 0,
125  "opts_len in ip_context_t should be aligned on 8 bytes");
126 _Static_assert((offsetof(ip_context_t, opts) % 8) == 0,
127  "opts in ip_context_t should be aligned on 8 bytes");
128 _Static_assert((sizeof(ip_context_t) % 8) == 0,
129  "ip_context_t length should be multiple of 8 bytes");
130 #endif
131 
132 #endif /* ROHC_DECOMP_SCHEMES_IP_CTXT_H */
133 
Define the IPv6 generic option context.
Definition: comp/schemes/ip_ctxt.h:41
uint16_t ip_id
Definition: decomp/schemes/ip_ctxt.h:98
uint16_t len
Definition: decomp/schemes/ip_ctxt.h:59
uint16_t opts_len
Definition: decomp/schemes/ip_ctxt.h:106
Definition: comp/schemes/ip_ctxt.h:64
#define IPV6_OPT_CTXT_LEN_MAX
Definition: ipv6.h:148
#define ROHC_MAX_IP_EXT_HDRS
The maximum number of IP extension headers supported.
Definition: protocols/ip.h:69
uint8_t nh_proto
Definition: decomp/schemes/ip_ctxt.h:62
The TCP compression context for one IPv4 or IPv6 header.
Definition: comp/schemes/ip_ctxt.h:76
Defines the common IPv4/v6 header.
TCP header description.
uint8_t proto
Definition: decomp/schemes/ip_ctxt.h:61
uint16_t data_len
Definition: decomp/schemes/ip_ctxt.h:43