Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 #ifndef _NET_ESP_H
0003 #define _NET_ESP_H
0004 
0005 #include <linux/skbuff.h>
0006 
0007 struct ip_esp_hdr;
0008 struct xfrm_state;
0009 
0010 static inline struct ip_esp_hdr *ip_esp_hdr(const struct sk_buff *skb)
0011 {
0012     return (struct ip_esp_hdr *)skb_transport_header(skb);
0013 }
0014 
0015 static inline void esp_output_fill_trailer(u8 *tail, int tfclen, int plen, __u8 proto)
0016 {
0017     /* Fill padding... */
0018     if (tfclen) {
0019         memset(tail, 0, tfclen);
0020         tail += tfclen;
0021     }
0022     do {
0023         int i;
0024         for (i = 0; i < plen - 2; i++)
0025             tail[i] = i + 1;
0026     } while (0);
0027     tail[plen - 2] = plen - 2;
0028     tail[plen - 1] = proto;
0029 }
0030 
0031 struct esp_info {
0032     struct  ip_esp_hdr *esph;
0033     __be64  seqno;
0034     int tfclen;
0035     int tailen;
0036     int plen;
0037     int clen;
0038     int     len;
0039     int     nfrags;
0040     __u8    proto;
0041     bool    inplace;
0042 };
0043 
0044 int esp_output_head(struct xfrm_state *x, struct sk_buff *skb, struct esp_info *esp);
0045 int esp_output_tail(struct xfrm_state *x, struct sk_buff *skb, struct esp_info *esp);
0046 int esp_input_done2(struct sk_buff *skb, int err);
0047 int esp6_output_head(struct xfrm_state *x, struct sk_buff *skb, struct esp_info *esp);
0048 int esp6_output_tail(struct xfrm_state *x, struct sk_buff *skb, struct esp_info *esp);
0049 int esp6_input_done2(struct sk_buff *skb, int err);
0050 #endif