xref: /freebsd/crypto/krb5/src/ccapi/lib/win/ccs_reply_proc.c (revision 7f2fe78b9dd5f51c821d771b63d2e096f6fd49e9)
1*7f2fe78bSCy Schubert /* ccapi/lib/win/ccs_reply_proc.c */
2*7f2fe78bSCy Schubert /*
3*7f2fe78bSCy Schubert  * Copyright 2008 Massachusetts Institute of Technology.
4*7f2fe78bSCy Schubert  * All Rights Reserved.
5*7f2fe78bSCy Schubert  *
6*7f2fe78bSCy Schubert  * Export of this software from the United States of America may
7*7f2fe78bSCy Schubert  * require a specific license from the United States Government.
8*7f2fe78bSCy Schubert  * It is the responsibility of any person or organization contemplating
9*7f2fe78bSCy Schubert  * export to obtain such a license before exporting.
10*7f2fe78bSCy Schubert  *
11*7f2fe78bSCy Schubert  * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and
12*7f2fe78bSCy Schubert  * distribute this software and its documentation for any purpose and
13*7f2fe78bSCy Schubert  * without fee is hereby granted, provided that the above copyright
14*7f2fe78bSCy Schubert  * notice appear in all copies and that both that copyright notice and
15*7f2fe78bSCy Schubert  * this permission notice appear in supporting documentation, and that
16*7f2fe78bSCy Schubert  * the name of M.I.T. not be used in advertising or publicity pertaining
17*7f2fe78bSCy Schubert  * to distribution of the software without specific, written prior
18*7f2fe78bSCy Schubert  * permission.  Furthermore if you modify this software you must label
19*7f2fe78bSCy Schubert  * your software as modified software and not distribute it in such a
20*7f2fe78bSCy Schubert  * fashion that it might be confused with the original M.I.T. software.
21*7f2fe78bSCy Schubert  * M.I.T. makes no representations about the suitability of
22*7f2fe78bSCy Schubert  * this software for any purpose.  It is provided "as is" without express
23*7f2fe78bSCy Schubert  * or implied warranty.
24*7f2fe78bSCy Schubert  */
25*7f2fe78bSCy Schubert 
26*7f2fe78bSCy Schubert #include <stdio.h>
27*7f2fe78bSCy Schubert #include <stdlib.h>
28*7f2fe78bSCy Schubert #include <windows.h>
29*7f2fe78bSCy Schubert 
30*7f2fe78bSCy Schubert #include "cci_debugging.h"
31*7f2fe78bSCy Schubert #include "ccs_reply.h"          /* generated by MIDL compiler */
32*7f2fe78bSCy Schubert #include "ccutils.h"
33*7f2fe78bSCy Schubert #include "tls.h"
34*7f2fe78bSCy Schubert #include "win-utils.h"
35*7f2fe78bSCy Schubert 
36*7f2fe78bSCy Schubert 
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*7f2fe78bSCy Schubert void ccs_rpc_request_reply(
38*7f2fe78bSCy Schubert     const long  rpcmsg,         /* Message type */
39*7f2fe78bSCy Schubert     const char  tspHandle[],    /* Client's tspdata* */
40*7f2fe78bSCy Schubert     const char* uuid,           /* uuid for making thread-specific event name */
41*7f2fe78bSCy Schubert     const long  srvStartTime,   /* Server Start Time */
42*7f2fe78bSCy Schubert     const long  cbIn,           /* Length of buffer */
43*7f2fe78bSCy Schubert     const char* chIn,           /* Data buffer */
44*7f2fe78bSCy Schubert     long*       ret_status ) {  /* Return code */
45*7f2fe78bSCy Schubert 
46*7f2fe78bSCy Schubert     HANDLE          hEvent  = openThreadEvent(uuid, REPLY_SUFFIX);
47*7f2fe78bSCy Schubert     struct tspdata* tsp;
48*7f2fe78bSCy Schubert     k5_ipc_stream    stream;
49*7f2fe78bSCy Schubert     long            status  = 0;
50*7f2fe78bSCy Schubert 
51*7f2fe78bSCy Schubert     memcpy(&tsp, tspHandle, sizeof(tsp));
52*7f2fe78bSCy Schubert     if (!status) {
53*7f2fe78bSCy Schubert         status = krb5int_ipc_stream_new (&stream);  /* Create a stream for the request data */
54*7f2fe78bSCy Schubert         }
55*7f2fe78bSCy Schubert 
56*7f2fe78bSCy Schubert     if (!status) {                          /* Put the data into the stream */
57*7f2fe78bSCy Schubert         status = krb5int_ipc_stream_write (stream, chIn, cbIn);
58*7f2fe78bSCy Schubert         }
59*7f2fe78bSCy Schubert 
60*7f2fe78bSCy Schubert     if (!status) {                          /* Put the data into the stream */
61*7f2fe78bSCy Schubert         tspdata_setStream(tsp, stream);
62*7f2fe78bSCy Schubert         }
63*7f2fe78bSCy Schubert 
64*7f2fe78bSCy Schubert     SetEvent(hEvent);
65*7f2fe78bSCy Schubert     CloseHandle(hEvent);
66*7f2fe78bSCy Schubert     *ret_status  = status;
67*7f2fe78bSCy Schubert     }
68*7f2fe78bSCy Schubert 
ccs_rpc_connect_reply(const long rpcmsg,const char tspHandle[],const char * uuid,const long srvStartTime,long * status)69*7f2fe78bSCy Schubert void ccs_rpc_connect_reply(
70*7f2fe78bSCy Schubert     const long  rpcmsg,         /* Message type */
71*7f2fe78bSCy Schubert     const char  tspHandle[],    /* Client's tspdata* */
72*7f2fe78bSCy Schubert     const char* uuid,           /* uuid for making thread-specific event name */
73*7f2fe78bSCy Schubert     const long  srvStartTime,   /* Server Start Time */
74*7f2fe78bSCy Schubert     long*       status ) {      /* Return code */
75*7f2fe78bSCy Schubert 
76*7f2fe78bSCy Schubert     HANDLE  hEvent  = openThreadEvent(uuid, REPLY_SUFFIX);
77*7f2fe78bSCy Schubert     DWORD*  p       = (DWORD*)(tspHandle);
78*7f2fe78bSCy Schubert 
79*7f2fe78bSCy Schubert     SetEvent(hEvent);
80*7f2fe78bSCy Schubert     CloseHandle(hEvent);
81*7f2fe78bSCy Schubert     }
82*7f2fe78bSCy Schubert 
ccapi_listen(RPC_ASYNC_STATE * rpcState,handle_t hBinding,const long rpcmsg,long * status)83*7f2fe78bSCy Schubert void ccapi_listen(
84*7f2fe78bSCy Schubert     RPC_ASYNC_STATE*    rpcState,
85*7f2fe78bSCy Schubert     handle_t            hBinding,
86*7f2fe78bSCy Schubert     const long          rpcmsg,         /* Message type */
87*7f2fe78bSCy Schubert     long*               status ) {      /* Return code */
88*7f2fe78bSCy Schubert 
89*7f2fe78bSCy Schubert     cci_debug_printf("%s %s!", __FUNCTION__, rpcState->UserInfo);
90*7f2fe78bSCy Schubert     *status = 0;
91*7f2fe78bSCy Schubert     }
92