10Sstevel@tonic-gate /* 20Sstevel@tonic-gate * CDDL HEADER START 30Sstevel@tonic-gate * 40Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*10639SDarren.Reed@Sun.COM * Common Development and Distribution License (the "License"). 6*10639SDarren.Reed@Sun.COM * You may not use this file except in compliance with the License. 70Sstevel@tonic-gate * 80Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 90Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 100Sstevel@tonic-gate * See the License for the specific language governing permissions 110Sstevel@tonic-gate * and limitations under the License. 120Sstevel@tonic-gate * 130Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 140Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 150Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 160Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 170Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 180Sstevel@tonic-gate * 190Sstevel@tonic-gate * CDDL HEADER END 200Sstevel@tonic-gate */ 210Sstevel@tonic-gate /* 22*10639SDarren.Reed@Sun.COM * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 230Sstevel@tonic-gate * Use is subject to license terms. 240Sstevel@tonic-gate */ 250Sstevel@tonic-gate 260Sstevel@tonic-gate /* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ 270Sstevel@tonic-gate /* All Rights Reserved */ 280Sstevel@tonic-gate 290Sstevel@tonic-gate /* 300Sstevel@tonic-gate * Portions of this source code were derived from Berkeley 4.3 BSD 310Sstevel@tonic-gate * under license from the Regents of the University of California. 320Sstevel@tonic-gate */ 330Sstevel@tonic-gate 340Sstevel@tonic-gate #ifndef _SYS_SOCKET_IMPL_H 350Sstevel@tonic-gate #define _SYS_SOCKET_IMPL_H 360Sstevel@tonic-gate 370Sstevel@tonic-gate #ifdef __cplusplus 380Sstevel@tonic-gate extern "C" { 390Sstevel@tonic-gate #endif 400Sstevel@tonic-gate 410Sstevel@tonic-gate #ifndef _SA_FAMILY_T 420Sstevel@tonic-gate #define _SA_FAMILY_T 430Sstevel@tonic-gate typedef uint16_t sa_family_t; 440Sstevel@tonic-gate #endif 450Sstevel@tonic-gate 460Sstevel@tonic-gate /* 470Sstevel@tonic-gate * Structure used by kernel to store most 480Sstevel@tonic-gate * addresses. 490Sstevel@tonic-gate */ 500Sstevel@tonic-gate struct sockaddr { 510Sstevel@tonic-gate sa_family_t sa_family; /* address family */ 520Sstevel@tonic-gate char sa_data[14]; /* up to 14 bytes of direct address */ 530Sstevel@tonic-gate }; 540Sstevel@tonic-gate 550Sstevel@tonic-gate #if !defined(_XPG4_2) || defined(__EXTENSIONS__) 560Sstevel@tonic-gate #include <sys/un.h> 570Sstevel@tonic-gate #include <net/if_dl.h> 580Sstevel@tonic-gate #endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) */ 590Sstevel@tonic-gate 600Sstevel@tonic-gate #if !defined(_XPG4_2) || defined(_XPG6) || defined(__EXTENSIONS__) 610Sstevel@tonic-gate /* 620Sstevel@tonic-gate * sockaddr_storage: 630Sstevel@tonic-gate * Common superset of at least AF_INET, AF_INET6 and AF_LINK sockaddr 640Sstevel@tonic-gate * structures. Has sufficient size and alignment for those sockaddrs. 650Sstevel@tonic-gate */ 660Sstevel@tonic-gate 670Sstevel@tonic-gate /* 680Sstevel@tonic-gate * Desired maximum size, alignment size and related types. 690Sstevel@tonic-gate */ 700Sstevel@tonic-gate #define _SS_MAXSIZE 256 /* Implementation specific max size */ 710Sstevel@tonic-gate 720Sstevel@tonic-gate /* 730Sstevel@tonic-gate * To represent desired sockaddr max alignment for platform, a 740Sstevel@tonic-gate * type is chosen which may depend on implementation platform architecture. 750Sstevel@tonic-gate * Type chosen based on alignment size restrictions from <sys/isa_defs.h>. 760Sstevel@tonic-gate * We desire to force up to (but no more than) 64-bit (8 byte) alignment, 770Sstevel@tonic-gate * on platforms where it is possible to do so. (e.g not possible on ia32). 780Sstevel@tonic-gate * For all currently supported platforms by our implementation 790Sstevel@tonic-gate * in <sys/isa_defs.h>, (i.e. sparc, sparcv9, ia32, ia64) 800Sstevel@tonic-gate * type "double" is suitable for that intent. 810Sstevel@tonic-gate * 820Sstevel@tonic-gate * Note: Type "double" is chosen over the more obvious integer type int64_t. 830Sstevel@tonic-gate * int64_t is not a valid type for strict ANSI/ISO C compilation on ILP32. 840Sstevel@tonic-gate */ 850Sstevel@tonic-gate typedef double sockaddr_maxalign_t; 860Sstevel@tonic-gate 870Sstevel@tonic-gate #define _SS_ALIGNSIZE (sizeof (sockaddr_maxalign_t)) 880Sstevel@tonic-gate 890Sstevel@tonic-gate /* 900Sstevel@tonic-gate * Definitions used for sockaddr_storage structure paddings design. 910Sstevel@tonic-gate */ 920Sstevel@tonic-gate #define _SS_PAD1SIZE (_SS_ALIGNSIZE - sizeof (sa_family_t)) 930Sstevel@tonic-gate #define _SS_PAD2SIZE (_SS_MAXSIZE - (sizeof (sa_family_t)+ \ 940Sstevel@tonic-gate _SS_PAD1SIZE + _SS_ALIGNSIZE)) 950Sstevel@tonic-gate 960Sstevel@tonic-gate struct sockaddr_storage { 970Sstevel@tonic-gate sa_family_t ss_family; /* Address family */ 980Sstevel@tonic-gate /* Following fields are implementation specific */ 990Sstevel@tonic-gate char _ss_pad1[_SS_PAD1SIZE]; 1000Sstevel@tonic-gate sockaddr_maxalign_t _ss_align; 1010Sstevel@tonic-gate char _ss_pad2[_SS_PAD2SIZE]; 1020Sstevel@tonic-gate }; 1030Sstevel@tonic-gate #endif /* !defined(_XPG4_2) || defined(_XPG6) || defined(__EXTENSIONS__) */ 1040Sstevel@tonic-gate 105*10639SDarren.Reed@Sun.COM /* 106*10639SDarren.Reed@Sun.COM * To be compatible with the Linux interfaces used, this structure is 107*10639SDarren.Reed@Sun.COM * placed in socket_impl.h so that an include for <sys/socket.h> will 108*10639SDarren.Reed@Sun.COM * pickup this structure. This structure is for use with PF_PACKET 109*10639SDarren.Reed@Sun.COM * sockets. 110*10639SDarren.Reed@Sun.COM */ 111*10639SDarren.Reed@Sun.COM struct sockaddr_ll { 112*10639SDarren.Reed@Sun.COM uint16_t sll_family; 113*10639SDarren.Reed@Sun.COM uint16_t sll_protocol; 114*10639SDarren.Reed@Sun.COM int32_t sll_ifindex; 115*10639SDarren.Reed@Sun.COM uint16_t sll_hatype; 116*10639SDarren.Reed@Sun.COM uint8_t sll_pkttype; 117*10639SDarren.Reed@Sun.COM uint8_t sll_halen; 118*10639SDarren.Reed@Sun.COM uint8_t sll_addr[8]; 119*10639SDarren.Reed@Sun.COM }; 120*10639SDarren.Reed@Sun.COM 121*10639SDarren.Reed@Sun.COM #define LINUX_SLL_HOST 0 122*10639SDarren.Reed@Sun.COM #define LINUX_SLL_BROADCAST 1 123*10639SDarren.Reed@Sun.COM #define LINUX_SLL_MULTICAST 2 124*10639SDarren.Reed@Sun.COM #define LINUX_SLL_OTHERHOST 3 125*10639SDarren.Reed@Sun.COM #define LINUX_SLL_OUTGOING 4 126*10639SDarren.Reed@Sun.COM 1270Sstevel@tonic-gate #ifdef __cplusplus 1280Sstevel@tonic-gate } 1290Sstevel@tonic-gate #endif 1300Sstevel@tonic-gate 1310Sstevel@tonic-gate #endif /* _SYS_SOCKET_IMPL_H */ 132