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