Julian Hall | 6c59e4e | 2020-11-23 17:50:47 +0100 | [diff] [blame] | 1 | /* |
julhal01 | c3f4e9a | 2020-12-15 13:39:01 +0000 | [diff] [blame^] | 2 | * Copyright (c) 2020-2021, Arm Limited and Contributors. All rights reserved. |
Julian Hall | 6c59e4e | 2020-11-23 17:50:47 +0100 | [diff] [blame] | 3 | * |
| 4 | * SPDX-License-Identifier: BSD-3-Clause |
| 5 | */ |
| 6 | |
| 7 | #include <rpc_caller.h> |
| 8 | #include <stdint.h> |
julhal01 | c3f4e9a | 2020-12-15 13:39:01 +0000 | [diff] [blame^] | 9 | #include <protocols/rpc/common/packed-c/encoding.h> |
| 10 | |
| 11 | void rpc_caller_init(struct rpc_caller *s, void *context) |
| 12 | { |
| 13 | s->context = context; |
| 14 | |
| 15 | /* The default encoding scheme - may be overridden by a client */ |
| 16 | s->encoding = TS_RPC_ENCODING_PACKED_C; |
| 17 | } |
| 18 | |
| 19 | void rpc_caller_set_encoding_scheme(struct rpc_caller *s, uint32_t encoding) |
| 20 | { |
| 21 | s->encoding = encoding; |
| 22 | } |
Julian Hall | 6c59e4e | 2020-11-23 17:50:47 +0100 | [diff] [blame] | 23 | |
| 24 | rpc_call_handle rpc_caller_begin(struct rpc_caller *s, |
| 25 | uint8_t **req_buf, size_t req_len) |
| 26 | { |
| 27 | return s->call_begin(s->context, req_buf, req_len); |
| 28 | } |
| 29 | |
| 30 | rpc_status_t rpc_caller_invoke(struct rpc_caller *s, rpc_call_handle handle, |
| 31 | uint32_t opcode, int *opstatus, uint8_t **resp_buf, size_t *resp_len) |
| 32 | { |
| 33 | return s->call_invoke(s->context, handle, opcode, opstatus, resp_buf, resp_len); |
| 34 | } |
| 35 | |
| 36 | void rpc_caller_end(struct rpc_caller *s, rpc_call_handle handle) |
| 37 | { |
| 38 | s->call_end(s->context, handle); |
| 39 | } |