• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _LINUX_ICMPV6_H
3 #define _LINUX_ICMPV6_H
4 
5 #include <linux/skbuff.h>
6 #include <linux/ipv6.h>
7 #include <uapi/linux/icmpv6.h>
8 
icmp6_hdr(const struct sk_buff * skb)9 static inline struct icmp6hdr *icmp6_hdr(const struct sk_buff *skb)
10 {
11 	return (struct icmp6hdr *)skb_transport_header(skb);
12 }
13 
14 #include <linux/netdevice.h>
15 
16 #if IS_ENABLED(CONFIG_IPV6)
17 
18 typedef void ip6_icmp_send_t(struct sk_buff *skb, u8 type, u8 code, __u32 info,
19 			     const struct in6_addr *force_saddr,
20 			     const struct inet6_skb_parm *parm);
21 void icmp6_send(struct sk_buff *skb, u8 type, u8 code, __u32 info,
22 		const struct in6_addr *force_saddr,
23 		const struct inet6_skb_parm *parm);
24 #if IS_BUILTIN(CONFIG_IPV6)
__icmpv6_send(struct sk_buff * skb,u8 type,u8 code,__u32 info,const struct inet6_skb_parm * parm)25 static inline void __icmpv6_send(struct sk_buff *skb, u8 type, u8 code, __u32 info,
26 				 const struct inet6_skb_parm *parm)
27 {
28 	icmp6_send(skb, type, code, info, NULL, parm);
29 }
inet6_register_icmp_sender(ip6_icmp_send_t * fn)30 static inline int inet6_register_icmp_sender(ip6_icmp_send_t *fn)
31 {
32 	BUILD_BUG_ON(fn != icmp6_send);
33 	return 0;
34 }
inet6_unregister_icmp_sender(ip6_icmp_send_t * fn)35 static inline int inet6_unregister_icmp_sender(ip6_icmp_send_t *fn)
36 {
37 	BUILD_BUG_ON(fn != icmp6_send);
38 	return 0;
39 }
40 #else
41 extern void __icmpv6_send(struct sk_buff *skb, u8 type, u8 code, __u32 info,
42 			  const struct inet6_skb_parm *parm);
43 extern int inet6_register_icmp_sender(ip6_icmp_send_t *fn);
44 extern int inet6_unregister_icmp_sender(ip6_icmp_send_t *fn);
45 #endif
46 
47 void icmpv6_send(struct sk_buff *skb, u8 type, u8 code, __u32 info);
48 
49 int ip6_err_gen_icmpv6_unreach(struct sk_buff *skb, int nhs, int type,
50 			       unsigned int data_len);
51 
52 #if IS_ENABLED(CONFIG_NF_NAT)
53 void icmpv6_ndo_send(struct sk_buff *skb_in, u8 type, u8 code, __u32 info);
54 #else
icmpv6_ndo_send(struct sk_buff * skb_in,u8 type,u8 code,__u32 info)55 static inline void icmpv6_ndo_send(struct sk_buff *skb_in, u8 type, u8 code, __u32 info)
56 {
57 	struct inet6_skb_parm parm = { 0 };
58 	__icmpv6_send(skb_in, type, code, info, &parm);
59 }
60 #endif
61 
62 #else
63 
icmpv6_send(struct sk_buff * skb,u8 type,u8 code,__u32 info)64 static inline void icmpv6_send(struct sk_buff *skb,
65 			       u8 type, u8 code, __u32 info)
66 {
67 }
68 
icmpv6_ndo_send(struct sk_buff * skb,u8 type,u8 code,__u32 info)69 static inline void icmpv6_ndo_send(struct sk_buff *skb,
70 				   u8 type, u8 code, __u32 info)
71 {
72 }
73 #endif
74 
75 extern int				icmpv6_init(void);
76 extern int				icmpv6_err_convert(u8 type, u8 code,
77 							   int *err);
78 extern void				icmpv6_cleanup(void);
79 extern void				icmpv6_param_prob(struct sk_buff *skb,
80 							  u8 code, int pos);
81 
82 struct flowi6;
83 struct in6_addr;
84 extern void				icmpv6_flow_init(struct sock *sk,
85 							 struct flowi6 *fl6,
86 							 u8 type,
87 							 const struct in6_addr *saddr,
88 							 const struct in6_addr *daddr,
89 							 int oif);
90 #endif
91