xref: /freebsd/sys/compat/linux/linux_socket.h (revision 13f20d7e8607cbd09df8ec9f82eaea86874e4af2)
140dbba57SAssar Westerlund /*-
240dbba57SAssar Westerlund  * Copyright (c) 2000 Assar Westerlund
340dbba57SAssar Westerlund  * All rights reserved.
440dbba57SAssar Westerlund  *
540dbba57SAssar Westerlund  * Redistribution and use in source and binary forms, with or without
640dbba57SAssar Westerlund  * modification, are permitted provided that the following conditions
740dbba57SAssar Westerlund  * are met:
840dbba57SAssar Westerlund  * 1. Redistributions of source code must retain the above copyright
940dbba57SAssar Westerlund  *    notice, this list of conditions and the following disclaimer
1040dbba57SAssar Westerlund  *    in this position and unchanged.
1140dbba57SAssar Westerlund  * 2. Redistributions in binary form must reproduce the above copyright
1240dbba57SAssar Westerlund  *    notice, this list of conditions and the following disclaimer in the
1340dbba57SAssar Westerlund  *    documentation and/or other materials provided with the distribution.
1440dbba57SAssar Westerlund  * 3. The name of the author may not be used to endorse or promote products
1521dc7d4fSJens Schweikhardt  *    derived from this software without specific prior written permission
1640dbba57SAssar Westerlund  *
1740dbba57SAssar Westerlund  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
1840dbba57SAssar Westerlund  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
1940dbba57SAssar Westerlund  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
2040dbba57SAssar Westerlund  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
2140dbba57SAssar Westerlund  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
2240dbba57SAssar Westerlund  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
2340dbba57SAssar Westerlund  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
2440dbba57SAssar Westerlund  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
2540dbba57SAssar Westerlund  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
2640dbba57SAssar Westerlund  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2740dbba57SAssar Westerlund  *
2840dbba57SAssar Westerlund  * $FreeBSD$
2940dbba57SAssar Westerlund  */
3040dbba57SAssar Westerlund 
3140dbba57SAssar Westerlund #ifndef _LINUX_SOCKET_H_
3240dbba57SAssar Westerlund #define _LINUX_SOCKET_H_
3340dbba57SAssar Westerlund 
3440dbba57SAssar Westerlund /* msg flags in recvfrom/recvmsg */
3540dbba57SAssar Westerlund 
3640dbba57SAssar Westerlund #define LINUX_MSG_OOB		0x01
3740dbba57SAssar Westerlund #define LINUX_MSG_PEEK		0x02
3840dbba57SAssar Westerlund #define LINUX_MSG_DONTROUTE	0x04
3940dbba57SAssar Westerlund #define LINUX_MSG_CTRUNC	0x08
4040dbba57SAssar Westerlund #define LINUX_MSG_PROXY		0x10
4140dbba57SAssar Westerlund #define LINUX_MSG_TRUNC		0x20
4240dbba57SAssar Westerlund #define LINUX_MSG_DONTWAIT	0x40
4340dbba57SAssar Westerlund #define LINUX_MSG_EOR		0x80
4440dbba57SAssar Westerlund #define LINUX_MSG_WAITALL	0x100
4540dbba57SAssar Westerlund #define LINUX_MSG_FIN		0x200
4640dbba57SAssar Westerlund #define LINUX_MSG_SYN		0x400
4740dbba57SAssar Westerlund #define LINUX_MSG_CONFIRM	0x800
4840dbba57SAssar Westerlund #define LINUX_MSG_RST		0x1000
4940dbba57SAssar Westerlund #define LINUX_MSG_ERRQUEUE	0x2000
5040dbba57SAssar Westerlund #define LINUX_MSG_NOSIGNAL	0x4000
5140dbba57SAssar Westerlund 
5274f5d680SKonstantin Belousov /* Socket-level control message types */
5374f5d680SKonstantin Belousov 
5474f5d680SKonstantin Belousov #define LINUX_SCM_RIGHTS	0x01
5574f5d680SKonstantin Belousov 
5674f5d680SKonstantin Belousov /* Ancilliary data object information macros */
5774f5d680SKonstantin Belousov 
5874f5d680SKonstantin Belousov #define LINUX_CMSG_ALIGN(len)	roundup2(len, sizeof(l_ulong))
5974f5d680SKonstantin Belousov #define LINUX_CMSG_DATA(cmsg)	((void *)((char *)(cmsg) + \
6074f5d680SKonstantin Belousov 				    LINUX_CMSG_ALIGN(sizeof(struct l_cmsghdr))))
6174f5d680SKonstantin Belousov #define LINUX_CMSG_SPACE(len)	(LINUX_CMSG_ALIGN(sizeof(struct l_cmsghdr)) + \
6274f5d680SKonstantin Belousov 				    LINUX_CMSG_ALIGN(len))
6374f5d680SKonstantin Belousov #define LINUX_CMSG_LEN(len)	(LINUX_CMSG_ALIGN(sizeof(struct l_cmsghdr)) + \
6474f5d680SKonstantin Belousov 				    (len))
6574f5d680SKonstantin Belousov #define LINUX_CMSG_FIRSTHDR(msg) \
6674f5d680SKonstantin Belousov 				((msg)->msg_controllen >= \
6774f5d680SKonstantin Belousov 				    sizeof(struct l_cmsghdr) ? \
6874f5d680SKonstantin Belousov 				    (struct l_cmsghdr *)((msg)->msg_control) : \
6974f5d680SKonstantin Belousov 				    (struct l_cmsghdr *)(NULL))
7074f5d680SKonstantin Belousov #define LINUX_CMSG_NXTHDR(msg, cmsg) \
7174f5d680SKonstantin Belousov 				((((char *)(cmsg) + \
7274f5d680SKonstantin Belousov 				    LINUX_CMSG_ALIGN((cmsg)->cmsg_len) + \
7374f5d680SKonstantin Belousov 				    sizeof(*(cmsg))) > \
7474f5d680SKonstantin Belousov 				    (((char *)(msg)->msg_control) + \
7574f5d680SKonstantin Belousov 				    (msg)->msg_controllen)) ? \
7674f5d680SKonstantin Belousov 				    (struct l_cmsghdr *) NULL : \
7774f5d680SKonstantin Belousov 				    (struct l_cmsghdr *)((char *)(cmsg) + \
7874f5d680SKonstantin Belousov 				    LINUX_CMSG_ALIGN((cmsg)->cmsg_len)))
7974f5d680SKonstantin Belousov 
8074f5d680SKonstantin Belousov #define CMSG_HDRSZ		CMSG_LEN(0)
8174f5d680SKonstantin Belousov #define L_CMSG_HDRSZ		LINUX_CMSG_LEN(0)
8274f5d680SKonstantin Belousov 
8313f20d7eSDmitry Chagin /* Supported address families */
8413f20d7eSDmitry Chagin 
8513f20d7eSDmitry Chagin #define	LINUX_AF_UNSPEC		0
8613f20d7eSDmitry Chagin #define	LINUX_AF_UNIX		1
8713f20d7eSDmitry Chagin #define	LINUX_AF_INET		2
8813f20d7eSDmitry Chagin #define	LINUX_AF_AX25		3
8913f20d7eSDmitry Chagin #define	LINUX_AF_IPX		4
9013f20d7eSDmitry Chagin #define	LINUX_AF_APPLETALK	5
9113f20d7eSDmitry Chagin #define	LINUX_AF_INET6		10
9213f20d7eSDmitry Chagin 
9340dbba57SAssar Westerlund #endif /* _LINUX_SOCKET_H_ */
94