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