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 /* 317c478bd9Sstevel@tonic-gate * WARNING: This file contains implementation-specific constants, typedefs 327c478bd9Sstevel@tonic-gate * and macros which may change from release to release. 337c478bd9Sstevel@tonic-gate */ 347c478bd9Sstevel@tonic-gate 357c478bd9Sstevel@tonic-gate #ifdef __cplusplus 367c478bd9Sstevel@tonic-gate extern "C" { 377c478bd9Sstevel@tonic-gate #endif 387c478bd9Sstevel@tonic-gate 397c478bd9Sstevel@tonic-gate #include <sys/inttypes.h> 407c478bd9Sstevel@tonic-gate #include <sys/sysmacros.h> 41*aa92d85bSgt145670 #include <sys/mkdev.h> 427c478bd9Sstevel@tonic-gate 437c478bd9Sstevel@tonic-gate #define A_CNT(arr) (sizeof (arr) / sizeof (arr[0])) 447c478bd9Sstevel@tonic-gate #define A_END(arr) (&arr[A_CNT(arr)]) 457c478bd9Sstevel@tonic-gate #define A_LAST(arr) (&arr[A_CNT(arr) - 1]) 467c478bd9Sstevel@tonic-gate 477c478bd9Sstevel@tonic-gate #define nilp(t) ((t *)0) 487c478bd9Sstevel@tonic-gate #define nil(t) ((t)0) 497c478bd9Sstevel@tonic-gate #define noop 507c478bd9Sstevel@tonic-gate 517c478bd9Sstevel@tonic-gate typedef int (*pfi_t)(); 527c478bd9Sstevel@tonic-gate typedef void (*pfv_t)(); 537c478bd9Sstevel@tonic-gate 547c478bd9Sstevel@tonic-gate #define BE32_EQL(a, b) (((uint8_t *)a)[0] == ((uint8_t *)b)[0] && \ 557c478bd9Sstevel@tonic-gate ((uint8_t *)a)[1] == ((uint8_t *)b)[1] && \ 567c478bd9Sstevel@tonic-gate ((uint8_t *)a)[2] == ((uint8_t *)b)[2] && \ 577c478bd9Sstevel@tonic-gate ((uint8_t *)a)[3] == ((uint8_t *)b)[3]) 587c478bd9Sstevel@tonic-gate #define BE16_EQL(a, b) (((uint8_t *)a)[0] == ((uint8_t *)b)[0] && \ 597c478bd9Sstevel@tonic-gate ((uint8_t *)a)[1] == ((uint8_t *)b)[1]) 607c478bd9Sstevel@tonic-gate #define BE16_TO_U16(a) ((((uint16_t)((uint8_t *)a)[0] << 8) | \ 617c478bd9Sstevel@tonic-gate ((uint16_t)((uint8_t *)a)[1])) & 0xFFFF) 627c478bd9Sstevel@tonic-gate #define BE32_TO_U32(a) ((((uint32_t)((uint8_t *)a)[0]) << 24) | \ 637c478bd9Sstevel@tonic-gate (((uint32_t)((uint8_t *)a)[1]) << 16) | \ 647c478bd9Sstevel@tonic-gate (((uint32_t)((uint8_t *)a)[2]) << 8) | \ 657c478bd9Sstevel@tonic-gate ((uint32_t)((uint8_t *)a)[3])) 667c478bd9Sstevel@tonic-gate #define U16_TO_BE16(u, a) ((((uint8_t *)a)[0] = (uint8_t)((u) >> 8)), \ 677c478bd9Sstevel@tonic-gate (((uint8_t *)a)[1] = (uint8_t)(u))) 687c478bd9Sstevel@tonic-gate #define U32_TO_BE32(u, a) ((((uint8_t *)a)[0] = (uint8_t)((u) >> 24)), \ 697c478bd9Sstevel@tonic-gate (((uint8_t *)a)[1] = (uint8_t)((u) >> 16)), \ 707c478bd9Sstevel@tonic-gate (((uint8_t *)a)[2] = (uint8_t)((u) >> 8)), \ 717c478bd9Sstevel@tonic-gate (((uint8_t *)a)[3] = (uint8_t)(u))) 727c478bd9Sstevel@tonic-gate 737c478bd9Sstevel@tonic-gate /* 747c478bd9Sstevel@tonic-gate * Local Environment Definition, this may and should override the 757c478bd9Sstevel@tonic-gate * the default definitions above where the local environment differs. 767c478bd9Sstevel@tonic-gate */ 777c478bd9Sstevel@tonic-gate #include <inet/led.h> 787c478bd9Sstevel@tonic-gate #include <sys/isa_defs.h> 797c478bd9Sstevel@tonic-gate 807c478bd9Sstevel@tonic-gate #ifdef _BIG_ENDIAN 817c478bd9Sstevel@tonic-gate #define ABE32_TO_U32(p) (*((uint32_t *)p)) 827c478bd9Sstevel@tonic-gate #define ABE16_TO_U16(p) (*((uint16_t *)p)) 837c478bd9Sstevel@tonic-gate #define U16_TO_ABE16(u, p) (*((uint16_t *)p) = (u)) 847c478bd9Sstevel@tonic-gate #define U32_TO_ABE16(u, p) U16_TO_ABE16(u, p) 857c478bd9Sstevel@tonic-gate #define U32_TO_ABE32(u, p) (*((uint32_t *)p) = (u)) 867c478bd9Sstevel@tonic-gate #else 877c478bd9Sstevel@tonic-gate #define ABE16_TO_U16(p) BE16_TO_U16(p) 887c478bd9Sstevel@tonic-gate #define ABE32_TO_U32(p) BE32_TO_U32(p) 897c478bd9Sstevel@tonic-gate #define U16_TO_ABE16(u, p) U16_TO_BE16(u, p) 907c478bd9Sstevel@tonic-gate #define U32_TO_ABE16(u, p) U16_TO_ABE16(u, p) 917c478bd9Sstevel@tonic-gate #define U32_TO_ABE32(u, p) U32_TO_BE32(u, p) 927c478bd9Sstevel@tonic-gate #endif 937c478bd9Sstevel@tonic-gate 947c478bd9Sstevel@tonic-gate #define INET_MIN_DEV 2 /* minimum minor device number */ 957c478bd9Sstevel@tonic-gate 967c478bd9Sstevel@tonic-gate #ifdef _KERNEL 97ff550d0eSmasputra #include <sys/stream.h> 987c478bd9Sstevel@tonic-gate 99*aa92d85bSgt145670 extern void *inet_minor_create(char *, dev_t, dev_t, int); 1007c478bd9Sstevel@tonic-gate extern void inet_minor_destroy(void *); 1017c478bd9Sstevel@tonic-gate extern dev_t inet_minor_alloc(void *); 1027c478bd9Sstevel@tonic-gate extern void inet_minor_free(void *, dev_t); 103ff550d0eSmasputra extern void inet_freemsg(mblk_t *); 1047c478bd9Sstevel@tonic-gate 1057c478bd9Sstevel@tonic-gate #endif /* _KERNEL */ 1067c478bd9Sstevel@tonic-gate 1077c478bd9Sstevel@tonic-gate #ifdef __cplusplus 1087c478bd9Sstevel@tonic-gate } 1097c478bd9Sstevel@tonic-gate #endif 1107c478bd9Sstevel@tonic-gate 1117c478bd9Sstevel@tonic-gate #endif /* _INET_COMMON_H */ 112