xref: /openbmc/linux/include/net/compat.h (revision 4f2c0a4acffbec01079c28f839422e64ddeff004)
1b2441318SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 */
21da177e4SLinus Torvalds #ifndef NET_COMPAT_H
31da177e4SLinus Torvalds #define NET_COMPAT_H
41da177e4SLinus Torvalds 
51da177e4SLinus Torvalds 
629f767a2SAndrew Morton struct sock;
729f767a2SAndrew Morton 
81da177e4SLinus Torvalds #include <linux/compat.h>
91da177e4SLinus Torvalds 
101da177e4SLinus Torvalds struct compat_msghdr {
111da177e4SLinus Torvalds 	compat_uptr_t	msg_name;	/* void * */
121da177e4SLinus Torvalds 	compat_int_t	msg_namelen;
131da177e4SLinus Torvalds 	compat_uptr_t	msg_iov;	/* struct compat_iovec * */
141da177e4SLinus Torvalds 	compat_size_t	msg_iovlen;
151da177e4SLinus Torvalds 	compat_uptr_t	msg_control;	/* void * */
161da177e4SLinus Torvalds 	compat_size_t	msg_controllen;
171da177e4SLinus Torvalds 	compat_uint_t	msg_flags;
181da177e4SLinus Torvalds };
191da177e4SLinus Torvalds 
20a2e27255SArnaldo Carvalho de Melo struct compat_mmsghdr {
21a2e27255SArnaldo Carvalho de Melo 	struct compat_msghdr msg_hdr;
22a2e27255SArnaldo Carvalho de Melo 	compat_uint_t        msg_len;
23a2e27255SArnaldo Carvalho de Melo };
24a2e27255SArnaldo Carvalho de Melo 
251da177e4SLinus Torvalds struct compat_cmsghdr {
261da177e4SLinus Torvalds 	compat_size_t	cmsg_len;
271da177e4SLinus Torvalds 	compat_int_t	cmsg_level;
281da177e4SLinus Torvalds 	compat_int_t	cmsg_type;
291da177e4SLinus Torvalds };
301da177e4SLinus Torvalds 
31dc13c876SChristoph Hellwig struct compat_rtentry {
32dc13c876SChristoph Hellwig 	u32		rt_pad1;
33dc13c876SChristoph Hellwig 	struct sockaddr rt_dst;         /* target address               */
34dc13c876SChristoph Hellwig 	struct sockaddr rt_gateway;     /* gateway addr (RTF_GATEWAY)   */
35dc13c876SChristoph Hellwig 	struct sockaddr rt_genmask;     /* target network mask (IP)     */
36dc13c876SChristoph Hellwig 	unsigned short	rt_flags;
37dc13c876SChristoph Hellwig 	short		rt_pad2;
38dc13c876SChristoph Hellwig 	u32		rt_pad3;
39dc13c876SChristoph Hellwig 	unsigned char	rt_tos;
40dc13c876SChristoph Hellwig 	unsigned char	rt_class;
41dc13c876SChristoph Hellwig 	short		rt_pad4;
42dc13c876SChristoph Hellwig 	short		rt_metric;      /* +1 for binary compatibility! */
43dc13c876SChristoph Hellwig 	compat_uptr_t	rt_dev;         /* forcing the device at add    */
44dc13c876SChristoph Hellwig 	u32		rt_mtu;         /* per route MTU/Window         */
45dc13c876SChristoph Hellwig 	u32		rt_window;      /* Window clamping              */
46dc13c876SChristoph Hellwig 	unsigned short  rt_irtt;        /* Initial RTT                  */
47dc13c876SChristoph Hellwig };
48dc13c876SChristoph Hellwig 
49*72c531f8SDylan Yudaken int __get_compat_msghdr(struct msghdr *kmsg, struct compat_msghdr *msg,
50*72c531f8SDylan Yudaken 			struct sockaddr __user **save_addr);
51da184284SAl Viro int get_compat_msghdr(struct msghdr *, struct compat_msghdr __user *,
5208adb7daSAl Viro 		      struct sockaddr __user **, struct iovec **);
53e8d895a4SJoe Perches int put_cmsg_compat(struct msghdr*, int, int, int, void *);
54e50ef933SDavid S. Miller 
55e8d895a4SJoe Perches int cmsghdr_from_user_compat_to_kern(struct msghdr *, struct sock *,
56e8d895a4SJoe Perches 				     unsigned char *, int);
571da177e4SLinus Torvalds 
5863287de6SAl Viro struct compat_group_req {
5963287de6SAl Viro 	__u32				 gr_interface;
6063287de6SAl Viro 	struct __kernel_sockaddr_storage gr_group
6163287de6SAl Viro 		__aligned(4);
6263287de6SAl Viro } __packed;
6363287de6SAl Viro 
6463287de6SAl Viro struct compat_group_source_req {
6563287de6SAl Viro 	__u32				 gsr_interface;
6663287de6SAl Viro 	struct __kernel_sockaddr_storage gsr_group
6763287de6SAl Viro 		__aligned(4);
6863287de6SAl Viro 	struct __kernel_sockaddr_storage gsr_source
6963287de6SAl Viro 		__aligned(4);
7063287de6SAl Viro } __packed;
7163287de6SAl Viro 
7263287de6SAl Viro struct compat_group_filter {
73db243b79SGustavo A. R. Silva 	union {
74db243b79SGustavo A. R. Silva 		struct {
75db243b79SGustavo A. R. Silva 			__u32				 gf_interface_aux;
76db243b79SGustavo A. R. Silva 			struct __kernel_sockaddr_storage gf_group_aux
77db243b79SGustavo A. R. Silva 				__aligned(4);
78db243b79SGustavo A. R. Silva 			__u32				 gf_fmode_aux;
79db243b79SGustavo A. R. Silva 			__u32				 gf_numsrc_aux;
80db243b79SGustavo A. R. Silva 			struct __kernel_sockaddr_storage gf_slist[1]
81db243b79SGustavo A. R. Silva 				__aligned(4);
82db243b79SGustavo A. R. Silva 		} __packed;
83db243b79SGustavo A. R. Silva 		struct {
8463287de6SAl Viro 			__u32				 gf_interface;
8563287de6SAl Viro 			struct __kernel_sockaddr_storage gf_group
8663287de6SAl Viro 				__aligned(4);
8763287de6SAl Viro 			__u32				 gf_fmode;
8863287de6SAl Viro 			__u32				 gf_numsrc;
89db243b79SGustavo A. R. Silva 			struct __kernel_sockaddr_storage gf_slist_flex[]
9063287de6SAl Viro 				__aligned(4);
9163287de6SAl Viro 		} __packed;
92db243b79SGustavo A. R. Silva 	};
93db243b79SGustavo A. R. Silva } __packed;
9463287de6SAl Viro 
951da177e4SLinus Torvalds #endif /* NET_COMPAT_H */
96