paraslash Paraslash Audio Streaming
About   News   Download   Documentation   Development

Data Structures | Macros | Functions | Variables
server.h File Reference

Common server data structures. More...

Data Structures

struct  sender_command_data
 Arguments for the sender command. More...
 
struct  misc_meta_data
 Miscellaneous data for communication between server and command handlers. More...
 

Macros

#define MMD_INFO_SIZE   16384
 Size of the selector_info and audio_file info strings of struct misc_meta_data. More...
 
#define OPT_RESULT(_name)
 Get the parse result of an option to para_server. More...
 
#define OPT_GIVEN(_name)   (lls_opt_given(OPT_RESULT(_name)))
 How many times a server option was given. More...
 
#define OPT_STRING_VAL(_name)   (lls_string_val(0, OPT_RESULT(_name)))
 The (first) argument to a server option of type string. More...
 
#define OPT_UINT32_VAL(_name)   (lls_uint32_val(0, OPT_RESULT(_name)))
 The (first) argument to a server option of type uint32. More...
 
#define OPT_INT32_VAL(_name)   (lls_int32_val(0, OPT_RESULT(_name)))
 The (first) argument to a server option of type int32. More...
 

Functions

int handle_connect (int fd)
 Perform user authentication and execute a command. More...
 
void parse_config_or_die (bool reload)
 (Re-)read the server configuration files. More...
 
char * server_get_tasks (void)
 Return the list of tasks for the server process. More...
 
bool process_is_command_handler (void)
 Tell whether the executing process is a command handler. More...
 
void free_lpr (void)
 Deallocate all lopsub parse results. More...
 

Variables

pid_t afs_pid
 The process id of the audio file selector process. More...
 
struct lls_parse_result * server_lpr
 The active value for all config options of para_server. More...
 

Detailed Description

Common server data structures.

Macro Definition Documentation

◆ MMD_INFO_SIZE

#define MMD_INFO_SIZE   16384

Size of the selector_info and audio_file info strings of struct misc_meta_data.

◆ OPT_RESULT

#define OPT_RESULT (   _name)
Value:
(lls_opt_result( \
LSG_SERVER_PARA_SERVER_OPT_ ## _name, server_lpr))

Get the parse result of an option to para_server.

◆ OPT_GIVEN

#define OPT_GIVEN (   _name)    (lls_opt_given(OPT_RESULT(_name)))

How many times a server option was given.

◆ OPT_STRING_VAL

#define OPT_STRING_VAL (   _name)    (lls_string_val(0, OPT_RESULT(_name)))

The (first) argument to a server option of type string.

◆ OPT_UINT32_VAL

#define OPT_UINT32_VAL (   _name)    (lls_uint32_val(0, OPT_RESULT(_name)))

The (first) argument to a server option of type uint32.

◆ OPT_INT32_VAL

#define OPT_INT32_VAL (   _name)    (lls_int32_val(0, OPT_RESULT(_name)))

The (first) argument to a server option of type int32.

Function Documentation

◆ handle_connect()

int handle_connect ( int  fd)

Perform user authentication and execute a command.

Parameters
fdThe file descriptor to send output to.

Whenever para_server accepts an incoming tcp connection on the port it listens on, it forks and the resulting child calls this function.

An RSA-based challenge/response is used to authenticate the peer. If the authentication succeeds, a random session key is generated and sent back to the peer, encrypted with its RSA public key. From this point on, all transfers are encrypted with this session key using a stream cipher.

Next it is checked if the peer supplied a valid server command or a command for the audio file selector. If yes, and if the user has sufficient permissions to execute this command, the function calls the corresponding command handler which performs argument checking and further processing.

To cope with DOS attacks, a timer is set up right after the fork. If the connection was still not authenticated when the timeout expires, the child process is terminated.

Returns
Standard.
See also
alarm(2), openssl.c, crypt.h.

References APC_CHALLENGE_SIZE, stream_cipher_context::fd, HANDSHAKE_BUFSIZE, HASH2_SIZE, command_context::scc, SESSION_KEY_LEN, and command_context::u.

◆ parse_config_or_die()

void parse_config_or_die ( bool  reload)

(Re-)read the server configuration files.

Parameters
reloadWhether config file overrides command line.

This function also re-opens the logfile and the user list. On SIGHUP it is called from both server and afs context.

References MCF_DONT_FREE, and server_lpr.

◆ server_get_tasks()

char* server_get_tasks ( void  )

Return the list of tasks for the server process.

This is called from com_tasks(). The helper is necessary since command handlers can not access the scheduler structure directly.

Returns
A dynamically allocated string that must be freed by the caller.

References get_task_list().

◆ process_is_command_handler()

bool process_is_command_handler ( void  )

Tell whether the executing process is a command handler.

Cleanup on exit must be performed differently for command handlers.

Returns
True if the pid of the executing process is neither the server pid nor the afs pid.

References afs_pid.

Referenced by shutdown_client(), and vss_shutdown().

◆ free_lpr()

void free_lpr ( void  )

Deallocate all lopsub parse results.

The server allocates a parse result for command line options and optionally a second parse result for the effective configuration, defined by merging the command line options with the options stored in the configuration file. This function frees both structures.

References CMD_PTR, and server_lpr.

Variable Documentation

◆ afs_pid

pid_t afs_pid
extern

The process id of the audio file selector process.

Referenced by process_is_command_handler().

◆ server_lpr

struct lls_parse_result* server_lpr
extern

The active value for all config options of para_server.

It is computed by merging the parse result of the command line options with the parse result of the config file.

Referenced by free_lpr(), and parse_config_or_die().

server_lpr
struct lls_parse_result * server_lpr
The active value for all config options of para_server.
Definition: server.c:60