You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

tcp_comm.h 870B

123456789101112131415161718192021222324252627282930
  1. /**
  2. * Copyright (c) 2022 Brian Starkey <stark3y@gmail.com>
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. #ifndef __TCP_COMM_H__
  7. #define __TCP_COMM_H__
  8. #include <stdint.h>
  9. #include <stdbool.h>
  10. struct comm_command {
  11. uint32_t opcode;
  12. uint32_t nargs;
  13. uint32_t resp_nargs;
  14. uint32_t (*size)(uint32_t *args_in, uint32_t *data_len_out, uint32_t *resp_data_len_out);
  15. uint32_t (*handle)(uint32_t *args_in, uint8_t *data_in, uint32_t *resp_args_out, uint8_t *resp_data_out);
  16. };
  17. struct tcp_comm_ctx;
  18. err_t tcp_comm_listen(struct tcp_comm_ctx *ctx, uint16_t port);
  19. err_t tcp_comm_server_close(struct tcp_comm_ctx *ctx);
  20. bool tcp_comm_server_done(struct tcp_comm_ctx *ctx);
  21. struct tcp_comm_ctx *tcp_comm_new(const struct comm_command *const *cmds,
  22. unsigned int n_cmds, uint32_t sync_opcode);
  23. void tcp_comm_delete(struct tcp_comm_ctx *ctx);
  24. #endif /* __TCP_COMM_H__ */