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 /** The maximum length of the host component in an URL */
9 #define MAX_HOSTLEN 256
12 /** Arguments for the sender command. */
13 struct sender_command_data {
14 /** Greater than zero indicates that a sender cmd is already queued. */
16 /** The number of the sender in question. */
18 /** Used for the allow/deny/add/remove subcommands. */
19 char host[MAX_HOSTLEN];
20 /** Used for allow/deny. */
22 /** The port number for add/remove. */
24 /** Maximal slice size. */
25 uint16_t max_slice_bytes;
26 /** Number of data slices plus redundant slices. */
27 uint8_t slices_per_group;
28 /** Number of slices minus number of redundant slices. */
29 uint8_t data_slices_per_group;
33 * Miscellaneous data for communication between server and command handlers.
35 * There's only one instance of this structure which lives in a shared memory
36 * area. Command handlers communicate with the server process through this
37 * area. Changes made by the command handlers stay after the command handler
38 * exits. Conversely, changes made by the server process propagate to the
39 * command handlers. Access to this area is serialized via mmd_lock() and
42 * There are two reasons for a variable to be included here: (a) at least one
43 * command handler changes its value, or (b) updates by the server must
44 * propagate to the stat command handlers.
46 struct misc_meta_data {
47 /** The "old" status flags -- commands may only read them. */
48 unsigned int vss_status_flags;
49 /** The new status flags -- commands may set them. */
50 unsigned int new_vss_status_flags;
51 /** The number of data chunks sent so far. */
52 long unsigned chunks_sent;
53 /** Set by the jmp/ff commands to the new position in chunks. */
54 long unsigned repos_request;
55 /** The number of the chunk currently being sent. */
56 long unsigned current_chunk;
57 /** The milliseconds that have been skipped of the current audio file. */
59 /** The time para_server started to stream. */
60 struct timeval stream_start;
64 * Commands may increase this to force a status update to be sent to
65 * all connected stat clients.
68 /** The number of audio files already sent. */
69 unsigned int num_played;
70 /** The number of executed commands. */
71 unsigned int num_commands;
72 /** The number of connections para_server received so far. */
73 unsigned int num_connects;
74 /** The number of connections currently active. */
75 unsigned int active_connections;
76 /** The process id of the audio file selector. */
78 /** This gets updated by afs and contains its current mode. */
79 char afs_mode_string[MAXLINE];
80 /** Used by the sender command. */
81 struct sender_command_data sender_cmd_data;
82 /** Describes the current audio file. */
83 struct audio_file_data afd;
86 extern struct lls_parse_result *server_lpr;
89 * Get a reference to the supercommand of para_server.
91 * This is needed for parsing the command line and for the ENUM_STRING_VAL()
92 * macro below. The latter macro is used in command.c, so CMD_PTR() can not
93 * be made local to server.c.
95 #define CMD_PTR (lls_cmd(0, server_suite))
97 /** Get the parse result of an option to para_server. */
98 #define OPT_RESULT(_name) (lls_opt_result( \
99 LSG_SERVER_PARA_SERVER_OPT_ ## _name, server_lpr))
101 /** How many times a server option was given. */
102 #define OPT_GIVEN(_name) (lls_opt_given(OPT_RESULT(_name)))
104 /** The (first) argument to a server option of type string. */
105 #define OPT_STRING_VAL(_name) (lls_string_val(0, OPT_RESULT(_name)))
107 /** The (first) argument to a server option of type uint32. */
108 #define OPT_UINT32_VAL(_name) (lls_uint32_val(0, OPT_RESULT(_name)))
110 /** The (first) argument to a server option of type int32. */
111 #define OPT_INT32_VAL(_name) (lls_int32_val(0, OPT_RESULT(_name)))
113 /** Get the string which corresponds to an enum constant. */
114 #define ENUM_STRING_VAL(_name) (lls_enum_string_val(OPT_UINT32_VAL(_name), \
115 lls_opt(LSG_SERVER_PARA_SERVER_OPT_ ## _name, CMD_PTR)))
117 __noreturn void handle_connect(int fd, const char *peername);
118 void parse_config_or_die(bool reload);
119 char *server_get_tasks(void);