This repository has been archived on 2025-09-14. You can view files and clone it, but cannot push or open issues or pull requests.
Files
stellar-stellar/infra/plugin_manager/test/plugin_manager_gtest_mock.h

106 lines
1.6 KiB
C
Raw Normal View History

#pragma once
#ifdef __cplusplus
extern "C"
{
#endif
#include "plugin_manager/plugin_manager_interna.h"
#include "stellar/session.h"
#include "tuple.h"
//mock stellar
struct stellar
{
struct plugin_manager_schema *plug_mgr;
};
enum packet_type
{
UNKNOWN,
IPv4,
IPv6,
UDP,
TCP,
TCP_STREAM,
CONTROL,
};
struct packet
{
struct stellar *st;
enum packet_type type;
unsigned char ip_proto;
};
struct session
{
struct exdata_handle *session_exdat_rt;
enum session_type type;
enum session_state state;
int sess_pkt_cnt;
};
struct plugin_manager_schema * stellar_get_plugin_manager(struct stellar *st)
{
return st->plug_mgr;
}
int stellar_set_plugin_manger(struct stellar *st, struct plugin_manager_schema *pm)
{
st->plug_mgr=pm;
return 0;
}
int stellar_get_worker_thread_num(struct stellar *st __attribute__((unused)))
{
return 16;
}
uint16_t stellar_get_current_thread_index()
{
return 0;
}
unsigned char packet_get_ip_protocol(struct packet *pkt)
{
return pkt->ip_proto;
}
enum session_type session_get_type(const struct session *sess)
{
return sess->type;
}
void session_set_user_data(struct session *sess, void *user_data)
{
sess->session_exdat_rt = (struct exdata_handle *)user_data;
}
void *session_get_user_data(const struct session *sess)
{
return sess->session_exdat_rt;
}
void *packet_get_user_data(const struct packet *pkt)
{
return pkt->st->plug_mgr;
}
int packet_get_innermost_tuple6(const struct packet *pkt, struct tuple6 *tuple)
{
tuple->ip_proto = pkt->ip_proto;
return 0;
}
uint8_t packet_is_ctrl(const struct packet *pkt __attribute__((unused)))
{
return 0;
}
#ifdef __cplusplus
}
#endif