1*7836SJohn.Forte@Sun.COM /*
2*7836SJohn.Forte@Sun.COM * CDDL HEADER START
3*7836SJohn.Forte@Sun.COM *
4*7836SJohn.Forte@Sun.COM * The contents of this file are subject to the terms of the
5*7836SJohn.Forte@Sun.COM * Common Development and Distribution License (the "License").
6*7836SJohn.Forte@Sun.COM * You may not use this file except in compliance with the License.
7*7836SJohn.Forte@Sun.COM *
8*7836SJohn.Forte@Sun.COM * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9*7836SJohn.Forte@Sun.COM * or http://www.opensolaris.org/os/licensing.
10*7836SJohn.Forte@Sun.COM * See the License for the specific language governing permissions
11*7836SJohn.Forte@Sun.COM * and limitations under the License.
12*7836SJohn.Forte@Sun.COM *
13*7836SJohn.Forte@Sun.COM * When distributing Covered Code, include this CDDL HEADER in each
14*7836SJohn.Forte@Sun.COM * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15*7836SJohn.Forte@Sun.COM * If applicable, add the following below this CDDL HEADER, with the
16*7836SJohn.Forte@Sun.COM * fields enclosed by brackets "[]" replaced with your own identifying
17*7836SJohn.Forte@Sun.COM * information: Portions Copyright [yyyy] [name of copyright owner]
18*7836SJohn.Forte@Sun.COM *
19*7836SJohn.Forte@Sun.COM * CDDL HEADER END
20*7836SJohn.Forte@Sun.COM */
21*7836SJohn.Forte@Sun.COM /*
22*7836SJohn.Forte@Sun.COM * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
23*7836SJohn.Forte@Sun.COM * Use is subject to license terms.
24*7836SJohn.Forte@Sun.COM */
25*7836SJohn.Forte@Sun.COM
26*7836SJohn.Forte@Sun.COM #include <sys/types.h>
27*7836SJohn.Forte@Sun.COM #include <sys/errno.h>
28*7836SJohn.Forte@Sun.COM #include <sys/ddi.h>
29*7836SJohn.Forte@Sun.COM #include <sys/sunddi.h>
30*7836SJohn.Forte@Sun.COM
31*7836SJohn.Forte@Sun.COM #include <sys/varargs.h>
32*7836SJohn.Forte@Sun.COM #ifdef DS_DDICT
33*7836SJohn.Forte@Sun.COM #include <sys/nsctl/contract.h>
34*7836SJohn.Forte@Sun.COM #endif
35*7836SJohn.Forte@Sun.COM #include "ncall.h"
36*7836SJohn.Forte@Sun.COM #include "ncall_module.h"
37*7836SJohn.Forte@Sun.COM
38*7836SJohn.Forte@Sun.COM static ncall_node_t nodeinfo;
39*7836SJohn.Forte@Sun.COM
40*7836SJohn.Forte@Sun.COM
41*7836SJohn.Forte@Sun.COM /* ARGSUSED */
42*7836SJohn.Forte@Sun.COM void
ncall_stub_register_svc(int svc_id,void (* func)(ncall_t *,int *))43*7836SJohn.Forte@Sun.COM ncall_stub_register_svc(int svc_id, void (*func)(ncall_t *, int *))
44*7836SJohn.Forte@Sun.COM {
45*7836SJohn.Forte@Sun.COM ;
46*7836SJohn.Forte@Sun.COM }
47*7836SJohn.Forte@Sun.COM
48*7836SJohn.Forte@Sun.COM /* ARGSUSED */
49*7836SJohn.Forte@Sun.COM void
ncall_stub_unregister_svc(int svc_id)50*7836SJohn.Forte@Sun.COM ncall_stub_unregister_svc(int svc_id)
51*7836SJohn.Forte@Sun.COM {
52*7836SJohn.Forte@Sun.COM ;
53*7836SJohn.Forte@Sun.COM }
54*7836SJohn.Forte@Sun.COM
55*7836SJohn.Forte@Sun.COM /* ARGSUSED */
56*7836SJohn.Forte@Sun.COM int
ncall_stub_nodeid(char * nodename)57*7836SJohn.Forte@Sun.COM ncall_stub_nodeid(char *nodename)
58*7836SJohn.Forte@Sun.COM {
59*7836SJohn.Forte@Sun.COM return (nodeinfo.nc_nodeid);
60*7836SJohn.Forte@Sun.COM }
61*7836SJohn.Forte@Sun.COM
62*7836SJohn.Forte@Sun.COM /* ARGSUSED */
63*7836SJohn.Forte@Sun.COM char *
ncall_stub_nodename(int nodeid)64*7836SJohn.Forte@Sun.COM ncall_stub_nodename(int nodeid)
65*7836SJohn.Forte@Sun.COM {
66*7836SJohn.Forte@Sun.COM if (nodeid == nodeinfo.nc_nodeid)
67*7836SJohn.Forte@Sun.COM return (nodeinfo.nc_nodename);
68*7836SJohn.Forte@Sun.COM else
69*7836SJohn.Forte@Sun.COM return ("");
70*7836SJohn.Forte@Sun.COM }
71*7836SJohn.Forte@Sun.COM
72*7836SJohn.Forte@Sun.COM /* ARGSUSED */
73*7836SJohn.Forte@Sun.COM int
ncall_stub_mirror(int nodeid)74*7836SJohn.Forte@Sun.COM ncall_stub_mirror(int nodeid)
75*7836SJohn.Forte@Sun.COM {
76*7836SJohn.Forte@Sun.COM return (-1);
77*7836SJohn.Forte@Sun.COM }
78*7836SJohn.Forte@Sun.COM
79*7836SJohn.Forte@Sun.COM /* ARGSUSED */
80*7836SJohn.Forte@Sun.COM int
ncall_stub_self(void)81*7836SJohn.Forte@Sun.COM ncall_stub_self(void)
82*7836SJohn.Forte@Sun.COM {
83*7836SJohn.Forte@Sun.COM return (nodeinfo.nc_nodeid);
84*7836SJohn.Forte@Sun.COM }
85*7836SJohn.Forte@Sun.COM
86*7836SJohn.Forte@Sun.COM /* ARGSUSED */
87*7836SJohn.Forte@Sun.COM int
ncall_stub_alloc(int host_id,int flags,int net,ncall_t ** ncall_p)88*7836SJohn.Forte@Sun.COM ncall_stub_alloc(int host_id, int flags, int net, ncall_t **ncall_p)
89*7836SJohn.Forte@Sun.COM {
90*7836SJohn.Forte@Sun.COM return (ENOLINK);
91*7836SJohn.Forte@Sun.COM }
92*7836SJohn.Forte@Sun.COM
93*7836SJohn.Forte@Sun.COM /* ARGSUSED */
94*7836SJohn.Forte@Sun.COM int
ncall_stub_timedsend(ncall_t * ncall,int flags,int svc_id,struct timeval * t,va_list ap)95*7836SJohn.Forte@Sun.COM ncall_stub_timedsend(ncall_t *ncall, int flags, int svc_id,
96*7836SJohn.Forte@Sun.COM struct timeval *t, va_list ap)
97*7836SJohn.Forte@Sun.COM {
98*7836SJohn.Forte@Sun.COM return (ENOLINK);
99*7836SJohn.Forte@Sun.COM }
100*7836SJohn.Forte@Sun.COM
101*7836SJohn.Forte@Sun.COM /* ARGSUSED */
102*7836SJohn.Forte@Sun.COM int
ncall_stub_timedsendnotify(ncall_t * ncall,int flags,int svc_id,struct timeval * t,void (* ncall_callback)(ncall_t *,void *),void * vptr,va_list ap)103*7836SJohn.Forte@Sun.COM ncall_stub_timedsendnotify(ncall_t *ncall, int flags, int svc_id,
104*7836SJohn.Forte@Sun.COM struct timeval *t, void (*ncall_callback)(ncall_t *, void *), void *vptr,
105*7836SJohn.Forte@Sun.COM va_list ap)
106*7836SJohn.Forte@Sun.COM {
107*7836SJohn.Forte@Sun.COM return (ENOLINK);
108*7836SJohn.Forte@Sun.COM }
109*7836SJohn.Forte@Sun.COM
110*7836SJohn.Forte@Sun.COM /* ARGSUSED */
111*7836SJohn.Forte@Sun.COM int
ncall_stub_broadcast(ncall_t * ncall,int flags,int svc_id,struct timeval * t,va_list ap)112*7836SJohn.Forte@Sun.COM ncall_stub_broadcast(ncall_t *ncall, int flags, int svc_id,
113*7836SJohn.Forte@Sun.COM struct timeval *t, va_list ap)
114*7836SJohn.Forte@Sun.COM {
115*7836SJohn.Forte@Sun.COM return (ENOLINK);
116*7836SJohn.Forte@Sun.COM }
117*7836SJohn.Forte@Sun.COM
118*7836SJohn.Forte@Sun.COM /* ARGSUSED */
119*7836SJohn.Forte@Sun.COM int
ncall_stub_read_reply(ncall_t * ncall,int n,va_list ap)120*7836SJohn.Forte@Sun.COM ncall_stub_read_reply(ncall_t *ncall, int n, va_list ap)
121*7836SJohn.Forte@Sun.COM {
122*7836SJohn.Forte@Sun.COM return (ENOLINK);
123*7836SJohn.Forte@Sun.COM }
124*7836SJohn.Forte@Sun.COM
125*7836SJohn.Forte@Sun.COM /* ARGSUSED */
126*7836SJohn.Forte@Sun.COM void
ncall_stub_reset(ncall_t * ncall)127*7836SJohn.Forte@Sun.COM ncall_stub_reset(ncall_t *ncall)
128*7836SJohn.Forte@Sun.COM {
129*7836SJohn.Forte@Sun.COM ;
130*7836SJohn.Forte@Sun.COM }
131*7836SJohn.Forte@Sun.COM
132*7836SJohn.Forte@Sun.COM /* ARGSUSED */
133*7836SJohn.Forte@Sun.COM void
ncall_stub_free(ncall_t * ncall)134*7836SJohn.Forte@Sun.COM ncall_stub_free(ncall_t *ncall)
135*7836SJohn.Forte@Sun.COM {
136*7836SJohn.Forte@Sun.COM ;
137*7836SJohn.Forte@Sun.COM }
138*7836SJohn.Forte@Sun.COM
139*7836SJohn.Forte@Sun.COM /* ARGSUSED */
140*7836SJohn.Forte@Sun.COM int
ncall_stub_put_data(ncall_t * ncall,void * data,int len)141*7836SJohn.Forte@Sun.COM ncall_stub_put_data(ncall_t *ncall, void *data, int len)
142*7836SJohn.Forte@Sun.COM {
143*7836SJohn.Forte@Sun.COM return (ENOLINK);
144*7836SJohn.Forte@Sun.COM }
145*7836SJohn.Forte@Sun.COM
146*7836SJohn.Forte@Sun.COM /* ARGSUSED */
147*7836SJohn.Forte@Sun.COM int
ncall_stub_get_data(ncall_t * ncall,void * data,int len)148*7836SJohn.Forte@Sun.COM ncall_stub_get_data(ncall_t *ncall, void *data, int len)
149*7836SJohn.Forte@Sun.COM {
150*7836SJohn.Forte@Sun.COM return (ENOLINK);
151*7836SJohn.Forte@Sun.COM }
152*7836SJohn.Forte@Sun.COM
153*7836SJohn.Forte@Sun.COM /* ARGSUSED */
154*7836SJohn.Forte@Sun.COM int
ncall_stub_sender(ncall_t * ncall)155*7836SJohn.Forte@Sun.COM ncall_stub_sender(ncall_t *ncall)
156*7836SJohn.Forte@Sun.COM {
157*7836SJohn.Forte@Sun.COM return (nodeinfo.nc_nodeid);
158*7836SJohn.Forte@Sun.COM }
159*7836SJohn.Forte@Sun.COM
160*7836SJohn.Forte@Sun.COM /* ARGSUSED */
161*7836SJohn.Forte@Sun.COM void
ncall_stub_reply(ncall_t * ncall,va_list ap)162*7836SJohn.Forte@Sun.COM ncall_stub_reply(ncall_t *ncall, va_list ap)
163*7836SJohn.Forte@Sun.COM {
164*7836SJohn.Forte@Sun.COM ;
165*7836SJohn.Forte@Sun.COM }
166*7836SJohn.Forte@Sun.COM
167*7836SJohn.Forte@Sun.COM /* ARGSUSED */
168*7836SJohn.Forte@Sun.COM void
ncall_stub_pend(ncall_t * ncall)169*7836SJohn.Forte@Sun.COM ncall_stub_pend(ncall_t *ncall)
170*7836SJohn.Forte@Sun.COM {
171*7836SJohn.Forte@Sun.COM ;
172*7836SJohn.Forte@Sun.COM }
173*7836SJohn.Forte@Sun.COM
174*7836SJohn.Forte@Sun.COM /* ARGSUSED */
175*7836SJohn.Forte@Sun.COM void
ncall_stub_done(ncall_t * ncall)176*7836SJohn.Forte@Sun.COM ncall_stub_done(ncall_t *ncall)
177*7836SJohn.Forte@Sun.COM {
178*7836SJohn.Forte@Sun.COM ;
179*7836SJohn.Forte@Sun.COM }
180*7836SJohn.Forte@Sun.COM
181*7836SJohn.Forte@Sun.COM int
ncall_stub_ping(char * nodename,int * up)182*7836SJohn.Forte@Sun.COM ncall_stub_ping(char *nodename, int *up)
183*7836SJohn.Forte@Sun.COM {
184*7836SJohn.Forte@Sun.COM int rc = 0;
185*7836SJohn.Forte@Sun.COM
186*7836SJohn.Forte@Sun.COM if (strcmp(nodename, nodeinfo.nc_nodename) == 0) {
187*7836SJohn.Forte@Sun.COM *up = 1;
188*7836SJohn.Forte@Sun.COM } else {
189*7836SJohn.Forte@Sun.COM rc = EHOSTUNREACH;
190*7836SJohn.Forte@Sun.COM *up = 0;
191*7836SJohn.Forte@Sun.COM }
192*7836SJohn.Forte@Sun.COM
193*7836SJohn.Forte@Sun.COM return (rc);
194*7836SJohn.Forte@Sun.COM }
195*7836SJohn.Forte@Sun.COM
196*7836SJohn.Forte@Sun.COM /* ARGSUSED */
197*7836SJohn.Forte@Sun.COM int
ncall_stub_maxnodes()198*7836SJohn.Forte@Sun.COM ncall_stub_maxnodes()
199*7836SJohn.Forte@Sun.COM {
200*7836SJohn.Forte@Sun.COM return (0);
201*7836SJohn.Forte@Sun.COM }
202*7836SJohn.Forte@Sun.COM
203*7836SJohn.Forte@Sun.COM
204*7836SJohn.Forte@Sun.COM /* ARGSUSED */
205*7836SJohn.Forte@Sun.COM int
ncall_stub_nextnode(void ** vptr)206*7836SJohn.Forte@Sun.COM ncall_stub_nextnode(void **vptr)
207*7836SJohn.Forte@Sun.COM {
208*7836SJohn.Forte@Sun.COM return (0);
209*7836SJohn.Forte@Sun.COM }
210*7836SJohn.Forte@Sun.COM
211*7836SJohn.Forte@Sun.COM /* ARGSUSED */
212*7836SJohn.Forte@Sun.COM int
ncall_stub_errcode(ncall_t * ncall,int * result)213*7836SJohn.Forte@Sun.COM ncall_stub_errcode(ncall_t *ncall, int *result)
214*7836SJohn.Forte@Sun.COM {
215*7836SJohn.Forte@Sun.COM return (ENOLINK);
216*7836SJohn.Forte@Sun.COM }
217*7836SJohn.Forte@Sun.COM
218*7836SJohn.Forte@Sun.COM
219*7836SJohn.Forte@Sun.COM
220*7836SJohn.Forte@Sun.COM
221*7836SJohn.Forte@Sun.COM static int ncall_stub_stop(void);
222*7836SJohn.Forte@Sun.COM
223*7836SJohn.Forte@Sun.COM static ncall_module_t ncall_stubinfo = {
224*7836SJohn.Forte@Sun.COM NCALL_MODULE_VER,
225*7836SJohn.Forte@Sun.COM "ncall stubs",
226*7836SJohn.Forte@Sun.COM ncall_stub_stop,
227*7836SJohn.Forte@Sun.COM ncall_stub_register_svc,
228*7836SJohn.Forte@Sun.COM ncall_stub_unregister_svc,
229*7836SJohn.Forte@Sun.COM ncall_stub_nodeid,
230*7836SJohn.Forte@Sun.COM ncall_stub_nodename,
231*7836SJohn.Forte@Sun.COM ncall_stub_mirror,
232*7836SJohn.Forte@Sun.COM ncall_stub_self,
233*7836SJohn.Forte@Sun.COM ncall_stub_alloc,
234*7836SJohn.Forte@Sun.COM ncall_stub_timedsend,
235*7836SJohn.Forte@Sun.COM ncall_stub_timedsendnotify,
236*7836SJohn.Forte@Sun.COM ncall_stub_broadcast,
237*7836SJohn.Forte@Sun.COM ncall_stub_read_reply,
238*7836SJohn.Forte@Sun.COM ncall_stub_reset,
239*7836SJohn.Forte@Sun.COM ncall_stub_free,
240*7836SJohn.Forte@Sun.COM ncall_stub_put_data,
241*7836SJohn.Forte@Sun.COM ncall_stub_get_data,
242*7836SJohn.Forte@Sun.COM ncall_stub_sender,
243*7836SJohn.Forte@Sun.COM ncall_stub_reply,
244*7836SJohn.Forte@Sun.COM ncall_stub_pend,
245*7836SJohn.Forte@Sun.COM ncall_stub_done,
246*7836SJohn.Forte@Sun.COM ncall_stub_ping,
247*7836SJohn.Forte@Sun.COM ncall_stub_maxnodes,
248*7836SJohn.Forte@Sun.COM ncall_stub_nextnode,
249*7836SJohn.Forte@Sun.COM ncall_stub_errcode
250*7836SJohn.Forte@Sun.COM };
251*7836SJohn.Forte@Sun.COM
252*7836SJohn.Forte@Sun.COM
253*7836SJohn.Forte@Sun.COM static int
ncall_stub_stop(void)254*7836SJohn.Forte@Sun.COM ncall_stub_stop(void)
255*7836SJohn.Forte@Sun.COM {
256*7836SJohn.Forte@Sun.COM bzero(&nodeinfo, sizeof (nodeinfo));
257*7836SJohn.Forte@Sun.COM return (ncall_unregister_module(&ncall_stubinfo));
258*7836SJohn.Forte@Sun.COM }
259*7836SJohn.Forte@Sun.COM
260*7836SJohn.Forte@Sun.COM
261*7836SJohn.Forte@Sun.COM void
ncall_init_stub(void)262*7836SJohn.Forte@Sun.COM ncall_init_stub(void)
263*7836SJohn.Forte@Sun.COM {
264*7836SJohn.Forte@Sun.COM (void) ncall_register_module(&ncall_stubinfo, &nodeinfo);
265*7836SJohn.Forte@Sun.COM }
266