Merge topic branch t/openssl-3 into master
[paraslash.git] / server.h
1 /* Copyright (C) 1997 Andre Noll <maan@tuebingen.mpg.de>, see file COPYING. */
2
3 /** \file server.h Common server data structures. */
4
5 /** Size of the selector_info and audio_file info strings of struct misc_meta_data. */
6 #define MMD_INFO_SIZE 16384
7
8 /** Arguments for the sender command. */
9 struct sender_command_data {
10 /** Greater than zero indicates that a sender cmd is already queued. */
11 int cmd_num;
12 /** The number of the sender in question. */
13 int sender_num;
14 /** Used for the allow/deny/add/remove subcommands. */
15 char host[MAX_HOSTLEN];
16 /** Used for allow/deny. */
17 int netmask;
18 /** The port number for add/remove. */
19 int port;
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;
26 };
27
28 /**
29 * Miscellaneous data for communication between server and command handlers.
30 *
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
36 * mmd_unlock().
37 *
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.
41 */
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. */
54 long offset;
55 /** The time para_server started to stream. */
56 struct timeval stream_start;
57 /**
58 * The event counter.
59 *
60 * Commands may increase this to force a status update to be sent to
61 * all connected stat clients.
62 */
63 unsigned int events;
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. */
77 int loglevel;
78 /** Describes the current audio file. */
79 struct audio_file_data afd;
80 };
81
82 extern pid_t afs_pid;
83 extern struct lls_parse_result *server_lpr;
84
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))
88
89 /** How many times a server option was given. */
90 #define OPT_GIVEN(_name) (lls_opt_given(OPT_RESULT(_name)))
91
92 /** The (first) argument to a server option of type string. */
93 #define OPT_STRING_VAL(_name) (lls_string_val(0, OPT_RESULT(_name)))
94
95 /** The (first) argument to a server option of type uint32. */
96 #define OPT_UINT32_VAL(_name) (lls_uint32_val(0, OPT_RESULT(_name)))
97
98 /** The (first) argument to a server option of type int32. */
99 #define OPT_INT32_VAL(_name) (lls_int32_val(0, OPT_RESULT(_name)))
100
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);
105 void free_lpr(void);