blob: 90cd02ff77ef67f7f65e2c53127c4510c23bd4a9 [file] [log] [blame]
Andrew Scullb4b6d4a2019-01-02 15:54:55 +00001/* SPDX-License-Identifier: GPL-2.0 */
2#ifndef _NET_ESP_H
3#define _NET_ESP_H
4
5#include <linux/skbuff.h>
6
Olivier Deprez157378f2022-04-04 15:47:50 +02007#define ESP_SKB_FRAG_MAXSIZE (PAGE_SIZE << SKB_FRAG_PAGE_ORDER)
8
Andrew Scullb4b6d4a2019-01-02 15:54:55 +00009struct ip_esp_hdr;
10
11static inline struct ip_esp_hdr *ip_esp_hdr(const struct sk_buff *skb)
12{
13 return (struct ip_esp_hdr *)skb_transport_header(skb);
14}
15
Olivier Deprez157378f2022-04-04 15:47:50 +020016static inline void esp_output_fill_trailer(u8 *tail, int tfclen, int plen, __u8 proto)
17{
18 /* Fill padding... */
19 if (tfclen) {
20 memset(tail, 0, tfclen);
21 tail += tfclen;
22 }
23 do {
24 int i;
25 for (i = 0; i < plen - 2; i++)
26 tail[i] = i + 1;
27 } while (0);
28 tail[plen - 2] = plen - 2;
29 tail[plen - 1] = proto;
30}
31
Andrew Scullb4b6d4a2019-01-02 15:54:55 +000032struct esp_info {
33 struct ip_esp_hdr *esph;
34 __be64 seqno;
35 int tfclen;
36 int tailen;
37 int plen;
38 int clen;
39 int len;
40 int nfrags;
41 __u8 proto;
42 bool inplace;
43};
44
45int esp_output_head(struct xfrm_state *x, struct sk_buff *skb, struct esp_info *esp);
46int esp_output_tail(struct xfrm_state *x, struct sk_buff *skb, struct esp_info *esp);
47int esp_input_done2(struct sk_buff *skb, int err);
48int esp6_output_head(struct xfrm_state *x, struct sk_buff *skb, struct esp_info *esp);
49int esp6_output_tail(struct xfrm_state *x, struct sk_buff *skb, struct esp_info *esp);
50int esp6_input_done2(struct sk_buff *skb, int err);
51#endif