ROHC compression/decompression library
comp/schemes/ip_ctxt.h
Go to the documentation of this file.
1 /*
2  * Copyright 2012,2013,2014,2015,2016 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 src/comp/schemes/ip_ctxt.h
23  * @brief The compression 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_COMP_SCHEMES_IP_CTXT_H
30 #define ROHC_COMP_SCHEMES_IP_CTXT_H
31 
32 #include "protocols/ip.h"
33 #include "protocols/ipv6.h"
34 #include "protocols/tcp.h"
35 #include "ip.h"
36 
37 
38 /**
39  * @brief Define the IPv6 generic option context
40  */
41 typedef struct
42 {
43  uint8_t data[IPV6_OPT_CTXT_LEN_MAX];
44  /**
45  * @brief The IPv6 option length
46  *
47  * Standard reads that max length = (0xff + 1) * 8 = 2048 bytes, but the ROHC
48  * implementation limits the length to (4 + 1) * 8 = 40 bytes.
49  */
50  uint16_t option_length;
51 
53 
54 /* compiler sanity check for C11-compliant compilers and GCC >= 4.6 */
55 #if ((defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L) || \
56  (defined(__GNUC__) && defined(__GNUC_MINOR__) && \
57  (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6))))
58 _Static_assert((sizeof(ipv6_generic_option_context_t) % 8) == 0,
59  "ipv6_generic_option_context_t length should be multiple of 8 bytes");
60 #endif
61 
62 
63 /** The compression context for one IPv6 extension header */
64 typedef union
65 {
66  ipv6_generic_option_context_t generic; /**< IPv6 generic extension header */
67  /* TODO: GRE not yet supported */
68  /* TODO: MINE not yet supported */
69  /* TODO: AH not yet supported */
71 
72 
73 /**
74  * @brief The TCP compression context for one IPv4 or IPv6 header
75  */
76 typedef struct
77 {
78  uint32_t flow_label:20;
79  union
80  {
81  struct
82  {
83  uint32_t dscp:6;
84  uint32_t ip_ecn_flags:2;
85  };
86  uint32_t tos_tc:8;
87  };
88  uint32_t df:1;
89  uint32_t unused:3;
90 
91  uint16_t last_ip_id;
92  uint8_t next_header;
93  uint8_t ttl_hopl;
94 
95  uint32_t saddr[4];
96  uint32_t daddr[4];
97 
99  uint8_t opts_nr;
100 
101  uint8_t version:4;
102  uint8_t ip_id_behavior:2;
104 
105  uint8_t unused2[6];
106 
107 } ip_context_t;
108 
109 /* compiler sanity check for C11-compliant compilers and GCC >= 4.6 */
110 #if ((defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L) || \
111  (defined(__GNUC__) && defined(__GNUC_MINOR__) && \
112  (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6))))
113 _Static_assert((offsetof(ip_context_t, saddr) % 8) == 0,
114  "saddr in ip_context_t should be aligned on 8 bytes");
115 _Static_assert((offsetof(ip_context_t, daddr) % 8) == 0,
116  "daddr in ip_context_t should be aligned on 8 bytes");
117 _Static_assert((offsetof(ip_context_t, opts) % 8) == 0,
118  "opts in ip_context_t should be aligned on 8 bytes");
119 _Static_assert((sizeof(ip_context_t) % 8) == 0,
120  "ip_context_t length should be multiple of 8 bytes");
121 #endif
122 
123 #endif /* ROHC_COMP_SCHEMES_IP_CTXT_H */
124 
uint8_t opts_nr
Definition: comp/schemes/ip_ctxt.h:99
uint16_t option_length
The IPv6 option length.
Definition: comp/schemes/ip_ctxt.h:50
uint16_t last_ip_id
Definition: comp/schemes/ip_ctxt.h:91
uint32_t unused
Definition: comp/schemes/ip_ctxt.h:89
Define the IPv6 generic option context.
Definition: comp/schemes/ip_ctxt.h:41
uint32_t tos_tc
Definition: comp/schemes/ip_ctxt.h:86
uint32_t ip_ecn_flags
Definition: comp/schemes/ip_ctxt.h:84
Definition: comp/schemes/ip_ctxt.h:64
#define IPV6_OPT_CTXT_LEN_MAX
Definition: ipv6.h:148
uint32_t dscp
Definition: comp/schemes/ip_ctxt.h:83
uint32_t df
Definition: comp/schemes/ip_ctxt.h:88
#define ROHC_MAX_IP_EXT_HDRS
The maximum number of IP extension headers supported.
Definition: protocols/ip.h:69
uint8_t ttl_hopl
Definition: comp/schemes/ip_ctxt.h:93
The IPv6 header.
uint8_t version
Definition: comp/schemes/ip_ctxt.h:101
uint32_t flow_label
Definition: comp/schemes/ip_ctxt.h:78
uint8_t ip_id_behavior
Definition: comp/schemes/ip_ctxt.h:102
uint8_t next_header
Definition: comp/schemes/ip_ctxt.h:92
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 last_ip_id_behavior
Definition: comp/schemes/ip_ctxt.h:103