1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216
|
// SPDX-License-Identifier: BSD-3-Clause
/**
* @file three.c
*
* @brief MPTCP test plugin.
*
* Copyright (c) 2019-2022, Intel Corporation
*/
#include <ell/ell.h>
#ifdef HAVE_CONFIG_H
# include <mptcpd/private/config.h>
#endif
#include <mptcpd/plugin.h>
#include "test-plugin.h"
#undef NDEBUG
#include <assert.h>
// ----------------------------------------------------------------
static struct plugin_call_count call_count;
// ----------------------------------------------------------------
static void plugin_three_new_connection(mptcpd_token_t token,
struct sockaddr const *laddr,
struct sockaddr const *raddr,
bool server_side,
bool deny_join_id0,
struct mptcpd_pm *pm)
{
(void) token;
(void) laddr;
(void) raddr;
(void) server_side;
(void) deny_join_id0;
(void) pm;
++call_count.new_connection;
}
static void plugin_three_connection_established(
mptcpd_token_t token,
struct sockaddr const *laddr,
struct sockaddr const *raddr,
bool server_side,
bool deny_join_id0,
struct mptcpd_pm *pm)
{
(void) token;
(void) laddr;
(void) raddr;
(void) server_side;
(void) deny_join_id0;
(void) pm;
++call_count.connection_established;
}
static void plugin_three_connection_closed(mptcpd_token_t token,
struct mptcpd_pm *pm)
{
(void) token;
(void) pm;
++call_count.connection_closed;
}
static void plugin_three_new_address(mptcpd_token_t token,
mptcpd_aid_t addr_id,
struct sockaddr const *addr,
struct mptcpd_pm *pm)
{
(void) token;
(void) addr_id;
(void) addr;
(void) pm;
++call_count.new_address;
}
static void plugin_three_address_removed(mptcpd_token_t token,
mptcpd_aid_t addr_id,
struct mptcpd_pm *pm)
{
(void) token;
(void) addr_id;
(void) pm;
++call_count.address_removed;
}
static void plugin_three_new_subflow(mptcpd_token_t token,
struct sockaddr const *laddr,
struct sockaddr const *raddr,
bool backup,
struct mptcpd_pm *pm)
{
(void) token;
(void) laddr;
(void) raddr;
(void) backup;
(void) pm;
++call_count.new_subflow;
}
static void plugin_three_subflow_closed(mptcpd_token_t token,
struct sockaddr const *laddr,
struct sockaddr const *raddr,
bool backup,
uint8_t error,
struct mptcpd_pm *pm)
{
(void) token;
(void) laddr;
(void) raddr;
(void) backup;
(void) error;
(void) pm;
++call_count.subflow_closed;
}
static void plugin_three_subflow_priority(mptcpd_token_t token,
struct sockaddr const *laddr,
struct sockaddr const *raddr,
bool backup,
struct mptcpd_pm *pm)
{
(void) token;
(void) laddr;
(void) raddr;
(void) backup;
(void) pm;
++call_count.subflow_priority;
}
static void plugin_three_listener_created(struct sockaddr const *laddr,
struct mptcpd_pm *pm)
{
(void) laddr;
(void) pm;
++call_count.listener_created;
}
static void plugin_three_listener_closed(struct sockaddr const *laddr,
struct mptcpd_pm *pm)
{
(void) laddr;
(void) pm;
++call_count.listener_closed;
}
static struct mptcpd_plugin_ops const pm_ops = {
.new_connection = plugin_three_new_connection,
.connection_established = plugin_three_connection_established,
.connection_closed = plugin_three_connection_closed,
.new_address = plugin_three_new_address,
.address_removed = plugin_three_address_removed,
.new_subflow = plugin_three_new_subflow,
.subflow_closed = plugin_three_subflow_closed,
.subflow_priority = plugin_three_subflow_priority,
.listener_created = plugin_three_listener_created,
.listener_closed = plugin_three_listener_closed,
};
static int plugin_three_init(struct mptcpd_pm *pm)
{
(void) pm;
static char const name[] = TEST_PLUGIN;
if (!mptcpd_plugin_register_ops(name, &pm_ops)) {
l_error("Failed to initialize test "
"plugin \"" TEST_PLUGIN "\".");
return -1;
}
return 0;
}
static void plugin_three_exit(struct mptcpd_pm *pm)
{
(void) pm;
struct plugin_call_count const count = { .new_connection = 0 };
assert(call_count_is_sane(&call_count));
assert(call_count_is_equal(&call_count, &count));
call_count_reset(&call_count);
}
MPTCPD_PLUGIN_DEFINE(plugin_three,
"test plugin three",
MPTCPD_PLUGIN_PRIORITY_DEFAULT, // Between the
// other plugins.
plugin_three_init,
plugin_three_exit)
/*
Local Variables:
c-file-style: "linux"
End:
*/
|