Path: blob/main/crypto/krb5/src/ccapi/lib/ccapi_ipc.c
39536 views
/* ccapi/lib/ccapi_ipc.c */1/*2* Copyright 2006 Massachusetts Institute of Technology.3* All Rights Reserved.4*5* Export of this software from the United States of America may6* require a specific license from the United States Government.7* It is the responsibility of any person or organization contemplating8* export to obtain such a license before exporting.9*10* WITHIN THAT CONSTRAINT, permission to use, copy, modify, and11* distribute this software and its documentation for any purpose and12* without fee is hereby granted, provided that the above copyright13* notice appear in all copies and that both that copyright notice and14* this permission notice appear in supporting documentation, and that15* the name of M.I.T. not be used in advertising or publicity pertaining16* to distribution of the software without specific, written prior17* permission. Furthermore if you modify this software you must label18* your software as modified software and not distribute it in such a19* fashion that it might be confused with the original M.I.T. software.20* M.I.T. makes no representations about the suitability of21* this software for any purpose. It is provided "as is" without express22* or implied warranty.23*/2425#include "ccapi_ipc.h"26#include "ccapi_os_ipc.h"2728/* ------------------------------------------------------------------------ */2930cc_int32 cci_ipc_process_init (void)31{32return cci_os_ipc_process_init ();33}3435/* ------------------------------------------------------------------------ */3637cc_int32 cci_ipc_thread_init (void)38{39return cci_os_ipc_thread_init ();40}4142/* ------------------------------------------------------------------------ */4344static cc_int32 _cci_ipc_send (enum cci_msg_id_t in_request_name,45cc_int32 in_launch_server,46cci_identifier_t in_identifier,47k5_ipc_stream in_request_data,48k5_ipc_stream *out_reply_data)49{50cc_int32 err = ccNoError;51k5_ipc_stream request = NULL;52k5_ipc_stream reply = NULL;53cc_int32 reply_error = 0;5455if (!in_identifier) { err = cci_check_error (ccErrBadParam); }56/* in_request_data may be NULL */57/* out_reply_data may be NULL */5859if (!err) {60err = cci_message_new_request_header (&request,61in_request_name,62in_identifier);63}6465if (!err && in_request_data) {66err = krb5int_ipc_stream_write (request,67krb5int_ipc_stream_data (in_request_data),68krb5int_ipc_stream_size (in_request_data));69}7071if (!err) {72err = cci_os_ipc (in_launch_server, request, &reply);7374if (!err && krb5int_ipc_stream_size (reply) > 0) {75err = cci_message_read_reply_header (reply, &reply_error);76}77}7879if (!err && reply_error) {80err = reply_error;81}8283if (!err && out_reply_data) {84*out_reply_data = reply;85reply = NULL; /* take ownership */86}8788krb5int_ipc_stream_release (request);89krb5int_ipc_stream_release (reply);9091return cci_check_error (err);92}9394/* ------------------------------------------------------------------------ */9596cc_int32 cci_ipc_send (enum cci_msg_id_t in_request_name,97cci_identifier_t in_identifier,98k5_ipc_stream in_request_data,99k5_ipc_stream *out_reply_data)100{101return cci_check_error (_cci_ipc_send (in_request_name, 1,102in_identifier,103in_request_data,104out_reply_data));105}106107/* ------------------------------------------------------------------------ */108109cc_int32 cci_ipc_send_no_launch (enum cci_msg_id_t in_request_name,110cci_identifier_t in_identifier,111k5_ipc_stream in_request_data,112k5_ipc_stream *out_reply_data)113{114return cci_check_error (_cci_ipc_send (in_request_name, 0,115in_identifier,116in_request_data,117out_reply_data));118}119120121