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