An allnet packet constitutes of a header and a payload. The minimally required header is struct allnet_header defined in packet.h. Additional header fields are possible depending on the header's transport field.
A packet is at most ALLNET_MTU bytes long. This constraint is required because buffers must be allocated before receiving datagrams (UDP).
Accessing the Payload
The payload should be accessed using the macro ALLNET_DATA_START which takes three arguments and returns a pointer to the start of the payload:
- hp header pointer. Pointer to the start of the packet
- t the message type bitfield (hp->message_type)
- s the packet size
- ALLNET_TYPE_DATA An encrypted data message.
- ALLNET_TYPE_CLEAR A cleartext message is always a broadcast message.
- ALLNET_TYPE_ACK An acknowledgement.
- ALLNET_TRANSPORT_ACK_REQ Request that the packet be ACK'ed. For data (encrypted) messages, this will cause the recepient's application to send back an ACK on the message_id. For cleartext (broadcast) messages, the ACK will be sent back to the previous hop (not implemented yet -- probably should go in trace).
- ALLNET_TRANSPORT_EXPIRATION Indicates that the expiration field is part of the header. This field marks the time after which a packet is no longer useful and and can be discarded. The time is encoded in the [AllnetEpoch] format.