|
pianod2
multisource multiuser scriptable networked music player
|
Football service and connection creation/destruction. More...
#include <config.h>#include <stdio.h>#include <errno.h>#include <stdlib.h>#include <string.h>#include <unistd.h>#include <fcntl.h>#include <sys/types.h>#include <sys/socket.h>#include <netinet/in.h>#include <arpa/inet.h>#include <assert.h>#include "fb_transport.h"#include "fb_service.h"
Macros | |
| #define | _BSD_SOURCE /* strdup, realpath */ |
| #define | _DEFAULT_SOURCE |
Functions | |
| bool | fb_services_are_open (void) |
| Indicate whether there are any services open. More... | |
| static bool | fb_sanitize_socket (int socket) |
| static bool | fb_setup_socket (FB_SERVICE *service, FB_SOCKETID which) |
| FB_SERVICE * | fb_create_service (const FB_SERVICE_OPTIONS *options) |
| Create a new service and initialize its listeners. More... | |
| void | fb_destroy_service (FB_SERVICE *service) |
| void | fb_close_service (FB_SERVICE *service) |
| Initiate closure of a service. More... | |
| bool | fb_validate_connection (FB_SERVICE *service, FB_CONNECTION *connection) |
| Validate connection with hosts_access. More... | |
| static FB_CONNECTION * | fb_new_connection (FB_SERVICE *service) |
| FB_CONNECTION * | fb_accept_connection (FB_SERVICE *service, FB_SOCKETID id) |
| static void | fb_remove_connection_from_service (FB_SERVICE *service, FB_CONNECTION *connection) |
| bool | fb_transfer (FB_CONNECTION *connection, FB_SERVICE *service) |
| Transfer a connection to a new service. More... | |
| bool | fb_transfer_by_name (FB_CONNECTION *connection, const char *name) |
| void | fb_destroy_connection (FB_CONNECTION *connection) |
| void | fb_close_connection (FB_CONNECTION *connection) |
| Initiate connection closure. More... | |
| FB_EVENT * | fb_accept_file (FB_SERVICE *service, char *filename) |
| Make a connection that reads from a file. More... | |
| FB_EVENT * | fb_loopback_socket (FB_SERVICE *service) |
| Make a connection with a pipe. More... | |
| FB_ITERATOR * | fb_new_iterator (FB_SERVICE *service) |
| Create a new iterator. More... | |
| FB_EVENT * | fb_iterate_next (FB_ITERATOR *it) |
| Get the next iteration. More... | |
| void | fb_destroy_iterator (FB_ITERATOR *it) |
| Destroy an iterator and release its resources. More... | |
Variables | |
| static int | fb_open_service_count = 0 |
Football service and connection creation/destruction.
| #define _BSD_SOURCE /* strdup, realpath */ |
| #define _DEFAULT_SOURCE |
| FB_CONNECTION* fb_accept_connection | ( | FB_SERVICE * | service, |
| FB_SOCKETID | id | ||
| ) |
Accept a connection.
| service | The service on which a connection is arriving. |
| id | Identifies the arrival socket (line, HTTP, TLS, IP4 vs IP6) |


| FB_EVENT* fb_accept_file | ( | FB_SERVICE * | service, |
| char * | filename | ||
| ) |
Make a connection that reads from a file.
| service | the service to register the connection with |
| filename | the file to read from |


| void fb_close_connection | ( | FB_CONNECTION * | connection | ) |
Initiate connection closure.
If the socket is in an open state, change its state and enable writes. The next write attempt will generate a close event. If the connection is already on its way out, leave it alone.
| connection | the connection to close |


| void fb_close_service | ( | FB_SERVICE * | service | ) |
Initiate closure of a service.


| FB_SERVICE* fb_create_service | ( | const FB_SERVICE_OPTIONS * | options | ) |
Create a new service and initialize its listeners.
Subsequent changes made to the options do not effect behavior.
| options | Options for the new service's behavior. |


| void fb_destroy_connection | ( | FB_CONNECTION * | connection | ) |
Close and destroy a connection.


| void fb_destroy_iterator | ( | FB_ITERATOR * | it | ) |
Destroy an iterator and release its resources.
| it | The iterator |
| void fb_destroy_service | ( | FB_SERVICE * | service | ) |
Destroy a service's resources. Abruptly closes any remaining connections, frees them, closes listener sockets and frees service.
| service | the service to terminate. |


| FB_EVENT* fb_iterate_next | ( | FB_ITERATOR * | it | ) |
Get the next iteration.
| it | The iterator |


| FB_EVENT* fb_loopback_socket | ( | FB_SERVICE * | service | ) |
Make a connection with a pipe.
| service | the service to register the connection with |


|
static |
Prepare a new connection. Make space in the service's connection array, allocate a connection and (if requested in service options) a user context. Any mutexing is expected to be handled by the caller.
| service | the service for the new connection. |


| FB_ITERATOR* fb_new_iterator | ( | FB_SERVICE * | service | ) |
Create a new iterator.
Create and initialize a new iterator for a service.
|
static |
Remove a connection from a service's connection list.
| service | The service to remove from. |
| connection | The connection to remove. |

|
static |
Set sane options on a socket after opening.
| socket | The socket to sanitize. |

| bool fb_services_are_open | ( | void | ) |
Indicate whether there are any services open.

|
static |
Initialize and set up a listening socket.


| bool fb_transfer | ( | FB_CONNECTION * | connection, |
| FB_SERVICE * | service | ||
| ) |
Transfer a connection to a new service.
| connection | The connection to transfer. |
| service | The service to reassign it to. |


| bool fb_transfer_by_name | ( | FB_CONNECTION * | connection, |
| const char * | name | ||
| ) |
Transfer a connection to a related service.
| connection | The connection to transfer. |
| name | The name of the service to reassign it to. |


| bool fb_validate_connection | ( | FB_SERVICE * | service, |
| FB_CONNECTION * | connection | ||
| ) |
Validate connection with hosts_access.
| service | The service on which the connection is arriving. |
| connection | The connection. |

|
static |