xref: /titanic_52/usr/src/uts/common/sys/socket_impl.h (revision ac88567a7a5bb7f01cf22cf366bc9d6203e24d7a)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 /*	Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T	*/
27 /*	  All Rights Reserved	*/
28 
29 /*
30  * Portions of this source code were derived from Berkeley 4.3 BSD
31  * under license from the Regents of the University of California.
32  */
33 
34 #ifndef	_SYS_SOCKET_IMPL_H
35 #define	_SYS_SOCKET_IMPL_H
36 
37 #ifdef	__cplusplus
38 extern "C" {
39 #endif
40 
41 #ifndef	_SA_FAMILY_T
42 #define	_SA_FAMILY_T
43 typedef uint16_t	sa_family_t;
44 #endif
45 
46 /*
47  * Structure used by kernel to store most
48  * addresses.
49  */
50 struct sockaddr {
51 	sa_family_t	sa_family;	/* address family */
52 	char		sa_data[14];	/* up to 14 bytes of direct address */
53 };
54 
55 #if !defined(_XPG4_2) || defined(__EXTENSIONS__)
56 #include <sys/un.h>
57 #include <net/if_dl.h>
58 #endif	/* !defined(_XPG4_2) || defined(__EXTENSIONS__) */
59 
60 #if !defined(_XPG4_2) || defined(_XPG6) || defined(__EXTENSIONS__)
61 /*
62  * sockaddr_storage:
63  * Common superset of at least AF_INET, AF_INET6 and AF_LINK sockaddr
64  * structures. Has sufficient size and alignment for those sockaddrs.
65  */
66 
67 /*
68  * Desired maximum size, alignment size and related types.
69  */
70 #define	_SS_MAXSIZE	256	/* Implementation specific max size */
71 
72 /*
73  * To represent desired sockaddr max alignment for platform, a
74  * type is chosen which may depend on implementation platform architecture.
75  * Type chosen based on alignment size restrictions from <sys/isa_defs.h>.
76  * We desire to force up to (but no more than) 64-bit (8 byte) alignment,
77  * on platforms where it is possible to do so. (e.g not possible on ia32).
78  * For all currently supported platforms by our implementation
79  * in <sys/isa_defs.h>, (i.e. sparc, sparcv9, ia32, ia64)
80  * type "double" is suitable for that intent.
81  *
82  * Note: Type "double" is chosen over the more obvious integer type int64_t.
83  *   int64_t is not a valid type for strict ANSI/ISO C compilation on ILP32.
84  */
85 typedef	double		sockaddr_maxalign_t;
86 
87 #define	_SS_ALIGNSIZE	(sizeof (sockaddr_maxalign_t))
88 
89 /*
90  * Definitions used for sockaddr_storage structure paddings design.
91  */
92 #define	_SS_PAD1SIZE	(_SS_ALIGNSIZE - sizeof (sa_family_t))
93 #define	_SS_PAD2SIZE	(_SS_MAXSIZE - (sizeof (sa_family_t)+ \
94 			_SS_PAD1SIZE + _SS_ALIGNSIZE))
95 
96 struct sockaddr_storage {
97 	sa_family_t	ss_family;	/* Address family */
98 	/* Following fields are implementation specific */
99 	char		_ss_pad1[_SS_PAD1SIZE];
100 	sockaddr_maxalign_t _ss_align;
101 	char		_ss_pad2[_SS_PAD2SIZE];
102 };
103 #endif	/* !defined(_XPG4_2) || defined(_XPG6) || defined(__EXTENSIONS__) */
104 
105 /*
106  * To be compatible with the Linux interfaces used, this structure is
107  * placed in socket_impl.h so that an include for <sys/socket.h> will
108  * pickup this structure. This structure is for use with PF_PACKET
109  * sockets.
110  */
111 struct sockaddr_ll {
112 	uint16_t	sll_family;
113 	uint16_t	sll_protocol;
114 	int32_t		sll_ifindex;
115 	uint16_t	sll_hatype;
116 	uint8_t		sll_pkttype;
117 	uint8_t		sll_halen;
118 	uint8_t		sll_addr[8];
119 };
120 
121 #define	LINUX_SLL_HOST		0
122 #define	LINUX_SLL_BROADCAST	1
123 #define	LINUX_SLL_MULTICAST	2
124 #define	LINUX_SLL_OTHERHOST	3
125 #define	LINUX_SLL_OUTGOING	4
126 
127 #ifdef	__cplusplus
128 }
129 #endif
130 
131 #endif	/* _SYS_SOCKET_IMPL_H */
132