football
socket abstraction layer
Loading...
Searching...
No Matches
fb_transport.h
Go to the documentation of this file.
1
8
9#ifndef __football__transport__
10#define __football__transport__
11
12#include <config.h>
13
14#include "fb_public.h"
15
16
17
18#define FB_HAVE_TLS
19#if defined(HAVE_LIBGNUTLS)
20
21#include <gnutls/gnutls.h>
22typedef gnutls_session_t FB_TLS_CONTEXT;
23
24#elif defined(HAVE_LIBMBEDTLS)
25
26#pragma GCC diagnostic push
27#pragma GCC diagnostic ignored "-Wdocumentation"
28#include <mbedtls/ssl.h>
29#pragma GCC diagnostic pop
30
31typedef struct fb_tls_context_t {
32 mbedtls_ssl_context context;
33 bool pending_read;
34 unsigned char buffered_char;
35} FB_TLS_CONTEXT;
36
37#elif defined(HAVE_LIBTLS)
38
39typedef struct fb_tls_context_t {
40 struct tls *context;
41 bool pending_read;
42 char buffered_char;
43} FB_TLS_CONTEXT;
44
45#elif defined(HAVE_LIBSSL)
46
47#include <openssl/ssl.h>
48
49typedef SSL *FB_TLS_CONTEXT;
50
51#elif defined(HAVE_SECURETRANSPORT)
52
53#include <Security/SecureTransport.h>
54
55typedef SSLContextRef FB_TLS_CONTEXT;
56
57#else
58#undef FB_HAVE_TLS
59#endif
60
61
62
63extern const ssize_t FB_TRANSPORT_CLOSED;
64extern const ssize_t FB_TRANSPORT_INCOMPLETE;
65extern const ssize_t FB_TRANSPORT_FAILURE;
66
68typedef struct fb_config_files_t {
69 char *public_key_name;
70 char *x509_certificate_name;
71 char *x509_revokation_name;
73
74typedef struct fb_transport_funcs_t {
76 bool (*configure) (const FB_TLS_CONFIG_FILENAMES *files);
78 void (*cleanup) ();
79
81 bool (*init) (FB_CONNECTION *connection);
83 ssize_t (*handshake) (struct fb_connection_t *connection);
85 ssize_t (*buffering) (struct fb_connection_t *connection);
87 ssize_t (*read) (struct fb_connection_t *connection, char *data, ssize_t byte_count);
89 ssize_t (*write) (struct fb_connection_t *connection, const char *data, ssize_t byte_count);
91 void (*done) (FB_CONNECTION *connection);
93
96#ifdef FB_HAVE_TLS
97extern const FB_TRANSPORT_FUNCS fb_transport_encrypted;
98#endif
99
100
101#endif /* defined(__football__transport__) */
Football public declarations.
const FB_TRANSPORT_FUNCS fb_transport_unencrypted
Transport virtual method table for unenrypted connections.
Definition fb_transport.c:104
const ssize_t FB_TRANSPORT_INCOMPLETE
An action was incomplete, but can be retried in the future.
Definition fb_transport.c:35
const FB_TRANSPORT_FUNCS fb_transport_read_file
Transport virtual method table for reading from files.
Definition fb_transport.c:159
const ssize_t FB_TRANSPORT_FAILURE
An action failed permanently; the connection has failed and should be closed.
Definition fb_transport.c:38
const ssize_t FB_TRANSPORT_CLOSED
Connection closed normally. Returned by read transport function only.
Definition fb_transport.c:32
struct fb_config_files_t FB_TLS_CONFIG_FILENAMES
Structure with various I/O functions.
Structure with various I/O functions.
Definition fb_transport.h:68
Connection state information.
Definition fb_service.h:199
Definition fb_transport.h:74
void(* done)(FB_CONNECTION *connection)
Clean up a closing connection.
Definition fb_transport.h:91
void(* cleanup)()
One-time teardown before exit. Not called per-connection.
Definition fb_transport.h:78
bool(* init)(FB_CONNECTION *connection)
Initialize a new connection. Return true on success, 0 on failure.
Definition fb_transport.h:81
ssize_t(* write)(struct fb_connection_t *connection, const char *data, ssize_t byte_count)
Write data to a connection. Return incomplete, failure, or bytes written (0 is not an error).
Definition fb_transport.h:89
ssize_t(* buffering)(struct fb_connection_t *connection)
Query number of bytes in TLS buffers.
Definition fb_transport.h:85
bool(* configure)(const FB_TLS_CONFIG_FILENAMES *files)
One-time initialization on startup. Not called per-connection.
Definition fb_transport.h:76
ssize_t(* handshake)(struct fb_connection_t *connection)
Perform TLS handshaking on a new connection. Return incomplete, failure, or 0.
Definition fb_transport.h:83
ssize_t(* read)(struct fb_connection_t *connection, char *data, ssize_t byte_count)
Read data from a connection. Return transport constant or bytes read.
Definition fb_transport.h:87