With lwIP we have a chunked UDP payload, so just providing the
stack-internal buffer is not possible. To be able to iterate over such
a chunked payload, this change allows the `sock_*_recv_buf()` functions
to use the internal buffer context as an iteration state.
As the internal buffer space can be released when the function would
return 0, `sock_recv_buf_free()` becomes unnecessary.
This change amends the `sock` API by a set of functions to `sock` that
allow provisioning of stack-internal buffers to the caller on receive.
This allows to cover two use-cases
1. Zero-copy systems: if the stacks supported the buffer space provided
by these functions can be the same that was filled in the link-layer
2. asynchronous receive within a wrapping sock layer (e.g. `sock_dtls`
wrapping `sock_udp`): to receive packets of the lower level protocol
asynchronously, the wrapping implementation layer would currently
need to allocate its own buffer space, introducing a third buffer
space in addition to the one of the application and the network
stack. For a wrapping layer this is undesirable.
While there are security considerations exposing stack internal memory
space to the caller, I believe they are minor, as in the end the
application developer is the person in control of the node.
Saving RAM is more important than saving a few cycles
used by re-creating the request buffer in the error case.
Also reduce the size of the buffer to 128 bytes.
If we are just requesting the AAAA record it is unlikely
for the reply to take up the maximum size of 512 bytes.
We were already placing restrictions on the domain name length,
those are now actually a bit more relaxed (112 bytes instead of 64)
This way, the sock-types can use the sock_async_ctx_t type in their
definition without including `sock_async_ctx.h` (potentially creating
further cyclic includes).
Typically a stack needs to add the callback for a sock as a member of
its respective `sock` type so `sock_types.h` needs to include
`net/sock/async.h` at the moment. As those however include
`net/sock/<prot>.h`, which in turn include `sock_types.h`, we create a
cyclic dependency.
This fix resolves this cyclic dependency, by putting the callback
definitions in its own header that then in turn can be also included
by `sock_types.h`.
This change allows the port for local endpoint to be zero 0. If this is
the case the `sock_udp_create()` function binds the object to an
ephemeral port.
I applied the following terminology and changed the wording in the doc
accordingly:
* must not: If the parameter is of the value it *must not* be it either
hits an assert or crashes the system.
* may not: The value can be that value, but the function will return an
error.
Since sock_tcp_t isn't defined at this moment (only declared) the
compiler is complaining about the use of an array in the parameter list
here.
sys/include/net/sock/tcp.h:119:32: error: array type has incomplete element type ‘sock_tcp_t {aka struct
sock_tcp}’
sock_tcp_t queue_array[], unsigned queue_len,
^
This introduces a new alternative and better API to `conn`. It differs in the
following aspects:
* a common address type for both IPv4 and IPv6 addresses is introduced
* communication end-points are abstracted as end-point types `sock_x_ep_t`,
containing the address, its family, its port (if required for protocol) and
the interface identifier.
* All functions require some kind of state. Sending of datagrams to the same
source or replying to incoming datagrams is thus simplified
* TCP connection establishment was overall reworked: connected sockets and
listening sockets are now two distinct types. An accept on a listening socket
than yields a connected socket