Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/freebsd-src
Path: blob/main/crypto/krb5/src/ccapi/lib/ccapi_ipc.c
39536 views
1
/* ccapi/lib/ccapi_ipc.c */
2
/*
3
* Copyright 2006 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 "ccapi_ipc.h"
27
#include "ccapi_os_ipc.h"
28
29
/* ------------------------------------------------------------------------ */
30
31
cc_int32 cci_ipc_process_init (void)
32
{
33
return cci_os_ipc_process_init ();
34
}
35
36
/* ------------------------------------------------------------------------ */
37
38
cc_int32 cci_ipc_thread_init (void)
39
{
40
return cci_os_ipc_thread_init ();
41
}
42
43
/* ------------------------------------------------------------------------ */
44
45
static cc_int32 _cci_ipc_send (enum cci_msg_id_t in_request_name,
46
cc_int32 in_launch_server,
47
cci_identifier_t in_identifier,
48
k5_ipc_stream in_request_data,
49
k5_ipc_stream *out_reply_data)
50
{
51
cc_int32 err = ccNoError;
52
k5_ipc_stream request = NULL;
53
k5_ipc_stream reply = NULL;
54
cc_int32 reply_error = 0;
55
56
if (!in_identifier) { err = cci_check_error (ccErrBadParam); }
57
/* in_request_data may be NULL */
58
/* out_reply_data may be NULL */
59
60
if (!err) {
61
err = cci_message_new_request_header (&request,
62
in_request_name,
63
in_identifier);
64
}
65
66
if (!err && in_request_data) {
67
err = krb5int_ipc_stream_write (request,
68
krb5int_ipc_stream_data (in_request_data),
69
krb5int_ipc_stream_size (in_request_data));
70
}
71
72
if (!err) {
73
err = cci_os_ipc (in_launch_server, request, &reply);
74
75
if (!err && krb5int_ipc_stream_size (reply) > 0) {
76
err = cci_message_read_reply_header (reply, &reply_error);
77
}
78
}
79
80
if (!err && reply_error) {
81
err = reply_error;
82
}
83
84
if (!err && out_reply_data) {
85
*out_reply_data = reply;
86
reply = NULL; /* take ownership */
87
}
88
89
krb5int_ipc_stream_release (request);
90
krb5int_ipc_stream_release (reply);
91
92
return cci_check_error (err);
93
}
94
95
/* ------------------------------------------------------------------------ */
96
97
cc_int32 cci_ipc_send (enum cci_msg_id_t in_request_name,
98
cci_identifier_t in_identifier,
99
k5_ipc_stream in_request_data,
100
k5_ipc_stream *out_reply_data)
101
{
102
return cci_check_error (_cci_ipc_send (in_request_name, 1,
103
in_identifier,
104
in_request_data,
105
out_reply_data));
106
}
107
108
/* ------------------------------------------------------------------------ */
109
110
cc_int32 cci_ipc_send_no_launch (enum cci_msg_id_t in_request_name,
111
cci_identifier_t in_identifier,
112
k5_ipc_stream in_request_data,
113
k5_ipc_stream *out_reply_data)
114
{
115
return cci_check_error (_cci_ipc_send (in_request_name, 0,
116
in_identifier,
117
in_request_data,
118
out_reply_data));
119
}
120
121