From 795c1240c9fb09c42bcdc45d5a8d44e6a406ee9c Mon Sep 17 00:00:00 2001 From: Michael Steinert Date: Thu, 10 May 2012 13:28:17 -0600 Subject: Add plumbing for SSL/TLS support This change abstracts out the networking functions so that the user can provide an SSL/TLS implementation. Callback functions replace `writev()`, `send()`, and `recv()` (there is also a callback for error reporting). The default interface remains unchanged. If the user wants to create a SSL/TLS connection they first negotiate the connection and then use the new function `amqp_set_sockfd_full()` to provide the networking implementation for their SSL/TLS library. The user may provide an optional pointer to data that is passed through to the networking functions. Signed-off-by: Michael Steinert --- librabbitmq/amqp_socket.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'librabbitmq/amqp_socket.c') diff --git a/librabbitmq/amqp_socket.c b/librabbitmq/amqp_socket.c index 22cc2c5..f57a512 100644 --- a/librabbitmq/amqp_socket.c +++ b/librabbitmq/amqp_socket.c @@ -39,12 +39,16 @@ #endif #include "amqp_private.h" -#include +#include +#include +#include +#include +#include +#include #include +#include #include -#include -#include -#include +#include int amqp_open_socket(char const *hostname, int portnumber) @@ -117,7 +121,7 @@ int amqp_send_header(amqp_connection_state_t state) AMQP_PROTOCOL_VERSION_MINOR, AMQP_PROTOCOL_VERSION_REVISION }; - return send(state->sockfd, (void *)header, 8, MSG_NOSIGNAL); + return state->send(state->sockfd, (void *)header, 8, 0, state->user_data); } static amqp_bytes_t sasl_method_name(amqp_sasl_method_enum method) @@ -214,13 +218,13 @@ static int wait_frame_inner(amqp_connection_state_t state, assert(res != 0); } - res = recv(state->sockfd, state->sock_inbound_buffer.bytes, - state->sock_inbound_buffer.len, 0); + res = state->recv(state->sockfd, state->sock_inbound_buffer.bytes, + state->sock_inbound_buffer.len, 0, state->user_data); if (res <= 0) { if (res == 0) { return -ERROR_CONNECTION_CLOSED; } else { - return -amqp_socket_error(); + return -state->error(state->user_data); } } -- cgit v1.2.1