1b2441318SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 */ 21da177e4SLinus Torvalds #ifndef _LINUX_ICMPV6_H 31da177e4SLinus Torvalds #define _LINUX_ICMPV6_H 41da177e4SLinus Torvalds 5cc70ab26SArnaldo Carvalho de Melo #include <linux/skbuff.h> 6607ca46eSDavid Howells #include <uapi/linux/icmpv6.h> 7cc70ab26SArnaldo Carvalho de Melo 8cc70ab26SArnaldo Carvalho de Melo static inline struct icmp6hdr *icmp6_hdr(const struct sk_buff *skb) 9cc70ab26SArnaldo Carvalho de Melo { 109c70220bSArnaldo Carvalho de Melo return (struct icmp6hdr *)skb_transport_header(skb); 11cc70ab26SArnaldo Carvalho de Melo } 121da177e4SLinus Torvalds 131da177e4SLinus Torvalds #include <linux/netdevice.h> 141da177e4SLinus Torvalds 155f5624cfSPravin B Shelar #if IS_ENABLED(CONFIG_IPV6) 165f5624cfSPravin B Shelar extern void icmpv6_send(struct sk_buff *skb, u8 type, u8 code, __u32 info); 175f5624cfSPravin B Shelar 18b1cadc1aSEric Dumazet typedef void ip6_icmp_send_t(struct sk_buff *skb, u8 type, u8 code, __u32 info, 19b1cadc1aSEric Dumazet const struct in6_addr *force_saddr); 205f5624cfSPravin B Shelar extern int inet6_register_icmp_sender(ip6_icmp_send_t *fn); 215f5624cfSPravin B Shelar extern int inet6_unregister_icmp_sender(ip6_icmp_send_t *fn); 2220e1954fSEric Dumazet int ip6_err_gen_icmpv6_unreach(struct sk_buff *skb, int nhs, int type, 2320e1954fSEric Dumazet unsigned int data_len); 245f5624cfSPravin B Shelar 25*a8e41f60SJason A. Donenfeld #if IS_ENABLED(CONFIG_NF_NAT) 26*a8e41f60SJason A. Donenfeld void icmpv6_ndo_send(struct sk_buff *skb_in, u8 type, u8 code, __u32 info); 27*a8e41f60SJason A. Donenfeld #else 28*a8e41f60SJason A. Donenfeld #define icmpv6_ndo_send icmpv6_send 29*a8e41f60SJason A. Donenfeld #endif 30*a8e41f60SJason A. Donenfeld 315f5624cfSPravin B Shelar #else 325f5624cfSPravin B Shelar 335f5624cfSPravin B Shelar static inline void icmpv6_send(struct sk_buff *skb, 345f5624cfSPravin B Shelar u8 type, u8 code, __u32 info) 355f5624cfSPravin B Shelar { 365f5624cfSPravin B Shelar } 371da177e4SLinus Torvalds 38*a8e41f60SJason A. Donenfeld static inline void icmpv6_ndo_send(struct sk_buff *skb, 39*a8e41f60SJason A. Donenfeld u8 type, u8 code, __u32 info) 40*a8e41f60SJason A. Donenfeld { 41*a8e41f60SJason A. Donenfeld } 420b41713bSJason A. Donenfeld #endif 430b41713bSJason A. Donenfeld 449b0f976fSDenis V. Lunev extern int icmpv6_init(void); 45d5fdd6baSBrian Haley extern int icmpv6_err_convert(u8 type, u8 code, 461da177e4SLinus Torvalds int *err); 471da177e4SLinus Torvalds extern void icmpv6_cleanup(void); 481da177e4SLinus Torvalds extern void icmpv6_param_prob(struct sk_buff *skb, 49d5fdd6baSBrian Haley u8 code, int pos); 5095e41e93SYOSHIFUJI Hideaki 514c9483b2SDavid S. Miller struct flowi6; 52f59d4389SDavid S. Miller struct in6_addr; 5395e41e93SYOSHIFUJI Hideaki extern void icmpv6_flow_init(struct sock *sk, 544c9483b2SDavid S. Miller struct flowi6 *fl6, 5595e41e93SYOSHIFUJI Hideaki u8 type, 5695e41e93SYOSHIFUJI Hideaki const struct in6_addr *saddr, 5795e41e93SYOSHIFUJI Hideaki const struct in6_addr *daddr, 5895e41e93SYOSHIFUJI Hideaki int oif); 5915122464SMatteo Croce 6015122464SMatteo Croce static inline bool icmpv6_is_err(int type) 6115122464SMatteo Croce { 6215122464SMatteo Croce switch (type) { 6315122464SMatteo Croce case ICMPV6_DEST_UNREACH: 6415122464SMatteo Croce case ICMPV6_PKT_TOOBIG: 6515122464SMatteo Croce case ICMPV6_TIME_EXCEED: 6615122464SMatteo Croce case ICMPV6_PARAMPROB: 6715122464SMatteo Croce return true; 6815122464SMatteo Croce } 6915122464SMatteo Croce 7015122464SMatteo Croce return false; 7115122464SMatteo Croce } 7215122464SMatteo Croce 731da177e4SLinus Torvalds #endif 74