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