1 /* SPDX-License-Identifier: BSD-3-Clause 2 * Copyright(c) 2023 Marvell. 3 */ 4 5 #ifndef APP_GRAPH_CONN_H 6 #define APP_GRAPH_CONN_H 7 8 #define CONN_WELCOME_LEN_MAX 1024 9 #define CONN_PROMPT_LEN_MAX 16 10 11 typedef void (*conn_msg_handle_t)(char *msg_in, char *msg_out, size_t msg_out_len_max, void *arg); 12 13 struct conn { 14 char *welcome; 15 char *prompt; 16 char *buf; 17 char *msg_in; 18 char *msg_out; 19 size_t buf_size; 20 size_t msg_in_len_max; 21 size_t msg_out_len_max; 22 size_t msg_in_len; 23 int fd_server; 24 int fd_client_group; 25 conn_msg_handle_t msg_handle; 26 void *msg_handle_arg; 27 }; 28 29 struct conn_params { 30 const char *welcome; 31 const char *prompt; 32 const char *addr; 33 uint16_t port; 34 size_t buf_size; 35 size_t msg_in_len_max; 36 size_t msg_out_len_max; 37 conn_msg_handle_t msg_handle; 38 void *msg_handle_arg; 39 }; 40 41 struct conn *conn_init(struct conn_params *p); 42 void conn_free(struct conn *conn); 43 int conn_req_poll(struct conn *conn); 44 int conn_msg_poll(struct conn *conn); 45 46 #endif 47