xref: /openbmc/linux/include/net/compat.h (revision 04b3c795)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef NET_COMPAT_H
3 #define NET_COMPAT_H
4 
5 
6 struct sock;
7 
8 #if defined(CONFIG_COMPAT)
9 
10 #include <linux/compat.h>
11 
12 struct compat_msghdr {
13 	compat_uptr_t	msg_name;	/* void * */
14 	compat_int_t	msg_namelen;
15 	compat_uptr_t	msg_iov;	/* struct compat_iovec * */
16 	compat_size_t	msg_iovlen;
17 	compat_uptr_t	msg_control;	/* void * */
18 	compat_size_t	msg_controllen;
19 	compat_uint_t	msg_flags;
20 };
21 
22 struct compat_mmsghdr {
23 	struct compat_msghdr msg_hdr;
24 	compat_uint_t        msg_len;
25 };
26 
27 struct compat_cmsghdr {
28 	compat_size_t	cmsg_len;
29 	compat_int_t	cmsg_level;
30 	compat_int_t	cmsg_type;
31 };
32 
33 struct compat_rtentry {
34 	u32		rt_pad1;
35 	struct sockaddr rt_dst;         /* target address               */
36 	struct sockaddr rt_gateway;     /* gateway addr (RTF_GATEWAY)   */
37 	struct sockaddr rt_genmask;     /* target network mask (IP)     */
38 	unsigned short	rt_flags;
39 	short		rt_pad2;
40 	u32		rt_pad3;
41 	unsigned char	rt_tos;
42 	unsigned char	rt_class;
43 	short		rt_pad4;
44 	short		rt_metric;      /* +1 for binary compatibility! */
45 	compat_uptr_t	rt_dev;         /* forcing the device at add    */
46 	u32		rt_mtu;         /* per route MTU/Window         */
47 	u32		rt_window;      /* Window clamping              */
48 	unsigned short  rt_irtt;        /* Initial RTT                  */
49 };
50 
51 #else /* defined(CONFIG_COMPAT) */
52 /*
53  * To avoid compiler warnings:
54  */
55 #define compat_msghdr	msghdr
56 #define compat_mmsghdr	mmsghdr
57 #endif /* defined(CONFIG_COMPAT) */
58 
59 int __get_compat_msghdr(struct msghdr *kmsg, struct compat_msghdr __user *umsg,
60 			struct sockaddr __user **save_addr, compat_uptr_t *ptr,
61 			compat_size_t *len);
62 int get_compat_msghdr(struct msghdr *, struct compat_msghdr __user *,
63 		      struct sockaddr __user **, struct iovec **);
64 struct sock_fprog __user *get_compat_bpf_fprog(char __user *optval);
65 int put_cmsg_compat(struct msghdr*, int, int, int, void *);
66 
67 int cmsghdr_from_user_compat_to_kern(struct msghdr *, struct sock *,
68 				     unsigned char *, int);
69 
70 struct compat_group_req {
71 	__u32				 gr_interface;
72 	struct __kernel_sockaddr_storage gr_group
73 		__aligned(4);
74 } __packed;
75 
76 struct compat_group_source_req {
77 	__u32				 gsr_interface;
78 	struct __kernel_sockaddr_storage gsr_group
79 		__aligned(4);
80 	struct __kernel_sockaddr_storage gsr_source
81 		__aligned(4);
82 } __packed;
83 
84 struct compat_group_filter {
85 	__u32				 gf_interface;
86 	struct __kernel_sockaddr_storage gf_group
87 		__aligned(4);
88 	__u32				 gf_fmode;
89 	__u32				 gf_numsrc;
90 	struct __kernel_sockaddr_storage gf_slist[1]
91 		__aligned(4);
92 } __packed;
93 
94 #endif /* NET_COMPAT_H */
95