pianod2
multisource multiuser scriptable networked music player
Macros | Functions | Variables
fb_transport.c File Reference

Football transport layer implementation. More...

#include <config.h>
#include <errno.h>
#include <assert.h>
#include "fb_public.h"
#include "fb_transport.h"
#include "fb_service.h"
#include <sys/socket.h>
Include dependency graph for fb_transport.c:

Macros

#define MSG_NOSIGNAL   (0)
 
#define TLS_PUBLIC_KEY_FILE   "x509-server-key.pem"
 
#define TLS_CERTIFICATE_FILE   "x509-server.pem"
 

Functions

bool fb_unencrypted_init (struct fb_connection_t *connection)
 
ssize_t fb_unencrypted_handshake (struct fb_connection_t *connection)
 Perform TLS handshaking on a new connection. Return incomplete, failure, or 0. More...
 
ssize_t fb_unencrypted_buffering (struct fb_connection_t *connection)
 Query number of bytes in TLS buffers. More...
 
ssize_t fb_unencrypted_read (struct fb_connection_t *connection, char *data, ssize_t byte_count)
 
ssize_t fb_unencrypted_write (struct fb_connection_t *connection, const char *data, ssize_t byte_count)
 
void fb_unencrypted_done (FB_CONNECTION *connection)
 
bool fb_file_init (struct fb_connection_t *connection)
 
ssize_t fb_file_read (struct fb_connection_t *connection, char *data, ssize_t byte_count)
 
ssize_t fb_file_write (struct fb_connection_t *connection, const char *data, ssize_t byte_count)
 
void fb_file_done (FB_CONNECTION *connection)
 
bool fb_init_tls_support (const char *path)
 
void fb_cleanup_tls_support (void)
 

Variables

const ssize_t FB_TRANSPORT_CLOSED = 0
 Connection closed normally. Returned by read transport function only. More...
 
const ssize_t FB_TRANSPORT_INCOMPLETE = -1
 An action was incomplete, but can be retried in the future. More...
 
const ssize_t FB_TRANSPORT_FAILURE = -2
 An action failed permanently; the connection has failed and should be closed. More...
 
const FB_TRANSPORT_FUNCS fb_transport_unencrypted
 Transport virtual method table for unenrypted connections. More...
 
const FB_TRANSPORT_FUNCS fb_transport_read_file
 Transport virtual method table for reading from files. More...
 

Detailed Description

Football transport layer implementation.

Generic functions and support for unsecured connections and files.

Macro Definition Documentation

◆ MSG_NOSIGNAL

#define MSG_NOSIGNAL   (0)

◆ TLS_CERTIFICATE_FILE

#define TLS_CERTIFICATE_FILE   "x509-server.pem"

◆ TLS_PUBLIC_KEY_FILE

#define TLS_PUBLIC_KEY_FILE   "x509-server-key.pem"

Function Documentation

◆ fb_cleanup_tls_support()

void fb_cleanup_tls_support ( void  )
Here is the caller graph for this function:

◆ fb_file_done()

void fb_file_done ( FB_CONNECTION connection)

Wrap up reading from a file.

◆ fb_file_init()

bool fb_file_init ( struct fb_connection_t connection)

Prepare to read from a file in the guise of a connection.

◆ fb_file_read()

ssize_t fb_file_read ( struct fb_connection_t connection,
char *  data,
ssize_t  byte_count 
)

Read data from an unencrypted BSD Sockets connection.

◆ fb_file_write()

ssize_t fb_file_write ( struct fb_connection_t connection,
const char *  data,
ssize_t  byte_count 
)

Send writes to the logfile when reading from a file.

◆ fb_init_tls_support()

bool fb_init_tls_support ( const char *  path)
Here is the caller graph for this function:

◆ fb_unencrypted_buffering()

ssize_t fb_unencrypted_buffering ( struct fb_connection_t connection)

Query number of bytes in TLS buffers.

◆ fb_unencrypted_done()

void fb_unencrypted_done ( FB_CONNECTION connection)

Close an unencrypted BSD Sockets connection.

◆ fb_unencrypted_handshake()

ssize_t fb_unencrypted_handshake ( struct fb_connection_t connection)

Perform TLS handshaking on a new connection. Return incomplete, failure, or 0.

◆ fb_unencrypted_init()

bool fb_unencrypted_init ( struct fb_connection_t connection)

Initialize an unencrypted BSD sockets connection.

◆ fb_unencrypted_read()

ssize_t fb_unencrypted_read ( struct fb_connection_t connection,
char *  data,
ssize_t  byte_count 
)

Read data from an unencrypted BSD Sockets connection.

◆ fb_unencrypted_write()

ssize_t fb_unencrypted_write ( struct fb_connection_t connection,
const char *  data,
ssize_t  byte_count 
)

Write data to an unencrytped BSD Sockets connection.

Variable Documentation

◆ FB_TRANSPORT_CLOSED

const ssize_t FB_TRANSPORT_CLOSED = 0

Connection closed normally. Returned by read transport function only.

◆ FB_TRANSPORT_FAILURE

const ssize_t FB_TRANSPORT_FAILURE = -2

An action failed permanently; the connection has failed and should be closed.

◆ FB_TRANSPORT_INCOMPLETE

const ssize_t FB_TRANSPORT_INCOMPLETE = -1

An action was incomplete, but can be retried in the future.

◆ fb_transport_read_file

const FB_TRANSPORT_FUNCS fb_transport_read_file
Initial value:
= {
.init = fb_file_init,
.read = fb_file_read,
.write = fb_file_write,
.done = fb_file_done
}
ssize_t fb_file_write(struct fb_connection_t *connection, const char *data, ssize_t byte_count)
Definition: fb_transport.c:143
bool fb_file_init(struct fb_connection_t *connection)
Definition: fb_transport.c:121
ssize_t fb_unencrypted_handshake(struct fb_connection_t *connection)
Perform TLS handshaking on a new connection. Return incomplete, failure, or 0.
Definition: fb_transport.c:52
ssize_t fb_file_read(struct fb_connection_t *connection, char *data, ssize_t byte_count)
Definition: fb_transport.c:128
ssize_t fb_unencrypted_buffering(struct fb_connection_t *connection)
Query number of bytes in TLS buffers.
Definition: fb_transport.c:60
void fb_file_done(FB_CONNECTION *connection)
Definition: fb_transport.c:154

Transport virtual method table for reading from files.

◆ fb_transport_unencrypted

const FB_TRANSPORT_FUNCS fb_transport_unencrypted
Initial value:
= {
}
ssize_t fb_unencrypted_write(struct fb_connection_t *connection, const char *data, ssize_t byte_count)
Definition: fb_transport.c:83
void fb_unencrypted_done(FB_CONNECTION *connection)
Definition: fb_transport.c:98
bool fb_unencrypted_init(struct fb_connection_t *connection)
Definition: fb_transport.c:45
ssize_t fb_unencrypted_read(struct fb_connection_t *connection, char *data, ssize_t byte_count)
Definition: fb_transport.c:68

Transport virtual method table for unenrypted connections.