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 2007 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
24 * Copyright (c) 2011 Bayard G. Bell. All rights reserved.
27 #include <sys/types.h>
29 #include <sys/modctl.h>
30 #include <sys/stream.h>
31 #include <sys/strsubr.h>
32 #include <sys/strsun.h>
34 #include <inet/common.h>
37 #include <netinet/in.h>
41 extern caddr_t nca_g_nd
; /* Head of 'named dispatch' variable list */
43 #define INET_NAME "nca"
44 #define INET_MODSTRTAB ncainfo
45 #define INET_DEVSTRTAB ncainfo
46 #define INET_MODDESC "NCA STREAMS module 1.6"
47 #define INET_DEVDESC "NCA STREAMS driver 1.6"
48 #define INET_DEVMINOR 0
49 #define INET_DEVMTFLAGS D_MP
50 #define INET_MODMTFLAGS D_MP
52 #include "../inetddi.c"
56 nca_open(queue_t
*q
, dev_t
*devp
, int flag
, int sflag
, cred_t
*credp
)
58 /* Reopen supported */
63 * NCA is not supported in non-global zones; we enforce this restriction
66 if (credp
!= NULL
&& crgetzoneid(credp
) != GLOBAL_ZONEID
) {
70 if (! (sflag
& MODOPEN
)) {
72 RD(q
)->q_ptr
= (void *)B_TRUE
;
73 WR(q
)->q_ptr
= (void *)B_TRUE
;
75 /* Modopen just pass through */
76 RD(q
)->q_ptr
= (void *)B_FALSE
;
77 WR(q
)->q_ptr
= (void *)B_FALSE
;
85 nca_close(queue_t
*q
, int flags __unused
, cred_t
*credp __unused
)
94 nca_rput(queue_t
*q
, mblk_t
*mp
)
101 nca_wput(queue_t
*q
, mblk_t
*mp
)
105 if (! (boolean_t
)q
->q_ptr
) {
106 iocp
= (struct iocblk
*)mp
->b_rptr
;
107 if (DB_TYPE(mp
) == M_IOCTL
&& iocp
->ioc_cmd
== NCA_SET_IF
) {
108 miocnak(q
, mp
, 0, ENOTSUP
);
111 /* Module, passthrough */
116 switch (DB_TYPE(mp
)) {
118 iocp
= (struct iocblk
*)mp
->b_rptr
;
119 switch (iocp
->ioc_cmd
) {
122 if (! nd_getset(q
, nca_g_nd
, mp
)) {
123 miocnak(q
, mp
, 0, ENOENT
);
129 miocnak(q
, mp
, 0, ENOTSUP
);
139 static struct module_info info
= {
140 0, "nca", 1, INFPSZ
, 65536, 1024
143 static struct qinit rinit
= {
144 (pfi_t
)nca_rput
, NULL
, nca_open
, nca_close
, NULL
, &info
147 static struct qinit winit
= {
148 (pfi_t
)nca_wput
, NULL
, nca_open
, nca_close
, NULL
, &info
151 struct streamtab ncainfo
= {
158 return (mod_install(&modlinkage
));
168 _info(struct modinfo
*modinfop
)
170 return (mod_info(&modlinkage
, modinfop
));