ROHC compression/decompression library
uncomp_pkt_hdrs.h
Go to the documentation of this file.
1 /*
2  * Copyright 2018 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/uncomp_pkt_hdrs.h
21  * @brief Information about the uncompressed packet headers
22  * @author Didier Barvaux <didier@barvaux.org>
23  */
24 
25 #ifndef ROHC_PROTOCOLS_UNCOMP_PKT_HDRS_H
26 #define ROHC_PROTOCOLS_UNCOMP_PKT_HDRS_H
27 
28 #include "protocols/ip.h"
29 #include "protocols/ipv4.h"
30 #include "protocols/ipv6.h"
31 #include "protocols/tcp.h"
32 #include "protocols/udp.h"
33 #include "protocols/esp.h"
34 #include "protocols/rtp.h"
35 
36 #include <stdint.h>
37 
38 #ifdef __KERNEL__
39 # include <endian.h>
40 #else
41 # include "config.h" /* for WORDS_BIGENDIAN */
42 #endif
43 
44 
45 /**
46  * @brief The information collected about one of the packet IP extension headers
47  */
49 {
50  const uint8_t *data;
51  uint8_t type;
52  uint8_t len;
53 };
54 
55 
56 /**
57  * @brief The information collected about one of the packet IP headers
58  */
60 {
61  union
62  {
63  const uint8_t *data;
64  const struct ip_hdr *ip;
65  const struct ipv4_hdr *ipv4;
66  const struct ipv6_hdr *ipv6;
67  };
68  uint8_t version;
69  uint8_t next_proto;
70  uint16_t tot_len;
71  union
72  {
73  uint8_t tos_tc; /**< The IPv4 TOS or IPv6 TC field */
74  struct
75  {
76 #if WORDS_BIGENDIAN == 1
77  uint8_t dscp:6; /**< The IPv4/v6 DSCP value */
78  uint8_t ecn:2; /**< The IPv4/v6 ECN value */
79 #else
80  uint8_t ecn:2;
81  uint8_t dscp:6;
82 #endif
83  } __attribute__((packed));
84  };
85  uint8_t ttl_hl; /**< The IPv4 TTL or IPv6 Hop Limit */
86 
87  uint8_t exts_len; /**< The length of IP extensions headers */
88  uint8_t exts_nr; /**< The number of IP extensions headers */
89  struct rohc_pkt_ip_ext_hdr exts[ROHC_MAX_IP_EXT_HDRS]; /**< The IP ext. headers */
90 };
91 
92 
93 /**
94  * @brief The information collected about the packet headers
95  *
96  * The information about the packet headers is collected while the best profile
97  * is detected, and that information may be later used while the best context is
98  * detected or while changes with the compression context are detected.
99  *
100  * The collection of information avoids parsing the packet headers several times.
101  */
103 {
104  /* The network headers */
105  uint8_t ip_hdrs_nr; /**< The number of IP headers */
106  struct rohc_pkt_ip_hdr ip_hdrs[ROHC_MAX_IP_HDRS]; /**< The IP headers */
107  const struct rohc_pkt_ip_hdr *innermost_ip_hdr; /**< The innermost IP header */
108 
109  /* The transport header */
110  union
111  {
112  struct
113  {
114  const struct tcphdr *tcp; /**< The TCP header (if any) */
115  struct
116  {
117  uint8_t nr;
118  uint8_t tot_len;
119  const uint8_t *data[ROHC_TCP_OPTS_MAX];
122  } tcp_opts;
123  };
124  const struct udphdr *udp; /**< The UDP header (if any) */
125  const struct esphdr *esp; /**< The ESP header (if any) */
126  const uint8_t *transport; /**< The transport header (if any) */
127  };
128 
129  const struct rtphdr *rtp; /**< The RTP header (if any) */
130 
131  uint16_t all_hdrs_len; /**< The cumulated length of all headers */
132  const uint8_t *all_hdrs; /**< All raw headers */
133  uint16_t payload_len; /**< The length of the packet payload */
134  const uint8_t *payload; /**< The packet payload */
135 };
136 
137 #endif
138 
const uint8_t * all_hdrs
Definition: uncomp_pkt_hdrs.h:132
uint8_t exts_nr
Definition: uncomp_pkt_hdrs.h:88
uint8_t lengths[ROHC_TCP_OPTS_MAX]
Definition: uncomp_pkt_hdrs.h:121
The information collected about one of the packet IP headers.
Definition: uncomp_pkt_hdrs.h:59
const uint8_t * payload
Definition: uncomp_pkt_hdrs.h:134
struct rohc_pkt_ip_ext_hdr exts[ROHC_MAX_IP_EXT_HDRS]
Definition: uncomp_pkt_hdrs.h:89
const struct rtphdr * rtp
Definition: uncomp_pkt_hdrs.h:129
uint8_t exts_len
Definition: uncomp_pkt_hdrs.h:87
uint8_t types[ROHC_TCP_OPTS_MAX]
Definition: uncomp_pkt_hdrs.h:120
const struct ip_hdr * ip
Definition: uncomp_pkt_hdrs.h:64
uint8_t dscp
Definition: uncomp_pkt_hdrs.h:81
const struct tcphdr * tcp
Definition: uncomp_pkt_hdrs.h:114
uint8_t type
Definition: uncomp_pkt_hdrs.h:51
uint8_t tot_len
Definition: uncomp_pkt_hdrs.h:118
uint8_t next_proto
Definition: uncomp_pkt_hdrs.h:69
uint8_t ecn
Definition: uncomp_pkt_hdrs.h:80
The IPv6 header.
Definition: ipv6.h:82
const struct ipv4_hdr * ipv4
Definition: uncomp_pkt_hdrs.h:65
uint16_t tot_len
Definition: uncomp_pkt_hdrs.h:70
ESP header description.
uint8_t nr
Definition: uncomp_pkt_hdrs.h:117
Definition: udp.h:38
The IPv4 header.
Definition: ipv4.h:53
uint8_t ttl_hl
Definition: uncomp_pkt_hdrs.h:85
The IPv4 header.
const struct udphdr * udp
Definition: uncomp_pkt_hdrs.h:124
const struct rohc_pkt_ip_hdr * innermost_ip_hdr
Definition: uncomp_pkt_hdrs.h:107
const struct esphdr * esp
Definition: uncomp_pkt_hdrs.h:125
The RTP header.
Definition: rtp.h:48
struct rohc_pkt_ip_hdr ip_hdrs[ROHC_MAX_IP_HDRS]
Definition: uncomp_pkt_hdrs.h:106
The TCP base header without options.
Definition: tcp.h:50
#define ROHC_MAX_IP_EXT_HDRS
The maximum number of IP extension headers supported.
Definition: protocols/ip.h:69
uint8_t version
Definition: uncomp_pkt_hdrs.h:68
uint8_t ip_hdrs_nr
Definition: uncomp_pkt_hdrs.h:105
The IPv6 header.
The information collected about the packet headers.
Definition: uncomp_pkt_hdrs.h:102
const struct ipv6_hdr * ipv6
Definition: uncomp_pkt_hdrs.h:66
uint8_t tos_tc
Definition: uncomp_pkt_hdrs.h:73
uint16_t payload_len
Definition: uncomp_pkt_hdrs.h:133
const uint8_t * data
Definition: uncomp_pkt_hdrs.h:63
RTP header.
Definition: esp.h:40
uint16_t all_hdrs_len
Definition: uncomp_pkt_hdrs.h:131
const uint8_t * transport
Definition: uncomp_pkt_hdrs.h:126
Definition: protocols/ip.h:73
const uint8_t * data
Definition: uncomp_pkt_hdrs.h:50
RTP header.
Defines the common IPv4/v6 header.
#define ROHC_TCP_OPTS_MAX
The maximum of TCP options supported by the TCP profile.
Definition: tcp.h:124
The information collected about one of the packet IP extension headers.
Definition: uncomp_pkt_hdrs.h:48
TCP header description.
Defines the UDP header.
const uint8_t * data[ROHC_TCP_OPTS_MAX]
Definition: uncomp_pkt_hdrs.h:119
#define ROHC_MAX_IP_HDRS
The maximum number of IP headers supported.
Definition: protocols/ip.h:46
struct rohc_pkt_hdrs::@26::@28::@30 tcp_opts
uint8_t len
Definition: uncomp_pkt_hdrs.h:52