1 /*  Copyright (C) 2021 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
2 
3     This program is free software: you can redistribute it and/or modify
4     it under the terms of the GNU General Public License as published by
5     the Free Software Foundation, either version 3 of the License, or
6     (at your option) any later version.
7 
8     This program is distributed in the hope that it will be useful,
9     but WITHOUT ANY WARRANTY; without even the implied warranty of
10     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11     GNU General Public License for more details.
12 
13     You should have received a copy of the GNU General Public License
14     along with this program.  If not, see <https://www.gnu.org/licenses/>.
15  */
16 
17 /*!
18  * \file
19  *
20  * \brief XDP message description.
21  *
22  * \addtogroup xdp
23  * @{
24  */
25 
26 #pragma once
27 
28 #include <stdint.h>
29 #include <linux/if_ether.h>
30 #include <linux/ipv6.h>
31 #include <sys/uio.h>
32 
33 /*! \brief Message flags. */
34 typedef enum {
35 	KNOT_XDP_MSG_IPV6  = (1 << 0), /*!< This packet is a IPv6 (IPv4 otherwise). */
36 	KNOT_XDP_MSG_TCP   = (1 << 1), /*!< This packet is a TCP (UDP otherwise). */
37 	KNOT_XDP_MSG_SYN   = (1 << 2), /*!< SYN flag set (TCP only). */
38 	KNOT_XDP_MSG_ACK   = (1 << 3), /*!< ACK flag set (TCP only). */
39 	KNOT_XDP_MSG_FIN   = (1 << 4), /*!< FIN flag set (TCP only). */
40 	KNOT_XDP_MSG_RST   = (1 << 5), /*!< RST flag set (TCP only). */
41 	KNOT_XDP_MSG_MSS   = (1 << 6), /*!< MSS option in TCP header (TCP only). */
42 } knot_xdp_msg_flag_t;
43 
44 /*! \brief Packet description with src & dst MAC & IP addrs + DNS payload. */
45 typedef struct knot_xdp_msg {
46 	struct sockaddr_in6 ip_from;
47 	struct sockaddr_in6 ip_to;
48 	uint8_t eth_from[ETH_ALEN];
49 	uint8_t eth_to[ETH_ALEN];
50 	knot_xdp_msg_flag_t flags;
51 	struct iovec payload;
52 	uint32_t seqno;
53 	uint32_t ackno;
54 	uint16_t mss;
55 } knot_xdp_msg_t;
56 
57 /*! @} */
58