2 * Copyright 2008, Google Inc.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * * Redistributions in binary form must reproduce the above
12 * copyright notice, this list of conditions and the following disclaimer
13 * in the documentation and/or other materials provided with the
15 * * Neither the name of Google Inc. nor the names of its
16 * contributors may be used to endorse or promote products derived from
17 * this software without specific prior written permission.
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 * Native Client Resource Descriptor Transfer Protocol for trusted code.
35 * The public API consists of a subset of the interface used
36 * internally by the service runtime. Use only the functions declared
37 * in this header file, NaClDescUnref, and NaClDesc*{Ctor}.
39 * The intent is that trusted code have to act as a forwarding agent,
40 * e.g., the browser plugin, must also implement the NRD transfer
41 * protocol in order to pass objects between NaCl modules even if the
42 * forwarding agent itself will not use the access rights itself. By
43 * permitting the forwarding agent to receive the data-only portion of
44 * an IMC message and to receive the NRDs as separate opaque object
45 * references, the forwarding agent is free to forward individual NRDs
46 * embedded in an incoming message separately, hold on to them to send
50 #ifndef NATIVE_CLIENT_SERVICE_RUNTIME_NRD_XFER_LIB_NRD_XFER_H_
51 #define NATIVE_CLIENT_SERVICE_RUNTIME_NRD_XFER_LIB_NRD_XFER_H_
54 * @addtogroup nrd_xfer NaCl Resource Descriptor Transfer
55 * Contains functions used by trusted code to participate in the
56 * NRD transfer protocol used by the NaCl service runtime.
61 /* in lieu of sys/types for int32_t */
62 #include "native_client/include/portability.h"
64 #include "native_client/include/nacl_base.h"
65 #include "native_client/service_runtime/include/sys/nacl_imc_api.h"
70 struct NaClDescEffector
;
72 struct NaClImcTypedMsgHdr
{
73 struct NaClImcMsgIoVec
*iov
;
75 struct NaClDesc
**ndescv
; /* ptr to array of ptrs */
82 * Send a high-level IMC message (containing typed descriptors) over
83 * an IMC channel. Returns the number of bytes sent on success, and
84 * a negated errno value (essentially the kernel return ABI) on error.
86 int32_t NaClImcSendTypedMessage(struct NaClDesc
*channel
,
87 struct NaClDescEffector
*effp
,
88 const struct NaClImcTypedMsgHdr
*nitmhp
,
92 * Receive a high-level IMC message (containing typed descriptors)
93 * over an IMC channel. Returns the number of bytes received on
94 * success, and a negative value, a negated errno value, on error
95 * (the kernel return ABI).
97 int32_t NaClImcRecvTypedMessage(struct NaClDesc
*channel
,
98 struct NaClDescEffector
*effp
,
99 struct NaClImcTypedMsgHdr
*nitmhp
,
103 * Create a bound socket and corresponding socket address as a pair.
104 * Returns 0 on success, and a negative value (negated errno) on
107 * pair[0] is a NaClDescImcBoundDesc, and
108 * pair[1] is a NaClDescConnCap.
110 int32_t NaClCommonDescMakeBoundSock(struct NaClDesc
*pair
[2]);
116 * End of NaCl Resource Descriptor Transfer group
119 #endif /* NATIVE_CLIENT_SERVICE_RUNTIME_NRD_XFER_LIB_NRD_XFER_H_ */