Revert "l4p/tcp: introduce tle_tcp_stream_establish() API"
[tldk.git] / lib / libtle_l4p / net_misc.h
1 /*
2  * Copyright (c) 2016  Intel Corporation.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at:
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15
16 #ifndef _NET_MISC_H_
17 #define _NET_MISC_H_
18
19 #include <rte_ip.h>
20 #include <rte_udp.h>
21 #include "osdep.h"
22
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26
27 #define PKT_L234_HLEN(m)        (_tx_offload_l4_offset(m->tx_offload))
28 #define PKT_L4_PLEN(m)          ((m)->pkt_len - PKT_L234_HLEN(m))
29
30 /*
31  * Some network protocols related structures definitions.
32  * Main purpose to simplify (and optimise) processing and representation
33  * of protocol related data.
34  */
35
36 enum {
37         TLE_V4,
38         TLE_V6,
39         TLE_VNUM
40 };
41
42 extern const struct in6_addr tle_ipv6_any;
43 extern const struct in6_addr tle_ipv6_none;
44
45 union l4_ports {
46         uint32_t raw;
47         struct {
48                 uint16_t src;
49                 uint16_t dst;
50         };
51 };
52
53 union ipv4_addrs {
54         uint64_t raw;
55         struct {
56                 uint32_t src;
57                 uint32_t dst;
58         };
59 };
60
61 union ipv6_addrs {
62         _ymm_t raw;
63         struct {
64                 rte_xmm_t src;
65                 rte_xmm_t dst;
66         };
67 } __attribute__((packed, aligned(1)));
68
69 union ip_addrs {
70         union ipv4_addrs v4;
71         union ipv6_addrs v6;
72 };
73
74 #ifdef __cplusplus
75 }
76 #endif
77
78 #endif /* _NET_MISC_H_ */