c7e4935f5b755b4bbeaec416f1ad24337aeac7a4ss/*
c7e4935f5b755b4bbeaec416f1ad24337aeac7a4ss * CDDL HEADER START
c7e4935f5b755b4bbeaec416f1ad24337aeac7a4ss *
c7e4935f5b755b4bbeaec416f1ad24337aeac7a4ss * The contents of this file are subject to the terms of the
c7e4935f5b755b4bbeaec416f1ad24337aeac7a4ss * Common Development and Distribution License (the "License").
c7e4935f5b755b4bbeaec416f1ad24337aeac7a4ss * You may not use this file except in compliance with the License.
c7e4935f5b755b4bbeaec416f1ad24337aeac7a4ss *
c7e4935f5b755b4bbeaec416f1ad24337aeac7a4ss * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
c7e4935f5b755b4bbeaec416f1ad24337aeac7a4ss * or http://www.opensolaris.org/os/licensing.
c7e4935f5b755b4bbeaec416f1ad24337aeac7a4ss * See the License for the specific language governing permissions
c7e4935f5b755b4bbeaec416f1ad24337aeac7a4ss * and limitations under the License.
c7e4935f5b755b4bbeaec416f1ad24337aeac7a4ss *
c7e4935f5b755b4bbeaec416f1ad24337aeac7a4ss * When distributing Covered Code, include this CDDL HEADER in each
c7e4935f5b755b4bbeaec416f1ad24337aeac7a4ss * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
c7e4935f5b755b4bbeaec416f1ad24337aeac7a4ss * If applicable, add the following below this CDDL HEADER, with the
c7e4935f5b755b4bbeaec416f1ad24337aeac7a4ss * fields enclosed by brackets "[]" replaced with your own identifying
c7e4935f5b755b4bbeaec416f1ad24337aeac7a4ss * information: Portions Copyright [yyyy] [name of copyright owner]
c7e4935f5b755b4bbeaec416f1ad24337aeac7a4ss *
c7e4935f5b755b4bbeaec416f1ad24337aeac7a4ss * CDDL HEADER END
c7e4935f5b755b4bbeaec416f1ad24337aeac7a4ss */
c7e4935f5b755b4bbeaec416f1ad24337aeac7a4ss/*
2b24ab6b3865caeede9eeb9db6b83e1d89dcd1eaSebastien Roy * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
c7e4935f5b755b4bbeaec416f1ad24337aeac7a4ss * Use is subject to license terms.
c7e4935f5b755b4bbeaec416f1ad24337aeac7a4ss */
c7e4935f5b755b4bbeaec416f1ad24337aeac7a4ss
c7e4935f5b755b4bbeaec416f1ad24337aeac7a4ss#ifndef _LIBDLPI_IMPL_H
c7e4935f5b755b4bbeaec416f1ad24337aeac7a4ss#define _LIBDLPI_IMPL_H
c7e4935f5b755b4bbeaec416f1ad24337aeac7a4ss
c7e4935f5b755b4bbeaec416f1ad24337aeac7a4ss#include <libdlpi.h>
c7e4935f5b755b4bbeaec416f1ad24337aeac7a4ss#include <sys/sysmacros.h>
c7e4935f5b755b4bbeaec416f1ad24337aeac7a4ss
c7e4935f5b755b4bbeaec416f1ad24337aeac7a4ss#ifdef __cplusplus
c7e4935f5b755b4bbeaec416f1ad24337aeac7a4ssextern "C" {
c7e4935f5b755b4bbeaec416f1ad24337aeac7a4ss#endif
c7e4935f5b755b4bbeaec416f1ad24337aeac7a4ss
c7e4935f5b755b4bbeaec416f1ad24337aeac7a4ss/*
c7e4935f5b755b4bbeaec416f1ad24337aeac7a4ss * Maximum DLPI response size, in bytes.
c7e4935f5b755b4bbeaec416f1ad24337aeac7a4ss */
c7e4935f5b755b4bbeaec416f1ad24337aeac7a4ss#define DLPI_CHUNKSIZE 8192
c7e4935f5b755b4bbeaec416f1ad24337aeac7a4ss
c7e4935f5b755b4bbeaec416f1ad24337aeac7a4ss/*
c7e4935f5b755b4bbeaec416f1ad24337aeac7a4ss * Maximum SAP length, in bytes.
c7e4935f5b755b4bbeaec416f1ad24337aeac7a4ss */
c7e4935f5b755b4bbeaec416f1ad24337aeac7a4ss#define DLPI_SAPLEN_MAX 4
c7e4935f5b755b4bbeaec416f1ad24337aeac7a4ss
c7e4935f5b755b4bbeaec416f1ad24337aeac7a4ss/*
c7e4935f5b755b4bbeaec416f1ad24337aeac7a4ss * Number of elements in 'arr'.
c7e4935f5b755b4bbeaec416f1ad24337aeac7a4ss */
c7e4935f5b755b4bbeaec416f1ad24337aeac7a4ss#define NELEMS(arr) (sizeof (arr) / sizeof ((arr)[0]))
c7e4935f5b755b4bbeaec416f1ad24337aeac7a4ss
c7e4935f5b755b4bbeaec416f1ad24337aeac7a4ss/*
c7e4935f5b755b4bbeaec416f1ad24337aeac7a4ss * Allocate buffer size for DLPI message, in bytes and set DLPI primitive.
c7e4935f5b755b4bbeaec416f1ad24337aeac7a4ss */
c7e4935f5b755b4bbeaec416f1ad24337aeac7a4ss#define DLPI_MSG_CREATE(dlmsg, dlprimitive) \
c7e4935f5b755b4bbeaec416f1ad24337aeac7a4ss (dlmsg).dlm_msgsz = i_dlpi_getprimsize((dlprimitive)); \
c7e4935f5b755b4bbeaec416f1ad24337aeac7a4ss (dlmsg).dlm_msg = alloca((dlmsg).dlm_msgsz); \
c7e4935f5b755b4bbeaec416f1ad24337aeac7a4ss (dlmsg).dlm_msg->dl_primitive = (dlprimitive);
c7e4935f5b755b4bbeaec416f1ad24337aeac7a4ss
3ab45760e29dbab3ec3197fc452899c4d4b1c4c4ss/*
3ab45760e29dbab3ec3197fc452899c4d4b1c4c4ss * Publicly available DLPI notification types. This list may change if
3ab45760e29dbab3ec3197fc452899c4d4b1c4c4ss * new DLPI notification types are made public. See dlpi(7P).
3ab45760e29dbab3ec3197fc452899c4d4b1c4c4ss *
3ab45760e29dbab3ec3197fc452899c4d4b1c4c4ss */
3ab45760e29dbab3ec3197fc452899c4d4b1c4c4ss#define DLPI_NOTIFICATION_TYPES (DL_NOTE_LINK_DOWN | DL_NOTE_LINK_UP | \
3ab45760e29dbab3ec3197fc452899c4d4b1c4c4ss DL_NOTE_PHYS_ADDR | DL_NOTE_SDU_SIZE | DL_NOTE_SPEED | \
3ab45760e29dbab3ec3197fc452899c4d4b1c4c4ss DL_NOTE_PROMISC_ON_PHYS | DL_NOTE_PROMISC_OFF_PHYS)
3ab45760e29dbab3ec3197fc452899c4d4b1c4c4ss
c7e4935f5b755b4bbeaec416f1ad24337aeac7a4ss/*
c7e4935f5b755b4bbeaec416f1ad24337aeac7a4ss * Used in a mactype lookup table.
c7e4935f5b755b4bbeaec416f1ad24337aeac7a4ss */
c7e4935f5b755b4bbeaec416f1ad24337aeac7a4sstypedef struct dlpi_mactype_s {
c7e4935f5b755b4bbeaec416f1ad24337aeac7a4ss uint_t dm_mactype; /* DLPI/Private mactype */
c7e4935f5b755b4bbeaec416f1ad24337aeac7a4ss char *dm_desc; /* Description of mactype */
c7e4935f5b755b4bbeaec416f1ad24337aeac7a4ss} dlpi_mactype_t;
c7e4935f5b755b4bbeaec416f1ad24337aeac7a4ss
c7e4935f5b755b4bbeaec416f1ad24337aeac7a4ss/*
c7e4935f5b755b4bbeaec416f1ad24337aeac7a4ss * Used to get the maximum DLPI message buffer size, in bytes.
c7e4935f5b755b4bbeaec416f1ad24337aeac7a4ss */
c7e4935f5b755b4bbeaec416f1ad24337aeac7a4sstypedef struct dlpi_primsz {
c7e4935f5b755b4bbeaec416f1ad24337aeac7a4ss t_uscalar_t dp_prim; /* store DLPI primitive */
c7e4935f5b755b4bbeaec416f1ad24337aeac7a4ss size_t dp_primsz;
c7e4935f5b755b4bbeaec416f1ad24337aeac7a4ss /* max. message size, in bytes, for dp_prim */
c7e4935f5b755b4bbeaec416f1ad24337aeac7a4ss} dlpi_primsz_t;
c7e4935f5b755b4bbeaec416f1ad24337aeac7a4ss
c7e4935f5b755b4bbeaec416f1ad24337aeac7a4ss/*
c7e4935f5b755b4bbeaec416f1ad24337aeac7a4ss * Used to create DLPI message.
c7e4935f5b755b4bbeaec416f1ad24337aeac7a4ss */
c7e4935f5b755b4bbeaec416f1ad24337aeac7a4sstypedef struct dlpi_msg {
c7e4935f5b755b4bbeaec416f1ad24337aeac7a4ss union DL_primitives *dlm_msg;
c7e4935f5b755b4bbeaec416f1ad24337aeac7a4ss /* store DLPI primitive message */
c7e4935f5b755b4bbeaec416f1ad24337aeac7a4ss size_t dlm_msgsz;
c7e4935f5b755b4bbeaec416f1ad24337aeac7a4ss /* provide buffer size for dlm_msg */
c7e4935f5b755b4bbeaec416f1ad24337aeac7a4ss} dlpi_msg_t;
c7e4935f5b755b4bbeaec416f1ad24337aeac7a4ss
3ab45760e29dbab3ec3197fc452899c4d4b1c4c4sstypedef struct dlpi_notifyent {
3ab45760e29dbab3ec3197fc452899c4d4b1c4c4ss uint_t dln_notes;
3ab45760e29dbab3ec3197fc452899c4d4b1c4c4ss /* notification types registered */
3ab45760e29dbab3ec3197fc452899c4d4b1c4c4ss dlpi_notifyfunc_t *dln_fnp;
3ab45760e29dbab3ec3197fc452899c4d4b1c4c4ss /* callback to call */
3ab45760e29dbab3ec3197fc452899c4d4b1c4c4ss void *arg; /* argument to pass to callback */
3ab45760e29dbab3ec3197fc452899c4d4b1c4c4ss uint_t dln_rm; /* true if should be removed */
3ab45760e29dbab3ec3197fc452899c4d4b1c4c4ss struct dlpi_notifyent *dln_next;
3ab45760e29dbab3ec3197fc452899c4d4b1c4c4ss} dlpi_notifyent_t;
3ab45760e29dbab3ec3197fc452899c4d4b1c4c4ss
c7e4935f5b755b4bbeaec416f1ad24337aeac7a4ss/*
c7e4935f5b755b4bbeaec416f1ad24337aeac7a4ss * Private libdlpi structure associated with each DLPI handle.
c7e4935f5b755b4bbeaec416f1ad24337aeac7a4ss */
c7e4935f5b755b4bbeaec416f1ad24337aeac7a4sstypedef struct dlpi_impl_s {
c7e4935f5b755b4bbeaec416f1ad24337aeac7a4ss int dli_fd; /* fd attached to stream */
c7e4935f5b755b4bbeaec416f1ad24337aeac7a4ss int dli_timeout; /* timeout for operations, in sec */
c7e4935f5b755b4bbeaec416f1ad24337aeac7a4ss char dli_linkname[DLPI_LINKNAME_MAX];
c7e4935f5b755b4bbeaec416f1ad24337aeac7a4ss /* full linkname including PPA */
c7e4935f5b755b4bbeaec416f1ad24337aeac7a4ss char dli_provider[DLPI_LINKNAME_MAX];
c7e4935f5b755b4bbeaec416f1ad24337aeac7a4ss /* only provider name */
c7e4935f5b755b4bbeaec416f1ad24337aeac7a4ss t_uscalar_t dli_style; /* style 1 or 2 */
c7e4935f5b755b4bbeaec416f1ad24337aeac7a4ss uint_t dli_saplen; /* bound SAP length */
c7e4935f5b755b4bbeaec416f1ad24337aeac7a4ss uint_t dli_sap; /* bound SAP value */
c7e4935f5b755b4bbeaec416f1ad24337aeac7a4ss boolean_t dli_sapbefore; /* true if SAP precedes address */
c7e4935f5b755b4bbeaec416f1ad24337aeac7a4ss uint_t dli_ppa; /* physical point of attachment */
c7e4935f5b755b4bbeaec416f1ad24337aeac7a4ss uint_t dli_mactype; /* mac type */
c7e4935f5b755b4bbeaec416f1ad24337aeac7a4ss uint_t dli_oflags; /* flags set at open */
3ab45760e29dbab3ec3197fc452899c4d4b1c4c4ss uint_t dli_note_processing;
3ab45760e29dbab3ec3197fc452899c4d4b1c4c4ss /* true if notification is being */
3ab45760e29dbab3ec3197fc452899c4d4b1c4c4ss /* processed */
3ab45760e29dbab3ec3197fc452899c4d4b1c4c4ss dlpi_notifyent_t *dli_notifylistp;
3ab45760e29dbab3ec3197fc452899c4d4b1c4c4ss /* list of registered notifications */
c7e4935f5b755b4bbeaec416f1ad24337aeac7a4ss} dlpi_impl_t;
c7e4935f5b755b4bbeaec416f1ad24337aeac7a4ss
c7e4935f5b755b4bbeaec416f1ad24337aeac7a4ss#ifdef __cplusplus
c7e4935f5b755b4bbeaec416f1ad24337aeac7a4ss}
c7e4935f5b755b4bbeaec416f1ad24337aeac7a4ss#endif
c7e4935f5b755b4bbeaec416f1ad24337aeac7a4ss
c7e4935f5b755b4bbeaec416f1ad24337aeac7a4ss#endif /* _LIBDLPI_IMPL_H */