Linux kernel mirror (for testing)
git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel
os
linux
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
9static 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
18void icmp6_send(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
22static inline void icmpv6_send(struct sk_buff *skb, u8 type, u8 code, __u32 info)
23{
24 icmp6_send(skb, type, code, info, NULL, IP6CB(skb));
25}
26
27int ip6_err_gen_icmpv6_unreach(struct sk_buff *skb, int nhs, int type,
28 unsigned int data_len);
29
30#if IS_ENABLED(CONFIG_NF_NAT)
31void icmpv6_ndo_send(struct sk_buff *skb_in, u8 type, u8 code, __u32 info);
32#else
33static inline void icmpv6_ndo_send(struct sk_buff *skb_in, u8 type, u8 code, __u32 info)
34{
35 struct inet6_skb_parm parm = { 0 };
36 icmp6_send(skb_in, type, code, info, NULL, &parm);
37}
38#endif
39
40#else
41
42static inline void icmpv6_send(struct sk_buff *skb,
43 u8 type, u8 code, __u32 info)
44{
45}
46
47static inline void icmpv6_ndo_send(struct sk_buff *skb,
48 u8 type, u8 code, __u32 info)
49{
50}
51#endif
52
53extern int icmpv6_init(void);
54extern int icmpv6_err_convert(u8 type, u8 code,
55 int *err);
56extern void icmpv6_cleanup(void);
57extern void icmpv6_param_prob_reason(struct sk_buff *skb,
58 u8 code, int pos,
59 enum skb_drop_reason reason);
60
61struct flowi6;
62struct in6_addr;
63
64void icmpv6_flow_init(const struct sock *sk, struct flowi6 *fl6, u8 type,
65 const struct in6_addr *saddr,
66 const struct in6_addr *daddr, int oif);
67
68static inline void icmpv6_param_prob(struct sk_buff *skb, u8 code, int pos)
69{
70 icmpv6_param_prob_reason(skb, code, pos,
71 SKB_DROP_REASON_NOT_SPECIFIED);
72}
73
74static inline bool icmpv6_is_err(int type)
75{
76 switch (type) {
77 case ICMPV6_DEST_UNREACH:
78 case ICMPV6_PKT_TOOBIG:
79 case ICMPV6_TIME_EXCEED:
80 case ICMPV6_PARAMPROB:
81 return true;
82 }
83
84 return false;
85}
86
87#endif