4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
22 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
26 #ifndef _LIBDLPI_IMPL_H
27 #define _LIBDLPI_IMPL_H
30 #include <sys/sysmacros.h>
37 * Maximum DLPI response size, in bytes.
39 #define DLPI_CHUNKSIZE 8192
42 * Maximum SAP length, in bytes.
44 #define DLPI_SAPLEN_MAX 4
47 * Number of elements in 'arr'.
49 #define NELEMS(arr) (sizeof (arr) / sizeof ((arr)[0]))
52 * Allocate buffer size for DLPI message, in bytes and set DLPI primitive.
54 #define DLPI_MSG_CREATE(dlmsg, dlprimitive) \
55 (dlmsg).dlm_msgsz = i_dlpi_getprimsize((dlprimitive)); \
56 (dlmsg).dlm_msg = alloca((dlmsg).dlm_msgsz); \
57 (dlmsg).dlm_msg->dl_primitive = (dlprimitive);
60 * Publicly available DLPI notification types. This list may change if
61 * new DLPI notification types are made public. See dlpi(7P).
64 #define DLPI_NOTIFICATION_TYPES (DL_NOTE_LINK_DOWN | DL_NOTE_LINK_UP | \
65 DL_NOTE_PHYS_ADDR | DL_NOTE_SDU_SIZE | DL_NOTE_SPEED | \
66 DL_NOTE_PROMISC_ON_PHYS | DL_NOTE_PROMISC_OFF_PHYS)
69 * Used in a mactype lookup table.
71 typedef struct dlpi_mactype_s
{
72 uint_t dm_mactype
; /* DLPI/Private mactype */
73 char *dm_desc
; /* Description of mactype */
77 * Used to get the maximum DLPI message buffer size, in bytes.
79 typedef struct dlpi_primsz
{
80 t_uscalar_t dp_prim
; /* store DLPI primitive */
82 /* max. message size, in bytes, for dp_prim */
86 * Used to create DLPI message.
88 typedef struct dlpi_msg
{
89 union DL_primitives
*dlm_msg
;
90 /* store DLPI primitive message */
92 /* provide buffer size for dlm_msg */
95 typedef struct dlpi_notifyent
{
97 /* notification types registered */
98 dlpi_notifyfunc_t
*dln_fnp
;
99 /* callback to call */
100 void *arg
; /* argument to pass to callback */
101 uint_t dln_rm
; /* true if should be removed */
102 struct dlpi_notifyent
*dln_next
;
106 * Private libdlpi structure associated with each DLPI handle.
108 typedef struct dlpi_impl_s
{
109 int dli_fd
; /* fd attached to stream */
110 int dli_timeout
; /* timeout for operations, in sec */
111 char dli_linkname
[DLPI_LINKNAME_MAX
];
112 /* full linkname including PPA */
113 char dli_provider
[DLPI_LINKNAME_MAX
];
114 /* only provider name */
115 t_uscalar_t dli_style
; /* style 1 or 2 */
116 uint_t dli_saplen
; /* bound SAP length */
117 uint_t dli_sap
; /* bound SAP value */
118 boolean_t dli_sapbefore
; /* true if SAP precedes address */
119 uint_t dli_ppa
; /* physical point of attachment */
120 uint_t dli_mactype
; /* mac type */
121 uint_t dli_oflags
; /* flags set at open */
122 uint_t dli_note_processing
;
123 /* true if notification is being */
125 dlpi_notifyent_t
*dli_notifylistp
;
126 /* list of registered notifications */
133 #endif /* _LIBDLPI_IMPL_H */