Home | History | Annotate | Line # | Download | only in common
linux_socket.h revision 1.10.16.4
      1 /*	$NetBSD: linux_socket.h,v 1.10.16.4 2005/11/10 14:01:07 skrll Exp $	*/
      2 
      3 /*-
      4  * Copyright (c) 1995, 1998 The NetBSD Foundation, Inc.
      5  * All rights reserved.
      6  *
      7  * This code is derived from software contributed to The NetBSD Foundation
      8  * by Frank van der Linden and Eric Haszlakiewicz.
      9  *
     10  * Redistribution and use in source and binary forms, with or without
     11  * modification, are permitted provided that the following conditions
     12  * are met:
     13  * 1. Redistributions of source code must retain the above copyright
     14  *    notice, this list of conditions and the following disclaimer.
     15  * 2. Redistributions in binary form must reproduce the above copyright
     16  *    notice, this list of conditions and the following disclaimer in the
     17  *    documentation and/or other materials provided with the distribution.
     18  * 3. All advertising materials mentioning features or use of this software
     19  *    must display the following acknowledgement:
     20  *	This product includes software developed by the NetBSD
     21  *	Foundation, Inc. and its contributors.
     22  * 4. Neither the name of The NetBSD Foundation nor the names of its
     23  *    contributors may be used to endorse or promote products derived
     24  *    from this software without specific prior written permission.
     25  *
     26  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     27  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     28  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     29  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     30  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     31  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     32  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     33  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     34  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     35  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     36  * POSSIBILITY OF SUCH DAMAGE.
     37  */
     38 
     39 #ifndef _LINUX_SOCKET_H
     40 #define _LINUX_SOCKET_H
     41 
     42 /*
     43  * Various Linux socket defines. Everything that is not re-defined here
     44  * is the same as in NetBSD.
     45  *
     46  * COMPAT_43 is assumed, and the osockaddr struct is used (it is what
     47  * Linux uses)
     48  */
     49 
     50 /*
     51  * Address families. There are fewer of them, and they're numbered
     52  * a bit different
     53  */
     54 
     55 #define LINUX_AF_UNSPEC		0
     56 #define LINUX_AF_UNIX		1
     57 #define LINUX_AF_INET		2
     58 #define LINUX_AF_AX25		3
     59 #define LINUX_AF_IPX		4
     60 #define LINUX_AF_APPLETALK	5
     61 #define LINUX_AF_NETROM		6
     62 #define LINUX_AF_BRIDGE		7
     63 #define LINUX_AF_ATMPVC		8
     64 #define LINUX_AF_X25		9
     65 #define LINUX_AF_INET6		10
     66 #define LINUX_AF_ROSE		11
     67 #define LINUX_AF_DECnet		12
     68 #define LINUX_AF_NETBEUI	13
     69 #define LINUX_AF_SECURITY	14
     70 #define LINUX_pseudo_AF_KEY	15
     71 #define LINUX_AF_NETLINK	16
     72 #define LINUX_AF_PACKET		17
     73 #define LINUX_AF_ASH		18
     74 #define LINUX_AF_ECONET		19
     75 #define	LINUX_AF_ATMSVC		20
     76 #define	LINUX_AF_SNA		22
     77 #define LINUX_AF_MAX		32
     78 
     79 /*
     80  * Option levels for [gs]etsockopt(2). Only SOL_SOCKET is different,
     81  * the rest matches IPPROTO_XXX
     82  */
     83 
     84 /* SOL_SOCKET is machine dependant on Linux */
     85 #define LINUX_SOL_IP		0
     86 #define LINUX_SOL_TCP		6
     87 #define LINUX_SOL_UDP		17
     88 /* Unused for now: */
     89 #define LINUX_SOL_IPV6		41
     90 #define LINUX_SOL_ICMPV6	58
     91 #define LINUX_SOL_RAW		255
     92 #define LINUX_SOL_IPX		256
     93 #define LINUX_SOL_AX25		257
     94 #define LINUX_SOL_ATALK		258
     95 #define LINUX_SOL_NETROM	259
     96 #define LINUX_SOL_ROSE		260
     97 #define LINUX_SOL_DECNET	261
     98 #define LINUX_SOL_X25		262
     99 #define LINUX_SOL_PACKET	263
    100 #define LINUX_SOL_ATM		264
    101 #define LINUX_SOL_AAL		265
    102 
    103 /*
    104  * Options for [gs]etsockopt(2), socket level are machine dependant.
    105  */
    106 
    107 /*
    108  * Options for [gs]etsockopt(2), IP level.
    109  */
    110 
    111 #define LINUX_IP_TOS		1
    112 #define LINUX_IP_TTL		2
    113 #define	LINUX_IP_MULTICAST_IF	32
    114 #define	LINUX_IP_MULTICAST_TTL	33
    115 #define	LINUX_IP_MULTICAST_LOOP	34
    116 #define	LINUX_IP_ADD_MEMBERSHIP	35
    117 #define	LINUX_IP_DROP_MEMBERSHIP 36
    118 
    119 /*
    120  * Options for [gs]etsockopt(2), TCP level.
    121  */
    122 
    123 #define	LINUX_TCP_NODELAY	1
    124 #define	LINUX_TCP_MAXSEG	2
    125 
    126 /* "Socket"-level control message types: */
    127 #define LINUX_SCM_RIGHTS	1	/* same as SCM_RIGHTS */
    128 #define LINUX_SCM_CREDENTIALS	2	/* accepts ucred rather than sockcred */
    129 #define LINUX_SCM_CONNECT	3	/* not supported in NetBSD */
    130 #define LINUX_SCM_TIMESTAMP	LINUX_SO_TIMESTAMP
    131 				/* not actually implemented in Linux 2.5.15? */
    132 
    133 /*
    134  * Message flags (for sendmsg/recvmsg)
    135  */
    136 #define LINUX_MSG_OOB		0x001
    137 #define LINUX_MSG_PEEK		0x002
    138 #define LINUX_MSG_DONTROUTE	0x004
    139 #define LINUX_MSG_TRYHARD	0x004
    140 #define LINUX_MSG_CTRUNC	0x008
    141 #define LINUX_MSG_PROBE		0x010	/* Don't send, only probe path */
    142 #define LINUX_MSG_TRUNC		0x020
    143 #define LINUX_MSG_DONTWAIT	0x040	/* this msg should be nonblocking */
    144 #define LINUX_MSG_EOR		0x080	/* data completes record */
    145 #define LINUX_MSG_WAITALL	0x100	/* wait for full request or error */
    146 #define LINUX_MSG_FIN		0x200
    147 #define LINUX_MSG_EOF		LINUX_MSG_FIN
    148 #define LINUX_MSG_SYN		0x400
    149 #define LINUX_MSG_CONFIRM	0x800	/* Confirm path validity */
    150 #define LINUX_MSG_RST		0x1000
    151 #define LINUX_MSG_ERRQUEUE	0x2000	/* fetch message from error queue */
    152 #define LINUX_MSG_NOSIGNAL	0x4000	/* do not generate SIGPIPE */
    153 #define LINUX_MSG_MORE		0x8000	/* Sender will send more */
    154 
    155 /*
    156  * Linux alignment requirement for CMSG struct manipulation.
    157  * Linux aligns on (long) boundary on all architectures.
    158  */
    159 #define LINUX_CMSG_ALIGN(n)	\
    160 	(((n) + sizeof(long)-1) & ~(sizeof(long)-1))
    161 #define LINUX_CMSG_DATA(cmsg)	\
    162 	((u_char *)(void *)(cmsg) + __CMSG_ALIGN(sizeof(struct cmsghdr)))
    163 #define	LINUX_CMSG_NXTHDR(mhdr, cmsg)	\
    164 	(((__caddr_t)(cmsg) + LINUX_CMSG_ALIGN((cmsg)->cmsg_len) + \
    165 			    LINUX_CMSG_ALIGN(sizeof(struct cmsghdr)) > \
    166 	    (((__caddr_t)(mhdr)->msg_control) + (mhdr)->msg_controllen)) ? \
    167 	    (struct cmsghdr *)NULL : \
    168 	    (struct cmsghdr *)((__caddr_t)(cmsg) + \
    169 	        LINUX_CMSG_ALIGN((cmsg)->cmsg_len)))
    170 #define LINUX_CMSG_ALIGNDIFF	\
    171 	(CMSG_ALIGN(sizeof(struct cmsghdr)) - LINUX_CMSG_ALIGN(sizeof(struct cmsghdr)))
    172 
    173 /*
    174  * Machine specific definitions.
    175  */
    176 #if defined(__i386__)
    177 #include <compat/linux/arch/i386/linux_socket.h>
    178 #elif defined(__m68k__)
    179 #include <compat/linux/arch/m68k/linux_socket.h>
    180 #elif defined(__alpha__)
    181 #include <compat/linux/arch/alpha/linux_socket.h>
    182 #elif defined(__powerpc__)
    183 #include <compat/linux/arch/powerpc/linux_socket.h>
    184 #elif defined(__mips__)
    185 #include <compat/linux/arch/mips/linux_socket.h>
    186 #elif defined(__arm__)
    187 #include <compat/linux/arch/arm/linux_socket.h>
    188 #elif defined(__amd64__)
    189 #include <compat/linux/arch/amd64/linux_socket.h>
    190 #else
    191 #error Undefined linux_socket.h machine type.
    192 #endif
    193 
    194 #endif /* !_LINUX_SOCKET_H */
    195