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 /** This gets updated by afs and contains its current mode. */
77 char afs_mode_string[MAXLINE];
78 /** Used by the sender command. */
79 struct sender_command_data sender_cmd_data;
80 /** Describes the current audio file. */
81 struct audio_file_data afd;
85 extern struct lls_parse_result *server_lpr;
88 * Get a reference to the supercommand of para_server.
90 * This is needed for parsing the command line and for the ENUM_STRING_VAL()
91 * macro below. The latter macro is used in command.c, so CMD_PTR() can not
92 * be made local to server.c.
94 #define CMD_PTR (lls_cmd(0, server_suite))
96 /** Get the parse result of an option to para_server. */
97 #define OPT_RESULT(_name) (lls_opt_result( \
98 LSG_SERVER_PARA_SERVER_OPT_ ## _name, server_lpr))
100 /** How many times a server option was given. */
101 #define OPT_GIVEN(_name) (lls_opt_given(OPT_RESULT(_name)))
103 /** The (first) argument to a server option of type string. */
104 #define OPT_STRING_VAL(_name) (lls_string_val(0, OPT_RESULT(_name)))
106 /** The (first) argument to a server option of type uint32. */
107 #define OPT_UINT32_VAL(_name) (lls_uint32_val(0, OPT_RESULT(_name)))
109 /** The (first) argument to a server option of type int32. */
110 #define OPT_INT32_VAL(_name) (lls_int32_val(0, OPT_RESULT(_name)))
112 /** Get the string which corresponds to an enum constant. */
113 #define ENUM_STRING_VAL(_name) (lls_enum_string_val(OPT_UINT32_VAL(_name), \
114 lls_opt(LSG_SERVER_PARA_SERVER_OPT_ ## _name, CMD_PTR)))
116 int handle_connect(int fd);
117 void parse_config_or_die(bool reload);
118 char *server_get_tasks(void);
119 bool process_is_command_handler(void);