From: Andre Noll Date: Sun, 13 May 2018 12:03:20 +0000 (+0200) Subject: Merge branch 'refs/heads/t/crypt' X-Git-Tag: v0.6.2~5 X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=commitdiff_plain;h=3998a8c581623224b7b56bce593646b2c8516a0f;hp=0ad0518b47e4637ad3a4ce12adecffb3b557bc40 Merge branch 'refs/heads/t/crypt' A couple of simple patches which clean up the openssl and gcrypt crypto backends. The non-trivial parts are the get_public_key() unification, the memory leak fixes for openssl and the activation of the secmem pool for gcrypt. * refs/heads/t/crypt: gcrypt: Allocate a secmem pool at startup. crypt: Introduce crypt_shutdown(). crypt: Rename init_random_seed_or_die() -> crypt_init(). gcrypt: Use ROUND_DOWN() macro. crypt: Rename RSA functions. crypt: Deduplicate get_public_key(). crypt.h: Remove two unused constants. Rename crypt.c -> openssl.c. --- diff --git a/Doxyfile b/Doxyfile index d8960dde..b11683e4 100644 --- a/Doxyfile +++ b/Doxyfile @@ -812,7 +812,7 @@ RECURSIVE = NO # Note that relative paths are relative to the directory from which doxygen is # run. -EXCLUDE = +EXCLUDE = config.h # The EXCLUDE_SYMLINKS tag can be used to select whether or not files or # directories that are symbolic links (a Unix file system feature) are excluded diff --git a/NEWS.md b/NEWS.md index d0bd6585..11f275da 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,6 +1,15 @@ NEWS ==== +------------------------------------------- +0.6.2 (to be accounced) "elastic diversity" +------------------------------------------- + +- para_gui no longer waits up to one second to update the screen when + the geometry of the terminal changes. +- Minor documentation improvements. +- Improvements to the crypto subsystem. + ---------------------------------------- 0.6.1 (2017-09-23) "segmented iteration" ---------------------------------------- diff --git a/afh_recv.c b/afh_recv.c index c3e6ddbd..6525209b 100644 --- a/afh_recv.c +++ b/afh_recv.c @@ -68,7 +68,7 @@ static int afh_recv_open(struct receiver_node *rn) struct lls_parse_result *lpr = rn->lpr; struct private_afh_recv_data *pard; struct afh_info *afhi; - const char *fn = RECV_CMD_OPT_STRING_VAL(AFH, FILENAME, lpr); + const char *fn = RECV_CMD_OPT_STRING_VAL(AFH, FILENAME, lpr), *msg; int32_t bc = RECV_CMD_OPT_INT32_VAL(AFH, BEGIN_CHUNK, lpr); const struct lls_opt_result *r_e = RECV_CMD_OPT_RESULT(AFH, END_CHUNK, lpr); int ret; @@ -87,8 +87,10 @@ static int afh_recv_open(struct receiver_node *rn) goto out_unmap; pard->audio_format_num = ret; ret = -ERRNO_TO_PARA_ERROR(EINVAL); + msg = "no data chunks"; if (afhi->chunks_total == 0) goto out_clear_afhi; + msg = "invalid begin chunk"; if (PARA_ABS(bc) >= afhi->chunks_total) goto out_clear_afhi; if (bc >= 0) @@ -100,6 +102,7 @@ static int afh_recv_open(struct receiver_node *rn) if (lls_opt_given(r_e)) { int32_t ec = lls_int32_val(0, r_e); ret = -ERRNO_TO_PARA_ERROR(EINVAL); + msg = "invalid end chunk"; if (PARA_ABS(ec) > afhi->chunks_total) goto out_clear_afhi; if (ec >= 0) @@ -109,12 +112,14 @@ static int afh_recv_open(struct receiver_node *rn) } else pard->last_chunk = afhi->chunks_total - 1; ret = -ERRNO_TO_PARA_ERROR(EINVAL); + msg = "begin chunk >= end chunk!?"; if (pard->first_chunk >= pard->last_chunk) goto out_clear_afhi; pard->current_chunk = pard->first_chunk; return pard->audio_format_num; out_clear_afhi: clear_afhi(afhi); + PARA_ERROR_LOG("%s: %s\n", fn, msg); out_unmap: para_munmap(pard->map, pard->map_size); close(pard->fd); diff --git a/afs.c b/afs.c index c2d5e7af..538606ad 100644 --- a/afs.c +++ b/afs.c @@ -22,8 +22,8 @@ #include "string.h" #include "afh.h" #include "afs.h" -#include "server.h" #include "net.h" +#include "server.h" #include "ipc.h" #include "list.h" #include "sched.h" @@ -685,8 +685,7 @@ static int open_afs_tables(void) ret = afs_tables[i].open(database_dir); if (ret >= 0) continue; - PARA_ERROR_LOG("%s init: %s\n", afs_tables[i].name, - para_strerror(-ret)); + PARA_ERROR_LOG("could not open %s\n", afs_tables[i].name); break; } if (ret >= 0) diff --git a/afs.h b/afs.h index f506cbff..8beca5ae 100644 --- a/afs.h +++ b/afs.h @@ -161,6 +161,14 @@ struct afs_callback_arg { struct osl_object query; /** Will be written on band SBD_OUTPUT, fully buffered. */ struct para_buffer pbout; + /** + * Convenience pointer for the deserialized parse result. + * + * Most afs command handlers call \ref send_lls_callback_request() to + * serialize the parse result of the subcommand and pass it to the + * callback. In afs context a pointer to the deserialized parse result + * is stored here. + */ struct lls_parse_result *lpr; }; diff --git a/aft.c b/aft.c index 1234ee5a..8969e7ac 100644 --- a/aft.c +++ b/aft.c @@ -22,9 +22,30 @@ #include "sideband.h" #include "command.h" -static struct osl_table *audio_file_table; +/* Data about one audio file. Needed for ls and stat output. */ +struct ls_data { + /* Usual audio format handler information. */ + struct afh_info afhi; + /* Audio file selector information. */ + struct afs_info afsi; + /* The full path of the audio file. */ + char *path; + /* The score value (if -a was given). */ + long score; + /* The hash value of the audio file data. */ + unsigned char *hash; +}; + +/* + * The internal state of the audio file table is described by the following + * variables which are private to aft.c. + */ +static struct osl_table *audio_file_table; /* NULL if table not open */ +static struct osl_row *current_aft_row; /* NULL if no audio file open */ + static char *status_items; static char *parser_friendly_status_items; +static struct ls_data status_item_ls_data; /** The different sorting methods of the ls command. */ enum ls_sorting_method { @@ -70,20 +91,6 @@ enum ls_listing_mode { LS_MODE_PARSER, }; -/* Data about one audio file. Needed for ls and stat output. */ -struct ls_data { - /* Usual audio format handler information. */ - struct afh_info afhi; - /* Audio file selector information. */ - struct afs_info afsi; - /* The full path of the audio file. */ - char *path; - /* The score value (if -a was given). */ - long score; - /* The hash value of the audio file data. */ - unsigned char *hash; -}; - /** * The size of the individual output fields of the ls command. * @@ -954,9 +961,6 @@ out: return ret; } -static struct ls_data status_item_ls_data; -static struct osl_row *current_aft_row; - static void make_inode_status_items(struct para_buffer *pb) { struct stat statbuf = {.st_size = 0}; @@ -1590,7 +1594,7 @@ ACTION: Table modifications to be done by the callback. +----+----+---+------+---------------------------------------------------+ | N | N | Y | Y | (new file) create new entry (force has no effect) +----+----+---+------+---------------------------------------------------+ -| N | N | N | Y | (new file) create new entry +| N | N | N | Y | (new file) create new entry +----+----+---+------+---------------------------------------------------+ Notes: diff --git a/base64.h b/base64.h index 4bfaa99d..ea62d98f 100644 --- a/base64.h +++ b/base64.h @@ -1,3 +1,7 @@ +/* Copyright (C) 2016 Andre Noll , see file COPYING. */ + +/** \file base64.h uudecode/base64 API. */ + int uudecode(char const *src, size_t encoded_size, char **result, size_t *decoded_size); int base64_decode(char const *src, size_t encoded_size, char **result, diff --git a/client.h b/client.h index f8cc5d64..7ba56b91 100644 --- a/client.h +++ b/client.h @@ -36,8 +36,6 @@ struct client_task { unsigned char *challenge_hash; /** The parsed command line (including the command). */ struct lls_parse_result *lpr; - /** The config file for client options. */ - char *config_file; /** The RSA private key. */ char *key_file; /** Paraslash user name. */ diff --git a/client_common.c b/client_common.c index 0d87a8d2..b28e8951 100644 --- a/client_common.c +++ b/client_common.c @@ -40,7 +40,6 @@ void client_close(struct client_task *ct) if (!ct) return; free(ct->user); - free(ct->config_file); free(ct->key_file); lls_free_parse_result(ct->lpr, CLIENT_CMD_PTR); free(ct->challenge_hash); @@ -536,7 +535,6 @@ int client_parse_config(int argc, char *argv[], struct client_task **ct_ptr, ret = lls(lls_parse(argc, argv, cmd, &lpr, &errctx)); if (ret < 0) goto out; - ll = CLIENT_OPT_UINT32_VAL(LOGLEVEL, lpr); version_handle_flag("client", CLIENT_OPT_GIVEN(VERSION, lpr)); handle_help_flag(lpr); @@ -573,6 +571,9 @@ int client_parse_config(int argc, char *argv[], struct client_task **ct_ptr, lpr = merged_lpr; } /* success */ + ll = CLIENT_OPT_UINT32_VAL(LOGLEVEL, lpr); + if (loglevel) + *loglevel = ll; user = CLIENT_OPT_GIVEN(USER, lpr)? para_strdup(CLIENT_OPT_STRING_VAL(USER, lpr)) : para_logname(); @@ -593,21 +594,17 @@ int client_parse_config(int argc, char *argv[], struct client_task **ct_ptr, ct->scc.fd = -1; ct->lpr = lpr; ct->key_file = kf; - ct->config_file = cf; ct->user = user; *ct_ptr = ct; - if (loglevel) - *loglevel = ll; ret = lls_num_inputs(lpr); out: free(home); + free(cf); if (ret < 0) { if (errctx) PARA_ERROR_LOG("%s\n", errctx); free(errctx); - PARA_ERROR_LOG("%s\n", para_strerror(-ret)); lls_free_parse_result(lpr, cmd); - free(cf); free(kf); *ct_ptr = NULL; } diff --git a/command.c b/command.c index e934e23b..bfce809a 100644 --- a/command.c +++ b/command.c @@ -22,12 +22,12 @@ #include "string.h" #include "afh.h" #include "afs.h" +#include "net.h" #include "server.h" #include "list.h" #include "send.h" #include "sched.h" #include "vss.h" -#include "net.h" #include "daemon.h" #include "fd.h" #include "ipc.h" @@ -663,8 +663,7 @@ static int com_nomore(__a_unused struct command_context *cc, } EXPORT_SERVER_CMD_HANDLER(nomore); -static int com_ff(__a_unused struct command_context *cc, - struct lls_parse_result *lpr) +static int com_ff(struct command_context *cc, struct lls_parse_result *lpr) { long promille; int ret, backwards = 0; @@ -684,6 +683,7 @@ static int com_ff(__a_unused struct command_context *cc, ret = -E_NO_AUDIO_FILE; if (!mmd->afd.afhi.chunks_total || !mmd->afd.afhi.seconds_total) goto out; + ret = 1; promille = (1000 * mmd->current_chunk) / mmd->afd.afhi.chunks_total; if (backwards) promille -= 1000 * i / mmd->afd.afhi.seconds_total; @@ -699,15 +699,13 @@ static int com_ff(__a_unused struct command_context *cc, mmd->new_vss_status_flags |= VSS_REPOS; mmd->new_vss_status_flags &= ~VSS_NEXT; mmd->events++; - ret = 1; out: mutex_unlock(mmd_mutex); return ret; } EXPORT_SERVER_CMD_HANDLER(ff); -static int com_jmp(__a_unused struct command_context *cc, - struct lls_parse_result *lpr) +static int com_jmp(struct command_context *cc, struct lls_parse_result *lpr) { long unsigned int i; int ret; diff --git a/dccp_send.c b/dccp_send.c index 6f989541..69ba65f5 100644 --- a/dccp_send.c +++ b/dccp_send.c @@ -21,8 +21,8 @@ #include "error.h" #include "string.h" #include "afh.h" -#include "server.h" #include "net.h" +#include "server.h" #include "list.h" #include "send.h" #include "sched.h" @@ -161,7 +161,8 @@ static void dccp_post_select(fd_set *rfds, __a_unused fd_set *wfds) static int dccp_com_on(__a_unused struct sender_command_data *scd) { - return generic_com_on(dss, IPPROTO_DCCP); + generic_com_on(dss, IPPROTO_DCCP); + return 1; } static int dccp_com_off(__a_unused struct sender_command_data *scd) @@ -224,8 +225,6 @@ static char *dccp_status(void) */ void dccp_send_init(struct sender *s) { - int ret; - s->status = dccp_status; s->send = NULL; s->pre_select = dccp_pre_select; @@ -243,7 +242,5 @@ void dccp_send_init(struct sender *s) init_sender_status(dss, OPT_RESULT(DCCP_ACCESS), OPT_UINT32_VAL(DCCP_PORT), OPT_UINT32_VAL(DCCP_MAX_CLIENTS), OPT_GIVEN(DCCP_DEFAULT_DENY)); - ret = generic_com_on(dss, IPPROTO_DCCP); - if (ret < 0) - PARA_ERROR_LOG("%s\n", para_strerror(-ret)); + generic_com_on(dss, IPPROTO_DCCP); } diff --git a/fd.c b/fd.c index 7079b51c..0347fd83 100644 --- a/fd.c +++ b/fd.c @@ -179,15 +179,15 @@ __printf_2_3 int write_va_buffer(int fd, const char *fmt, ...) * \param rfds An optional fd set pointer. * \param num_bytes Result pointer. Contains the number of bytes read from \a fd. * - * If \a rfds is not \p NULL and the (non-blocking) file descriptor \a fd is - * not set in \a rfds, this function returns early without doing anything. - * Otherwise The function tries to read up to \a sz bytes from \a fd, where \a - * sz is the sum of the lengths of all vectors in \a iov. As for xwrite(), - * \p EAGAIN is not considered an error condition. However, \p EOF is. + * If rfds is not NULL and the (non-blocking) file descriptor fd is not set in + * rfds, this function returns early without doing anything. Otherwise it tries + * to read up to sz bytes from fd, where sz is the sum of the lengths of all + * vectors in iov. Like \ref xwrite(), EAGAIN and EINTR are not considered + * error conditions. However, EOF is. * * \return Zero or a negative error code. If the underlying call to readv(2) * returned zero (indicating an end of file condition) or failed for some - * reason other than \p EAGAIN, a negative error code is returned. + * reason other than EAGAIN or EINTR, a negative error code is returned. * * In any case, \a num_bytes contains the number of bytes that have been * successfully read from \a fd (zero if the first readv() call failed with @@ -226,7 +226,7 @@ int readv_nonblock(int fd, struct iovec *iov, int iovcnt, fd_set *rfds, if (ret == 0) return -E_EOF; if (ret < 0) { - if (errno == EAGAIN) + if (errno == EAGAIN || errno == EINTR) return 0; return -ERRNO_TO_PARA_ERROR(errno); } @@ -455,22 +455,20 @@ again: * PROT_EXEC PROT_READ PROT_WRITE. * \param flags Exactly one of MAP_SHARED and MAP_PRIVATE. * \param fd The file to mmap from. - * \param offset Mmap start. * \param map Result pointer. * * \return Standard. * * \sa mmap(2). */ -int para_mmap(size_t length, int prot, int flags, int fd, off_t offset, - void *map) +int para_mmap(size_t length, int prot, int flags, int fd, void *map) { void **m = map; errno = EINVAL; if (!length) goto err; - *m = mmap(NULL, length, prot, flags, fd, offset); + *m = mmap(NULL, length, prot, flags, fd, (off_t)0); if (*m != MAP_FAILED) return 1; err: @@ -639,7 +637,7 @@ int mmap_full_file(const char *path, int open_mode, void **map, if (S_ISDIR(file_status.st_mode)) goto out; - ret = para_mmap(*size, mmap_prot, mmap_flags, fd, 0, map); + ret = para_mmap(*size, mmap_prot, mmap_flags, fd, map); out: if (ret < 0 || !fd_ptr) close(fd); diff --git a/fd.h b/fd.h index 106f5a4c..25eea8a2 100644 --- a/fd.h +++ b/fd.h @@ -12,8 +12,7 @@ __must_check int mark_fd_nonblocking(int fd); __must_check int mark_fd_blocking(int fd); void para_fd_set(int fd, fd_set *fds, int *max_fileno); __must_check int para_fgets(char *line, int size, FILE *f); -int para_mmap(size_t length, int prot, int flags, int fd, off_t offset, - void *map); +int para_mmap(size_t length, int prot, int flags, int fd, void *map); int para_open(const char *path, int flags, mode_t mode); int para_mkdir(const char *path, mode_t mode); int para_chdir(const char *path); diff --git a/gui.c b/gui.c index 6882a31c..69a9243d 100644 --- a/gui.c +++ b/gui.c @@ -941,6 +941,14 @@ static int signal_post_select(struct sched *s, __a_unused void *context) switch (ret) { case SIGTERM: die(EXIT_FAILURE, "only the good die young (caught SIGTERM)\n"); + case SIGWINCH: + PARA_NOTICE_LOG("got SIGWINCH\n"); + if (curses_active()) { + shutdown_curses(); + init_curses(); + redraw_bot_win(); + } + return 1; case SIGINT: return 1; case SIGUSR1: @@ -1146,14 +1154,8 @@ static int input_post_select(__a_unused struct sched *s, ret = wgetch(top.win); if (ret == ERR) return 0; - if (ret == KEY_RESIZE) { - if (curses_active()) { - shutdown_curses(); - init_curses(); - redraw_bot_win(); - } + if (ret == KEY_RESIZE) /* already handled in signal_post_select() */ return 0; - } if (exs == EXEC_IDLE) handle_command(ret); else if (exec_pid > 0) @@ -1456,6 +1458,7 @@ static int setup_tasks_and_schedule(void) para_install_sighandler(SIGTERM); para_install_sighandler(SIGCHLD); para_install_sighandler(SIGUSR1); + para_install_sighandler(SIGWINCH); signal_task->task = task_register(&(struct task_info) { .name = "signal", .pre_select = signal_pre_select, diff --git a/http_recv.c b/http_recv.c index c581ebdd..3a723299 100644 --- a/http_recv.c +++ b/http_recv.c @@ -106,8 +106,10 @@ static int http_recv_post_select(struct sched *s, void *context) } if (phd->status == HTTP_SENT_GET_REQUEST) { ret = read_pattern(rn->fd, HTTP_OK_MSG, strlen(HTTP_OK_MSG), &s->rfds); - if (ret < 0) + if (ret < 0) { + PARA_ERROR_LOG("did not receive HTTP OK message\n"); goto out; + } if (ret == 0) return 0; PARA_INFO_LOG("received ok msg, streaming\n"); @@ -128,8 +130,10 @@ static int http_recv_post_select(struct sched *s, void *context) btr_add_output_pool(rn->btrp, num_bytes - iov[0].iov_len, btrn); } out: - if (ret < 0) + if (ret < 0) { + PARA_NOTICE_LOG("%s\n", para_strerror(-ret)); btr_remove_node(&rn->btrn); + } return ret; } diff --git a/http_send.c b/http_send.c index dace5c23..210f85ac 100644 --- a/http_send.c +++ b/http_send.c @@ -16,6 +16,7 @@ #include "error.h" #include "string.h" #include "afh.h" +#include "net.h" #include "server.h" #include "http.h" #include "list.h" @@ -23,7 +24,6 @@ #include "sched.h" #include "vss.h" #include "close_on_fork.h" -#include "net.h" #include "fd.h" #include "chunk_queue.h" #include "acl.h" @@ -209,7 +209,8 @@ static void http_pre_select(int *max_fileno, fd_set *rfds, fd_set *wfds) static int http_com_on(__a_unused struct sender_command_data *scd) { - return generic_com_on(hss, IPPROTO_TCP); + generic_com_on(hss, IPPROTO_TCP); + return 1; } static int http_com_off(__a_unused struct sender_command_data *scd) @@ -245,7 +246,6 @@ static char *http_status(void) */ void http_send_init(struct sender *s) { - int ret; s->status = http_status; s->send = http_send; s->pre_select = http_pre_select; @@ -265,7 +265,5 @@ void http_send_init(struct sender *s) OPT_GIVEN(HTTP_DEFAULT_DENY)); if (OPT_GIVEN(HTTP_NO_AUTOSTART)) return; - ret = generic_com_on(hss, IPPROTO_TCP); - if (ret < 0) - PARA_ERROR_LOG("%s\n", para_strerror(-ret)); + generic_com_on(hss, IPPROTO_TCP); } diff --git a/m4/lls/audioc.suite.m4 b/m4/lls/audioc.suite.m4 index 1c037bc7..6ad8c716 100644 --- a/m4/lls/audioc.suite.m4 +++ b/m4/lls/audioc.suite.m4 @@ -6,9 +6,9 @@ version-string = GIT_VERSION() purpose = communicate with para_audiod through a local socket non-opts-name = [command [options]] [description] - The client program to control para_audiod at runtime. It allows to - enable/disable streaming, to receive status info, or to grab the - audio stream at any point of the decoding process. + The client program to control para_audiod at runtime. It can + enable/disable streaming, receive status info, or grab the audio + stream at any point of the decoding process. If no command is given, para_audioc enters interactive mode. [/description] diff --git a/m4/lls/filter.suite.m4 b/m4/lls/filter.suite.m4 index 0cd69ebd..376e8758 100644 --- a/m4/lls/filter.suite.m4 +++ b/m4/lls/filter.suite.m4 @@ -4,9 +4,9 @@ version-string = GIT_VERSION() [supercommand para_filter] purpose = decode or process audio data from STDIN to STDOUT [description] - This program allows to specify a chain of filters which transform the - audio stream read from STDIN. A common mode of operation is to decode - an mp3 file with the mp3dec filter, but many other filters exist which + This program transforms the audio stream read from STDIN by chaining + one or more filters. A common mode of operation is to decode an + mp3 file with the mp3dec filter, but many other filters exist which transform the audio stream in different ways. [/description] m4_include(common-option-section.m4) @@ -35,3 +35,15 @@ version-string = GIT_VERSION() through all given filters (in a single thread without copying the data). The same filter may appear more than once, and order matters. [/help] +[section Examples] + .IP \(bu 4 + Decode a wma file to wav format: + .EX + \ para_filter -f wmadec -f wav < file.wma > file.wav + .EE + .IP \(bu 4 + Amplify a raw audio file by a factor of 1.5: + .EX + \ para_filter -f amp --amp 32 < foo.raw > bar.raw + .EE +[/section] diff --git a/m4/lls/include/log-timing.m4 b/m4/lls/include/log-timing.m4 index a7364e19..ba19be98 100644 --- a/m4/lls/include/log-timing.m4 +++ b/m4/lls/include/log-timing.m4 @@ -3,7 +3,7 @@ summary = show milliseconds in log messages [help] Selecting this option causes milliseconds to be included in - the log message output. This allows to measure the interval + the log message output. This allows measuring of the interval between log messages in milliseconds which is useful for identifying timing problems. [/help] diff --git a/m4/lls/play.suite.m4 b/m4/lls/play.suite.m4 index 0fbba0c0..4af2a05a 100644 --- a/m4/lls/play.suite.m4 +++ b/m4/lls/play.suite.m4 @@ -7,8 +7,8 @@ version-string = GIT_VERSION() purpose = command line audio player non-opts-name = ... [description] - para_play operates either in command mode or in insert mode. In - insert mode it presents a prompt and allows to enter commands like + para_play operates either in command mode or in insert mode. In insert + mode it presents a prompt and allows the user to enter commands like stop, play, pause etc. In command mode the current audio file and the playback position are shown and the program reads single key strokes from stdin. Keys may be mapped to commands so that the configured diff --git a/m4/lls/recv.suite.m4 b/m4/lls/recv.suite.m4 index 793a2f5f..993a4494 100644 --- a/m4/lls/recv.suite.m4 +++ b/m4/lls/recv.suite.m4 @@ -2,7 +2,16 @@ m4_define(PROGRAM, para_recv) [suite recv] version-string = GIT_VERSION() [supercommand para_recv] - purpose = a command line HTTP/DCCP/UDP stream grabber + purpose = receive an audio stream + [description] + para_recv starts one paraslash receiver (http, dccp, udp or afh) + to produce an audio stream in the same way para_audiod would download + the stream from para_server (http, dccp or udp) or para_server makes a + stream out of an audio file (afh). This is mostly useful for debugging. + + Regardless of which receiver was started, the audio stream is written + to stdout. + [/description] m4_include(common-option-section.m4) m4_include(help.m4) m4_include(detailed-help.m4) @@ -19,4 +28,6 @@ version-string = GIT_VERSION() Any options for the selected receiver must be quoted. Example: -r 'http -i www.paraslash.org -p 8009' + + If no receiver is given, http is assumed. [/help] diff --git a/m4/lls/recv_cmd.suite.m4 b/m4/lls/recv_cmd.suite.m4 index 674a4487..de6c5a68 100644 --- a/m4/lls/recv_cmd.suite.m4 +++ b/m4/lls/recv_cmd.suite.m4 @@ -79,7 +79,7 @@ caption = receivers The request is reconciled with the CCIDs on the server through the 'server-priority' mechanism of RFC 4340 6.3.1/10. The server CCIDs - can be listed by calling 'para_client si'. + can be listed by calling 'para_client sender dccp status'. [/help] [subcommand udp] purpose = receive an audio stream over UDP diff --git a/m4/lls/server.suite.m4 b/m4/lls/server.suite.m4 index 5bba85d4..6ffdc007 100644 --- a/m4/lls/server.suite.m4 +++ b/m4/lls/server.suite.m4 @@ -159,10 +159,10 @@ version-string = GIT_VERSION() summary = make the http access control list a whitelist [help] The default is to use blacklists, i.e. connections to the http sender - are allowed unless the connecting host matches a pattern given by a - http-access option. This allows to use access control the other way - round: Connections are denied from hosts which are not explicitly - allowed by one or more http-access options. + are allowed unless the connecting host matches a pattern given by + a http-access option. This option allows using access control lists + the other way round: Connections are denied from hosts which are not + explicitly allowed by one or more http-access options. [/help] [option http-access] summary = add an entry to the http access control list @@ -247,9 +247,9 @@ version-string = GIT_VERSION() (path MTU) of an incoming connection, i.e. on the largest packet size that can be transmitted without causing fragmentation. - This option allows to use a value less than the MPS in order to - fine-tune application performance. Values greater than the MPS of an - incoming connection can not be set. + This option allows values less than the MPS in order to fine-tune + application performance. Values greater than the MPS of an incoming + connection can not be set. [/help] [option dccp-data-slices-per-group] summary = the number of non-redundant slices per FEC group diff --git a/m4/lls/server_cmd.suite.m4 b/m4/lls/server_cmd.suite.m4 index 9378b7c3..96ce5302 100644 --- a/m4/lls/server_cmd.suite.m4 +++ b/m4/lls/server_cmd.suite.m4 @@ -407,20 +407,45 @@ aux_info_prefix = Permissions: [subcommand sender] purpose = control paraslash senders - synopsis = [sender cmd [arguments]] + synopsis = [sender subcmd [arguments]] aux_info = VSS_READ | VSS_WRITE [description] - Send a command to a specific sender. The following commands are - available, but not all senders support every command. + This command executes a subcommand for the given sender, which is + one of "http", "dccp" or "udp". Various subcommands exist to print + information about the sender, to activate and deactivate the sender, + and to change the access permissions and targets. The following + subcommands are available: - help, on, off, add, delete, allow, deny, status. + help, status, on, off, allow, deny, add, delete. - The help command prints the help text of the given sender. If no - command is given the list of available senders is shown. + All senders support the first four commands. The "allow" and "deny" + commands are supported by the http and the dccp senders while "add" + and "delete" are only supported by the udp sender. If no sender is + given, the list of available senders is shown. - Example: + Examples: + + Get help for the udp sender (contains further examples): + + sender udp help + + Show the access control list and the number of connected clients of + the http sender: + + sender http status + + Senders may be activated and deactivated independently of each + other. The following command switches off the dccp sender: + + sender dccp off + + Add an UDP unicast for a client to the target list of the UDP sender: + + sender udp add client.foo.org + + Start UDP multicast, using the default multicast address: - para_client sender http help + sender udp add 224.0.1.38 [/description] diff --git a/mixer.c b/mixer.c index 00af08a4..52af25f9 100644 --- a/mixer.c +++ b/mixer.c @@ -192,9 +192,6 @@ static void change_afs_mode(const char *afs_mode) { char *cmd; - client_cmd("stop"); - if (!afs_mode) - return; cmd = make_message("select %s", afs_mode); client_cmd(cmd); free(cmd); @@ -290,7 +287,7 @@ static int com_sleep(const struct mixer *m, struct mixer_handle *h) PARA_INFO_LOG("waketime: %d:%02d\n", tm->tm_hour, tm->tm_min); client_cmd("stop"); sleep(1); - if (fot) { + if (fot && fo_mood) { ret = set_initial_volume(m, h); if (ret < 0) return ret; @@ -307,12 +304,13 @@ static int com_sleep(const struct mixer *m, struct mixer_handle *h) if (ret < 0) return ret; } - if (OPT_GIVEN(SLEEP, SLEEP_MOOD)) { + if (sleep_mood) { change_afs_mode(sleep_mood); - client_cmd("play"); - } else + if (!fot || !fo_mood) /* currently stopped */ + client_cmd("play"); + } else if (fot && fo_mood) /* currently playing */ client_cmd("stop"); - if (!fit) + if (!fit || !fi_mood) /* nothing to do */ return 1; change_afs_mode(fi_mood); for (;;) { diff --git a/mp.c b/mp.c index c5702c62..bade05bc 100644 --- a/mp.c +++ b/mp.c @@ -6,7 +6,7 @@ * This file contains the public and the private API of the flex/bison based * mood parser. * - * The public API (at the bottom of the file) allows to parse the same mood + * The public API (at the bottom of the file) allows parsing the same mood * definition many times in an efficient manner. * * The first function to call is \ref mp_init(), which analyzes the given mood @@ -61,8 +61,8 @@ struct mp_context { * * This function turns a generalized C99 string literal like "xyz\n" into a C * string (containing the three characters 'x', 'y' and 'z', followed by a - * newline character and the terminating zero byte). The function allows to - * specify different quote characters so that, for example, regular expression + * newline character and the terminating zero byte). The function receives + * quote characters as an argument so that, for example, regular expression * patterns enclosed in '/' can be parsed as well. To parse a proper string * literal, one has to pass two double quotes as the second argument. * diff --git a/net.c b/net.c index 3f76d21c..1fece043 100644 --- a/net.c +++ b/net.c @@ -425,15 +425,20 @@ int makesock_addrinfo(unsigned l4type, bool passive, struct addrinfo *ai, for (; ai; ai = ai->ai_next) { int fd; ret = socket(ai->ai_family, sock_type(l4type), l4type); - if (ret < 0) + if (ret < 0) { + PARA_NOTICE_LOG("socket(): %s\n", strerror(errno)); continue; + } fd = ret; flowopt_setopts(fd, fo); if (!passive) { - if (connect(fd, ai->ai_addr, ai->ai_addrlen) == 0) - return fd; - close(fd); - continue; + if (connect(fd, ai->ai_addr, ai->ai_addrlen) < 0) { + PARA_NOTICE_LOG("connect(): %s\n", + strerror(errno)); + close(fd); + continue; + } + return fd; } /* * Reuse the address on passive sockets to avoid failure on @@ -442,10 +447,12 @@ int makesock_addrinfo(unsigned l4type, bool passive, struct addrinfo *ai, */ if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on)) == -1) { + PARA_NOTICE_LOG("setsockopt(): %s\n", strerror(errno)); close(fd); continue; } if (bind(fd, ai->ai_addr, ai->ai_addrlen) < 0) { + PARA_NOTICE_LOG("bind(): %s\n", strerror(errno)); close(fd); continue; } @@ -496,16 +503,15 @@ int makesock(unsigned l4type, bool passive, const char *host, uint16_t port_numb * * \param l4type The transport-layer type (\p IPPROTO_xxx). * \param port The decimal port number to listen on. - * \param fo Flowopts (if any) to set before starting to listen. * * \return Positive integer (socket descriptor) on success, negative value * otherwise. * * \sa \ref makesock(), ip(7), ipv6(7), bind(2), listen(2). */ -int para_listen(unsigned l4type, uint16_t port, struct flowopts *fo) +int para_listen_simple(unsigned l4type, uint16_t port) { - int ret, fd = makesock(l4type, 1, NULL, port, fo); + int ret, fd = makesock(l4type, 1, NULL, port, NULL); if (fd > 0) { ret = listen(fd, BACKLOG); diff --git a/net.h b/net.h index f172131e..143fb812 100644 --- a/net.h +++ b/net.h @@ -48,6 +48,9 @@ #define DCCP_SOCKOPT_TX_CCID 14 /**< Set/get the TX CCID. */ #endif +/** The maximum length of the host component in an URL. */ +#define MAX_HOSTLEN 256 + /** * Flowopts: Transport-layer independent encapsulation of socket options * that need to be registered prior to setting up a connection. @@ -124,12 +127,8 @@ bool sockaddr_equal(const struct sockaddr *sa1, const struct sockaddr *sa2); */ /** How many pending connections queue of a listening server will hold. */ #define BACKLOG 10 -extern int para_listen(unsigned l4type, uint16_t port, struct flowopts *fo); -static inline int para_listen_simple(unsigned l4type, uint16_t port) -{ - return para_listen(l4type, port, NULL); -} +int para_listen_simple(unsigned l4type, uint16_t port); /** Pretty-printing of IPv4/6 socket addresses */ extern char *remote_name(int sockfd); diff --git a/sched.c b/sched.c index 4fc65b4b..a2903940 100644 --- a/sched.c +++ b/sched.c @@ -168,7 +168,7 @@ again: * \param tptr Identifies the task to reap. * * This function is similar to wait(2) in that it returns information about a - * terminated task and allows to release the resources associated with the + * terminated task which allows releasing the resources associated with the * task. Until this function is called, the terminated task remains in a zombie * state. * diff --git a/send.h b/send.h index 9a6e5f74..84f35f92 100644 --- a/send.h +++ b/send.h @@ -186,7 +186,7 @@ void generic_com_allow(struct sender_command_data *scd, struct sender_status *ss); void generic_com_deny(struct sender_command_data *scd, struct sender_status *ss); -int generic_com_on(struct sender_status *ss, unsigned protocol); +void generic_com_on(struct sender_status *ss, unsigned protocol); void generic_com_off(struct sender_status *ss); char *generic_sender_help(void); struct sender_client *accept_sender_client(struct sender_status *ss, fd_set *rfds); diff --git a/send_common.c b/send_common.c index acb7aa6d..16820a53 100644 --- a/send_common.c +++ b/send_common.c @@ -30,34 +30,6 @@ /** Clients will be kicked if there are more than that many bytes pending. */ #define MAX_CQ_BYTES 40000 -/** - * Open a passive socket of given layer4 type. - * - * Set the resulting file descriptor to nonblocking mode and add it to the list - * of fds that are being closed in the child process when the server calls - * fork(). - * - * \param l4type The transport-layer protocol. - * \param port The port number. - * - * \return The listening fd on success, negative on errors. - */ -static int open_sender(unsigned l4type, int port) -{ - int fd, ret = para_listen_simple(l4type, port); - - if (ret < 0) - return ret; - fd = ret; - ret = mark_fd_nonblocking(fd); - if (ret < 0) { - close(fd); - return ret; - } - add_close_on_fork_list(fd); - return fd; -} - /** * Shut down a client connected to a paraslash sender. * @@ -234,21 +206,38 @@ void generic_com_deny(struct sender_command_data *scd, * Activate a paraslash sender. * * \param ss The sender to activate. - * \param protocol The symbolic name of the transport-layer protocol. + * \param protocol layer4 type (IPPROTO_TCP or IPPROTO_DCCP). * - * \return Standard. + * This opens a passive socket of given layer4 type, sets the resulting file + * descriptor to nonblocking mode and adds it to the close on fork list. + * + * Errors are logged but otherwise ignored. */ -int generic_com_on(struct sender_status *ss, unsigned protocol) +void generic_com_on(struct sender_status *ss, unsigned protocol) { - int ret; + int fd, ret; if (ss->listen_fd >= 0) - return 1; - ret = open_sender(protocol, ss->port); - if (ret < 0) - return ret; - ss->listen_fd = ret; - return 1; + return; + ret = para_listen_simple(protocol, ss->port); + if (ret < 0) { + PARA_ERROR_LOG("could not listen on port %d: %s\n", ss->port, + para_strerror(-ret)); + return; + } + fd = ret; + ret = mark_fd_nonblocking(fd); + if (ret < 0) { + PARA_ERROR_LOG("could not set %s socket fd for port %d to " + "nonblocking mode: %s\n", + protocol == IPPROTO_TCP? "TCP" : "DCCP", ss->port, + para_strerror(-ret)); + close(fd); + return; + } + add_close_on_fork_list(fd); + ss->listen_fd = fd; + return; } /** @@ -277,9 +266,8 @@ void generic_com_off(struct sender_status *ss) * \param ss The sender whose listening fd is ready for reading. * \param rfds Passed to para_accept(), * - * This must be called only if the socket fd of \a ss is ready for reading. It - * calls para_accept() to accept the connection and performs the following - * actions on the resulting file descriptor \a fd: + * This calls para_accept() and performs the following actions on the resulting + * file descriptor fd: * * - Checks whether the maximal number of connections are exceeded. * - Sets \a fd to nonblocking mode. diff --git a/server.c b/server.c index aba05688..011367e3 100644 --- a/server.c +++ b/server.c @@ -45,6 +45,7 @@ #include "afh.h" #include "string.h" #include "afs.h" +#include "net.h" #include "server.h" #include "list.h" #include "send.h" @@ -52,7 +53,6 @@ #include "vss.h" #include "config.h" #include "close_on_fork.h" -#include "net.h" #include "daemon.h" #include "ipc.h" #include "fd.h" diff --git a/server.h b/server.h index 1852dd50..988a98d8 100644 --- a/server.h +++ b/server.h @@ -5,10 +5,6 @@ /** Size of the selector_info and audio_file info strings of struct misc_meta_data. */ #define MMD_INFO_SIZE 16384 -/** The maximum length of the host component in an URL */ -#define MAX_HOSTLEN 256 - - /** Arguments for the sender command. */ struct sender_command_data { /** Greater than zero indicates that a sender cmd is already queued. */ diff --git a/sideband.h b/sideband.h index 3023c7b6..6973b845 100644 --- a/sideband.h +++ b/sideband.h @@ -97,7 +97,7 @@ struct sb_context; /** * The type of a sideband transformation. * - * The sideband API allows to filter all data through an arbitrary + * The sideband API allows the filtering of data through an arbitrary * transformation, which is useful for crypto purposes. The transformation may * either transform the data in place, or return a pointer to a new buffer * which contains the transformed source buffer. The internal sideband diff --git a/udp_send.c b/udp_send.c index 49c17631..38d49e3e 100644 --- a/udp_send.c +++ b/udp_send.c @@ -18,13 +18,13 @@ #include "error.h" #include "string.h" #include "afh.h" +#include "net.h" #include "server.h" #include "list.h" #include "send.h" #include "sched.h" #include "vss.h" #include "portable_io.h" -#include "net.h" #include "fd.h" #include "close_on_fork.h" diff --git a/vss.c b/vss.c index 00c632c7..8b850fe1 100644 --- a/vss.c +++ b/vss.c @@ -25,8 +25,8 @@ #include "string.h" #include "afh.h" #include "afs.h" -#include "server.h" #include "net.h" +#include "server.h" #include "list.h" #include "send.h" #include "sched.h" @@ -298,7 +298,7 @@ static int initialize_fec_client(struct fec_client *fc, struct vss_task *vsst) if (fcp->init_fec) { /* * Set the maximum slice size to the Maximum Packet Size if the - * transport protocol allows to determine this value. The user + * transport protocol allows determination of this value. The user * can specify a slice size up to this value. */ ret = fcp->init_fec(fc->sc); @@ -997,7 +997,7 @@ static void recv_afs_result(struct vss_task *vsst, fd_set *rfds) goto err; } ret = para_mmap(statbuf.st_size, PROT_READ, MAP_PRIVATE | MAP_POPULATE, - passed_fd, 0, &vsst->map); + passed_fd, &vsst->map); if (ret < 0) goto err; vsst->mapsize = statbuf.st_size; diff --git a/web/download.in.html b/web/download.in.html index 1ca8a4d2..9ef92b7a 100644 --- a/web/download.in.html +++ b/web/download.in.html @@ -15,8 +15,8 @@ provided at this point. There are several ways to download the source:

The repository contains the full history of the project since 2006, all work in progress and the source - code for the web pages. Choosing this option allows to - check out any of the four integration branches maint, + code for the web pages. Choosing this option allows the + checkout of any of the four integration branches maint, master, next, pu (see the Git branches @@ -68,7 +68,7 @@ provided at this point. There are several ways to download the source: gitweb page contains a snapshot link for each revision. This - allows to get a specific revision without downloading + allows getting a specific revision without downloading the full history. diff --git a/web/manual.md b/web/manual.md index fb3a05f7..04c716a8 100644 --- a/web/manual.md +++ b/web/manual.md @@ -230,9 +230,9 @@ compatible with arbitrary HTTP streaming sources (e.g. icecast). In addition to the three network streaming modes, para_recv can also operate in local (afh) mode. In this mode it writes the content of an audio file on the local file system in complete chunks to stdout, -optionally 'just in time'. This allows to cut an audio file without -first decoding it, and it enables third-party software which is unaware -of the particular audio format to send complete frames in real time. +optionally 'just in time'. This allows cutting audio files without +decoding, and it enables third-party software which is unaware of +the particular audio format to send complete frames in real time.

para_filter

@@ -1541,27 +1541,6 @@ currently running server process. para_client si -The sender command of para_server prints information about senders, -like the various access control lists, and it allows to (de-)activate -senders and to change the access permissions at runtime. - --> List all senders - - para_client sender - --> Obtain general help for the sender command: - - para_client help sender - --> Get help for a specific sender (contains further examples): - - s=http # or dccp or udp - para_client sender $s help - --> Show status of the http sender - - para_client sender http status - By default para_server activates both the HTTP and th DCCP sender on startup. This can be changed via command line options or para_server's config file. @@ -1570,13 +1549,6 @@ config file. para_server -h -All senders share the "on" and "off" commands, so senders may be -activated and deactivated independently of each other. - --> Switch off the http sender: - - para_client sender http off - -> Receive a DCCP stream using CCID2 and write the output into a file: host=foo.org; ccid=2; filename=bar @@ -1587,20 +1559,11 @@ receiver has its own set of command line options and its own command line parser, so arguments for the dccp receiver must be protected from being interpreted by para_recv. --> Start UDP multicast, using the default multicast address: - - para_client sender udp add 224.0.1.38 - -> Receive FEC-encoded multicast stream and write the output into a file: filename=foo para_recv -r udp > $filename --> Add an UDP unicast for a client to the target list of the UDP sender: - - t=client.foo.org - para_client sender udp add $t - -> Receive this (FEC-encoded) unicast stream: filename=foo @@ -1778,7 +1741,7 @@ These filters are rather simple and do not modify the audio stream at all. The wav filter is only useful with para_filter and in connection with a decoder. It asks the decoder for the number of channels and the sample rate of the stream and adds a Microsoft wave header containing -this information at the beginning. This allows to write wav files +this information at the beginning. This allows writing wav files rather than raw PCM files (which do not contain any information about the number of channels and the sample rate). @@ -1792,17 +1755,6 @@ Both filters require almost no additional computing time, even when operating on uncompressed audio streams, since data buffers are simply "pushed down" rather than copied. -Examples --------- - --> Decode an mp3 file to wav format: - - para_filter -f mp3dec -f wav < file.mp3 > file.wav - --> Amplify a raw audio file by a factor of 1.5: - - para_filter -f amp --amp 32 < foo.raw > bar.raw - ====== Output ====== @@ -1852,8 +1804,8 @@ emulation for backwards compatibility. This API is rather simple but also limited. For example only one application can open the device at any time. The OSS writer is activated by default on BSD Systems. -- *FILE*. The file writer allows to capture the audio stream and -write the PCM data to a file on the file system rather than playing +- *FILE*. The file writer allows capturing the audio stream and +writing the PCM data to a file on the file system rather than playing it through a sound device. It is supported on all platforms and is always compiled in.