New upstream version 18.08
[deb_dpdk.git] / examples / ip_pipeline / conn.h
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 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 (*conn_msg_handle_t)(char *msg_in,
21         char *msg_out,
22         size_t msg_out_len_max);
23
24 struct conn_params {
25         const char *welcome;
26         const char *prompt;
27         const char *addr;
28         uint16_t port;
29         size_t buf_size;
30         size_t msg_in_len_max;
31         size_t msg_out_len_max;
32         conn_msg_handle_t msg_handle;
33 };
34
35 struct conn *
36 conn_init(struct conn_params *p);
37
38 void
39 conn_free(struct conn *conn);
40
41 int
42 conn_poll_for_conn(struct conn *conn);
43
44 int
45 conn_poll_for_msg(struct conn *conn);
46
47 #endif