17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*0a0e9771SDarren Reed * Common Development and Distribution License (the "License"). 6*0a0e9771SDarren Reed * You may not use this file except in compliance with the License. 77c478bd9Sstevel@tonic-gate * 87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 117c478bd9Sstevel@tonic-gate * and limitations under the License. 127c478bd9Sstevel@tonic-gate * 137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 187c478bd9Sstevel@tonic-gate * 197c478bd9Sstevel@tonic-gate * CDDL HEADER END 207c478bd9Sstevel@tonic-gate */ 217c478bd9Sstevel@tonic-gate /* 22*0a0e9771SDarren Reed * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 237c478bd9Sstevel@tonic-gate * Use is subject to license terms. 247c478bd9Sstevel@tonic-gate */ 257c478bd9Sstevel@tonic-gate 267c478bd9Sstevel@tonic-gate /* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ 277c478bd9Sstevel@tonic-gate /* All Rights Reserved */ 287c478bd9Sstevel@tonic-gate 297c478bd9Sstevel@tonic-gate /* 307c478bd9Sstevel@tonic-gate * Portions of this source code were derived from Berkeley 4.3 BSD 317c478bd9Sstevel@tonic-gate * under license from the Regents of the University of California. 327c478bd9Sstevel@tonic-gate */ 337c478bd9Sstevel@tonic-gate 347c478bd9Sstevel@tonic-gate #ifndef _SYS_SOCKET_IMPL_H 357c478bd9Sstevel@tonic-gate #define _SYS_SOCKET_IMPL_H 367c478bd9Sstevel@tonic-gate 377c478bd9Sstevel@tonic-gate #ifdef __cplusplus 387c478bd9Sstevel@tonic-gate extern "C" { 397c478bd9Sstevel@tonic-gate #endif 407c478bd9Sstevel@tonic-gate 417c478bd9Sstevel@tonic-gate #ifndef _SA_FAMILY_T 427c478bd9Sstevel@tonic-gate #define _SA_FAMILY_T 437c478bd9Sstevel@tonic-gate typedef uint16_t sa_family_t; 447c478bd9Sstevel@tonic-gate #endif 457c478bd9Sstevel@tonic-gate 467c478bd9Sstevel@tonic-gate /* 477c478bd9Sstevel@tonic-gate * Structure used by kernel to store most 487c478bd9Sstevel@tonic-gate * addresses. 497c478bd9Sstevel@tonic-gate */ 507c478bd9Sstevel@tonic-gate struct sockaddr { 517c478bd9Sstevel@tonic-gate sa_family_t sa_family; /* address family */ 527c478bd9Sstevel@tonic-gate char sa_data[14]; /* up to 14 bytes of direct address */ 537c478bd9Sstevel@tonic-gate }; 547c478bd9Sstevel@tonic-gate 557c478bd9Sstevel@tonic-gate #if !defined(_XPG4_2) || defined(__EXTENSIONS__) 567c478bd9Sstevel@tonic-gate #include <sys/un.h> 577c478bd9Sstevel@tonic-gate #include <net/if_dl.h> 587c478bd9Sstevel@tonic-gate #endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) */ 597c478bd9Sstevel@tonic-gate 607c478bd9Sstevel@tonic-gate #if !defined(_XPG4_2) || defined(_XPG6) || defined(__EXTENSIONS__) 617c478bd9Sstevel@tonic-gate /* 627c478bd9Sstevel@tonic-gate * sockaddr_storage: 637c478bd9Sstevel@tonic-gate * Common superset of at least AF_INET, AF_INET6 and AF_LINK sockaddr 647c478bd9Sstevel@tonic-gate * structures. Has sufficient size and alignment for those sockaddrs. 657c478bd9Sstevel@tonic-gate */ 667c478bd9Sstevel@tonic-gate 677c478bd9Sstevel@tonic-gate /* 687c478bd9Sstevel@tonic-gate * Desired maximum size, alignment size and related types. 697c478bd9Sstevel@tonic-gate */ 707c478bd9Sstevel@tonic-gate #define _SS_MAXSIZE 256 /* Implementation specific max size */ 717c478bd9Sstevel@tonic-gate 727c478bd9Sstevel@tonic-gate /* 737c478bd9Sstevel@tonic-gate * To represent desired sockaddr max alignment for platform, a 747c478bd9Sstevel@tonic-gate * type is chosen which may depend on implementation platform architecture. 757c478bd9Sstevel@tonic-gate * Type chosen based on alignment size restrictions from <sys/isa_defs.h>. 767c478bd9Sstevel@tonic-gate * We desire to force up to (but no more than) 64-bit (8 byte) alignment, 777c478bd9Sstevel@tonic-gate * on platforms where it is possible to do so. (e.g not possible on ia32). 787c478bd9Sstevel@tonic-gate * For all currently supported platforms by our implementation 797c478bd9Sstevel@tonic-gate * in <sys/isa_defs.h>, (i.e. sparc, sparcv9, ia32, ia64) 807c478bd9Sstevel@tonic-gate * type "double" is suitable for that intent. 817c478bd9Sstevel@tonic-gate * 827c478bd9Sstevel@tonic-gate * Note: Type "double" is chosen over the more obvious integer type int64_t. 837c478bd9Sstevel@tonic-gate * int64_t is not a valid type for strict ANSI/ISO C compilation on ILP32. 847c478bd9Sstevel@tonic-gate */ 857c478bd9Sstevel@tonic-gate typedef double sockaddr_maxalign_t; 867c478bd9Sstevel@tonic-gate 877c478bd9Sstevel@tonic-gate #define _SS_ALIGNSIZE (sizeof (sockaddr_maxalign_t)) 887c478bd9Sstevel@tonic-gate 897c478bd9Sstevel@tonic-gate /* 907c478bd9Sstevel@tonic-gate * Definitions used for sockaddr_storage structure paddings design. 917c478bd9Sstevel@tonic-gate */ 927c478bd9Sstevel@tonic-gate #define _SS_PAD1SIZE (_SS_ALIGNSIZE - sizeof (sa_family_t)) 937c478bd9Sstevel@tonic-gate #define _SS_PAD2SIZE (_SS_MAXSIZE - (sizeof (sa_family_t)+ \ 947c478bd9Sstevel@tonic-gate _SS_PAD1SIZE + _SS_ALIGNSIZE)) 957c478bd9Sstevel@tonic-gate 967c478bd9Sstevel@tonic-gate struct sockaddr_storage { 977c478bd9Sstevel@tonic-gate sa_family_t ss_family; /* Address family */ 987c478bd9Sstevel@tonic-gate /* Following fields are implementation specific */ 997c478bd9Sstevel@tonic-gate char _ss_pad1[_SS_PAD1SIZE]; 1007c478bd9Sstevel@tonic-gate sockaddr_maxalign_t _ss_align; 1017c478bd9Sstevel@tonic-gate char _ss_pad2[_SS_PAD2SIZE]; 1027c478bd9Sstevel@tonic-gate }; 1037c478bd9Sstevel@tonic-gate #endif /* !defined(_XPG4_2) || defined(_XPG6) || defined(__EXTENSIONS__) */ 1047c478bd9Sstevel@tonic-gate 105*0a0e9771SDarren Reed /* 106*0a0e9771SDarren Reed * To be compatible with the Linux interfaces used, this structure is 107*0a0e9771SDarren Reed * placed in socket_impl.h so that an include for <sys/socket.h> will 108*0a0e9771SDarren Reed * pickup this structure. This structure is for use with PF_PACKET 109*0a0e9771SDarren Reed * sockets. 110*0a0e9771SDarren Reed */ 111*0a0e9771SDarren Reed struct sockaddr_ll { 112*0a0e9771SDarren Reed uint16_t sll_family; 113*0a0e9771SDarren Reed uint16_t sll_protocol; 114*0a0e9771SDarren Reed int32_t sll_ifindex; 115*0a0e9771SDarren Reed uint16_t sll_hatype; 116*0a0e9771SDarren Reed uint8_t sll_pkttype; 117*0a0e9771SDarren Reed uint8_t sll_halen; 118*0a0e9771SDarren Reed uint8_t sll_addr[8]; 119*0a0e9771SDarren Reed }; 120*0a0e9771SDarren Reed 121*0a0e9771SDarren Reed #define LINUX_SLL_HOST 0 122*0a0e9771SDarren Reed #define LINUX_SLL_BROADCAST 1 123*0a0e9771SDarren Reed #define LINUX_SLL_MULTICAST 2 124*0a0e9771SDarren Reed #define LINUX_SLL_OTHERHOST 3 125*0a0e9771SDarren Reed #define LINUX_SLL_OUTGOING 4 126*0a0e9771SDarren Reed 1277c478bd9Sstevel@tonic-gate #ifdef __cplusplus 1287c478bd9Sstevel@tonic-gate } 1297c478bd9Sstevel@tonic-gate #endif 1307c478bd9Sstevel@tonic-gate 1317c478bd9Sstevel@tonic-gate #endif /* _SYS_SOCKET_IMPL_H */ 132