Update NEWS for 1.6.22
[pkg-k5-afs_openafs.git] / src / WINNT / client_osi / osidb.c
blob98adc044dda4ccdb8428d787bfa11a87c18be7a6
1 /*
2 * Copyright 2000, International Business Machines Corporation and others.
3 * All Rights Reserved.
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
8 */
10 /* Copyright (C) 1994 Cazamar Systems, Inc. */
13 #include <afs/param.h>
14 #include <afs/stds.h>
16 #include <windows.h>
17 #include <rpc.h>
18 #include <malloc.h>
19 #include "osi.h"
20 #include "dbrpc.h"
21 #include <assert.h>
23 long osi_maxCalls = OSI_MAXRPCCALLS;
25 static UUID debugType = { /* 95EEEAE0-1BD3-101B-8953-204C4F4F5020 */
26 0x95EEEAE0,
27 0x1BD3,
28 0x101B,
29 {0x89, 0x53, 0x20, 0x4C, 0x4F, 0x4F, 0x50, 0x20}
32 void dbrpc_Ping(handle_t handle)
34 return;
37 void dbrpc_GetFormat(handle_t handle, unsigned char *namep, long region, long index,
38 osi_remFormat_t *formatp, long *codep)
40 osi_fdType_t *typep;
41 osi_fdTypeFormat_t *fp;
43 typep = osi_FindFDType(namep);
44 if (typep == NULL) {
45 *codep = OSI_DBRPC_NOENTRY; /* no such type */
46 return;
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;
54 *codep = 0;
55 return;
59 /* if we get here, we didn't find the type, so return no such entry */
60 *codep = OSI_DBRPC_EOF;
61 return;
64 void dbrpc_Open(handle_t handle, unsigned char *namep, osi_remHyper_t *fnp, long *codep)
66 osi_fd_t *fdp;
68 fdp = osi_AllocFD(namep);
69 if (!fdp) {
70 *codep = OSI_DBRPC_NOFD;
72 else {
73 /* wire supports 64 bits but we only use 32 */
74 fnp->LowPart = fdp->fd;
75 fnp->HighPart = 0;
76 *codep = 0;
80 void dbrpc_GetInfo(handle_t handle, osi_remHyper_t *fnp, osi_remGetInfoParms_t *parmsp,
81 long *codep)
83 osi_fd_t *fdp;
85 /* always init return values */
86 parmsp->icount = 0;
87 parmsp->scount = 0;
89 fdp = osi_FindFD(fnp->LowPart);
90 if (fdp) {
91 *codep = (fdp->opsp->GetInfo)(fdp, parmsp);
93 else *codep = OSI_DBRPC_NOFD;
95 return;
98 void dbrpc_Close(handle_t handle, osi_remHyper_t *fnp, long *codep)
100 osi_fd_t *fdp;
102 fdp = osi_FindFD(fnp->LowPart);
103 if (fdp) {
104 *codep = osi_CloseFD(fdp);
106 else
107 *codep = OSI_DBRPC_NOFD;
110 #ifdef notdef
111 long osi_CleanupRPCEntry(char *exportName)
113 UUID_VECTOR uuidvp;
114 RPC_NS_HANDLE thandle;
115 UUID tuuid;
116 long code;
118 code = RpcNsEntryObjectInqBegin(RPC_C_NS_SYNTAX_DCE, exportName, &thandle);
119 if (code != RPC_S_OK && code != RPC_S_ENTRY_NOT_FOUND) return code;
120 while(1) {
121 code = RpcNsEntryObjectInqNext(thandle, &tuuid);
122 if (code == RPC_S_NO_MORE_MEMBERS) {
123 code = 0;
124 break;
126 else if (code != RPC_S_OK) {
127 break;
129 uuidvp.Count = 1;
130 uuidvp.Uuid[0] = &tuuid;
131 code = RpcNsBindingUnexport(RPC_C_NS_SYNTAX_DCE, exportName, dbrpc_v1_0_s_ifspec,
132 &uuidvp);
133 if (code != RPC_S_OK && code != RPC_S_INTERFACE_NOT_FOUND) break;
135 RpcNsEntryObjectInqDone(&thandle);
136 return code;
138 #endif /* notdef */
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;
149 osi_Init();
151 osi_InitFD();
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;
177 #ifdef notdef
178 /* don't use CDS any longer; too big and slow */
179 rpcStatus = osi_CleanupRPCEntry(exportName);
180 if (rpcStatus) goto done;
181 #endif /* notdef */
183 rpcStatus = RpcEpRegister(dbrpc_v1_0_s_ifspec, bindingVector,
184 &uuidVector, (unsigned char *) 0);
185 if (rpcStatus != RPC_S_OK) goto done;
187 #ifdef notdef
188 /* don't use CDS */
189 rpcStatus = RpcNsBindingExport(RPC_C_NS_SYNTAX_DCE, exportName,
190 dbrpc_v1_0_s_ifspec, bindingVector, &uuidVector);
191 #endif /* notdef */
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 */
204 rpcStatus = 0;
206 done:
207 osi_EndOnce(&once);
208 return rpcStatus;