xref: /freebsd/crypto/krb5/src/ccapi/lib/win/ccs_reply_proc.c (revision 7f2fe78b9dd5f51c821d771b63d2e096f6fd49e9)
1 /* ccapi/lib/win/ccs_reply_proc.c */
2 /*
3  * Copyright 2008 Massachusetts Institute of Technology.
4  * All Rights Reserved.
5  *
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.
10  *
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.
24  */
25 
26 #include <stdio.h>
27 #include <stdlib.h>
28 #include <windows.h>
29 
30 #include "cci_debugging.h"
31 #include "ccs_reply.h"          /* generated by MIDL compiler */
32 #include "ccutils.h"
33 #include "tls.h"
34 #include "win-utils.h"
35 
36 
ccs_rpc_request_reply(const long rpcmsg,const char tspHandle[],const char * uuid,const long srvStartTime,const long cbIn,const char * chIn,long * ret_status)37 void ccs_rpc_request_reply(
38     const long  rpcmsg,         /* Message type */
39     const char  tspHandle[],    /* Client's tspdata* */
40     const char* uuid,           /* uuid for making thread-specific event name */
41     const long  srvStartTime,   /* Server Start Time */
42     const long  cbIn,           /* Length of buffer */
43     const char* chIn,           /* Data buffer */
44     long*       ret_status ) {  /* Return code */
45 
46     HANDLE          hEvent  = openThreadEvent(uuid, REPLY_SUFFIX);
47     struct tspdata* tsp;
48     k5_ipc_stream    stream;
49     long            status  = 0;
50 
51     memcpy(&tsp, tspHandle, sizeof(tsp));
52     if (!status) {
53         status = krb5int_ipc_stream_new (&stream);  /* Create a stream for the request data */
54         }
55 
56     if (!status) {                          /* Put the data into the stream */
57         status = krb5int_ipc_stream_write (stream, chIn, cbIn);
58         }
59 
60     if (!status) {                          /* Put the data into the stream */
61         tspdata_setStream(tsp, stream);
62         }
63 
64     SetEvent(hEvent);
65     CloseHandle(hEvent);
66     *ret_status  = status;
67     }
68 
ccs_rpc_connect_reply(const long rpcmsg,const char tspHandle[],const char * uuid,const long srvStartTime,long * status)69 void ccs_rpc_connect_reply(
70     const long  rpcmsg,         /* Message type */
71     const char  tspHandle[],    /* Client's tspdata* */
72     const char* uuid,           /* uuid for making thread-specific event name */
73     const long  srvStartTime,   /* Server Start Time */
74     long*       status ) {      /* Return code */
75 
76     HANDLE  hEvent  = openThreadEvent(uuid, REPLY_SUFFIX);
77     DWORD*  p       = (DWORD*)(tspHandle);
78 
79     SetEvent(hEvent);
80     CloseHandle(hEvent);
81     }
82 
ccapi_listen(RPC_ASYNC_STATE * rpcState,handle_t hBinding,const long rpcmsg,long * status)83 void ccapi_listen(
84     RPC_ASYNC_STATE*    rpcState,
85     handle_t            hBinding,
86     const long          rpcmsg,         /* Message type */
87     long*               status ) {      /* Return code */
88 
89     cci_debug_printf("%s %s!", __FUNCTION__, rpcState->UserInfo);
90     *status = 0;
91     }
92