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 __attribute__((packed))
41 {
42  size_t data_len;
43  uint8_t data[IPV6_OPT_CTXT_LEN_MAX];
44 
46 
47 
48 /**
49  * @brief Define the IPv6 option context for GRE option
50  */
51 typedef struct __attribute__((packed)) ipv6_gre_option_context
52 {
53  uint8_t c_flag:1;
54  uint8_t k_flag:1;
55  uint8_t s_flag:1;
56  uint8_t protocol:1;
57  uint8_t padding:4;
58 
59  uint32_t key; // if k_flag set
60  uint32_t sequence_number; // if s_flag set
61 
63 
64 
65 /**
66  * @brief Define the IPv6 option context for MIME option
67  */
68 typedef struct __attribute__((packed)) ipv6_mime_option_context
69 {
70  uint8_t s_bit:1;
71  uint8_t res_bits:7;
72  uint32_t orig_dest;
73  uint32_t orig_src; // if s_bit set
74 
76 
77 
78 /**
79  * @brief Define the IPv6 option context for AH option
80  */
81 typedef struct __attribute__((packed)) ipv6_ah_option_context
82 {
83  uint32_t spi;
84  uint32_t sequence_number;
85  uint32_t auth_data[1];
87 
88 
89 /** The decompression context for one IP extension header */
90 typedef struct
91 {
92  size_t len; /**< The length (in bytes) of the extension header */
93  uint8_t proto; /**< The protocol of the extension header */
94  uint8_t nh_proto; /**< The protocol of the next header */
95 
96  union
97  {
98  ipv6_generic_option_context_t generic; /**< IPv6 generic extension header */
99  ipv6_gre_option_context_t gre; /**< IPv6 GRE extension header */
100  ipv6_mime_option_context_t mime; /**< IPv6 MIME extension header */
101  ipv6_ah_option_context_t ah; /**< IPv6 AH extension header */
102  };
103 
105 
106 
107 /**
108  * @brief Define the common IP header context to IPv4 and IPv6
109  */
110 typedef struct __attribute__((packed)) ipvx_context
111 {
112  uint8_t version:4;
113  uint8_t unused:4;
114 
115  union
116  {
117  struct
118  {
119  uint8_t dscp:6;
120  uint8_t ip_ecn_flags:2;
121  };
122  uint8_t tos_tc;
123  };
124 
125  uint8_t next_header;
126 
127  uint8_t ttl_hopl;
128 
129  uint8_t ip_id_behavior;
130 
132 
133 
134 /**
135  * @brief Define the IPv4 header context
136  */
137 typedef struct __attribute__((packed)) ipv4_context
138 {
139  uint8_t version:4;
140  uint8_t df:1;
141  uint8_t unused:3;
142 
143  union
144  {
145  struct
146  {
147  uint8_t dscp:6;
148  uint8_t ip_ecn_flags:2;
149  };
150  uint8_t tos;
151  };
152 
153  uint8_t protocol;
154 
155  uint8_t ttl;
156 
157  uint8_t ip_id_behavior;
158  uint16_t ip_id;
159 
160  uint32_t src_addr;
161  uint32_t dst_addr;
162 
164 
165 
166 /**
167  * @brief Define the IPv6 header context
168  */
169 typedef struct __attribute__((packed)) ipv6_context
170 {
171  uint8_t version:4;
172  uint8_t unused:4;
173 
174  union
175  {
176  struct
177  {
178  uint8_t dscp:6;
179  uint8_t ip_ecn_flags:2;
180  };
181  uint8_t tc;
182  };
183 
184  uint8_t next_header;
185 
186  uint8_t hopl;
187 
188  uint8_t ip_id_behavior;
189 
190  uint32_t flow_label:20; /**< IPv6 Flow Label */
191 
192  uint32_t src_addr[4];
193  uint32_t dest_addr[4];
194 
196 
197 
198 /**
199  * @brief Define union of IP contexts
200  */
201 typedef struct
202 {
203  ip_version version;
204  union
205  {
206  ipvx_context_t vx;
207  ipv4_context_t v4;
208  ipv6_context_t v6;
209  } ctxt;
210 
211  size_t opts_nr;
212  size_t opts_len;
214 
215 } ip_context_t;
216 
217 #endif /* ROHC_DECOMP_SCHEMES_IP_CTXT_H */
218 
size_t data_len
Definition: decomp/schemes/ip_ctxt.h:42
uint32_t sequence_number
Definition: decomp/schemes/ip_ctxt.h:60
uint8_t c_flag
Definition: decomp/schemes/ip_ctxt.h:53
uint8_t k_flag
Definition: decomp/schemes/ip_ctxt.h:54
Define the IPv6 option context for MIME option.
Definition: decomp/schemes/ip_ctxt.h:68
struct ipv4_context ipv4_context_t
Define the IPv4 header context.
struct ipv6_context ipv6_context_t
Define the IPv6 header context.
uint32_t orig_src
Definition: decomp/schemes/ip_ctxt.h:73
size_t len
Definition: decomp/schemes/ip_ctxt.h:92
Define the IPv6 option context for Destination, Hop-by-Hop and Routing option.
Definition: decomp/schemes/ip_ctxt.h:40
Define the common IP header context to IPv4 and IPv6.
Definition: comp/schemes/ip_ctxt.h:51
Definition: comp/schemes/ip_ctxt.h:110
struct ipv6_gre_option_context ipv6_gre_option_context_t
Define the IPv6 option context for GRE option.
#define IPV6_OPT_CTXT_LEN_MAX
Definition: ipv6.h:154
Define the IPv6 option context for AH option.
Definition: decomp/schemes/ip_ctxt.h:81
uint8_t s_bit
Definition: decomp/schemes/ip_ctxt.h:70
Define the IPv6 header context.
Definition: comp/schemes/ip_ctxt.h:122
uint32_t sequence_number
Definition: decomp/schemes/ip_ctxt.h:84
struct ipv6_ah_option_context ipv6_ah_option_context_t
Define the IPv6 option context for AH option.
Define the IPv4 header context.
Definition: comp/schemes/ip_ctxt.h:79
#define ROHC_MAX_IP_EXT_HDRS
The maximum number of IP extension headers supported.
Definition: protocols/ip.h:58
struct ipvx_context ipvx_context_t
Define the common IP header context to IPv4 and IPv6.
uint32_t key
Definition: decomp/schemes/ip_ctxt.h:59
Define the IPv6 option context for GRE option.
Definition: decomp/schemes/ip_ctxt.h:51
struct ipv6_generic_option_context ipv6_generic_option_context_t
Define the IPv6 generic option context.
uint8_t nh_proto
Definition: decomp/schemes/ip_ctxt.h:94
ipv6_gre_option_context_t gre
Definition: decomp/schemes/ip_ctxt.h:99
ip_version
IP version.
Definition: ip.h:49
uint8_t protocol
Definition: decomp/schemes/ip_ctxt.h:56
uint32_t spi
Definition: decomp/schemes/ip_ctxt.h:83
struct ipv6_mime_option_context ipv6_mime_option_context_t
Define the IPv6 option context for MIME option.
Define union of IP contexts.
Definition: comp/schemes/ip_ctxt.h:155
uint8_t padding
Definition: decomp/schemes/ip_ctxt.h:57
ipv6_ah_option_context_t ah
Definition: decomp/schemes/ip_ctxt.h:101
uint8_t s_flag
Definition: decomp/schemes/ip_ctxt.h:55
size_t opts_len
Definition: decomp/schemes/ip_ctxt.h:212
Defines the common IPv4/v6 header.
uint32_t orig_dest
Definition: decomp/schemes/ip_ctxt.h:72
uint8_t res_bits
Definition: decomp/schemes/ip_ctxt.h:71
TCP header description.
ipv6_mime_option_context_t mime
Definition: decomp/schemes/ip_ctxt.h:100
uint8_t proto
Definition: decomp/schemes/ip_ctxt.h:93
uint16_t ip_id
Definition: decomp/schemes/ip_ctxt.h:158