Currently, the tcp and udp implementations are bound to each other in a
module called *destiny*. Thus, when using only one of them then the
other one gets also compiled into the binary and initialized,
which results in unnecessary RAM usage and workload for the CPU.
The approach in this PR defines a common module named *socket_base*,
which contains functions used by the posix layer. Compiled by it's own,
those functions return negative error codes, to symbolize upper layers
that they are not supported. When also including the modules *udp* or
*tcp* respectively, functions from *socket_base* get overwritten with the
correct functionality.
Defining *udp* or *tcp* in a Makefile also includes *socket_base*.
Defining *pnet* in a Makefile also includes *socket_base*.
Instead of using differing integer types use kernel_pid_t for process
identifier. This type is introduced in a new header file to avoid
circular dependencies.
This PR converts tabs to white spaces.
The statement I used for the conversion:
```find . -name "*.[ch]" -exec zsh -c 'expand -t 4 "$0" > /tmp/e && mv /tmp/e "$0"' {} \;```
Afterwards, I had a quick overview of the converted files to prevent odd indentation.
Currently, the TCP_STACK_SIZE is `KERNEL_CONF_STACKSIZE_DEFAULT`.
However, since printf statements are used in the tcp relevant code,
this stack size is too small (esp. for MSBA2).
While testing the tcp implementation on MSBA2 I noticed that
the value of `tcp_input_buffer_end` gets changed whenever acquiring or
releasing the mutex of the struct on the server side.
After deleting the packed attribute of the struct this problem was
resolved and the value stayed the same after acquiring and releasing.
This problem could maybe arise from badly placed cache lines due to
missing padding... I am not sure.
Anyway, I guess using the packed attribute is useless here and makes it
more error-prone.
The current implementation does not set the ack bit
for outgoing data segments and the fin segment.
However, RFC793 states that all segments
should have an ack bit set in order to present a valid
ack nr. in outgoing segments.
Currently, data segments and acknowledgement segments
are distinguished by the existence of their ack bit.
With the new assumption, that both of these types of
segments need an ack bit set, I had to change several
parts of the current implementation to make this
decision by inspecting the payload size.
destiny: added parens
For many modules the `Makefile` contains a line like
```
MODULE:=$(shell basename $(CURDIR))
```
This conclusively shows that we do not have to set the module name
manually.
This PR removes the need to set the module name manually, if it is the
same as the basename. E.g. for `…/sys/vtimer/Makefile` the variable
make `MODULE` will still be `vtimer`, because it is the basename of the
Makefile.
In the current implementation the data offset is coded into an uint8_t.
Of this uint8_t only 3 bits apply for the data offset.
The remaining bits represent reserved flags for future use.
However, a proper bit masking is forgotten in order
to obtain the data offset part of this uint8_t.
Therefore, defining this uint8_t as a bit field allows a more convenient
method of access.
When accessing the length field of an ipv6_header a byte order switch (host -> network) is necessary.
Otherwise, it breaks calculations or the checksum and other tcp related computations.
Furthermore, when writing to ipv6_header->length it is important to switch this
from host byte order to network byte order.
send_tcp returns either the length of the sent data,
or -1, if an error was detected.
The current implementation checks for != 1.
This results in executing the error case, although
there was semantically no error returned from send_tcp.
This enum is also used to set the tcp flags within a tcp header.
With the current values in this enum, wireshark is not able to
recognize the tcp segments as their actual tcp type,
and thus odd messages in wireshark appear.
destiny: reusing tcp flags for combinations
get_socket(i) returns NULL, when no specific socket is found.
Without an appropriate check for NULL, the current state
of the code leads to a segfault.
destiny: added parens
destiny: continuing the loop makes more sense than returning at first sight of NULL
All other layers in the network stack use a msg_queue to not drop messages, which in this context represent packages.
This finally fixes the random crashes when UDP network traffic is present. Turns out RIOT is not handling lost messages well.