18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-or-later */ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * INET An implementation of the TCP/IP protocol suite for the LINUX 48c2ecf20Sopenharmony_ci * operating system. INET is implemented using the BSD Socket 58c2ecf20Sopenharmony_ci * interface as the means of communication with the user level. 68c2ecf20Sopenharmony_ci * 78c2ecf20Sopenharmony_ci * Definitions for the "ping" module. 88c2ecf20Sopenharmony_ci */ 98c2ecf20Sopenharmony_ci#ifndef _PING_H 108c2ecf20Sopenharmony_ci#define _PING_H 118c2ecf20Sopenharmony_ci 128c2ecf20Sopenharmony_ci#include <net/icmp.h> 138c2ecf20Sopenharmony_ci#include <net/netns/hash.h> 148c2ecf20Sopenharmony_ci 158c2ecf20Sopenharmony_ci/* PING_HTABLE_SIZE must be power of 2 */ 168c2ecf20Sopenharmony_ci#define PING_HTABLE_SIZE 64 178c2ecf20Sopenharmony_ci#define PING_HTABLE_MASK (PING_HTABLE_SIZE-1) 188c2ecf20Sopenharmony_ci 198c2ecf20Sopenharmony_ci#define ping_portaddr_for_each_entry(__sk, node, list) \ 208c2ecf20Sopenharmony_ci hlist_nulls_for_each_entry(__sk, node, list, sk_nulls_node) 218c2ecf20Sopenharmony_ci 228c2ecf20Sopenharmony_ci/* 238c2ecf20Sopenharmony_ci * gid_t is either uint or ushort. We want to pass it to 248c2ecf20Sopenharmony_ci * proc_dointvec_minmax(), so it must not be larger than MAX_INT 258c2ecf20Sopenharmony_ci */ 268c2ecf20Sopenharmony_ci#define GID_T_MAX (((gid_t)~0U) >> 1) 278c2ecf20Sopenharmony_ci 288c2ecf20Sopenharmony_ci/* Compatibility glue so we can support IPv6 when it's compiled as a module */ 298c2ecf20Sopenharmony_cistruct pingv6_ops { 308c2ecf20Sopenharmony_ci int (*ipv6_recv_error)(struct sock *sk, struct msghdr *msg, int len, 318c2ecf20Sopenharmony_ci int *addr_len); 328c2ecf20Sopenharmony_ci void (*ip6_datagram_recv_common_ctl)(struct sock *sk, 338c2ecf20Sopenharmony_ci struct msghdr *msg, 348c2ecf20Sopenharmony_ci struct sk_buff *skb); 358c2ecf20Sopenharmony_ci void (*ip6_datagram_recv_specific_ctl)(struct sock *sk, 368c2ecf20Sopenharmony_ci struct msghdr *msg, 378c2ecf20Sopenharmony_ci struct sk_buff *skb); 388c2ecf20Sopenharmony_ci int (*icmpv6_err_convert)(u8 type, u8 code, int *err); 398c2ecf20Sopenharmony_ci void (*ipv6_icmp_error)(struct sock *sk, struct sk_buff *skb, int err, 408c2ecf20Sopenharmony_ci __be16 port, u32 info, u8 *payload); 418c2ecf20Sopenharmony_ci int (*ipv6_chk_addr)(struct net *net, const struct in6_addr *addr, 428c2ecf20Sopenharmony_ci const struct net_device *dev, int strict); 438c2ecf20Sopenharmony_ci}; 448c2ecf20Sopenharmony_ci 458c2ecf20Sopenharmony_cistruct ping_iter_state { 468c2ecf20Sopenharmony_ci struct seq_net_private p; 478c2ecf20Sopenharmony_ci int bucket; 488c2ecf20Sopenharmony_ci sa_family_t family; 498c2ecf20Sopenharmony_ci}; 508c2ecf20Sopenharmony_ci 518c2ecf20Sopenharmony_ciextern struct proto ping_prot; 528c2ecf20Sopenharmony_ci#if IS_ENABLED(CONFIG_IPV6) 538c2ecf20Sopenharmony_ciextern struct pingv6_ops pingv6_ops; 548c2ecf20Sopenharmony_ci#endif 558c2ecf20Sopenharmony_ci 568c2ecf20Sopenharmony_cistruct pingfakehdr { 578c2ecf20Sopenharmony_ci struct icmphdr icmph; 588c2ecf20Sopenharmony_ci struct msghdr *msg; 598c2ecf20Sopenharmony_ci sa_family_t family; 608c2ecf20Sopenharmony_ci __wsum wcheck; 618c2ecf20Sopenharmony_ci}; 628c2ecf20Sopenharmony_ci 638c2ecf20Sopenharmony_ciint ping_get_port(struct sock *sk, unsigned short ident); 648c2ecf20Sopenharmony_ciint ping_hash(struct sock *sk); 658c2ecf20Sopenharmony_civoid ping_unhash(struct sock *sk); 668c2ecf20Sopenharmony_ci 678c2ecf20Sopenharmony_ciint ping_init_sock(struct sock *sk); 688c2ecf20Sopenharmony_civoid ping_close(struct sock *sk, long timeout); 698c2ecf20Sopenharmony_ciint ping_bind(struct sock *sk, struct sockaddr *uaddr, int addr_len); 708c2ecf20Sopenharmony_civoid ping_err(struct sk_buff *skb, int offset, u32 info); 718c2ecf20Sopenharmony_ciint ping_getfrag(void *from, char *to, int offset, int fraglen, int odd, 728c2ecf20Sopenharmony_ci struct sk_buff *); 738c2ecf20Sopenharmony_ci 748c2ecf20Sopenharmony_ciint ping_recvmsg(struct sock *sk, struct msghdr *msg, size_t len, int noblock, 758c2ecf20Sopenharmony_ci int flags, int *addr_len); 768c2ecf20Sopenharmony_ciint ping_common_sendmsg(int family, struct msghdr *msg, size_t len, 778c2ecf20Sopenharmony_ci void *user_icmph, size_t icmph_len); 788c2ecf20Sopenharmony_ciint ping_queue_rcv_skb(struct sock *sk, struct sk_buff *skb); 798c2ecf20Sopenharmony_cibool ping_rcv(struct sk_buff *skb); 808c2ecf20Sopenharmony_ci 818c2ecf20Sopenharmony_ci#ifdef CONFIG_PROC_FS 828c2ecf20Sopenharmony_civoid *ping_seq_start(struct seq_file *seq, loff_t *pos, sa_family_t family); 838c2ecf20Sopenharmony_civoid *ping_seq_next(struct seq_file *seq, void *v, loff_t *pos); 848c2ecf20Sopenharmony_civoid ping_seq_stop(struct seq_file *seq, void *v); 858c2ecf20Sopenharmony_ci 868c2ecf20Sopenharmony_ciint __init ping_proc_init(void); 878c2ecf20Sopenharmony_civoid ping_proc_exit(void); 888c2ecf20Sopenharmony_ci#endif 898c2ecf20Sopenharmony_ci 908c2ecf20Sopenharmony_civoid __init ping_init(void); 918c2ecf20Sopenharmony_ciint __init pingv6_init(void); 928c2ecf20Sopenharmony_civoid pingv6_exit(void); 938c2ecf20Sopenharmony_ci 948c2ecf20Sopenharmony_ci#endif /* _PING_H */ 95