1 /* Copyright (c) 2012 The Chromium OS 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 6 /* 7 * A remote client to the server. 8 */ 9 #ifndef CRAS_RCLIENT_H_ 10 #define CRAS_RCLIENT_H_ 11 12 struct cras_message; 13 struct cras_rclient; 14 15 /* Creates an rclient structure. 16 * Args: 17 * fd - The file descriptor used for communication with the client. 18 * id - Unique identifier for this client. 19 * Returns: 20 * A pointer to the newly created rclient on success, NULL on failure. 21 */ 22 struct cras_rclient *cras_rclient_create(int fd, size_t id); 23 24 /* Destroys an rclient created with "cras_rclient_create". 25 * Args: 26 * client - The client to destroy. 27 */ 28 void cras_rclient_destroy(struct cras_rclient *client); 29 30 /* Handles a message from the client. 31 * Args: 32 * client - The client that received this message. 33 * msg - The message that was sent by the remote client. 34 * fd - The file descriptor that was sent by the remote client (or -1 if no 35 * file descriptor was sent). 36 * Returns: 37 * 0 on success, otherwise a negative error code. 38 */ 39 int cras_rclient_message_from_client(struct cras_rclient *client, 40 const struct cras_server_message *msg, 41 int fd); 42 43 /* Sends a message to the client. 44 * Args: 45 * client - The client to send the message to. 46 * msg - The message to send. 47 * fds - Array of file descriptors or null 48 * num_fds - Number of entries in the fds array. 49 * Returns: 50 * number of bytes written on success, otherwise a negative error code. 51 */ 52 int cras_rclient_send_message(const struct cras_rclient *client, 53 const struct cras_client_message *msg, 54 int *fds, 55 unsigned int num_fds); 56 57 #endif /* CRAS_RCLIENT_H_ */ 58