diff options
author | Michael Steinert <mike.steinert@gmail.com> | 2012-05-10 13:28:17 -0600 |
---|---|---|
committer | Alan Antonuk <alan.antonuk@gmail.com> | 2013-04-09 15:18:39 -0700 |
commit | 795c1240c9fb09c42bcdc45d5a8d44e6a406ee9c (patch) | |
tree | ce8b060d7ee08435a6c7b668f56ccf5b7b460b69 /librabbitmq/amqp_socket.c | |
parent | 21b124e2fd2f1c343fb37b708f393d1b9580cfad (diff) | |
download | rabbitmq-c-github-ask-795c1240c9fb09c42bcdc45d5a8d44e6a406ee9c.tar.gz |
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 <mike.steinert@gmail.com>
Diffstat (limited to 'librabbitmq/amqp_socket.c')
-rw-r--r-- | librabbitmq/amqp_socket.c | 20 |
1 files changed, 12 insertions, 8 deletions
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 <stdlib.h> +#include <assert.h> +#include <netdb.h> +#include <netinet/in.h> +#include <netinet/tcp.h> +#include <stdarg.h> +#include <stdint.h> #include <stdio.h> +#include <stdlib.h> #include <string.h> -#include <stdint.h> -#include <stdarg.h> -#include <assert.h> +#include <sys/socket.h> 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); } } |