84 lines
2.1 KiB
C
84 lines
2.1 KiB
C
|
|
/*
|
||
|
|
* https://ciapini.wiki.esiliati.org/view/ArNet
|
||
|
|
*/
|
||
|
|
|
||
|
|
#ifndef ARNET_TYPES_H
|
||
|
|
#define ARNET_TYPES_H
|
||
|
|
|
||
|
|
#include <stdint.h>
|
||
|
|
|
||
|
|
#include "../net.h"
|
||
|
|
|
||
|
|
#define ARNET_PACKET_PROTOCOL 1 ///< 4bit net protocol id - arnet = 0
|
||
|
|
|
||
|
|
#define ARNET_PADDING 0
|
||
|
|
|
||
|
|
#define ARNET_ADDRESS_SIZE 256 ///< max arnet address space
|
||
|
|
#define ARNET_MAX_HEADER_NUMBER 16 ///< max arnet optional headers
|
||
|
|
#define ARNET_MAX_PACKET_SIZE 1024+((ARNET_MAX_HEADER_NUMBER+1)*4) ///< max arnet packet size
|
||
|
|
|
||
|
|
// ERRORS & STATUS
|
||
|
|
// #define ARNET_ERR_INVALID_SRC 1 // invalid source address
|
||
|
|
// #define ARNET_ERR_INVALID_DST 2 // invalid destination address
|
||
|
|
|
||
|
|
#define ARNET_EC_OK 0
|
||
|
|
#define ARNET_EC_WRONG 1
|
||
|
|
#define ARNET_EC_DISABLED 2
|
||
|
|
#define ARNET_EC_INVALID_ALGO 3
|
||
|
|
|
||
|
|
#define ARNET_CRC24_INIT 0xffffff
|
||
|
|
|
||
|
|
/* TODO
|
||
|
|
typedef struct {
|
||
|
|
uint8_t headers_pending;
|
||
|
|
uint8_t headers_parsed;
|
||
|
|
uint8_t headers_done[ARNET_MAX_HEADER_NUMBER];
|
||
|
|
} arnet_status;
|
||
|
|
*/
|
||
|
|
|
||
|
|
// il payload size va nella coda net
|
||
|
|
|
||
|
|
typedef struct {
|
||
|
|
uint8_t protocol; ///< codice protocollo
|
||
|
|
uint8_t header_size; ///< numero di header aggiuntivi
|
||
|
|
uint16_t payload_size; ///< dimensione del payload in byte
|
||
|
|
uint8_t src_addr; ///< indirizzo mittente
|
||
|
|
uint8_t dst_addr; ///< indirizzo destinatario
|
||
|
|
} DH;
|
||
|
|
|
||
|
|
typedef struct {
|
||
|
|
uint8_t enabled;
|
||
|
|
// uint16_t vci;
|
||
|
|
uint8_t sequence;
|
||
|
|
uint8_t acknowledge;
|
||
|
|
} VC;
|
||
|
|
|
||
|
|
typedef struct {
|
||
|
|
uint8_t enabled;
|
||
|
|
uint8_t algo;
|
||
|
|
uint8_t ARQ;
|
||
|
|
uint8_t ACK;
|
||
|
|
uint32_t value;
|
||
|
|
} EC;
|
||
|
|
|
||
|
|
typedef struct {
|
||
|
|
uint8_t enabled;
|
||
|
|
uint8_t segaddr;
|
||
|
|
uint8_t timeframe;
|
||
|
|
uint8_t beacon_period;
|
||
|
|
uint8_t reserved_window;
|
||
|
|
} SAAH;
|
||
|
|
|
||
|
|
typedef struct {
|
||
|
|
DH dh; ///< default header
|
||
|
|
VC vc;
|
||
|
|
EC ec;
|
||
|
|
SAAH saah;
|
||
|
|
} arnet_packet;
|
||
|
|
|
||
|
|
extern uint8_t arnet_tx_headers_pending, arnet_tx_headers_done[16], arnet_rx_headers_parsed;
|
||
|
|
extern arnet_packet arnet_tx_packet_queue[NET_PACKET_RINGBUF_SIZE], arnet_rx_packet_queue[NET_PACKET_RINGBUF_SIZE];
|
||
|
|
|
||
|
|
#endif /* ARNET_TYPES_H */
|
||
|
|
|