ROHC compression/decompression library
net_pkt.h
Go to the documentation of this file.
1 /*
2  * Copyright 2014 Didier Barvaux
3  * Copyright 2014 Viveris Technologies
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18  */
19 
20 /**
21  * @file common/net_pkt.h
22  * @brief Network packet (may contains several IP headers)
23  * @author Didier Barvaux <didier.barvaux@toulouse.viveris.com>
24  */
25 
26 #ifndef ROHC_COMMON_NET_PKT_H
27 #define ROHC_COMMON_NET_PKT_H
28 
29 #include <rohc/rohc_buf.h>
30 #include "ip.h"
31 #include "rohc_traces.h"
32 
33 
34 /** The key to help identify (not quaranted unique) a compression context */
35 typedef uint32_t rohc_ctxt_key_t;
36 
37 
38 /** One network packet */
39 struct net_pkt
40 {
41  const uint8_t *data; /**< The packet data */
42  size_t len; /**< The length (in bytes) of the packet data */
43 
44  size_t ip_hdr_nr; /**< The number of IP headers */
45  struct ip_packet outer_ip; /**< The outer IP header */
46  struct ip_packet inner_ip; /**< The inner IP header if any */
47 
48  struct net_hdr *transport; /**< The transport layer of the packet if any */
49 
50  rohc_ctxt_key_t key; /**< The hash key of the packet */
51 
52  /** The callback function used to manage traces */
54  /** The private context of the callback function used to manage traces */
56 };
57 
58 
59 bool net_pkt_parse(struct net_pkt *const packet,
60  const struct rohc_buf data,
61  rohc_trace_callback2_t trace_cb,
62  void *const trace_cb_priv,
63  rohc_trace_entity_t trace_entity)
64  __attribute__((warn_unused_result, nonnull(1)));
65 
66 size_t net_pkt_get_payload_offset(const struct net_pkt *const packet)
67  __attribute__((warn_unused_result, nonnull(1)));
68 
69 #endif
70 
size_t len
Definition: net_pkt.h:42
IP-agnostic packet.
size_t net_pkt_get_payload_offset(const struct net_pkt *const packet)
Get the offset of the IP payload in the given packet.
Definition: net_pkt.c:154
void(* rohc_trace_callback2_t)(void *const priv_ctxt, const rohc_trace_level_t level, const rohc_trace_entity_t entity, const int profile, const char *const format,...)
The function prototype for the trace callback.
Definition: rohc_traces.h:118
struct ip_packet inner_ip
Definition: net_pkt.h:46
rohc_ctxt_key_t key
Definition: net_pkt.h:50
bool net_pkt_parse(struct net_pkt *const packet, const struct rohc_buf data, rohc_trace_callback2_t trace_cb, void *const trace_cb_priv, rohc_trace_entity_t trace_entity)
Parse a network packet.
Definition: net_pkt.c:44
void * trace_callback_priv
Definition: net_pkt.h:55
uint32_t rohc_ctxt_key_t
Definition: net_pkt.h:35
size_t ip_hdr_nr
Definition: net_pkt.h:44
const uint8_t * data
Definition: net_pkt.h:41
Definition: net_pkt.h:39
rohc_trace_callback2_t trace_callback
Definition: net_pkt.h:53
A network buffer for the ROHC library.
Definition: rohc_buf.h:104
struct ip_packet outer_ip
Definition: net_pkt.h:45
Definition: ip.h:69
struct net_hdr * transport
Definition: net_pkt.h:48
ROHC definitions for traces.
Defines an IP-agnostic packet that can handle an IPv4 or IPv6 packet.
Definition: ip.h:81
rohc_trace_entity_t
The different entities concerned by the traces.
Definition: rohc_traces.h:81
uint8_t * data
Definition: ip.h:72