Julian Hall | 8363287 | 2023-03-06 14:33:32 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2023, Arm Limited and Contributors. All rights reserved. |
| 3 | * |
| 4 | * SPDX-License-Identifier: BSD-3-Clause |
| 5 | */ |
| 6 | |
| 7 | #ifndef HTTP_CALLER_H |
| 8 | #define HTTP_CALLER_H |
| 9 | |
| 10 | #include <stdbool.h> |
| 11 | #include <stdint.h> |
Gyorgy Szing | 3c44624 | 2023-03-31 01:53:15 +0200 | [diff] [blame] | 12 | |
| 13 | #include "rpc_caller.h" |
Julian Hall | 8363287 | 2023-03-06 14:33:32 +0000 | [diff] [blame] | 14 | |
| 15 | #ifdef __cplusplus |
| 16 | extern "C" { |
| 17 | #endif |
| 18 | |
Gyorgy Szing | 3c44624 | 2023-03-31 01:53:15 +0200 | [diff] [blame] | 19 | #define HTTP_CALLER_MAX_URL_LEN (2048) |
Julian Hall | 8363287 | 2023-03-06 14:33:32 +0000 | [diff] [blame] | 20 | |
| 21 | /* |
| 22 | * An RPC caller that makes call requests via a REST API 'call' endpoint |
| 23 | * that provides a generic way to call trusted service operations via HTTP. |
| 24 | * The fw-test-api supports a call endpoint with the path: |
| 25 | * /services/{servicename}/call/{opcode}. A call request body carries the |
| 26 | * rpc header defined in protocols/rpc/common/packed-c.header.h, followed by |
| 27 | * serialized call parameters. A call response body carries the response header |
| 28 | * defined in the same file, followed by any serialized response parameters. |
| 29 | */ |
| 30 | struct http_caller { |
| 31 | struct rpc_caller rpc_caller; |
| 32 | char rpc_call_url[HTTP_CALLER_MAX_URL_LEN]; |
| 33 | size_t req_body_size; |
| 34 | uint8_t *req_body_buf; |
| 35 | uint8_t *resp_body_buf; |
| 36 | }; |
| 37 | |
| 38 | struct rpc_caller *http_caller_init(struct http_caller *s); |
| 39 | void http_caller_deinit(struct http_caller *s); |
| 40 | |
| 41 | bool http_caller_probe(const char *url, long *http_code); |
| 42 | |
| 43 | int http_caller_open(struct http_caller *s, const char *rpc_call_url); |
| 44 | int http_caller_close(struct http_caller *s); |
| 45 | |
| 46 | #ifdef __cplusplus |
| 47 | } |
| 48 | #endif |
| 49 | |
| 50 | #endif /* HTTP_CALLER_H */ |