7 #ifndef UTIL_UNITTESTS_MOCKSOCKETSESSION_H
8 #define UTIL_UNITTESTS_MOCKSOCKETSESSION_H 1
19 #include <sys/socket.h>
36 is_connected_(false), connect_ok_(true), push_ok_(true),
41 pushed_sock_(-1), pushed_family_(-1), pushed_type_(-1),
48 "forwarding connection disabled for test");
59 is_connected_ =
false;
66 virtual void push(
int sock,
int family,
int type,
int protocol,
67 const struct sockaddr& local_end,
68 const struct sockaddr& remote_end,
69 const void* data,
size_t data_len)
73 "socket session forwarding is disabled for test");
77 "socket session is being pushed before connected");
82 pushed_family_ = family;
84 pushed_protocol_ = protocol;
86 sizeof(pushed_local_end_ss_));
87 std::memcpy(&pushed_local_end_ss_, &local_end,
90 sizeof(pushed_remote_end_ss_));
91 std::memcpy(&pushed_remote_end_ss_, &remote_end,
93 pushed_data_.resize(data_len);
94 std::memcpy(&pushed_data_[0], data, data_len);
127 return (pushed_data_);
138 int pushed_protocol_;
139 struct sockaddr_storage pushed_local_end_ss_;
140 struct sockaddr_storage pushed_remote_end_ss_;
141 std::vector<uint8_t> pushed_data_;
147 #endif // UTIL_UNITTESTS_MOCKSOCKETSESSION_H
int getPushedProtocol() const
socklen_t getSALength(const struct sockaddr &sa)
Mock socket session forwarder.
An exception indicating general errors that takes place in the socket session related class objects...
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
virtual void connectToReceiver()
The "base" class of SocketSessionForwarder.
int getPushedFamily() const
Defines the logger used by the top-level component of kea-dhcp-ddns.
int getPushedType() const
virtual void push(int sock, int family, int type, int protocol, const struct sockaddr &local_end, const struct sockaddr &remote_end, const void *data, size_t data_len)
const struct sockaddr * convertSockAddr(const SAType *sa)
const std::vector< uint8_t > & getPushedData() const
const struct sockaddr & getPushedLocalend() const
const struct sockaddr & getPushedRemoteend() const
int getPushedSock() const
MockSocketSessionForwarder()