Gerrit Renker [Sat, 13 Mar 2010 12:08:32 +0000 (13:08 +0100)]
net: fix broken dccp_available_ccids()
This fixes a dumb programming error in dccp_available_ccids(), where a
pointer to 1-byte address was type cast to a socklent_t (typically 4 byte)
pointer. Changed the interface to not expose internals of call.
In addition, this patch adds a missing close() in the error path of makesock().
Andre Noll [Wed, 10 Mar 2010 07:56:55 +0000 (08:56 +0100)]
audiod: Don't init slot info unless opening the receiver succeeds.
Currently we set the slot's audio format number even if the receiver could not
be opened. This confuses the slot clearing code as no writer is active in
this case which triggers the assertion
Andre Noll [Sun, 7 Mar 2010 15:34:25 +0000 (16:34 +0100)]
setup_next_fec_group(): Return early on eof.
The old code updated the group start via set_group_timing() even if the
end of the file was reached. This could confuse the logic in vss_send()
as it uses the goup start timestamp to find out whether all FEC clients
have sent all remaining slices.
Fix this by moving the check for the eof condition before the call to
set_group_timing() that updates the group start.
Andre Noll [Fri, 5 Mar 2010 08:18:49 +0000 (09:18 +0100)]
Minor doxygen fixes.
Fixes
net.c:279: Warning: Found unknown command `\opt'
net.h:104: Warning: argument 'l3type' of command @param is not found in the argument list of makesock...
Andre Noll [Fri, 5 Mar 2010 07:42:13 +0000 (08:42 +0100)]
audiod: Make default filters work also for udp streams.
Currently one has to use --no_default_filters and must specify fecdec as the
first filter for UDP streams, a fact that is not documented anywhere. Make decoding
of udp streams work if no filters were given by changing init_default_filters() to
add fecdec automatically if the udp receiver is used.
Gerrit Renker [Wed, 3 Mar 2010 16:57:14 +0000 (17:57 +0100)]
net: revert restricting SO_REUSEADDR
This reverts part of commit a5927501e41fa3fca2975452617474e78ffecc48
(08_refactor-makesock.diff, 25 Feb 2010), which restricted by default
SO_REUSEADDR to connection-oriented protocols only - it used to be
set on all passive sockets.
However, the same problem exists also for UDP, whenever connecting
more than one listener on the same host, hence revert it.
Andre Noll [Tue, 2 Mar 2010 06:10:00 +0000 (07:10 +0100)]
btr: Fix a nasty thinko in merge_input_pool().
We must take into account the number of bytes already consumed from the wrap buffer.
Otherwise, we might end up not merging as much as we must, which may cause errors
in the child nodes.
This bug was quite hard to hit, but it did bite the aac decoder reliably when used in audiod
with UDP + FEC.
Andre Noll [Thu, 25 Feb 2010 16:33:54 +0000 (17:33 +0100)]
net.h: Fic compilation on systems with partial DCCP support.
There exists at least one system that defines IPPROTO_DCCP but not
DCCP_SOCKOPT_CCID and friends. On such systems compilation fails due
to to undefined symbols.
Fix this problem by checking each value separately.
Gerrit Renker [Thu, 25 Feb 2010 16:05:46 +0000 (17:05 +0100)]
10_set-client-ccid.diff
This adds a commandline option to either
* select the CCID in use for the sender-receiver half-connection or
* advertise the (para_)client's priorities for the CCID;
* the feature is optional and can be used to fine-tune a connection.
The arguments are both range-checked by gengetopt, and against the CCIDs
available on the host. Currently known CCIDs are 2-4, 248-254. Trying a
CCID which is not supported by the host exits via the following route:
dccp_recv_ccid_support_check: 'CCID-253' not supported on this host.
main: parse failed
main: recv syntax error
The CCID negotiation can be watched in wireshark, between the 'Request'
packet sent by the para_client and the corresponding 'Response' packet of
the para_server. Here are some example negotiations:
The server list of (2, 3, 4) is the unaltered default, it can be changed on
the server using the same mechanism.
As shown, the easiest way is to use just a single '--ccid <n>' argument;
when passing multiple values, the outcome is determined by the algorithm
described in RFC 4340, 6.3.1:
* 'server-priority' means that the server overrids the result;
* the server traverses its list of preferences in order of priority and
* uses the first entry which also appears in the client-list;
* resets connection with negotiation failure when there is no common value.
Applying this algorithm on the above lists can be used to verify the
table. This also illustrates that repetition of CCID values has no effect
on the outcome: if the repeated value is first in the server list, it will
be chosen; otherwise all instances of that value are ignored.
Gerrit Renker [Thu, 25 Feb 2010 16:05:45 +0000 (17:05 +0100)]
09_fix-errno-usage.diff
This fixes a bug in the use of errno which corresponds to the 'common mistake'
in the use of errno(3): to not save it before making new system calls. Thanks.
Gerrit Renker [Thu, 25 Feb 2010 16:05:45 +0000 (17:05 +0100)]
08_refactor-makesock.diff
This is a refactoring of makesock():
* the ubiquitous AF_UNSPEC is promoted as the default;
* a wrapper for active sockets, para_connect_simple();
* para_listen() now supports flowopts;
* a wrapper for passive sockets, para_listen_simple();
* for consistency, port numbers (which are 2 byte in
UDP, TCP, and DCCP) have all been set to 'uint16_t'.
Gerrit Renker [Thu, 25 Feb 2010 16:05:45 +0000 (17:05 +0100)]
07_flow-opt-support.diff
In order to support a class of socket options which have to be set
before commiting a socket to a connection, this patch adds an API
for "pre-connection" socket options, called "flowopts" here.
The API is used as follows:
* to provide queue storage, a new head is allocated using flowopt_new();
* this queue is then populated with pre-connection socket options via
- generic 'add' method flowopt_add(),
- a specific variant for adding Boolean options - flowopt_add_bool(),
- convenience macros - OPT_ADD(), OPT_ENABLE(), OPT_DISABLE();
* the rest is then dealt with automatically by makesock():
- any provided flowopts are set before making the connection,
- due to using a queue, the order of invocation is preserved,
- after making the connection, makesock() frees storage that has been
previously allocated by flowopt_new() and flowopt_add.*().
Gerrit Renker [Thu, 25 Feb 2010 16:05:45 +0000 (17:05 +0100)]
06_get-tx-ccid.diff
This patch adds support for querying the TX half-connection CCID
in use to from sender to client.
On more recent kernels (> 2.6.30) supporting this functionality,
connected clients are now displayed in the manner
<IP-address>"#"<port>"~"<CCID-number>
Gerrit Renker [Thu, 25 Feb 2010 16:05:45 +0000 (17:05 +0100)]
05_dccp-supported-ccid-lookup.diff
This adds a self-contained function to return the space-separated list of
CCIDs available on the para_server. Visible via 'para_client si'.
Since feature negotiation for CCIDs is supported only from v2.6.30-rc1
(released 7th April 2009), a more recent kernel (>= 2.6.30) is needed to
support this feature, as well as subsequent per-connection use of CCIDs.
Note: This patch still uses a hardcoded upper bound (DCCP_MAX_HOST_CCIDS),
support dynamically detecting the number of CCIDs will be in 2.6.33.
Gerrit Renker [Thu, 25 Feb 2010 16:05:45 +0000 (17:05 +0100)]
04_per-connection-ccid-constants.diff
This adds symbolic constants for per-connection CCID support; these are used
by subsequent patches.
Per-connection CCID support is available in the Linux kernel from v2.6.30-rc1
(7th April 2009) onwards, further information is available at:
* symbolic names are taken from include/linux/dccp.h,
* API documentation is in Documentation/networking/dccp.txt.
The patch also corrects the manner of using doxygen comments in the #defines.
Gerrit Renker [Thu, 25 Feb 2010 16:05:45 +0000 (17:05 +0100)]
03_resolve-port-names.diff
This patch allows to resolve port numbers into names defined
in the services(5) /etc/services database:
(a) it provides a standalone function which will fall back to
stringifying a port number;
(b) it resets the 'numeric service' flag of getnameinfo(3) to
analogously consider a lookup in /etc/services.
Assuming the following had been added to /etc/services:
para_server_control 2990/tcp # para_server control
paraslash_http_service 8000/tcp # paraslash http sender
paraslash_dccp_service 8000/dccp # paraslash dccp sender
paraslash_udp_service 8000/udp # paraslash udp sender,
then the output of 'para_client si' would look like:
http sender:
status: on
port: paraslash_http_service
...
dccp sender:
status: on
port: paraslash_dccp_service
...
udp sender:
status: on
port: paraslash_udp_service
...
Note: On some systems the service lookup may involve LDAP or NIS lookups,
depending on the 'services' configuration in /etc/nsswitch.conf. This does
not seem to cause a problem, as it implies a working network connection.
Gerrit Renker [Thu, 25 Feb 2010 16:05:44 +0000 (17:05 +0100)]
01_convert-v6-mapped-v4-addresses.diff
This updates the resolution of v4/v6 addresses to present v6-mapped-v4
addresses in dot-quad format rather than as subtype of v6 address.
The getnameinfo(3) is in use for both address classes, where potential
DNS lookups (requiring Internet connectivity) are avoided by using the
NI_NUMERICHOST flag.
The use of this flag reduces getnameinfo() to inet_ntop(3). In the 'Bugs'
section of the inet_ntop() manpage it is stated that v6-mapped-v4 addresses
are converted into an IPv6 format, which is what had been observed here.
The patch works around the issue by casting the v6-mapped-v4 address into
a genuine AF_INET IPv4 socket address.
Andre Noll [Sun, 14 Feb 2010 21:58:12 +0000 (22:58 +0100)]
oggdec: Fix a thinko in post_select().
The old code broke out of the decoding loop if btr_node_status() returned zero
which is true if no more input data is available for decoding or we already
have decoded more than 640K. However, in the first case there might still be
decoded data available to be passed to the child nodes and we should pass
that data as quick as possible to avoid buffer underruns.
So call btr_get_output_queue_size() rather than btr_node_status() to detect
the second case.
Andre Noll [Sun, 14 Feb 2010 21:37:06 +0000 (22:37 +0100)]
btr: Rename btr_bytes_pending() and make it public.
The oggvorbis decoder needs to know this info, so make it public. As we have already
btr_get_input_queue_size() it is natural to rename btr_bytes_pending() to
btr_get_output_queue_size().
Andre Noll [Sat, 13 Feb 2010 12:12:47 +0000 (13:12 +0100)]
dccp_recv: Use para_readv() instead of recv_bin_buffer().
When the end of the buffer pool area is reached, the old code ended up calling recv()
with a buffer size smaller than a full datagram. This results in data being lost
because the remaining part of the datagram will be discarded rather than returned
at the next call to recv().
By using the new btr_pool_get_buffers() we obtain two buffers in this case, a small
one pointing to the end of the area and a larger one pointing to the area start. Passing
both buffers to para_readv() instead of using recv_bin_buffer() receives the full
datagram and therefore avoids the above mentioned loss of data.
Andre Noll [Sat, 13 Feb 2010 11:57:35 +0000 (12:57 +0100)]
Introduce btr_pool_get_buffers().
This allows the users of the buffer pool API to obtain references to both parts
of the buffer pool area in case there is free space available at the end of the
area as well as at the beginning.
This is needed for reading from file descriptors where reading less than a full
datagram would discard the remaining part (DCCP and UDP).
Andre Noll [Mon, 8 Feb 2010 13:46:48 +0000 (14:46 +0100)]
alsa: Remove xrun().
This function tried to compute the duration of the underun but never
really worked. The values were more or less random (up to hundreds
of seconds) and thus of little value.
Gerrit Renker [Wed, 3 Feb 2010 14:05:33 +0000 (15:05 +0100)]
Fix make clean and make install.
Commit 77aa6680 replaced the hardcoded list of binaries in Makefile.in
by the autoconf macro @executables@. However, the "install" and the
"clean" targets still used the now undefined $(BINARIES) variable. This
caused "make clean" to not remove any executables and "make install"
to fail with
/usr/bin/install -c -s -m 755 /usr/local/bin
/usr/bin/install: missing destination file operand after `/usr/local/bin'
Try `/usr/bin/install --help' for more information.
Fix this bug by using @executables@ rather than $(BINARIES).
Andre Noll [Sat, 30 Jan 2010 13:20:19 +0000 (14:20 +0100)]
audiod: Split open_current_receiver().
We need to check whether the current receiver should be opened from both
pre_select() and post_select(). So rename this function to must_start_decoder(),
make it return bool and do not start the decoder there.
This change makes audiod start the decoder as soon as possible.
Andre Noll [Tue, 19 Jan 2010 00:21:32 +0000 (01:21 +0100)]
Don't hardcode the list of executables in Makefile.in.
Just export the list via the $all_executables variable from configure.ac. Rename it to
$ececutables while we're at it and remove two unused variables in configure.ac.
Andre Noll [Sun, 17 Jan 2010 20:30:27 +0000 (21:30 +0100)]
[btr]: Avoid a gcc warning.
Although the warning
warning: 'brs[1]' may be used uninitialized in this function
is clearly bogus, it can't hurt to assert that i == 2 which also makes the warning to away.
Andre Noll [Fri, 15 Jan 2010 05:46:03 +0000 (06:46 +0100)]
btr support for para_client.
The use of the client code in audiod requires a node to be inserted
as the _parent_ of some existing node, which was not neccessary
before. Therefore a new btrn pointer for the child node is added to
struct btr_node_description and btr_new_node() is adjusted accordingly.
The patch also adds a small helper sched_request_barrier() to
the scheduler.
Andre Noll [Thu, 14 Jan 2010 03:19:59 +0000 (04:19 +0100)]
Introduce btr_node_description.
As the number of arguments to btr_new_node() grows, the code becomes
hard to read, especially since some callers must set many of the
arguments to NULL.
Using a pointer to a struct has the additional advantage that adding
new parameters does no longer require to touch all callers.
Andre Noll [Wed, 13 Jan 2010 23:11:46 +0000 (00:11 +0100)]
[btr] Fix merge_input_pool().
This function contained the following bug: wbr, buf1 and sz1 could
be used without being initialized. This was sometimes hitting the
assertion (buf1 && buf2).
Fix this by initializing these variables at the top.