at v5.6 1.8 kB view raw
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 <uapi/linux/icmpv6.h> 7 8static inline struct icmp6hdr *icmp6_hdr(const struct sk_buff *skb) 9{ 10 return (struct icmp6hdr *)skb_transport_header(skb); 11} 12 13#include <linux/netdevice.h> 14 15#if IS_ENABLED(CONFIG_IPV6) 16extern void icmpv6_send(struct sk_buff *skb, u8 type, u8 code, __u32 info); 17 18typedef void ip6_icmp_send_t(struct sk_buff *skb, u8 type, u8 code, __u32 info, 19 const struct in6_addr *force_saddr); 20extern int inet6_register_icmp_sender(ip6_icmp_send_t *fn); 21extern int inet6_unregister_icmp_sender(ip6_icmp_send_t *fn); 22int ip6_err_gen_icmpv6_unreach(struct sk_buff *skb, int nhs, int type, 23 unsigned int data_len); 24 25#if IS_ENABLED(CONFIG_NF_NAT) 26void icmpv6_ndo_send(struct sk_buff *skb_in, u8 type, u8 code, __u32 info); 27#else 28#define icmpv6_ndo_send icmpv6_send 29#endif 30 31#else 32 33static inline void icmpv6_send(struct sk_buff *skb, 34 u8 type, u8 code, __u32 info) 35{ 36} 37 38static inline void icmpv6_ndo_send(struct sk_buff *skb, 39 u8 type, u8 code, __u32 info) 40{ 41} 42#endif 43 44extern int icmpv6_init(void); 45extern int icmpv6_err_convert(u8 type, u8 code, 46 int *err); 47extern void icmpv6_cleanup(void); 48extern void icmpv6_param_prob(struct sk_buff *skb, 49 u8 code, int pos); 50 51struct flowi6; 52struct in6_addr; 53extern void icmpv6_flow_init(struct sock *sk, 54 struct flowi6 *fl6, 55 u8 type, 56 const struct in6_addr *saddr, 57 const struct in6_addr *daddr, 58 int oif); 59 60static inline bool icmpv6_is_err(int type) 61{ 62 switch (type) { 63 case ICMPV6_DEST_UNREACH: 64 case ICMPV6_PKT_TOOBIG: 65 case ICMPV6_TIME_EXCEED: 66 case ICMPV6_PARAMPROB: 67 return true; 68 } 69 70 return false; 71} 72 73#endif