1 /* Copyright (C) 1997 Andre Noll <maan@tuebingen.mpg.de>, see file COPYING. */
3 /** \file server.h Common server data structures. */
5 /** Size of the selector_info and audio_file info strings of struct misc_meta_data. */
6 #define MMD_INFO_SIZE 16384
8 /** Arguments for the sender command. */
9 struct sender_command_data {
10 /** Greater than zero indicates that a sender cmd is already queued. */
12 /** The number of the sender in question. */
14 /** Used for the allow/deny/add/remove subcommands. */
15 char host[MAX_HOSTLEN];
16 /** Used for allow/deny. */
18 /** The port number for add/remove. */
20 /** Maximal slice size. */
21 uint16_t max_slice_bytes;
22 /** Number of data slices plus redundant slices. */
23 uint8_t slices_per_group;
24 /** Number of slices minus number of redundant slices. */
25 uint8_t data_slices_per_group;
29 * Miscellaneous data for communication between server and command handlers.
31 * There's only one instance of this structure which lives in a shared memory
32 * area. Command handlers communicate with the server process through this
33 * area. Changes made by the command handlers stay after the command handler
34 * exits. Conversely, changes made by the server process propagate to the
35 * command handlers. Access to this area is serialized via mmd_lock() and
38 * There are two reasons for a variable to be included here: (a) at least one
39 * command handler changes its value, or (b) updates by the server must
40 * propagate to the stat command handlers.
42 struct misc_meta_data {
43 /** The "old" status flags -- commands may only read them. */
44 unsigned int vss_status_flags;
45 /** The new status flags -- commands may set them. */
46 unsigned int new_vss_status_flags;
47 /** The number of data chunks sent so far. */
48 long unsigned chunks_sent;
49 /** Set by the jmp/ff commands to the new position in chunks. */
50 long unsigned repos_request;
51 /** The number of the chunk currently being sent. */
52 long unsigned current_chunk;
53 /** The milliseconds that have been skipped of the current audio file. */
55 /** The time para_server started to stream. */
56 struct timeval stream_start;
60 * Commands may increase this to force a status update to be sent to
61 * all connected stat clients.
64 /** The number of audio files already sent. */
65 unsigned int num_played;
66 /** The number of executed commands. */
67 unsigned int num_commands;
68 /** The number of connections para_server received so far. */
69 unsigned int num_connects;
70 /** The number of connections currently active. */
71 unsigned int active_connections;
72 /** This gets updated by afs and contains its current mode. */
73 char afs_mode_string[MAXLINE];
74 /** Used by the sender command. */
75 struct sender_command_data sender_cmd_data;
76 /** Set by the ll command. */
78 /** Describes the current audio file. */
79 struct audio_file_data afd;
83 extern struct lls_parse_result *server_lpr;
85 /** Get the parse result of an option to para_server. */
86 #define OPT_RESULT(_name) (lls_opt_result( \
87 LSG_SERVER_PARA_SERVER_OPT_ ## _name, server_lpr))
89 /** How many times a server option was given. */
90 #define OPT_GIVEN(_name) (lls_opt_given(OPT_RESULT(_name)))
92 /** The (first) argument to a server option of type string. */
93 #define OPT_STRING_VAL(_name) (lls_string_val(0, OPT_RESULT(_name)))
95 /** The (first) argument to a server option of type uint32. */
96 #define OPT_UINT32_VAL(_name) (lls_uint32_val(0, OPT_RESULT(_name)))
98 /** The (first) argument to a server option of type int32. */
99 #define OPT_INT32_VAL(_name) (lls_int32_val(0, OPT_RESULT(_name)))
101 int handle_connect(int fd);
102 void parse_config_or_die(bool reload);
103 char *server_get_tasks(void);
104 bool process_is_command_handler(void);