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