]> git.proxmox.com Git - mirror_frr.git/blame - pceplib/pcep_socket_comm_mock.h
Merge pull request #12114 from opensourcerouting/feature/bgp_aigp_attribute
[mirror_frr.git] / pceplib / pcep_socket_comm_mock.h
CommitLineData
74971473
JG
1/*
2 * This file is part of the PCEPlib, a PCEP protocol library.
3 *
4 * Copyright (C) 2020 Volta Networks https://voltanet.io/
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 *
19 * Author : Brady Johnson <brady@voltanet.io>
20 *
21 */
22
23/*
24 * This module is built into a separate library, and is used by several
25 * other modules for unit testing, so that real sockets dont have to be
26 * created.
27 */
28
29#ifndef PCEP_SOCKET_COMM_MOCK_SOCKET_COMM_H_
30#define PCEP_SOCKET_COMM_MOCK_SOCKET_COMM_H_
31
32#include <stdbool.h>
33
34#include "pcep_utils_double_linked_list.h"
35
36typedef struct mock_socket_comm_info_ {
37 int socket_comm_initialize_external_infra_times_called;
38 int socket_comm_session_initialize_times_called;
39 int socket_comm_session_initialize_src_times_called;
40 int socket_comm_session_teardown_times_called;
41 int socket_comm_session_connect_tcp_times_called;
42 int socket_comm_session_send_message_times_called;
43 int socket_comm_session_close_tcp_after_write_times_called;
44 int socket_comm_session_close_tcp_times_called;
45 int destroy_socket_comm_loop_times_called;
46
47 /* TODO later if necessary, we can add return values for
48 * those functions that return something */
49
50 /* Used to access messages sent with socket_comm_session_send_message()
51 */
52 bool send_message_save_message;
53 double_linked_list *sent_message_list;
54
55} mock_socket_comm_info;
56
57void setup_mock_socket_comm_info(void);
58void teardown_mock_socket_comm_info(void);
59void reset_mock_socket_comm_info(void);
60bool destroy_socket_comm_loop(void);
61
62mock_socket_comm_info *get_mock_socket_comm_info(void);
63void verify_socket_comm_times_called(int initialized, int teardown, int connect,
64 int send_message, int close_after_write,
65 int close, int destroy);
66
67#endif /* PCEP_SOCKET_COMM_MOCK_SOCKET_COMM_H_ */