vss: add state variable for fec client
[paraslash.git] / server.h
1 /*
2 * Copyright (C) 1997-2010 Andre Noll <maan@systemlinux.org>
3 *
4 * Licensed under the GPL v2. For licencing details see COPYING.
5 */
6
7 /** \file server.h Common server data structures. */
8
9 /** Size of the selector_info and audio_file info strings of struct misc_meta_data. */
10 #define MMD_INFO_SIZE 16384
11
12 /** The maximum length of the host component in an URL */
13 #define MAX_HOSTLEN 256
14
15
16 /** Holds the arguments for the para_server's sender command. */
17 struct sender_command_data{
18 /** Greater than 0 indicates that a sender cmd is already queued. */
19 int cmd_num;
20 /** The number of the sender in question. */
21 int sender_num;
22 /** Used for the allow/deny/add/remove subcommands. */
23 char host[MAX_HOSTLEN];
24 /** Used for allow/deny. */
25 int netmask;
26 /** The port number for add/remove. */
27 int port;
28 /** Maximal slice size. */
29 uint16_t max_slice_bytes;
30 /** Number of data slices plus redundant slices. */
31 uint8_t slices_per_group;
32 /** Number of slices minus number of redundant slices. */
33 uint8_t data_slices_per_group;
34 };
35
36 /**
37 * Used for parent-child communication.
38 *
39 * There's only one struct of this type which lives in shared memory
40 * for communication between the server instances. Access to this
41 * area is serialized via mmd_lock() and mmd_unlock(). There are two
42 * reasons for a variable to be included here:
43 *
44 * - At least one command (i.e. child of the server) must be able to
45 * change its value.
46 *
47 * or
48 *
49 * - The contents are listed in the stat command and have to be up to
50 * date.
51 */
52 struct misc_meta_data {
53 /** The size of the current audio file in bytes. */
54 size_t size;
55 /** The last modification time of the current audio file. */
56 time_t mtime;
57 /** The "old" status flags -- commands may only read them. */
58 unsigned int vss_status_flags;
59 /** The new status flags -- commands may set them. */
60 unsigned int new_vss_status_flags;
61 /** The number of data chunks sent for the current audio file. */
62 long unsigned chunks_sent;
63 /** Set by the jmp/ff commands to the new position in chunks. */
64 long unsigned repos_request;
65 /** The number of the chunk currently sent out. */
66 long unsigned current_chunk;
67 /** The milliseconds that have been skipped of the current audio file. */
68 long offset;
69 /** The time para_server started to stream. */
70 struct timeval stream_start;
71 /**
72 * The event counter.
73 *
74 * Commands may increase this to force a status update to be sent to all
75 * connected clients.
76 */
77 unsigned int events;
78 /** The number of audio files already sent. */
79 unsigned int num_played;
80 /** The number of executed commands. */
81 unsigned int num_commands;
82 /** The number of connections para_server received so far. */
83 unsigned int num_connects;
84 /** The number of connections currently active. */
85 unsigned int active_connections;
86 /** The process id of the audio file selector. */
87 pid_t afs_pid;
88 /** This gets updated by afs and contains its current mode. */
89 char afs_mode_string[MAXLINE];
90 /** Used by the sender command. */
91 struct sender_command_data sender_cmd_data;
92 /** Describes the current audio file. */
93 struct audio_file_data afd;
94 };
95
96 /** Command line options for para_server. */
97 extern struct server_args_info conf;
98
99 __noreturn void handle_connect(int fd, const char *peername);
100 void parse_config_or_die(int override);