blob: 9c5637d41d95168052686caf7b3ff51b517e6b9b [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001/* SPDX-License-Identifier: GPL-2.0 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002#ifndef _NET_ESP_H
3#define _NET_ESP_H
4
Herbert Xu38320c72008-01-28 19:35:05 -08005#include <linux/skbuff.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -07006
Herbert Xu87bdc482007-10-10 15:45:25 -07007struct ip_esp_hdr;
8
9static inline struct ip_esp_hdr *ip_esp_hdr(const struct sk_buff *skb)
10{
11 return (struct ip_esp_hdr *)skb_transport_header(skb);
12}
13
Raed Salemdda520c2020-02-19 14:49:57 +020014static inline void esp_output_fill_trailer(u8 *tail, int tfclen, int plen, __u8 proto)
15{
16 /* Fill padding... */
17 if (tfclen) {
18 memset(tail, 0, tfclen);
19 tail += tfclen;
20 }
21 do {
22 int i;
23 for (i = 0; i < plen - 2; i++)
24 tail[i] = i + 1;
25 } while (0);
26 tail[plen - 2] = plen - 2;
27 tail[plen - 1] = proto;
28}
29
Steffen Klassertfca11eb2017-04-14 10:06:33 +020030struct esp_info {
31 struct ip_esp_hdr *esph;
32 __be64 seqno;
33 int tfclen;
34 int tailen;
35 int plen;
36 int clen;
37 int len;
38 int nfrags;
39 __u8 proto;
40 bool inplace;
41};
42
43int esp_output_head(struct xfrm_state *x, struct sk_buff *skb, struct esp_info *esp);
44int esp_output_tail(struct xfrm_state *x, struct sk_buff *skb, struct esp_info *esp);
45int esp_input_done2(struct sk_buff *skb, int err);
Steffen Klassert383d0352017-04-14 10:06:42 +020046int esp6_output_head(struct xfrm_state *x, struct sk_buff *skb, struct esp_info *esp);
47int esp6_output_tail(struct xfrm_state *x, struct sk_buff *skb, struct esp_info *esp);
48int esp6_input_done2(struct sk_buff *skb, int err);
Linus Torvalds1da177e2005-04-16 15:20:36 -070049#endif