18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 28c2ecf20Sopenharmony_ci#ifndef NET_COMPAT_H 38c2ecf20Sopenharmony_ci#define NET_COMPAT_H 48c2ecf20Sopenharmony_ci 58c2ecf20Sopenharmony_ci 68c2ecf20Sopenharmony_cistruct sock; 78c2ecf20Sopenharmony_ci 88c2ecf20Sopenharmony_ci#if defined(CONFIG_COMPAT) 98c2ecf20Sopenharmony_ci 108c2ecf20Sopenharmony_ci#include <linux/compat.h> 118c2ecf20Sopenharmony_ci 128c2ecf20Sopenharmony_cistruct compat_msghdr { 138c2ecf20Sopenharmony_ci compat_uptr_t msg_name; /* void * */ 148c2ecf20Sopenharmony_ci compat_int_t msg_namelen; 158c2ecf20Sopenharmony_ci compat_uptr_t msg_iov; /* struct compat_iovec * */ 168c2ecf20Sopenharmony_ci compat_size_t msg_iovlen; 178c2ecf20Sopenharmony_ci compat_uptr_t msg_control; /* void * */ 188c2ecf20Sopenharmony_ci compat_size_t msg_controllen; 198c2ecf20Sopenharmony_ci compat_uint_t msg_flags; 208c2ecf20Sopenharmony_ci}; 218c2ecf20Sopenharmony_ci 228c2ecf20Sopenharmony_cistruct compat_mmsghdr { 238c2ecf20Sopenharmony_ci struct compat_msghdr msg_hdr; 248c2ecf20Sopenharmony_ci compat_uint_t msg_len; 258c2ecf20Sopenharmony_ci}; 268c2ecf20Sopenharmony_ci 278c2ecf20Sopenharmony_cistruct compat_cmsghdr { 288c2ecf20Sopenharmony_ci compat_size_t cmsg_len; 298c2ecf20Sopenharmony_ci compat_int_t cmsg_level; 308c2ecf20Sopenharmony_ci compat_int_t cmsg_type; 318c2ecf20Sopenharmony_ci}; 328c2ecf20Sopenharmony_ci 338c2ecf20Sopenharmony_cistruct compat_rtentry { 348c2ecf20Sopenharmony_ci u32 rt_pad1; 358c2ecf20Sopenharmony_ci struct sockaddr rt_dst; /* target address */ 368c2ecf20Sopenharmony_ci struct sockaddr rt_gateway; /* gateway addr (RTF_GATEWAY) */ 378c2ecf20Sopenharmony_ci struct sockaddr rt_genmask; /* target network mask (IP) */ 388c2ecf20Sopenharmony_ci unsigned short rt_flags; 398c2ecf20Sopenharmony_ci short rt_pad2; 408c2ecf20Sopenharmony_ci u32 rt_pad3; 418c2ecf20Sopenharmony_ci unsigned char rt_tos; 428c2ecf20Sopenharmony_ci unsigned char rt_class; 438c2ecf20Sopenharmony_ci short rt_pad4; 448c2ecf20Sopenharmony_ci short rt_metric; /* +1 for binary compatibility! */ 458c2ecf20Sopenharmony_ci compat_uptr_t rt_dev; /* forcing the device at add */ 468c2ecf20Sopenharmony_ci u32 rt_mtu; /* per route MTU/Window */ 478c2ecf20Sopenharmony_ci u32 rt_window; /* Window clamping */ 488c2ecf20Sopenharmony_ci unsigned short rt_irtt; /* Initial RTT */ 498c2ecf20Sopenharmony_ci}; 508c2ecf20Sopenharmony_ci 518c2ecf20Sopenharmony_ci#else /* defined(CONFIG_COMPAT) */ 528c2ecf20Sopenharmony_ci/* 538c2ecf20Sopenharmony_ci * To avoid compiler warnings: 548c2ecf20Sopenharmony_ci */ 558c2ecf20Sopenharmony_ci#define compat_msghdr msghdr 568c2ecf20Sopenharmony_ci#define compat_mmsghdr mmsghdr 578c2ecf20Sopenharmony_ci#endif /* defined(CONFIG_COMPAT) */ 588c2ecf20Sopenharmony_ci 598c2ecf20Sopenharmony_ciint __get_compat_msghdr(struct msghdr *kmsg, struct compat_msghdr __user *umsg, 608c2ecf20Sopenharmony_ci struct sockaddr __user **save_addr, compat_uptr_t *ptr, 618c2ecf20Sopenharmony_ci compat_size_t *len); 628c2ecf20Sopenharmony_ciint get_compat_msghdr(struct msghdr *, struct compat_msghdr __user *, 638c2ecf20Sopenharmony_ci struct sockaddr __user **, struct iovec **); 648c2ecf20Sopenharmony_ciint put_cmsg_compat(struct msghdr*, int, int, int, void *); 658c2ecf20Sopenharmony_ci 668c2ecf20Sopenharmony_ciint cmsghdr_from_user_compat_to_kern(struct msghdr *, struct sock *, 678c2ecf20Sopenharmony_ci unsigned char *, int); 688c2ecf20Sopenharmony_ci 698c2ecf20Sopenharmony_cistruct compat_group_req { 708c2ecf20Sopenharmony_ci __u32 gr_interface; 718c2ecf20Sopenharmony_ci struct __kernel_sockaddr_storage gr_group 728c2ecf20Sopenharmony_ci __aligned(4); 738c2ecf20Sopenharmony_ci} __packed; 748c2ecf20Sopenharmony_ci 758c2ecf20Sopenharmony_cistruct compat_group_source_req { 768c2ecf20Sopenharmony_ci __u32 gsr_interface; 778c2ecf20Sopenharmony_ci struct __kernel_sockaddr_storage gsr_group 788c2ecf20Sopenharmony_ci __aligned(4); 798c2ecf20Sopenharmony_ci struct __kernel_sockaddr_storage gsr_source 808c2ecf20Sopenharmony_ci __aligned(4); 818c2ecf20Sopenharmony_ci} __packed; 828c2ecf20Sopenharmony_ci 838c2ecf20Sopenharmony_cistruct compat_group_filter { 848c2ecf20Sopenharmony_ci __u32 gf_interface; 858c2ecf20Sopenharmony_ci struct __kernel_sockaddr_storage gf_group 868c2ecf20Sopenharmony_ci __aligned(4); 878c2ecf20Sopenharmony_ci __u32 gf_fmode; 888c2ecf20Sopenharmony_ci __u32 gf_numsrc; 898c2ecf20Sopenharmony_ci struct __kernel_sockaddr_storage gf_slist[1] 908c2ecf20Sopenharmony_ci __aligned(4); 918c2ecf20Sopenharmony_ci} __packed; 928c2ecf20Sopenharmony_ci 938c2ecf20Sopenharmony_ci#endif /* NET_COMPAT_H */ 94