blob: ac3a336c5c590a0c6d25599dba690b9db107196b [file] [log] [blame]
Julian Hall83632872023-03-06 14:33:32 +00001/*
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 Szing3c446242023-03-31 01:53:15 +020012
13#include "rpc_caller.h"
Julian Hall83632872023-03-06 14:33:32 +000014
15#ifdef __cplusplus
16extern "C" {
17#endif
18
Gyorgy Szing3c446242023-03-31 01:53:15 +020019#define HTTP_CALLER_MAX_URL_LEN (2048)
Julian Hall83632872023-03-06 14:33:32 +000020
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 */
30struct 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
38struct rpc_caller *http_caller_init(struct http_caller *s);
39void http_caller_deinit(struct http_caller *s);
40
41bool http_caller_probe(const char *url, long *http_code);
42
43int http_caller_open(struct http_caller *s, const char *rpc_call_url);
44int http_caller_close(struct http_caller *s);
45
46#ifdef __cplusplus
47}
48#endif
49
50#endif /* HTTP_CALLER_H */