1 /* ccapi/server/win/ccs_request_proc.c */
3 * Copyright 2008 Massachusetts Institute of Technology.
6 * Export of this software from the United States of America may
7 * require a specific license from the United States Government.
8 * It is the responsibility of any person or organization contemplating
9 * export to obtain such a license before exporting.
11 * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and
12 * distribute this software and its documentation for any purpose and
13 * without fee is hereby granted, provided that the above copyright
14 * notice appear in all copies and that both that copyright notice and
15 * this permission notice appear in supporting documentation, and that
16 * the name of M.I.T. not be used in advertising or publicity pertaining
17 * to distribution of the software without specific, written prior
18 * permission. Furthermore if you modify this software you must label
19 * your software as modified software and not distribute it in such a
20 * fashion that it might be confused with the original M.I.T. software.
21 * M.I.T. makes no representations about the suitability of
22 * this software for any purpose. It is provided "as is" without express
23 * or implied warranty.
29 #include "ccs_request.h" // header file generated by MIDL compiler
30 #include "cci_debugging.h"
31 #include "WorkQueue.h"
32 #include "win-utils.h"
33 #include "ccs_win_pipe.h"
36 const long rpcmsg, /* Message type */
37 const char tspHandle[], /* Client's tspdata* */
38 const char* pszUUID, /* Where client will listen for the reply */
39 const long lenRequest, /* Length of buffer */
40 const char pbRequest[], /* Data buffer */
41 const long serverStartTime, /* Which server session we're talking to */
42 long* return_status ) { /* Return code */
46 UINT64* p = (UINT64*)(tspHandle);
47 WIN_PIPE* pipe = NULL;
49 cci_debug_printf("%s rpcmsg:%d; UUID:<%s> SST:<%s>", __FUNCTION__, rpcmsg, pszUUID, serverStartTime);
51 status = (rpcmsg != CCMSG_REQUEST) && (rpcmsg != CCMSG_PING);
54 status = krb5int_ipc_stream_new (&stream); /* Create a stream for the request data */
57 if (!status) { /* Put the data into the stream */
58 status = krb5int_ipc_stream_write (stream, pbRequest, lenRequest);
61 pipe = ccs_win_pipe_new(pszUUID, *p);
62 worklist_add(rpcmsg, pipe, stream, serverStartTime);
63 *return_status = status;
68 const long rpcmsg, /* Message type */
69 const char tspHandle[], /* Client's tspdata* */
70 const char* pszUUID, /* Data buffer */
71 long* return_status ) { /* Return code */
73 UINT64* p = (UINT64*)(tspHandle);
74 WIN_PIPE* pipe = ccs_win_pipe_new(pszUUID, *p);
76 cci_debug_printf("%s; rpcmsg:%d; UUID: <%s>", __FUNCTION__, rpcmsg, pszUUID);
80 NULL, /* No payload with connect request */
81 (const time_t)0 ); /* No server session number with connect request */
85 // 'Authentication' is client setting a value in a file and the server
86 // returning that value plus one.
87 CC_UINT32 ccs_authenticate(const CC_CHAR* name) {
93 cci_debug_printf("%s ( %s )", __FUNCTION__, name);
95 hMap = OpenFileMapping(FILE_MAP_ALL_ACCESS, FALSE, (LPSTR)name);
99 pvalue = (PDWORD)MapViewOfFile(hMap, FILE_MAP_WRITE, 0, 0, 0);
109 UnmapViewOfFile(pvalue);
112 if (hMap) CloseHandle(hMap);