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