123456789101112131415161718192021222324252627282930 |
- /**
- * Copyright (c) 2022 Brian Starkey <stark3y@gmail.com>
- *
- * SPDX-License-Identifier: BSD-3-Clause
- */
- #ifndef __TCP_COMM_H__
- #define __TCP_COMM_H__
-
- #include <stdint.h>
- #include <stdbool.h>
-
- struct comm_command {
- uint32_t opcode;
- uint32_t nargs;
- uint32_t resp_nargs;
- uint32_t (*size)(uint32_t *args_in, uint32_t *data_len_out, uint32_t *resp_data_len_out);
- uint32_t (*handle)(uint32_t *args_in, uint8_t *data_in, uint32_t *resp_args_out, uint8_t *resp_data_out);
- };
-
- struct tcp_comm_ctx;
-
- err_t tcp_comm_listen(struct tcp_comm_ctx *ctx, uint16_t port);
- err_t tcp_comm_server_close(struct tcp_comm_ctx *ctx);
- bool tcp_comm_server_done(struct tcp_comm_ctx *ctx);
-
- struct tcp_comm_ctx *tcp_comm_new(const struct comm_command *const *cmds,
- unsigned int n_cmds, uint32_t sync_opcode);
- void tcp_comm_delete(struct tcp_comm_ctx *ctx);
-
- #endif /* __TCP_COMM_H__ */
|