From 27e285909000ea322e40292a05f08d411ca5ee4a Mon Sep 17 00:00:00 2001 From: Thomas Kolb Date: Sun, 30 Jun 2024 16:18:11 +0200 Subject: [PATCH] Start defining layer2 structures --- impl/src/layer2/layer2_structs.h | 43 ++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 impl/src/layer2/layer2_structs.h diff --git a/impl/src/layer2/layer2_structs.h b/impl/src/layer2/layer2_structs.h new file mode 100644 index 0000000..1c042c6 --- /dev/null +++ b/impl/src/layer2/layer2_structs.h @@ -0,0 +1,43 @@ +#ifndef LAYER2_STRUCTS_H +#define LAYER2_STRUCTS_H + +#include +#include + +/* Common Link-layer Header */ + +typedef enum { + L2_MSG_TYPE_DATA = 0x0, + L2_MSG_TYPE_CONN_MGMT = 0x1, + L2_MSG_TYPE_CONNECTIONLESS = 0x4 +} layer2_message_type_t; + +typedef struct layer2_packet_header_s { + layer2_message_type_t msg_type; //!< message type + bool tx_request; //!< transmission request (marks the end of the burst) + uint8_t src_addr_len; //!< source address length (in 16-bit words) + uint8_t dst_addr_len; //!< destination address length (in 16-bit words) + + uint8_t tx_seq_nr; //!< sequence number of this packet + uint8_t rx_seq_nr; //!< sequence number expected next from he other side + + uint8_t src_addr[8]; //!< source HAM-64 address + uint8_t dst_addr[8]; //!< destination HAM-64 address +} layer2_packet_header_t; + +/* Data Packet Structs */ + +typedef enum { + L2_PAYLOAD_TYPE_IPV4 = 0x00, + L2_PAYLOAD_TYPE_IPV6 = 0x01 +} layer2_payload_type_t; + +typedef struct layer2_data_header_s { + layer2_payload_type_t payload_type; //!< Type of the contained layer 3 packet +} layer2_data_header_t; + +/* Connection Management Structs */ + +// TODO + +#endif // LAYER2_STRUCTS_H