If a packet of only 1 byte was received (which only can happen due to
noise), a segmentation fault could occur because the CRC expects at
least two bytes. This is now handled correctly.
The connection module now has a separate queueing mechanism for packets that
are only transmitted once and not acknowledged through the regular Go-back-N
mechanism. An example is the Connection Request that is a one-time response to
a received beacon.
When such a packet shall be sent, a simple flag is set and the packet is
transmitted first in the next burst. Data packets may follow depending on the
one-shot packet type (Connection Request ends the burst immediately).
As this system is currently half-duplex and therefore there are no packets that
can still be received after a burst transmission has started, retransmission
handling can be simplified a lot. This commit therefore removes all time-based
retransmission code and instead transmits all so far unacknowledged packets in
every burst.
- add and handle layer 2 packet type correctly in data packets
- don't produce garbage packets if a packet could not be decoded or was not a
data packet
- handle beacon/connection request/connection parameters handshake
- digipeater cycle timeout does not reset beacon timer anymore. This prevented
any beacon transmission.
- Reset the connection timeout when empty packets are received
Instead, connection and digipeater now update a event code passed by reference
to the maintain() function. This was the only place where the callback was
called before.
Minor side effect: maintain must be called multiple times if multiple events
trigger at the same time.
Without this flag the kernel adds packet information to each packet. The
interesting part of that information is the EtherType of the packet, which
simplifies handling.
The oneshot queue is for connection management frames that are only sent once,
at the beginning of the next burst. An example is the Connection Reset packet.
Intervals define the boundary between the handling of different connections.
The interval can be either ended by a packet with TX Request set, or by a
timeout. In either case, forwarding of packets to the current connection stops
and the connection is re-scheduled to a later point in time.
- split handle_packet() in two functions: the first does basic checks and calls
the second one. This allows to do the basic checks externally (in the
multi-connection management module) without duplicating them.
- use the new layer2_encode_packet() function.
This prevents loss of precision that occurs with double-precision floats if
timestamps become very large. Timestamps are already large if they contain a
UNIX time value (requires 60 bits; double has 53 bit resolution).