17 #ifndef YAMICORE_CHANNEL_H_INCLUDED 18 #define YAMICORE_CHANNEL_H_INCLUDED 21 #include "details-fwd.h" 25 #ifdef YAMI4_WITH_OPEN_SSL 31 #include <openssl/ssl.h> 32 #endif // YAMI4_WITH_OPEN_SSL 35 #include <details-types.h> 43 enum incoming_fsm { read_frame_header, read_frame_payload };
45 const std::size_t word_size = 4;
46 const std::size_t frame_head_size = 4 * word_size;
59 const options & configuration_options,
60 const core::parameters * overriding_options,
63 void * incoming_message_hint,
65 void * event_notification_hint,
67 void * io_error_callback_hint);
73 const options & configuration_options,
74 char * target, io_descriptor_type fd, protocol prot,
75 std::size_t preferred_frame_size,
77 void * incoming_message_hint,
79 void * event_notification_hint,
81 void * io_error_callback_hint);
83 #ifdef YAMI4_WITH_OPEN_SSL 84 void set_client_ssl(SSL * ssl);
85 void set_server_ssl(SSL * ssl);
86 #endif // YAMI4_WITH_OPEN_SSL 88 void close_connection();
91 std::size_t get_frame_size()
const;
95 char * * buffers,
const std::size_t * buffer_sizes,
96 std::size_t number_of_frames,
99 void * progress_hint);
104 const char * buffer,
const std::size_t buffer_size);
106 core::result do_some_work(io_direction direction,
bool & close_me);
108 #ifdef YAMI4_WITH_QNX 115 void set_default_qnx_listening_channel_id(
int chid);
120 void set_selector(selector & slc);
121 #endif // YAMI4_WITH_QNX 123 core::result post_close(std::size_t priority,
bool & close_me);
125 const char * get_target()
const {
return target_; }
126 const char * move_target();
128 io_descriptor_type get_io_descriptor()
const {
return fd_; }
130 void get_io_descriptor(
131 io_descriptor_type & fd, io_direction & direction)
const;
133 bool has_buffered_data()
const {
return buffer_available_ > buffer_consumed_; }
135 #ifdef YAMI4_WITH_OPEN_SSL 136 SSL * get_ssl()
const {
return ssl_; }
138 void set_pending_read(
bool pending) { pending_read_ = pending; }
139 bool get_pending_read()
const {
return pending_read_; }
140 #endif // YAMI4_WITH_OPEN_SSL 142 protocol get_protocol()
const {
return protocol_; }
144 void set_selector_index(
int index) { selector_index_ = index; }
145 int get_selector_index()
const {
return selector_index_; }
147 void inc_ref() { ++ref_count_; }
148 void dec_ref() { --ref_count_; }
149 bool can_be_removed()
const {
return ref_count_ == 0; }
152 outgoing_frame * get_first_outgoing_frame()
const;
153 outgoing_frame * get_last_outgoing_frame()
const;
154 incoming_message_frame_list * get_first_incoming_frame_list()
const;
155 incoming_message_frame_list * get_last_incoming_frame_list()
const;
156 incoming_fsm get_incoming_state()
const;
158 std::size_t get_pending_outgoing_bytes()
const;
162 void common_init(allocator & alloc, mutex & mtx,
163 const options & configuration_options,
164 const core::parameters * overriding_options,
166 void * incoming_message_hint,
168 void * event_notification_hint,
170 void * io_error_callback_hint);
172 outgoing_frame * * find_outgoing_insertion_point(std::size_t priority);
175 void clean_outgoing_frames(outgoing_frame * frame);
177 void notify_cancellation(
179 void * progress_hint);
181 void parse_incoming_frame_header();
187 incoming_message_frame_list * list);
190 void clean_incoming_messages();
193 void clean_incoming_frames(incoming_message_frame_list * list);
195 void notify_progress_and_consume_frame_list();
205 #ifdef YAMI4_WITH_QNX 207 #endif // YAMI4_WITH_QNX 208 #ifdef YAMI4_WITH_OPEN_SSL 210 #endif // YAMI4_WITH_OPEN_SSL 213 std::size_t & readn);
214 core::result write_bytes(
const char * buf, std::size_t size,
215 std::size_t & written);
217 options configuration_options_;
220 #ifdef YAMI4_WITH_OPEN_SSL 223 #endif // YAMI4_WITH_OPEN_SSL 229 io_direction direction_;
230 io_descriptor_type fd_;
234 char * frame_buffer_;
235 std::size_t buffer_capacity_;
236 std::size_t buffer_available_;
237 std::size_t buffer_consumed_;
239 std::size_t preferred_frame_size_;
242 void * target_address_;
243 int target_address_size_;
244 char * datagram_buffer_;
246 #ifdef YAMI4_WITH_QNX 249 selector * selector_;
251 char qnx_listener_channel_id_serialized_[4u];
252 #endif // YAMI4_WITH_QNX 254 std::size_t ref_count_;
258 enum mode { operational, soft_close, hard_close };
263 std::size_t output_frame_offset_;
264 outgoing_frame * first_outgoing_frame_;
265 outgoing_frame * last_outgoing_frame_;
269 incoming_fsm incoming_state_;
270 std::size_t read_offset_;
272 char frame_head_buffer_[frame_head_size];
273 int current_message_id_;
274 std::size_t current_frame_number_;
275 std::size_t current_message_header_size_;
276 std::size_t current_frame_payload_size_;
277 char * current_frame_payload_;
280 incoming_message_frame_list * first_incoming_frame_list_;
281 incoming_message_frame_list * last_incoming_frame_list_;
283 std::size_t pending_outgoing_bytes_;
286 void * incoming_message_hint_;
289 void * event_notification_hint_;
292 void * io_error_callback_hint_;
299 #endif // YAMICORE_CHANNEL_H_INCLUDED void(* io_error_function)(void *hint, int error_code, const char *description)
Type of function callback for internal I/O error logging.
Definition: core.h:149
void(* message_progress_function)(void *hint, std::size_t sent_bytes, std::size_t total_byte_count)
Definition: core.h:121
Namespace devoted for everything related to YAMI4.
Definition: agent.h:25
void(* incoming_message_dispatch_function)(void *hint, const char *source, const char *header_buffers[], std::size_t header_buffer_sizes[], std::size_t num_of_header_buffers, const char *body_buffers[], std::size_t body_buffer_sizes[], std::size_t num_of_body_buffers)
Definition: core.h:70
void(* event_notification_function)(void *hint, event_notification e, const char *str, std::size_t size)
Definition: core.h:142
result
General type for reporting success and error states.
Definition: core.h:32