2 *------------------------------------------------------------------
3 * Copyright (c) 2017 Cisco and/or its affiliates.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at:
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *------------------------------------------------------------------
21 #include <memif_private.h>
23 /* interface identification errors (disconnect messages)*/
24 #define MEMIF_VER_ERR "incompatible version"
25 #define MEMIF_ID_ERR "unmatched interface id"
26 #define MEMIF_SLAVE_ERR "cannot connect to salve"
27 #define MEMIF_CONN_ERR "already connected"
28 #define MEMIF_MODE_ERR "mode mismatch"
29 #define MEMIF_SECRET_ERR "incorrect secret"
30 #define MEMIF_NOSECRET_ERR "secret required"
34 int memif_conn_fd_read_ready (memif_connection_t * c);
36 int memif_conn_fd_write_ready (memif_connection_t * c);
38 int memif_conn_fd_error (memif_connection_t * c);
40 int memif_conn_fd_accept_ready (memif_socket_t * ms);
42 int memif_read_ready (libmemif_main_t *lm, int fd);
44 int memif_msg_send_disconnect (int fd, uint8_t * err_string,
47 /* when compiling unit tests, compile functions without static keyword
48 and declare functions in header file */
49 #ifdef MEMIF_UNIT_TEST
52 int memif_msg_send (int fd, memif_msg_t * msg, int afd);
54 int memif_msg_enq_ack (memif_connection_t * c);
56 int memif_msg_send_hello (libmemif_main_t *lm, int fd);
58 int memif_msg_enq_init (memif_connection_t * c);
60 int memif_msg_enq_add_region (memif_connection_t * c, uint8_t region);
62 int memif_msg_enq_add_ring (memif_connection_t * c, uint8_t index,
65 int memif_msg_receive_hello (memif_connection_t * c, memif_msg_t * msg);
67 int memif_msg_receive_init (memif_socket_t * ms, int fd, memif_msg_t * msg);
69 int memif_msg_receive_add_region (memif_connection_t * c, memif_msg_t * msg,
72 int memif_msg_receive_add_ring (memif_connection_t * c, memif_msg_t * msg,
75 int memif_msg_enq_connect (memif_connection_t * c);
77 int memif_msg_enq_connected (memif_connection_t * c);
79 int memif_msg_receive_connect (memif_connection_t * c, memif_msg_t * msg);
81 int memif_msg_receive_connected (memif_connection_t * c, memif_msg_t * msg);
83 int memif_msg_receive_disconnect (memif_connection_t * c, memif_msg_t * msg);
86 #define static_fn static
87 #endif /* MEMIF_UNIT_TEST */
89 #endif /* _SOCKET_H_ */