1 /* SPDX-License-Identifier: BSD-3-Clause 2 * Copyright(c) 2010-2018 Intel Corporation 3 */ 4 5 #ifndef __INCLUDE_CONN_H__ 6 #define __INCLUDE_CONN_H__ 7 8 #include <stdint.h> 9 10 struct softnic_conn; 11 12 #ifndef CONN_WELCOME_LEN_MAX 13 #define CONN_WELCOME_LEN_MAX 1024 14 #endif 15 16 #ifndef CONN_PROMPT_LEN_MAX 17 #define CONN_PROMPT_LEN_MAX 16 18 #endif 19 20 typedef void (*softnic_conn_msg_handle_t)(char *msg_in, 21 char *msg_out, 22 size_t msg_out_len_max, 23 void *arg); 24 25 struct softnic_conn_params { 26 const char *welcome; 27 const char *prompt; 28 const char *addr; 29 uint16_t port; 30 size_t buf_size; 31 size_t msg_in_len_max; 32 size_t msg_out_len_max; 33 softnic_conn_msg_handle_t msg_handle; 34 void *msg_handle_arg; 35 }; 36 37 struct softnic_conn * 38 softnic_conn_init(struct softnic_conn_params *p); 39 40 void 41 softnic_conn_free(struct softnic_conn *conn); 42 43 int 44 softnic_conn_poll_for_conn(struct softnic_conn *conn); 45 46 int 47 softnic_conn_poll_for_msg(struct softnic_conn *conn); 48 49 #endif 50