12 #ifndef ASIO_SSL_OLD_DETAIL_OPENSSL_STREAM_SERVICE_HPP 13 #define ASIO_SSL_OLD_DETAIL_OPENSSL_STREAM_SERVICE_HPP 15 #if defined(_MSC_VER) && (_MSC_VER >= 1200) 17 #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) 23 #include <boost/config.hpp> 24 #include <boost/noncopyable.hpp> 25 #include <boost/function.hpp> 26 #include <boost/bind.hpp> 48 enum { max_buffer_size = INT_MAX };
51 template <
typename Stream>
55 typedef boost::function<
60 , io_service_(io_service)
70 void set_func(func_t func) { func_ = func; }
85 template<
typename Stream,
typename Handler>
87 :
public base_handler<Stream>
91 : base_handler<Stream>(io_service)
95 &io_handler<Stream, Handler>::handler_impl,
96 this, boost::arg<1>(), boost::arg<2>() ));
103 std::auto_ptr<io_handler<Stream, Handler> > this_ptr(
this);
104 handler_(error, size);
109 template <
typename Stream,
typename Handler>
111 :
public base_handler<Stream>
115 : base_handler<Stream>(io_service)
119 &handshake_handler<Stream, Handler>::handler_impl,
120 this, boost::arg<1>(), boost::arg<2>() ));
127 std::auto_ptr<handshake_handler<Stream, Handler> > this_ptr(
this);
134 template <
typename Stream,
typename Handler>
136 :
public base_handler<Stream>
140 : base_handler<Stream>(io_service),
144 &shutdown_handler<Stream, Handler>::handler_impl,
145 this, boost::arg<1>(), boost::arg<2>() ));
152 std::auto_ptr<shutdown_handler<Stream, Handler> > this_ptr(
this);
185 template <
typename Stream,
typename Context_Service>
190 impl->
ssl = ::SSL_new(context.
impl());
191 ::SSL_set_mode(impl->
ssl, SSL_MODE_ENABLE_PARTIAL_WRITE);
192 ::SSL_set_mode(impl->
ssl, SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER);
195 ::BIO_new_bio_pair(&int_bio, 8192, &impl->
ext_bio, 8192);
196 ::SSL_set_bio(impl->
ssl, int_bio, int_bio);
200 template <
typename Stream>
206 ::SSL_free(impl->
ssl);
213 template <
typename Stream>
221 &ssl_wrap<mutex_type>::SSL_connect:
222 &ssl_wrap<mutex_type>::SSL_accept,
240 template <
typename Stream,
typename Handler>
246 connect_handler* local_handler =
252 &ssl_wrap<mutex_type>::SSL_connect:
253 &ssl_wrap<mutex_type>::SSL_accept,
260 &base_handler<Stream>::do_func,
267 local_handler->set_operation(op);
273 template <
typename Stream>
280 &ssl_wrap<mutex_type>::SSL_shutdown,
298 template <
typename Stream,
typename Handler>
301 typedef shutdown_handler<Stream, Handler> disconnect_handler;
303 disconnect_handler* local_handler =
308 &ssl_wrap<mutex_type>::SSL_shutdown,
315 &base_handler<Stream>::do_func,
322 local_handler->set_operation(op);
328 template <
typename Stream,
typename Const_Buffers>
332 size_t bytes_transferred = 0;
340 if (buffer_size > max_buffer_size)
341 buffer_size = max_buffer_size;
342 else if (buffer_size == 0)
348 boost::function<int (SSL*)> send_func =
349 boost::bind(boost::type<int>(), &::SSL_write, boost::arg<1>(),
350 asio::buffer_cast<const void*>(buffer),
351 static_cast<int>(buffer_size));
359 bytes_transferred =
static_cast<size_t>(op.
start());
368 return bytes_transferred;
372 template <
typename Stream,
typename Const_Buffers,
typename Handler>
374 const Const_Buffers&
buffers, Handler handler)
383 if (buffer_size > max_buffer_size)
384 buffer_size = max_buffer_size;
385 else if (buffer_size == 0)
394 boost::function<int (SSL*)> send_func =
395 boost::bind(boost::type<int>(), &::SSL_write, boost::arg<1>(),
396 asio::buffer_cast<const void*>(buffer),
397 static_cast<int>(buffer_size));
408 &base_handler<Stream>::do_func,
415 local_handler->set_operation(op);
421 template <
typename Stream,
typename Mutable_Buffers>
425 size_t bytes_transferred = 0;
433 if (buffer_size > max_buffer_size)
434 buffer_size = max_buffer_size;
435 else if (buffer_size == 0)
441 boost::function<int (SSL*)> recv_func =
442 boost::bind(boost::type<int>(), &::SSL_read, boost::arg<1>(),
443 asio::buffer_cast<void*>(buffer),
444 static_cast<int>(buffer_size));
452 bytes_transferred =
static_cast<size_t>(op.
start());
461 return bytes_transferred;
465 template <
typename Stream,
typename Mutable_Buffers,
typename Handler>
467 const Mutable_Buffers&
buffers, Handler handler)
469 typedef io_handler<Stream, Handler> recv_handler;
476 if (buffer_size > max_buffer_size)
477 buffer_size = max_buffer_size;
478 else if (buffer_size == 0)
485 recv_handler* local_handler =
new recv_handler(handler,
get_io_service());
487 boost::function<int (SSL*)> recv_func =
488 boost::bind(boost::type<int>(), &::SSL_read, boost::arg<1>(),
489 asio::buffer_cast<void*>(buffer),
490 static_cast<int>(buffer_size));
501 &base_handler<Stream>::do_func,
508 local_handler->set_operation(op);
514 template <
typename Stream,
typename Mutable_Buffers>
523 template <
typename Stream>
536 template<
typename Mutex>
539 static Mutex ssl_mutex_;
541 static int SSL_accept(SSL *ssl)
543 typename Mutex::scoped_lock lock(ssl_mutex_);
544 return ::SSL_accept(ssl);
547 static int SSL_connect(SSL *ssl)
549 typename Mutex::scoped_lock lock(ssl_mutex_);
550 return ::SSL_connect(ssl);
553 static int SSL_shutdown(SSL *ssl)
555 typename Mutex::scoped_lock lock(ssl_mutex_);
556 return ::SSL_shutdown(ssl);
561 template<
typename Mutex>
562 Mutex openssl_stream_service::ssl_wrap<Mutex>::ssl_mutex_;
571 #endif // ASIO_SSL_OLD_DETAIL_OPENSSL_STREAM_SERVICE_HPP
void shutdown_handler(const asio::error_code &)
asio::error_code handshake(impl_type &impl, Stream &next_layer, stream_base::handshake_type type, asio::error_code &ec)
void send_handler(const asio::error_code &, std::size_t)
Provides core I/O functionality.
void async_shutdown(impl_type &impl, Stream &next_layer, Handler handler)
Holds a buffer that cannot be modified.
post(ASIO_MOVE_ARG(CompletionHandler) handler)
Request the io_service to invoke the given handler and return immediately.
Class to inform the io_service when it has work to do.
openssl_stream_service(asio::io_service &io_service)
pylon Camera Software Suite for Linux for Use with Basler Gigabit the pylon Viewer and the IP Configurator applications might not be available System I340 and I350 series Although the pylon software will work with any GigE network we would recommend to use one of these adapters USB For U3V devices a USB3 capable USB controller is necessary For best performance and stability we highly recommend a kernel the following settings should be i e
mutable_buffers_1 buffer(const mutable_buffer &b)
Create a new modifiable buffer from an existing buffer.
Provides serialised handler execution.
asio::io_service & get_io_service()
Get the io_service object that owns the service.
struct asio::ssl::old::detail::openssl_stream_service::impl_struct * impl_type
Perform handshaking as a client.
std::size_t buffer_size(const mutable_buffer &b)
Get the number of bytes in a modifiable buffer.
handshake_type
Different handshake types.
const MutableBufferSequence & buffers
std::size_t peek(impl_type &, Stream &, const Mutable_Buffers &, asio::error_code &ec)
void async_write_some(impl_type &impl, Stream &next_layer, const Const_Buffers &buffers, Handler handler)
std::size_t write_some(impl_type &impl, Stream &next_layer, const Const_Buffers &buffers, asio::error_code &ec)
Holds a buffer that can be modified.
void destroy(impl_type &impl, Stream &)
int bind(socket_type s, const socket_addr_type *addr, std::size_t addrlen, asio::error_code &ec)
std::size_t read_some(impl_type &impl, Stream &next_layer, const Mutable_Buffers &buffers, asio::error_code &ec)
Class to represent an error code value.
error_code code() const
Get the error code associated with the exception.
void async_read_some(impl_type &impl, Stream &next_layer, const Mutable_Buffers &buffers, Handler handler)
std::size_t in_avail(impl_type &, Stream &, asio::error_code &ec)
asio::error_code shutdown(impl_type &impl, Stream &next_layer, asio::error_code &ec)
binder1< Handler, Arg1 > bind_handler(Handler handler, const Arg1 &arg1)
service_base(asio::io_service &io_service)
void handshake_handler(const asio::error_code &)
void create(impl_type &impl, Stream &, basic_context< Context_Service > &context)
impl_type impl()
Get the underlying implementation in the native type.
void async_handshake(impl_type &impl, Stream &next_layer, stream_base::handshake_type type, Handler handler)
void connect_handler(const asio::error_code &e, debug_stream_socket *s)
void shutdown_service()
Destroy all user-defined handler objects owned by the service.