Paraslash Audio Streaming | |
About News Download Documentation Development |
Sender-related defines and structures. More...
Data Structures | |
struct | sender |
Describes one supported sender of para_server. More... | |
struct | sender_client |
Describes one client, connected to a paraslash sender. More... | |
struct | fec_client_parms |
Each paraslash sender may register arbitrary many clients to the virtual streaming system, possibly with varying fec parameters. More... | |
struct | sender_status |
Describes the current status of one paraslash sender. More... | |
Macros | |
#define | SENDER_SUBCOMMANDS |
A little preprocessor fu helps to create the sender_subcommand enumeration below and the list of sender name strings without duplicating the commands. More... | |
#define | SENDER_SUBCOMMAND(_name) SENDER_ ## _name, |
Concatenate "SENDER_" and the given arg and append a comma. More... | |
#define | SENDER_SUBCOMMAND(_name) #_name, |
Concatenate "SENDER_" and the given arg and append a comma. More... | |
#define | FOR_EACH_SENDER(_i) for ((_i) = 0; senders[(_i)]; (_i)++) |
Iterate over all senders. More... | |
#define | FOR_EACH_LISTEN_FD(_n, _ss) for (_n = 0; _n < (_ss)->num_listen_fds; _n++) |
Iterate over all listening addresses of the http/dccp sender. More... | |
Enumerations | |
enum | sender_subcommand { SENDER_add, SENDER_delete, SENDER_allow, SENDER_deny, SENDER_on, SENDER_off, NUM_SENDER_CMDS } |
Each sender subcommand gets an SENDER_xxx identifier. More... | |
Functions | |
void | shutdown_client (struct sender_client *sc, struct sender_status *ss) |
Shut down a client connected to a paraslash sender. More... | |
void | shutdown_clients (struct sender_status *ss) |
Shut down all clients connected to a paraslash sender. More... | |
void | init_sender_status (struct sender_status *ss, const struct lls_opt_result *acl_opt_result, const struct lls_opt_result *listen_address_opt_result, int default_port, int max_clients, int default_deny) |
Initialize a struct sender status. More... | |
void | free_sender_status (const struct sender_status *ss) |
Deallocate all resources allocated in init_sender_status(). More... | |
__malloc char * | generic_sender_status (struct sender_status *ss, const char *name) |
Return a string containing the current status of a sender. More... | |
void | generic_com_allow (struct sender_command_data *scd, struct sender_status *ss) |
Allow connections from the given range of IP addresses. More... | |
void | generic_com_deny (struct sender_command_data *scd, struct sender_status *ss) |
Deny connections from the given range of IP addresses. More... | |
void | generic_com_on (struct sender_status *ss, unsigned protocol) |
Activate a paraslash sender. More... | |
void | generic_acl_deplete (struct list_head *acl) |
Empty the access control list of a sender. More... | |
void | generic_com_off (struct sender_status *ss) |
Deactivate a paraslash sender. More... | |
__malloc char * | generic_sender_help (void) |
Get the generic help text. More... | |
struct sender_client * | accept_sender_client (struct sender_status *ss) |
Accept a connection on the socket(s) this server is listening on. More... | |
int | send_queued_chunks (int fd, struct chunk_queue *cq) |
Try to empty the chunk queue for this fd. More... | |
int | parse_fec_url (const char *arg, struct sender_command_data *scd) |
Parse a FEC URL string. More... | |
Variables | |
const struct sender *const | senders [] |
NULL-terminated list, defined in vss.c. More... | |
Sender-related defines and structures.
#define SENDER_SUBCOMMANDS |
A little preprocessor fu helps to create the sender_subcommand enumeration below and the list of sender name strings without duplicating the commands.
Deactivate the sender.
#define SENDER_SUBCOMMAND | ( | _name | ) | SENDER_ ## _name, |
Concatenate "SENDER_" and the given arg and append a comma.
Redefine it to expand to the stringified name of the sender so that SENDER_SUBCOMMANDS above now expands to the comma-separated list of sender name strings.
This is used in command.c to define and initialize an array of char pointers.
#define SENDER_SUBCOMMAND | ( | _name | ) | #_name, |
Concatenate "SENDER_" and the given arg and append a comma.
Redefine it to expand to the stringified name of the sender so that SENDER_SUBCOMMANDS above now expands to the comma-separated list of sender name strings.
This is used in command.c to define and initialize an array of char pointers.
#define FOR_EACH_SENDER | ( | _i | ) | for ((_i) = 0; senders[(_i)]; (_i)++) |
Iterate over all senders.
#define FOR_EACH_LISTEN_FD | ( | _n, | |
_ss | |||
) | for (_n = 0; _n < (_ss)->num_listen_fds; _n++) |
Iterate over all listening addresses of the http/dccp sender.
enum sender_subcommand |
Each sender subcommand gets an SENDER_xxx identifier.
The identifier is passed from the sender command handler to the server process via shared memory.
Enumerator | |
---|---|
SENDER_add | Add a target (udp only). |
SENDER_delete | Delete a target (udp only). |
SENDER_allow | Allow connections from given IP address(es). |
SENDER_deny | Deny connections from given IP address(es). |
SENDER_on | Activate the sender. |
SENDER_off | Deactivate the sender. List of SENDER_xxx identifiers. |
NUM_SENDER_CMDS | Used as array size in struct sender. |
void shutdown_client | ( | struct sender_client * | sc, |
struct sender_status * | ss | ||
) |
Shut down a client connected to a paraslash sender.
sc | The client to shut down. |
ss | The sender whose clients are to be shut down. |
Close the file descriptor given by sc, remove it from the close-on-fork list, destroy the chunk queue of this client, delete the client from the list of connected clients and free the sender_client struct.
References sender_client::cq, cq_destroy(), del_close_on_fork_list(), sender_client::fd, sender_client::name, PARA_INFO_LOG, and process_is_command_handler().
Referenced by shutdown_clients().
void shutdown_clients | ( | struct sender_status * | ss | ) |
Shut down all clients connected to a paraslash sender.
ss | The sender whose clients are to be shut down. |
This just loops over all connected clients and calls shutdown_client() for each client.
References sender_status::client_list, list_for_each_entry_safe, sender_client::node, and shutdown_client().
Referenced by generic_com_off().
void init_sender_status | ( | struct sender_status * | ss, |
const struct lls_opt_result * | acl_opt_result, | ||
const struct lls_opt_result * | listen_address_opt_result, | ||
int | default_port, | ||
int | max_clients, | ||
int | default_deny | ||
) |
Initialize a struct sender status.
ss | The struct to initialize. |
acl_opt_result | Contains array of –{http|dccp}-access arguments. |
listen_address_opt_result | Where to listen on. |
default_port | Used for addresses with no specified port. |
max_clients | The maximal number of simultaneous connections. |
default_deny | Whether a blacklist should be used for access control. |
References alloc(), sender_status::default_port, FOR_EACH_LISTEN_FD, sender_status::listen_addresses, sender_status::listen_fds, sender_status::num_listen_fds, and para_strdup().
void free_sender_status | ( | const struct sender_status * | ss | ) |
Deallocate all resources allocated in init_sender_status().
ss | The structure whose components should be freed. |
This frees the dynamically allocated parts of the structure which was initialized by an earlier call to init_sender_status(). It does not call free(ss), though.
References FOR_EACH_LISTEN_FD, sender_status::listen_addresses, and sender_status::listen_fds.
__malloc char* generic_sender_status | ( | struct sender_status * | ss, |
const char * | name | ||
) |
Return a string containing the current status of a sender.
ss | The sender. |
name | Used for printing the header line. |
References sender_status::acl, acl_get_contents(), sender_status::client_list, sender_status::default_deny, sender_status::default_port, FOR_EACH_LISTEN_FD, format_url(), list_for_each_entry_safe, sender_status::listen_addresses, sender_status::listen_fds, make_message(), sender_status::max_clients, sender_client::name, sender_client::node, sender_status::num_clients, and stringify_port().
void generic_com_allow | ( | struct sender_command_data * | scd, |
struct sender_status * | ss | ||
) |
Allow connections from the given range of IP addresses.
scd | Contains the IP and the netmask. |
ss | The sender. |
References sender_status::acl, acl_allow(), sender_status::default_deny, sender_command_data::host, and sender_command_data::netmask.
void generic_com_deny | ( | struct sender_command_data * | scd, |
struct sender_status * | ss | ||
) |
Deny connections from the given range of IP addresses.
scd | see generic_com_allow(). |
ss | see generic_com_allow(). |
References sender_status::acl, acl_deny(), sender_status::default_deny, sender_command_data::host, and sender_command_data::netmask.
void generic_com_on | ( | struct sender_status * | ss, |
unsigned | protocol | ||
) |
Activate a paraslash sender.
ss | The sender to activate. |
protocol | layer4 type (IPPROTO_TCP or IPPROTO_DCCP). |
This opens a passive socket of given layer4 type, sets the resulting file descriptor to nonblocking mode and adds it to the close on fork list.
Errors are logged but otherwise ignored.
References add_close_on_fork_list(), sender_status::default_port, FOR_EACH_LISTEN_FD, format_url(), sender_status::listen_addresses, sender_status::listen_fds, mark_fd_nonblocking(), PARA_ERROR_LOG, para_listen(), and para_strerror().
void generic_acl_deplete | ( | struct list_head * | acl | ) |
Empty the access control list of a sender.
acl | The access control list of the sender. |
This is called from the ->shutdown methods of the http and the dccp sender.
References acl_allow().
void generic_com_off | ( | struct sender_status * | ss | ) |
Deactivate a paraslash sender.
Shutdown all connected clients and stop listening on the TCP/DCCP socket.
ss | The sender to deactivate. |
References del_close_on_fork_list(), FOR_EACH_LISTEN_FD, sender_status::listen_fds, and shutdown_clients().
__malloc char* generic_sender_help | ( | void | ) |
Get the generic help text.
References make_message().
struct sender_client* accept_sender_client | ( | struct sender_status * | ss | ) |
Accept a connection on the socket(s) this server is listening on.
ss | The sender whose listening fd is ready for reading. |
This accepts incoming connections on any of the listening sockets of the server. If there is a connection pending, the function
- Checks whether the maximal number of connections are exceeded. - Sets \a fd to nonblocking mode. - Checks the acl of the sender to find out whether connections are allowed from the IP of the connecting peer. - Increases the number of connections for this sender. - Creates and initializes a new chunk queue for queuing network packets that can not be sent immediately. - Allocates a new struct sender_client and fills in its \a fd, \a cq and \a name members. - Adds \a fd to the list of connected clients for this sender. - Adds \a fd to the list of file descriptors that should be closed in the child process when the server calls fork().
NULL
on errors.References sender_status::acl, acl_check_access(), sender_client::cq, cq_new(), sender_status::default_deny, sender_client::fd, FOR_EACH_LISTEN_FD, sender_status::listen_fds, mark_fd_nonblocking(), sender_status::max_clients, MAX_CQ_BYTES, sender_client::name, sender_status::num_clients, para_accept(), para_strdup(), remote_name(), and zalloc().
int send_queued_chunks | ( | int | fd, |
struct chunk_queue * | cq | ||
) |
Try to empty the chunk queue for this fd.
fd | The file descriptor. |
cq | The list of queued chunks. |
References cq_dequeue(), cq_get(), cq_peek(), cq_update(), and xwrite().
int parse_fec_url | ( | const char * | arg, |
struct sender_command_data * | scd | ||
) |
Parse a FEC URL string.
arg | the URL string to parse. |
scd | The structure containing host, port and the FEC parameters. |
A FEC URL consists of an ordinary URL string according to RFC 3986, optionally followed by a slash and the three FEC parameters slice_size, data_slices_per_group and slices_per_group. The three FEC parameters are separated by colons.
References sender_command_data::data_slices_per_group, sender_command_data::max_slice_bytes, para_strdup(), and sender_command_data::slices_per_group.
|
extern |
NULL-terminated list, defined in vss.c.
Referenced by vss_shutdown().