blob: 2da0d9c9a62def9bfc6171bc0a4b61d2b4c8f43a [file] [log] [blame]
Doug Horn1427b6a2018-12-11 13:19:16 -08001// Copyright 2018 The Fuchsia Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef LIB_FIDL_TRANSPORT_H_
6#define LIB_FIDL_TRANSPORT_H_
7
8#include <zircon/compiler.h>
9#include <zircon/types.h>
10
11__BEGIN_CDECLS
12
13// Writes |capacity| bytes from |buffer| to the control channel of |socket|.
14//
15// Blocks until |socket| is able to accept a control plane message.
16zx_status_t fidl_socket_write_control(zx_handle_t socket, const void* buffer,
17 size_t capacity);
18
19// Reads |capacity| bytes from the control channel of |socket| to |buffer|.
20//
21// Blocks until a control plane message is able to be read from |socket|.
22//
23// The actual number of bytes reads from the control plan is returned in
24// |out_actual|.
25zx_status_t fidl_socket_read_control(zx_handle_t socket, void* buffer,
26 size_t capacity, size_t* out_actual);
27
28// Issues a transaction on the control channel of |socket|.
29//
30// First, writes |capacity| bytes from |buffer| to the control channel of
31// |socket|. Second, reads |out_capacity| bytes from the control channel of
32// |socket| to |out_buffer|.
33//
34// Blocks until the transaction is complete.
35//
36// |buffer| and |out_buffer| may be aliased.
37//
38// The actual number of bytes reads from the control plan is returned in
39// |out_actual|.
40zx_status_t fidl_socket_call_control(zx_handle_t socket, const void* buffer,
41 size_t capacity, void* out_buffer,
42 size_t out_capacity, size_t* out_actual);
43
44__END_CDECLS
45
46#endif // LIB_FIDL_TRANSPORT_H_