2 * Copyright 2000, International Business Machines Corporation and others.
5 * This software has been released under the terms of the IBM Public
6 * License. For details, see the LICENSE file in the top-level source
7 * directory or online at http://www.openafs.org/dl/license10.html
10 /* Copyright (C) 1994 Cazamar Systems, Inc. */
13 #include <afs/param.h>
23 long osi_maxCalls = OSI_MAXRPCCALLS;
25 static UUID debugType = { /* 95EEEAE0-1BD3-101B-8953-204C4F4F5020 */
29 {0x89, 0x53, 0x20, 0x4C, 0x4F, 0x4F, 0x50, 0x20}
32 void dbrpc_Ping(handle_t handle)
37 void dbrpc_GetFormat(handle_t handle, unsigned char *namep, long region, long index,
38 osi_remFormat_t *formatp, long *codep)
41 osi_fdTypeFormat_t *fp;
43 typep = osi_FindFDType(namep);
45 *codep = OSI_DBRPC_NOENTRY; /* no such type */
49 for(fp = typep->formatListp; fp; fp=fp->nextp) {
50 if (region == fp->region && index == fp->index) {
51 /* found the one to return */
52 strncpy(formatp->label, fp->labelp, sizeof(formatp->label));
53 formatp->format = fp->format;
59 /* if we get here, we didn't find the type, so return no such entry */
60 *codep = OSI_DBRPC_EOF;
64 void dbrpc_Open(handle_t handle, unsigned char *namep, osi_remHyper_t *fnp, long *codep)
68 fdp = osi_AllocFD(namep);
70 *codep = OSI_DBRPC_NOFD;
73 /* wire supports 64 bits but we only use 32 */
74 fnp->LowPart = fdp->fd;
80 void dbrpc_GetInfo(handle_t handle, osi_remHyper_t *fnp, osi_remGetInfoParms_t *parmsp,
85 /* always init return values */
89 fdp = osi_FindFD(fnp->LowPart);
91 *codep = (fdp->opsp->GetInfo)(fdp, parmsp);
93 else *codep = OSI_DBRPC_NOFD;
98 void dbrpc_Close(handle_t handle, osi_remHyper_t *fnp, long *codep)
102 fdp = osi_FindFD(fnp->LowPart);
104 *codep = osi_CloseFD(fdp);
107 *codep = OSI_DBRPC_NOFD;
111 long osi_CleanupRPCEntry(char *exportName)
114 RPC_NS_HANDLE thandle;
118 code = RpcNsEntryObjectInqBegin(RPC_C_NS_SYNTAX_DCE, exportName, &thandle);
119 if (code != RPC_S_OK && code != RPC_S_ENTRY_NOT_FOUND) return code;
121 code = RpcNsEntryObjectInqNext(thandle, &tuuid);
122 if (code == RPC_S_NO_MORE_MEMBERS) {
126 else if (code != RPC_S_OK) {
130 uuidvp.Uuid[0] = &tuuid;
131 code = RpcNsBindingUnexport(RPC_C_NS_SYNTAX_DCE, exportName, dbrpc_v1_0_s_ifspec,
133 if (code != RPC_S_OK && code != RPC_S_INTERFACE_NOT_FOUND) break;
135 RpcNsEntryObjectInqDone(&thandle);
140 long osi_InitDebug(osi_uid_t *exportIDp)
142 RPC_STATUS rpcStatus;
143 RPC_BINDING_VECTOR *bindingVector;
144 UUID_VECTOR uuidVector;
145 static osi_once_t once;
147 if (!osi_Once(&once)) return 0;
153 /* create local socket */
154 rpcStatus = RpcServerUseAllProtseqs(osi_maxCalls, (void *) 0);
155 if (rpcStatus != RPC_S_OK) goto done;
157 /* register sockets with runtime */
158 rpcStatus = RpcServerRegisterIf(dbrpc_v1_0_s_ifspec, &debugType, NULL);
159 if (rpcStatus != RPC_S_OK) goto done;
161 rpcStatus = RpcObjectSetType(exportIDp, &debugType);
162 if (rpcStatus != RPC_S_OK) goto done;
164 rpcStatus = RpcServerInqBindings(&bindingVector);
165 if (rpcStatus != RPC_S_OK) goto done;
167 /* the UUID_VECTOR structure contains an array of pointers to UUIDs,
168 * amazingly enough. Aren't those folks C programmers? Anyway, this
169 * represents the set of objects this server supports, and we register
170 * our unique UUID so that someone who finds our name can track down our
171 * unique instance, since the endpoint mapper doesn't see the name, but
172 * only sees the interface (duplicated of course) and the object UUID.
174 uuidVector.Count = 1;
175 uuidVector.Uuid[0] = exportIDp;
178 /* don't use CDS any longer; too big and slow */
179 rpcStatus = osi_CleanupRPCEntry(exportName);
180 if (rpcStatus) goto done;
183 rpcStatus = RpcEpRegister(dbrpc_v1_0_s_ifspec, bindingVector,
184 &uuidVector, (unsigned char *) 0);
185 if (rpcStatus != RPC_S_OK) goto done;
189 rpcStatus = RpcNsBindingExport(RPC_C_NS_SYNTAX_DCE, exportName,
190 dbrpc_v1_0_s_ifspec, bindingVector, &uuidVector);
193 rpcStatus = RpcBindingVectorFree(&bindingVector);
194 if (rpcStatus != RPC_S_OK) goto done;
196 #ifdef OSISTARTRPCSERVER /* Now done later */
198 /* now start server listening with appropriate # of threads */
199 rpcStatus = RpcServerListen(osi_maxCalls, osi_maxCalls, /* dontwait */1);
200 if (rpcStatus != RPC_S_OK) goto done;
202 #endif /* OSISTARTRPCSERVER */