• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #include <linux/ipv6.h>
3 #include <net/dsfield.h>
4 #include <net/xfrm.h>
5 
6 #ifndef XFRM_INOUT_H
7 #define XFRM_INOUT_H 1
8 
xfrm6_beet_make_header(struct sk_buff * skb)9 static inline void xfrm6_beet_make_header(struct sk_buff *skb)
10 {
11 	struct ipv6hdr *iph = ipv6_hdr(skb);
12 
13 	iph->version = 6;
14 
15 	memcpy(iph->flow_lbl, XFRM_MODE_SKB_CB(skb)->flow_lbl,
16 	       sizeof(iph->flow_lbl));
17 	iph->nexthdr = XFRM_MODE_SKB_CB(skb)->protocol;
18 
19 	ipv6_change_dsfield(iph, 0, XFRM_MODE_SKB_CB(skb)->tos);
20 	iph->hop_limit = XFRM_MODE_SKB_CB(skb)->ttl;
21 }
22 
xfrm4_beet_make_header(struct sk_buff * skb)23 static inline void xfrm4_beet_make_header(struct sk_buff *skb)
24 {
25 	struct iphdr *iph = ip_hdr(skb);
26 
27 	iph->ihl = 5;
28 	iph->version = 4;
29 
30 	iph->protocol = XFRM_MODE_SKB_CB(skb)->protocol;
31 	iph->tos = XFRM_MODE_SKB_CB(skb)->tos;
32 
33 	iph->id = XFRM_MODE_SKB_CB(skb)->id;
34 	iph->frag_off = XFRM_MODE_SKB_CB(skb)->frag_off;
35 	iph->ttl = XFRM_MODE_SKB_CB(skb)->ttl;
36 }
37 
38 #endif
39