summaryrefslogtreecommitdiff
path: root/net.h (follow)
Commit message (Collapse)AuthorAge
* Move generic_max_transport_msg_size() into udp_send.c.Andre Noll2026-04-11
| | | | | | | Thanks to the previous patch, the function is only called from udp_send.c, so move it there, along with its dependencies in net.c. To accomplish this, we have to make ss_is_addr_v4mapped() public. Since it is very small, it's easiest to move it to net.h as a static inline function.
* Switch to SPDX identifiers.Andre Noll2026-03-17
| | | | | | | | Generated with sed -i 's|Copyright.*Andre Noll.*|SPDX-License-Identifier: GPL-2.0 */|g' *.c *.h followed by manually tweaking the result a bit. No license change intended.
* Move format_url() from net.c to http_send.c.Andre Noll2026-01-26
| | | | It's only needed there.
* Remove dccp.Andre Noll2026-01-26
| | | | | | | | | | | This removes all traces of dccp, specifically dccp_recv.c and dccp_send.c. The flowops related functions of net.c can go away as well, as flowops were only needed for the dccp transport. A few other functions are simplified by dropping the flowops or protocol parameter. Further cleanups are possible, but are deferred to subsequent commits. In particular, some functions of send_common.c are only called by the http transport now. These can be moved to http_send.c and then be made static.
* Make send_cred_buffer() and recv_cred_buffer() local.Andre Noll2026-01-04
| | | | | | Only para_audioc needs the former, and only para_audiod needs the latter. With this patch in place, both functions can be static and the other executables which link in net.o don't get bloated with unnecessary code.
* Compile with -Wsuggest-attribute=malloc.Andre Noll2023-12-24
| | | | | | | | | | | | We already employ this attribute extensively to help the compiler improve optimization. However, a few malloc-like functions were not yet marked with __malloc. Fix that and enable the warning to make sure that new malloc-like functions get marked. Since not all supported compilers know about this warning option, we need to check at compile time whether the option is supported. Thanks to the existing cc-option make(1) function, this is a simple one-liner for Makefile.real.
* net: Pass true/false instead of 0/1 to makesock().Andre Noll2022-10-03
| | | | The function receives a boolean argument, after all.
* net: Rename para_connect_simple() -> para_connect().Andre Noll2022-10-03
| | | | | We used to have para_connect() at some point (hence the need for the _simple suffix), but it was removed long ago.
* net: Make is_valid_ipv{4,6}_address() local to net.c.Andre Noll2022-10-03
| | | | | | These inline functions are only used in net.c, so they do not need to be declared in net.h. De-doxyfy their documentation because static functions don't need doxygen comments.
* net: Remove IPPROTO_DCCP define.Andre Noll2022-10-03
| | | | | | This macro is defined in the system headers on all moderately new Linux versions, FreeBSD-13 and NetBSD-9, so our local fallback is not needed anymore.
* net: Make single-use macros local.Andre Noll2022-10-03
| | | | | | | | A few macros are defined in net.h but are only used in a single C file. Move those to where they are used to make the code easier to follow. DCCP_SOCKOPT_RX_CCID is not used at all, so remove that.
* net: Combine documentation of struct flowopts.Andre Noll2022-10-03
| | | | It was documented both in net.h and net.c.
* net: Drop extern keyword of function declarations.Andre Noll2022-10-03
| | | | It has no effect.
* net: Drop fd_set parameter from para_accept().Andre Noll2022-08-25
| | | | | | As for read_nonblock(), the parameter is dispensable because it is only used for an optimization to avoid a system call. Get rid of it because it hinders the conversion from select(2) to poll(2).
* server: Add --http-listen-address and --dccp-listen-address.Andre Noll2018-04-17
| | | | | | | | | | | | | | | | | | Currently the http and the dccp sender accept connections on all IP addresses. This commit makes it possible to configure the senders to listen only on the specified subset of addresses. To make this work, the sender_status structure has to be extended to store an array of file descriptors rather than just a single one. Several places need to iterate over all listening sockets of the sender. The new FOR_EACH_LISTEN_FD macro helps to avoid duplicating the corresponding loop. The status part of the sender command now prints the listening addresses instead of just on/off. This is why we also maintain the ascii representation of the listening addresses in the sender_status structure and introduce the format_url() helper to format host/port pairs.
* server: Implement --listen-address for control service.Andre Noll2018-04-17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | For hosts with multiple IP addresses one might want to configure the listening sockets so that connections can only arrive on a subset of the host's addresses. This patch implements this feature. Unlike para_listen_simple() the new para_listen() receives an optional argument to let the caller specify the listening address in addition to the port number. para_listen_simple() is now a simple wrapper that passes a NULL pointer as the new argument which indicates that the socket should listen on all local addresses, just like prior to this change. The set of listening addresses for the control service of para_server can be specified via the new --listen-address option. This option can be given multiple times, once for each listening address. Due to this change the server needs to maintain more than a single file descriptor to dispatch incoming connections. Hence the integer ->listen_fd of struct server_command_task has to be replaced by an array of file descriptors and the {pre,post}_select methods of the command task have iterate over all descriptors in the array. The meaning of the --port option has changed due to the new option: since the argument to --listen-address can also contain a port number, the argument to --port is only used for addresses with no port number, or if --listen-address is not given at all. Although the http and dccp senders also open a listening socket, this commit affects only the control service of para_server (listening on TCP 2990 by default). Senders will be covered in the next commit.
* Move MAX_HOSTLEN from server.h to net.h.Andre Noll2018-04-17
| | | | | | This generic networking-related constant does not belong to server.h. However, since server.h uses the constant, we have to make sure that net.h is included before server.h.
* net: Combine para_listen() and para_listen_simple().Andre Noll2018-04-17
| | | | | The only caller of para_listen() is para_listen_simple(), since flowops are only used for active sockets.
* Shorten copyright notice.Andre Noll2017-09-22
| | | | | | | | | | | | | | | | | | | | | The GPLv2 line does not add any additional information, so drop it. This leaves a single line of legalese text for most files, which is about the amount of screen real estate it deserves. This patch was created with the following script (plus some manual fixups): awk '{ if (NR <= 5) { gs = gensub(/.*Copyright.* ([0-9]+).*Andre Noll.*/, "\\1", "g") if (gs != $0) year = gs next } if (NR == 6 && year != "") printf("/* Copyright (C) %s Andre Noll <maan@tuebingen.mpg.de>, see file COPYING. */\n", year) print }'
* doxygen: Trivial cleanups.Andre Noll2017-06-25
| | | | A couple of capitalization and punctuation fixes.
* Remove compatibility code for abstract unix domain sockets.Andre Noll2017-01-22
| | | | | | | | | | | | | | | | Abstract sockets were introduced in paraslash-0.5.5 (2015-09-20). For backwards compatibility, create_local_socket() was modified to create an abtract socket *and* an ordinary pathname socket so that old audiod clients (which connect to the pathname socket) would still work. This patch breaks compatibility by going back to a single socket, either abstract (Linux) or pathname (all other systems), as determined in the first call to create_local_socket(). This allows to drop the "abstract" argument of init_unix_addr() and the "mode" argument of create_local_socket(). The code in net.c and the callers get quite a bit shorter since it has to deal with only a single file descriptor and one type of socket.
* Remove socket address parameter of create_local_socket().Andre Noll2015-02-14
| | | | | | | The two callers of create_local_socket() are not interested in the sockaddr_un structure at all. So we may define the structure in create_local_socket() rather than in each caller, and kill the function parameter.
* Update year in copyright headers.Andre Noll2015-01-12
| | | | | | | | | | | | | | | | Done with files=$(git grep -l 'Copyright (C) [0-9]\{4\}\(-2014\)* Andre Noll') sed --in-place= -e 's/Copyright (C) \([0-9]\{4\}\)-2014 Andre Noll/Copyright (C) \1 Andre Noll/1' $files In previous years we ran a similar script to set the second year in the range to the current year. This is kind of silly, so let's get rid of this useless information. This commit replaces "Copyright (C) A-B" by "Copyright (C) A" in all file headers, i.e. only the first year (A) is left in. Accurate information including time stamps for each change can be obtained from the git history.
* net.c: Remove unused local_name().Andre Noll2015-01-12
| | | | Found by cppcheck.
* doc: Change email address to maan@tuebingen.mpg.deAndre Noll2014-08-18
| | | | | | | | | | | | | | The mail server on systemlinux.org was down for more than a week lately, so let's use an alternative official address. This commit changes all maan@systemlinux.org addresses to maan@tuebingen.mpg.de. Most .c and .h files contain the email address in the copyright header, so they must all be patched. Three other files contain the address for a different reason: * README lists email and git, gitweb and home page URLs * configure.ac needs it for configure -h * version.c contains it for the -V option of all commands
* Merge branch 't/misc'Andre Noll2014-03-30
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Various fixes, improvements, cleanups. Cooking since 2014-02-22. * t/misc: (29 commits) build: Don't link with -lreadline if readline was not found. audiod: Skip NULL pointer check in compute_time_diff(). audiod: Make compute_time_diff() return void. com_stat(): Remove pointless uptime variable. gcrypt: Fix gcc warning on Ubuntu Lucid. flac: Try to link also without -logg. version.c: Fix comment of version_single_line(). doxygen: Expand all macros, in particular config.h. recv_common.c: Improve documentation of check_receiver_arg(). audiod: get_time_string() comment fix. configure: Really print opus audio file handler if opus lib was found. Overhaul doxygen main page. afs.h: Don't try to list all supported audio formats. Change copyright year to 2014. Add link to sideband.h in doxygen main page. Doxify error2.c and add GPL header. Add -Wdeclaration-after-statement. Add some missing includes. Makefile.real: Add clean2 to the list of phony targets. mood.c: Fix a trivial whitespace issue. ...
| * Change copyright year to 2014.Andre Noll2014-02-22
| | | | | | | | | | | | | | | | | | This year, we're really on time. The changes in this patch were created by the following silly script: files=$(git grep -l 'Copyright (C) [0-9]\{4\}\(-2013\)* Andre Noll') sed --in-place= -e 's/Copyright (C) \([0-9]\{4\}\)-2013 Andre Noll/Copyright (C) \1-2014 Andre Noll/1' $files sed --in-place= -e 's/Copyright (C) 2013 Andre Noll/Copyright (C) 2013-2014 Andre Noll/1' $files
* | The sync filter.Andre Noll2014-01-01
| | | | | | | | | | | | | | | | | | | | | | | | | | This adds a new filter for synchronization between clients. It works by sending an UDP packet to other clients ("buddies"). To reduce latency, address resolution is only performed once on startup. Hence lookup_address() and makesock_addrinfo() of net.c are made public. This commit introduces new public function sockaddr_equal() in net.c which compares two IPv4 or IPv6 addresses. It is used in sync_find_buddy().
* | net: Let maksock() callers perform flowopt cleanup.Andre Noll2014-01-01
|/ | | | | | | | | | Currently the flowopt user allocates the flowopt structure but cleanup is performed in makesock(). This commit makes the API symmetric by dropping the cleanup part in makesock() and exporting flowopt_cleanup(). Now callers have to perform both the allocation and the cleanup. The single user (ddcp_recv) is adjusted accordingly.
* extract_v4_addr(): Don't return a structure.Andre Noll2013-09-04
| | | | | | | | | | | | | | When compiling with -Waggregate-return, gcc issues the following warning: net.c: In function 'extract_v4_addr': net.c:682: warning: function returns an aggregate acl.c: In function 'acl_check_access': acl.c:60: warning: function call has aggregate value It's not entirely clear how bad it is these days to return a structure, but extract_v4_addr() is the only function in the tree which does it. Since it can be easily changed to take a pointer instead and there is only a single caller, let's implement it this way.
* net: Remove unused flowopt_add_bool().Andre Noll2013-07-13
|
* Change copyright year to 2013.Andre Noll2013-03-25
| | | | Better late than never.
* Move send_buffer() and send_va_buffer() from net.c to fd.c.Andre Noll2012-01-20
| | | | | | | These functions end up calling plain write(), hence they work on arbitrary file descriptors, not just network sockets. So they really belong to fd.c rather than to net.c. Rename the two functions to write_buffer() and write_va_buffer().
* Remove send_bin_buffer().Andre Noll2012-01-20
| | | | | It is just a trivial wrapper for write_all(). This patch changes all callers to use write_all() directly and removes the wrapper.
* Change year in copyright message to 2012.Andre Noll2012-01-07
|
* Always include stdbool.h.Andre Noll2011-12-18
| | | | | | | | | This adds the #include statement for stdbool.h to para.h. This allows to get rid of the individual includes in *.c. More importantly, since all *.c files include para.h, booleans will now be available everywhere so that we won't need to touch dozens of files anymore whenever a boolean is added to a public structure.
* Fix UNIX_PATH_MAX on NetBSD.Andre Noll2011-09-28
| | | | | | | | | UNIX_PATH_MAX was hardcoded to 108 for all systems. However, at least on 32 bit NetBSD the size of the sun_path buffer is only 104 bytes. This resulted in a very nasty bug caused by a memset() overwriting 4 bytes on the stack. Fix this by calculating the correct value at compile time.
* Constify flowop functions.Andre Noll2011-05-22
| | | | | This trivial patch fixes some "discards qualifiers" gcc warnings when compiling with -Wwrite-strings.
* Replace 2010 in copyright message by 2011.Andre Noll2011-01-17
|
* net: Rename create_remote_socket() connect_local_socket().Andre Noll2010-08-23
| | | | | | It's all about local unix domain sockets, so avoid the word "remote". Also, this function does not create the socket special in /var/paraslash.
* dccp_send: send data in MPS-sized chunksGerrit Renker2010-06-07
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | As mandated by RFC 4340, 14., DCCP maintains an internal variable called 'Maximum Packet Size', which can be queried via the DCCP_SOCKOPT_GET_CUR_MPS socket option. This option has been available since 2007-10-04 (v2.6.23) and is documented in Documentation/networking/dccp.txt. The Maximum Packet Size takes into account the path MTU, size of headers and the estimated overhead for DCCP options. The following table shows various values that were determined experimentally between two hosts: +----------+------------+--------------+--------------------+ | Medium | IP version | MTU in bytes | Resulting DCCP MPS | +----------+------------+--------------+--------------------+ | Ethernet | IPv4 | 1500 | 1424 bytes | | Ethernet | IPv6 | 1500 | 1404 bytes | +----------+------------+--------------+--------------------+ | WiFi | IPv4 | 576 | 500 bytes | | WiFi | IPv4 | 1280 | 1204 bytes | | WiFi | IPv4 | 1500 | 1424 bytes | | WiFi (a) | IPv4 | 2048 | 1972 bytes | +----------+------------+--------------+--------------------+ | WiFi | IPv6 | 576 | see (b) | | WiFi | IPv6 | 1280 | 1184 bytes | | WiFi | IPv6 | 1500 | 1404 bytes | | WiFi (a) | IPv6 | 2048 | 1952 bytes | +----------+------------+--------------+--------------------+ Notes: (a) WiFi normally uses Ethernet MTU of 1500 bytes, but the medium supports a much larger MTU (Fragmentation threshold) of up to about 2300 bytes (system used 802.11g). (b) 576 byte MTU not tested for IPv6 since IPv6 mandates a minimum MTU of 1280 bytes, as per RFC 2460 section 5 (also RFC 5405, 3.2). The patch implements the dccp init_fec() function based on the DCCP MPS.
* net: generic code to query the maximum message sizeGerrit Renker2010-06-07
| | | | | | | This adds a fallback routine to determine the address-family specific maximum message size (MMS). This value is an over-estimation of the maximum payload size that the network layer can take, i.e. it returns the maximum size for transport-layer header and transport-layer payload.
* Rework para_accept().Andre Noll2010-04-25
| | | | | | | | | Make it take an fd_set pointer and check the fd for readability within para_accept() rather than in each caller. Also, don't return an error on EAGAIN. Fix all callers accordingly. Most of them become a bit simpler due to this change.
* Make recv_pattern() use the nonblock API.Andre Noll2010-04-25
| | | | | Move it to fd.c and rename it to read_pattern(). Both users, http_recv.c and http_send.c, are adjusted accordingly.
* Change year in COPYRIGHT to 2010.Andre Noll2010-04-05
| | | | Hey, this is earlier than last year :)
* net: fix broken dccp_available_ccids()Gerrit Renker2010-03-13
| | | | | | | | 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().
* net.h: Fic compilation on systems with partial DCCP support.Andre Noll2010-02-25
| | | | | | | | 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.
* 08_refactor-makesock.diffGerrit Renker2010-02-25
| | | | | | | | | | 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'.
* 07_flow-opt-support.diffGerrit Renker2010-02-25
| | | | | | | | | | | | | | | | | | 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.*().
* 05_dccp-supported-ccid-lookup.diffGerrit Renker2010-02-25
| | | | | | | | | | | | 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.