linux_socket.h revision 220031
170178Sassar/*- 270178Sassar * Copyright (c) 2000 Assar Westerlund 370178Sassar * All rights reserved. 470178Sassar * 570178Sassar * Redistribution and use in source and binary forms, with or without 670178Sassar * modification, are permitted provided that the following conditions 770178Sassar * are met: 870178Sassar * 1. Redistributions of source code must retain the above copyright 970178Sassar * notice, this list of conditions and the following disclaimer 1070178Sassar * in this position and unchanged. 1170178Sassar * 2. Redistributions in binary form must reproduce the above copyright 1270178Sassar * notice, this list of conditions and the following disclaimer in the 1370178Sassar * documentation and/or other materials provided with the distribution. 1470178Sassar * 3. The name of the author may not be used to endorse or promote products 1597748Sschweikh * derived from this software without specific prior written permission 1670178Sassar * 1770178Sassar * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 1870178Sassar * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 1970178Sassar * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 2070178Sassar * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 2170178Sassar * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 2270178Sassar * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 2370178Sassar * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 2470178Sassar * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 2570178Sassar * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 2670178Sassar * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 2770178Sassar * 2870178Sassar * $FreeBSD: head/sys/compat/linux/linux_socket.h 220031 2011-03-26 11:05:53Z avg $ 2970178Sassar */ 3070178Sassar 3170178Sassar#ifndef _LINUX_SOCKET_H_ 3270178Sassar#define _LINUX_SOCKET_H_ 3370178Sassar 3470178Sassar/* msg flags in recvfrom/recvmsg */ 3570178Sassar 3670178Sassar#define LINUX_MSG_OOB 0x01 3770178Sassar#define LINUX_MSG_PEEK 0x02 3870178Sassar#define LINUX_MSG_DONTROUTE 0x04 3970178Sassar#define LINUX_MSG_CTRUNC 0x08 4070178Sassar#define LINUX_MSG_PROXY 0x10 4170178Sassar#define LINUX_MSG_TRUNC 0x20 4270178Sassar#define LINUX_MSG_DONTWAIT 0x40 4370178Sassar#define LINUX_MSG_EOR 0x80 4470178Sassar#define LINUX_MSG_WAITALL 0x100 4570178Sassar#define LINUX_MSG_FIN 0x200 4670178Sassar#define LINUX_MSG_SYN 0x400 4770178Sassar#define LINUX_MSG_CONFIRM 0x800 4870178Sassar#define LINUX_MSG_RST 0x1000 4970178Sassar#define LINUX_MSG_ERRQUEUE 0x2000 5070178Sassar#define LINUX_MSG_NOSIGNAL 0x4000 51192284Sdchagin#define LINUX_MSG_CMSG_CLOEXEC 0x40000000 5270178Sassar 53185442Skib/* Socket-level control message types */ 54185442Skib 55185442Skib#define LINUX_SCM_RIGHTS 0x01 56220031Savg#define LINUX_SCM_CREDENTIALS 0x02 57185442Skib 58185442Skib/* Ancilliary data object information macros */ 59185442Skib 60185442Skib#define LINUX_CMSG_ALIGN(len) roundup2(len, sizeof(l_ulong)) 61185442Skib#define LINUX_CMSG_DATA(cmsg) ((void *)((char *)(cmsg) + \ 62185442Skib LINUX_CMSG_ALIGN(sizeof(struct l_cmsghdr)))) 63185442Skib#define LINUX_CMSG_SPACE(len) (LINUX_CMSG_ALIGN(sizeof(struct l_cmsghdr)) + \ 64185442Skib LINUX_CMSG_ALIGN(len)) 65185442Skib#define LINUX_CMSG_LEN(len) (LINUX_CMSG_ALIGN(sizeof(struct l_cmsghdr)) + \ 66185442Skib (len)) 67185442Skib#define LINUX_CMSG_FIRSTHDR(msg) \ 68185442Skib ((msg)->msg_controllen >= \ 69185442Skib sizeof(struct l_cmsghdr) ? \ 70220031Savg (struct l_cmsghdr *) \ 71220031Savg PTRIN((msg)->msg_control) : \ 72185442Skib (struct l_cmsghdr *)(NULL)) 73185442Skib#define LINUX_CMSG_NXTHDR(msg, cmsg) \ 74185442Skib ((((char *)(cmsg) + \ 75185442Skib LINUX_CMSG_ALIGN((cmsg)->cmsg_len) + \ 76185442Skib sizeof(*(cmsg))) > \ 77220031Savg (((char *)PTRIN((msg)->msg_control)) + \ 78185442Skib (msg)->msg_controllen)) ? \ 79185442Skib (struct l_cmsghdr *) NULL : \ 80185442Skib (struct l_cmsghdr *)((char *)(cmsg) + \ 81185442Skib LINUX_CMSG_ALIGN((cmsg)->cmsg_len))) 82185442Skib 83185442Skib#define CMSG_HDRSZ CMSG_LEN(0) 84185442Skib#define L_CMSG_HDRSZ LINUX_CMSG_LEN(0) 85185442Skib 86191876Sdchagin/* Supported address families */ 87191876Sdchagin 88191876Sdchagin#define LINUX_AF_UNSPEC 0 89191876Sdchagin#define LINUX_AF_UNIX 1 90191876Sdchagin#define LINUX_AF_INET 2 91191876Sdchagin#define LINUX_AF_AX25 3 92191876Sdchagin#define LINUX_AF_IPX 4 93191876Sdchagin#define LINUX_AF_APPLETALK 5 94191876Sdchagin#define LINUX_AF_INET6 10 95191876Sdchagin 96192205Sdchagin/* Supported socket types */ 97192205Sdchagin 98192205Sdchagin#define LINUX_SOCK_STREAM 1 99192205Sdchagin#define LINUX_SOCK_DGRAM 2 100192205Sdchagin#define LINUX_SOCK_RAW 3 101192205Sdchagin#define LINUX_SOCK_RDM 4 102192205Sdchagin#define LINUX_SOCK_SEQPACKET 5 103192205Sdchagin 104192205Sdchagin#define LINUX_SOCK_MAX LINUX_SOCK_SEQPACKET 105192205Sdchagin 106192206Sdchagin#define LINUX_SOCK_TYPE_MASK 0xf 107192206Sdchagin 108192206Sdchagin/* Flags for socket, socketpair, accept4 */ 109192206Sdchagin 110192206Sdchagin#define LINUX_SOCK_CLOEXEC LINUX_O_CLOEXEC 111192206Sdchagin#define LINUX_SOCK_NONBLOCK LINUX_O_NONBLOCK 112192206Sdchagin 113192203Sdchaginstruct l_ucred { 114192203Sdchagin uint32_t pid; 115192203Sdchagin uint32_t uid; 116192203Sdchagin uint32_t gid; 117192203Sdchagin}; 118192203Sdchagin 11970178Sassar#endif /* _LINUX_SOCKET_H_ */ 120