Basic infrastructure changes for FEC/DCCP support.
[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 /** Number of data slices plus redundant slices. */
29 uint8_t slices_per_group;
30 /** Number of slices minus number of redundant slices. */
31 uint8_t data_slices_per_group;
32 };
33
34 /**
35 * Used for parent-child communication.
36 *
37 * There's only one struct of this type which lives in shared memory
38 * for communication between the server instances. Access to this
39 * area is serialized via mmd_lock() and mmd_unlock(). There are two
40 * reasons for a variable to be included here:
41 *
42 * - At least one command (i.e. child of the server) must be able to
43 * change its value.
44 *
45 * or
46 *
47 * - The contents are listed in the stat command and have to be up to
48 * date.
49 */
50 struct misc_meta_data {
51 /** The size of the current audio file in bytes. */
52 size_t size;
53 /** The last modification time of the current audio file. */
54 time_t mtime;
55 /** The "old" status flags -- commands may only read them. */
56 unsigned int vss_status_flags;
57 /** The new status flags -- commands may set them. */
58 unsigned int new_vss_status_flags;
59 /** The number of data chunks sent for the current audio file. */
60 long unsigned chunks_sent;
61 /** Set by the jmp/ff commands to the new position in chunks. */
62 long unsigned repos_request;
63 /** The number of the chunk currently sent out. */
64 long unsigned current_chunk;
65 /** The milliseconds that have been skipped of the current audio file. */
66 long offset;
67 /** The time para_server started to stream. */
68 struct timeval stream_start;
69 /**
70 * The event counter.
71 *
72 * Commands may increase this to force a status update to be sent to all
73 * connected clients.
74 */
75 unsigned int events;
76 /** The number of audio files already sent. */
77 unsigned int num_played;
78 /** The number of executed commands. */
79 unsigned int num_commands;
80 /** The number of connections para_server received so far. */
81 unsigned int num_connects;
82 /** The number of connections currently active. */
83 unsigned int active_connections;
84 /** The process id of the audio file selector. */
85 pid_t afs_pid;
86 /** This gets updated by afs and contains its current mode. */
87 char afs_mode_string[MAXLINE];
88 /** Used by the sender command. */
89 struct sender_command_data sender_cmd_data;
90 /** Describes the current audio file. */
91 struct audio_file_data afd;
92 };
93
94 /** Command line options for para_server. */
95 extern struct server_args_info conf;
96
97 __noreturn void handle_connect(int fd, const char *peername);
98 void parse_config_or_die(int override);