src: add new GSO handling capabilities
[platform/upstream/libnetfilter_queue.git] / include / libnetfilter_queue / linux_nfnetlink_queue.h
1 #ifndef _NFNETLINK_QUEUE_H
2 #define _NFNETLINK_QUEUE_H
3
4 #ifndef aligned_u64
5 #define aligned_u64 unsigned long long __attribute__((aligned(8)))
6 #endif
7
8 #include <libnfnetlink/linux_nfnetlink.h>
9
10 enum nfqnl_msg_types {
11         NFQNL_MSG_PACKET,               /* packet from kernel to userspace */
12         NFQNL_MSG_VERDICT,              /* verdict from userspace to kernel */
13         NFQNL_MSG_CONFIG,               /* connect to a particular queue */
14         NFQNL_MSG_VERDICT_BATCH,        /* batch verdict from userspace to kernel */
15
16         NFQNL_MSG_MAX
17 };
18
19 struct nfqnl_msg_packet_hdr {
20         u_int32_t       packet_id;      /* unique ID of packet in queue */
21         u_int16_t       hw_protocol;    /* hw protocol (network order) */
22         u_int8_t        hook;           /* netfilter hook */
23 } __attribute__ ((packed));
24
25 struct nfqnl_msg_packet_hw {
26         u_int16_t       hw_addrlen;
27         u_int16_t       _pad;
28         u_int8_t        hw_addr[8];
29 } __attribute__ ((packed));
30
31 struct nfqnl_msg_packet_timestamp {
32         aligned_u64     sec;
33         aligned_u64     usec;
34 } __attribute__ ((packed));
35
36 enum nfqnl_attr_type {
37         NFQA_UNSPEC,
38         NFQA_PACKET_HDR,
39         NFQA_VERDICT_HDR,               /* nfqnl_msg_verdict_hrd */
40         NFQA_MARK,                      /* u_int32_t nfmark */
41         NFQA_TIMESTAMP,                 /* nfqnl_msg_packet_timestamp */
42         NFQA_IFINDEX_INDEV,             /* u_int32_t ifindex */
43         NFQA_IFINDEX_OUTDEV,            /* u_int32_t ifindex */
44         NFQA_IFINDEX_PHYSINDEV,         /* u_int32_t ifindex */
45         NFQA_IFINDEX_PHYSOUTDEV,        /* u_int32_t ifindex */
46         NFQA_HWADDR,                    /* nfqnl_msg_packet_hw */
47         NFQA_PAYLOAD,                   /* opaque data payload */
48         NFQA_CT,                        /* nf_conntrack_netlink.h */
49         NFQA_CT_INFO,                   /* enum ip_conntrack_info */
50         NFQA_CAP_LEN,                   /* __u32 length of captured packet */
51         NFQA_SKB_INFO,                  /* __u32 skb meta information */
52
53         __NFQA_MAX
54 };
55 #define NFQA_MAX (__NFQA_MAX - 1)
56
57 struct nfqnl_msg_verdict_hdr {
58         u_int32_t verdict;
59         u_int32_t id;
60 } __attribute__ ((packed));
61
62
63 enum nfqnl_msg_config_cmds {
64         NFQNL_CFG_CMD_NONE,
65         NFQNL_CFG_CMD_BIND,
66         NFQNL_CFG_CMD_UNBIND,
67         NFQNL_CFG_CMD_PF_BIND,
68         NFQNL_CFG_CMD_PF_UNBIND,
69 };
70
71 struct nfqnl_msg_config_cmd {
72         u_int8_t        command;        /* nfqnl_msg_config_cmds */
73         u_int8_t        _pad;
74         u_int16_t       pf;             /* AF_xxx for PF_[UN]BIND */
75 } __attribute__ ((packed));
76
77 enum nfqnl_config_mode {
78         NFQNL_COPY_NONE,
79         NFQNL_COPY_META,
80         NFQNL_COPY_PACKET,
81 };
82
83 struct nfqnl_msg_config_params {
84         u_int32_t       copy_range;
85         u_int8_t        copy_mode;      /* enum nfqnl_config_mode */
86 } __attribute__ ((packed));
87
88
89 enum nfqnl_attr_config {
90         NFQA_CFG_UNSPEC,
91         NFQA_CFG_CMD,                   /* nfqnl_msg_config_cmd */
92         NFQA_CFG_PARAMS,                /* nfqnl_msg_config_params */
93         NFQA_CFG_QUEUE_MAXLEN,          /* u_int32_t */
94         NFQA_CFG_MASK,                  /* identify which flags to change */
95         NFQA_CFG_FLAGS,                 /* value of these flags (__u32) */
96         __NFQA_CFG_MAX
97 };
98 #define NFQA_CFG_MAX (__NFQA_CFG_MAX-1)
99
100 /* Flags/options for NFQA_CFG_FLAGS */
101 #define NFQA_CFG_F_FAIL_OPEN            (1 << 0)
102 #define NFQA_CFG_F_CONNTRACK            (1 << 1)
103 #define NFQA_CFG_F_GSO                  (1 << 2)
104 #define NFQA_CFG_F_MAX                  (1 << 3)
105
106 /* flags for NFQA_SKB_INFO */
107 /* packet appears to have wrong checksums, but they are ok */
108 #define NFQA_SKB_CSUMNOTREADY (1 << 0)
109 /* packet is GSO (i.e., exceeds device mtu) */
110 #define NFQA_SKB_GSO (1 << 1)
111
112 #endif /* _NFNETLINK_QUEUE_H */