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*aa92d85bSgt145670 * Common Development and Distribution License (the "License"). 6*aa92d85bSgt145670 * 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*aa92d85bSgt145670 * Copyright 2008 Sun Microsystems, Inc. All rights reserved. 237c478bd9Sstevel@tonic-gate * Use is subject to license terms. 247c478bd9Sstevel@tonic-gate */ 257c478bd9Sstevel@tonic-gate /* Copyright (c) 1990 Mentat Inc. */ 267c478bd9Sstevel@tonic-gate 277c478bd9Sstevel@tonic-gate #ifndef _INET_COMMON_H 287c478bd9Sstevel@tonic-gate #define _INET_COMMON_H 297c478bd9Sstevel@tonic-gate 307c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 317c478bd9Sstevel@tonic-gate 327c478bd9Sstevel@tonic-gate /* 337c478bd9Sstevel@tonic-gate * WARNING: This file contains implementation-specific constants, typedefs 347c478bd9Sstevel@tonic-gate * and macros which may change from release to release. 357c478bd9Sstevel@tonic-gate */ 367c478bd9Sstevel@tonic-gate 377c478bd9Sstevel@tonic-gate #ifdef __cplusplus 387c478bd9Sstevel@tonic-gate extern "C" { 397c478bd9Sstevel@tonic-gate #endif 407c478bd9Sstevel@tonic-gate 417c478bd9Sstevel@tonic-gate #include <sys/inttypes.h> 427c478bd9Sstevel@tonic-gate #include <sys/sysmacros.h> 43*aa92d85bSgt145670 #include <sys/mkdev.h> 447c478bd9Sstevel@tonic-gate 457c478bd9Sstevel@tonic-gate #define A_CNT(arr) (sizeof (arr) / sizeof (arr[0])) 467c478bd9Sstevel@tonic-gate #define A_END(arr) (&arr[A_CNT(arr)]) 477c478bd9Sstevel@tonic-gate #define A_LAST(arr) (&arr[A_CNT(arr) - 1]) 487c478bd9Sstevel@tonic-gate 497c478bd9Sstevel@tonic-gate #define nilp(t) ((t *)0) 507c478bd9Sstevel@tonic-gate #define nil(t) ((t)0) 517c478bd9Sstevel@tonic-gate #define noop 527c478bd9Sstevel@tonic-gate 537c478bd9Sstevel@tonic-gate typedef int (*pfi_t)(); 547c478bd9Sstevel@tonic-gate typedef void (*pfv_t)(); 557c478bd9Sstevel@tonic-gate 567c478bd9Sstevel@tonic-gate #define BE32_EQL(a, b) (((uint8_t *)a)[0] == ((uint8_t *)b)[0] && \ 577c478bd9Sstevel@tonic-gate ((uint8_t *)a)[1] == ((uint8_t *)b)[1] && \ 587c478bd9Sstevel@tonic-gate ((uint8_t *)a)[2] == ((uint8_t *)b)[2] && \ 597c478bd9Sstevel@tonic-gate ((uint8_t *)a)[3] == ((uint8_t *)b)[3]) 607c478bd9Sstevel@tonic-gate #define BE16_EQL(a, b) (((uint8_t *)a)[0] == ((uint8_t *)b)[0] && \ 617c478bd9Sstevel@tonic-gate ((uint8_t *)a)[1] == ((uint8_t *)b)[1]) 627c478bd9Sstevel@tonic-gate #define BE16_TO_U16(a) ((((uint16_t)((uint8_t *)a)[0] << 8) | \ 637c478bd9Sstevel@tonic-gate ((uint16_t)((uint8_t *)a)[1])) & 0xFFFF) 647c478bd9Sstevel@tonic-gate #define BE32_TO_U32(a) ((((uint32_t)((uint8_t *)a)[0]) << 24) | \ 657c478bd9Sstevel@tonic-gate (((uint32_t)((uint8_t *)a)[1]) << 16) | \ 667c478bd9Sstevel@tonic-gate (((uint32_t)((uint8_t *)a)[2]) << 8) | \ 677c478bd9Sstevel@tonic-gate ((uint32_t)((uint8_t *)a)[3])) 687c478bd9Sstevel@tonic-gate #define U16_TO_BE16(u, a) ((((uint8_t *)a)[0] = (uint8_t)((u) >> 8)), \ 697c478bd9Sstevel@tonic-gate (((uint8_t *)a)[1] = (uint8_t)(u))) 707c478bd9Sstevel@tonic-gate #define U32_TO_BE32(u, a) ((((uint8_t *)a)[0] = (uint8_t)((u) >> 24)), \ 717c478bd9Sstevel@tonic-gate (((uint8_t *)a)[1] = (uint8_t)((u) >> 16)), \ 727c478bd9Sstevel@tonic-gate (((uint8_t *)a)[2] = (uint8_t)((u) >> 8)), \ 737c478bd9Sstevel@tonic-gate (((uint8_t *)a)[3] = (uint8_t)(u))) 747c478bd9Sstevel@tonic-gate 757c478bd9Sstevel@tonic-gate /* 767c478bd9Sstevel@tonic-gate * Local Environment Definition, this may and should override the 777c478bd9Sstevel@tonic-gate * the default definitions above where the local environment differs. 787c478bd9Sstevel@tonic-gate */ 797c478bd9Sstevel@tonic-gate #include <inet/led.h> 807c478bd9Sstevel@tonic-gate #include <sys/isa_defs.h> 817c478bd9Sstevel@tonic-gate 827c478bd9Sstevel@tonic-gate #ifdef _BIG_ENDIAN 837c478bd9Sstevel@tonic-gate #define ABE32_TO_U32(p) (*((uint32_t *)p)) 847c478bd9Sstevel@tonic-gate #define ABE16_TO_U16(p) (*((uint16_t *)p)) 857c478bd9Sstevel@tonic-gate #define U16_TO_ABE16(u, p) (*((uint16_t *)p) = (u)) 867c478bd9Sstevel@tonic-gate #define U32_TO_ABE16(u, p) U16_TO_ABE16(u, p) 877c478bd9Sstevel@tonic-gate #define U32_TO_ABE32(u, p) (*((uint32_t *)p) = (u)) 887c478bd9Sstevel@tonic-gate #else 897c478bd9Sstevel@tonic-gate #define ABE16_TO_U16(p) BE16_TO_U16(p) 907c478bd9Sstevel@tonic-gate #define ABE32_TO_U32(p) BE32_TO_U32(p) 917c478bd9Sstevel@tonic-gate #define U16_TO_ABE16(u, p) U16_TO_BE16(u, p) 927c478bd9Sstevel@tonic-gate #define U32_TO_ABE16(u, p) U16_TO_ABE16(u, p) 937c478bd9Sstevel@tonic-gate #define U32_TO_ABE32(u, p) U32_TO_BE32(u, p) 947c478bd9Sstevel@tonic-gate #endif 957c478bd9Sstevel@tonic-gate 967c478bd9Sstevel@tonic-gate #define INET_MIN_DEV 2 /* minimum minor device number */ 977c478bd9Sstevel@tonic-gate 987c478bd9Sstevel@tonic-gate #ifdef _KERNEL 99ff550d0eSmasputra #include <sys/stream.h> 1007c478bd9Sstevel@tonic-gate 101*aa92d85bSgt145670 extern void *inet_minor_create(char *, dev_t, dev_t, int); 1027c478bd9Sstevel@tonic-gate extern void inet_minor_destroy(void *); 1037c478bd9Sstevel@tonic-gate extern dev_t inet_minor_alloc(void *); 1047c478bd9Sstevel@tonic-gate extern void inet_minor_free(void *, dev_t); 105ff550d0eSmasputra extern void inet_freemsg(mblk_t *); 1067c478bd9Sstevel@tonic-gate 1077c478bd9Sstevel@tonic-gate #endif /* _KERNEL */ 1087c478bd9Sstevel@tonic-gate 1097c478bd9Sstevel@tonic-gate #ifdef __cplusplus 1107c478bd9Sstevel@tonic-gate } 1117c478bd9Sstevel@tonic-gate #endif 1127c478bd9Sstevel@tonic-gate 1137c478bd9Sstevel@tonic-gate #endif /* _INET_COMMON_H */ 114