1*7c478bd9Sstevel@tonic-gate /* 2*7c478bd9Sstevel@tonic-gate * CDDL HEADER START 3*7c478bd9Sstevel@tonic-gate * 4*7c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*7c478bd9Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 6*7c478bd9Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 7*7c478bd9Sstevel@tonic-gate * with the License. 8*7c478bd9Sstevel@tonic-gate * 9*7c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*7c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 11*7c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 12*7c478bd9Sstevel@tonic-gate * and limitations under the License. 13*7c478bd9Sstevel@tonic-gate * 14*7c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 15*7c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*7c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 17*7c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 18*7c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 19*7c478bd9Sstevel@tonic-gate * 20*7c478bd9Sstevel@tonic-gate * CDDL HEADER END 21*7c478bd9Sstevel@tonic-gate */ 22*7c478bd9Sstevel@tonic-gate /* 23*7c478bd9Sstevel@tonic-gate * Copyright 1992-2001, 2003 Sun Microsystems, Inc. All rights reserved. 24*7c478bd9Sstevel@tonic-gate * Use is subject to license terms. 25*7c478bd9Sstevel@tonic-gate */ 26*7c478bd9Sstevel@tonic-gate /* Copyright (c) 1990 Mentat Inc. */ 27*7c478bd9Sstevel@tonic-gate 28*7c478bd9Sstevel@tonic-gate #ifndef _INET_COMMON_H 29*7c478bd9Sstevel@tonic-gate #define _INET_COMMON_H 30*7c478bd9Sstevel@tonic-gate 31*7c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 32*7c478bd9Sstevel@tonic-gate 33*7c478bd9Sstevel@tonic-gate /* 34*7c478bd9Sstevel@tonic-gate * WARNING: This file contains implementation-specific constants, typedefs 35*7c478bd9Sstevel@tonic-gate * and macros which may change from release to release. 36*7c478bd9Sstevel@tonic-gate */ 37*7c478bd9Sstevel@tonic-gate 38*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus 39*7c478bd9Sstevel@tonic-gate extern "C" { 40*7c478bd9Sstevel@tonic-gate #endif 41*7c478bd9Sstevel@tonic-gate 42*7c478bd9Sstevel@tonic-gate #include <sys/inttypes.h> 43*7c478bd9Sstevel@tonic-gate #include <sys/sysmacros.h> 44*7c478bd9Sstevel@tonic-gate 45*7c478bd9Sstevel@tonic-gate #define A_CNT(arr) (sizeof (arr) / sizeof (arr[0])) 46*7c478bd9Sstevel@tonic-gate #define A_END(arr) (&arr[A_CNT(arr)]) 47*7c478bd9Sstevel@tonic-gate #define A_LAST(arr) (&arr[A_CNT(arr) - 1]) 48*7c478bd9Sstevel@tonic-gate 49*7c478bd9Sstevel@tonic-gate #define nilp(t) ((t *)0) 50*7c478bd9Sstevel@tonic-gate #define nil(t) ((t)0) 51*7c478bd9Sstevel@tonic-gate #define noop 52*7c478bd9Sstevel@tonic-gate 53*7c478bd9Sstevel@tonic-gate typedef int (*pfi_t)(); 54*7c478bd9Sstevel@tonic-gate typedef void (*pfv_t)(); 55*7c478bd9Sstevel@tonic-gate 56*7c478bd9Sstevel@tonic-gate #define BE32_EQL(a, b) (((uint8_t *)a)[0] == ((uint8_t *)b)[0] && \ 57*7c478bd9Sstevel@tonic-gate ((uint8_t *)a)[1] == ((uint8_t *)b)[1] && \ 58*7c478bd9Sstevel@tonic-gate ((uint8_t *)a)[2] == ((uint8_t *)b)[2] && \ 59*7c478bd9Sstevel@tonic-gate ((uint8_t *)a)[3] == ((uint8_t *)b)[3]) 60*7c478bd9Sstevel@tonic-gate #define BE16_EQL(a, b) (((uint8_t *)a)[0] == ((uint8_t *)b)[0] && \ 61*7c478bd9Sstevel@tonic-gate ((uint8_t *)a)[1] == ((uint8_t *)b)[1]) 62*7c478bd9Sstevel@tonic-gate #define BE16_TO_U16(a) ((((uint16_t)((uint8_t *)a)[0] << 8) | \ 63*7c478bd9Sstevel@tonic-gate ((uint16_t)((uint8_t *)a)[1])) & 0xFFFF) 64*7c478bd9Sstevel@tonic-gate #define BE32_TO_U32(a) ((((uint32_t)((uint8_t *)a)[0]) << 24) | \ 65*7c478bd9Sstevel@tonic-gate (((uint32_t)((uint8_t *)a)[1]) << 16) | \ 66*7c478bd9Sstevel@tonic-gate (((uint32_t)((uint8_t *)a)[2]) << 8) | \ 67*7c478bd9Sstevel@tonic-gate ((uint32_t)((uint8_t *)a)[3])) 68*7c478bd9Sstevel@tonic-gate #define U16_TO_BE16(u, a) ((((uint8_t *)a)[0] = (uint8_t)((u) >> 8)), \ 69*7c478bd9Sstevel@tonic-gate (((uint8_t *)a)[1] = (uint8_t)(u))) 70*7c478bd9Sstevel@tonic-gate #define U32_TO_BE32(u, a) ((((uint8_t *)a)[0] = (uint8_t)((u) >> 24)), \ 71*7c478bd9Sstevel@tonic-gate (((uint8_t *)a)[1] = (uint8_t)((u) >> 16)), \ 72*7c478bd9Sstevel@tonic-gate (((uint8_t *)a)[2] = (uint8_t)((u) >> 8)), \ 73*7c478bd9Sstevel@tonic-gate (((uint8_t *)a)[3] = (uint8_t)(u))) 74*7c478bd9Sstevel@tonic-gate 75*7c478bd9Sstevel@tonic-gate /* 76*7c478bd9Sstevel@tonic-gate * Local Environment Definition, this may and should override the 77*7c478bd9Sstevel@tonic-gate * the default definitions above where the local environment differs. 78*7c478bd9Sstevel@tonic-gate */ 79*7c478bd9Sstevel@tonic-gate #include <inet/led.h> 80*7c478bd9Sstevel@tonic-gate #include <sys/isa_defs.h> 81*7c478bd9Sstevel@tonic-gate 82*7c478bd9Sstevel@tonic-gate #ifdef _BIG_ENDIAN 83*7c478bd9Sstevel@tonic-gate #define ABE32_TO_U32(p) (*((uint32_t *)p)) 84*7c478bd9Sstevel@tonic-gate #define ABE16_TO_U16(p) (*((uint16_t *)p)) 85*7c478bd9Sstevel@tonic-gate #define U16_TO_ABE16(u, p) (*((uint16_t *)p) = (u)) 86*7c478bd9Sstevel@tonic-gate #define U32_TO_ABE16(u, p) U16_TO_ABE16(u, p) 87*7c478bd9Sstevel@tonic-gate #define U32_TO_ABE32(u, p) (*((uint32_t *)p) = (u)) 88*7c478bd9Sstevel@tonic-gate #else 89*7c478bd9Sstevel@tonic-gate #define ABE16_TO_U16(p) BE16_TO_U16(p) 90*7c478bd9Sstevel@tonic-gate #define ABE32_TO_U32(p) BE32_TO_U32(p) 91*7c478bd9Sstevel@tonic-gate #define U16_TO_ABE16(u, p) U16_TO_BE16(u, p) 92*7c478bd9Sstevel@tonic-gate #define U32_TO_ABE16(u, p) U16_TO_ABE16(u, p) 93*7c478bd9Sstevel@tonic-gate #define U32_TO_ABE32(u, p) U32_TO_BE32(u, p) 94*7c478bd9Sstevel@tonic-gate #endif 95*7c478bd9Sstevel@tonic-gate 96*7c478bd9Sstevel@tonic-gate #define INET_MIN_DEV 2 /* minimum minor device number */ 97*7c478bd9Sstevel@tonic-gate #define INET_MAXMINOR MAXMIN /* maximum device minor number */ 98*7c478bd9Sstevel@tonic-gate 99*7c478bd9Sstevel@tonic-gate #ifdef _KERNEL 100*7c478bd9Sstevel@tonic-gate 101*7c478bd9Sstevel@tonic-gate extern void inet_init(void); 102*7c478bd9Sstevel@tonic-gate extern void inet_destroy(void); 103*7c478bd9Sstevel@tonic-gate extern void *inet_minor_create(char *, dev_t, int); 104*7c478bd9Sstevel@tonic-gate extern void inet_minor_destroy(void *); 105*7c478bd9Sstevel@tonic-gate extern dev_t inet_minor_alloc(void *); 106*7c478bd9Sstevel@tonic-gate extern void inet_minor_free(void *, dev_t); 107*7c478bd9Sstevel@tonic-gate 108*7c478bd9Sstevel@tonic-gate #endif /* _KERNEL */ 109*7c478bd9Sstevel@tonic-gate 110*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus 111*7c478bd9Sstevel@tonic-gate } 112*7c478bd9Sstevel@tonic-gate #endif 113*7c478bd9Sstevel@tonic-gate 114*7c478bd9Sstevel@tonic-gate #endif /* _INET_COMMON_H */ 115