init
This commit is contained in:
107
main/packetstructs.h
Normal file
107
main/packetstructs.h
Normal file
@@ -0,0 +1,107 @@
|
||||
#ifndef PACKETSTRUCTS_FILE
|
||||
#define PACKETSTRUCTS_FILE
|
||||
|
||||
#include <stdint.h>
|
||||
#define ROUTE_TYPE_MASK 0x03
|
||||
#define PAYLOAD_TYPE_MASK 0x3C
|
||||
#define PAYLOAD_VERSION_MASK 0xC0
|
||||
|
||||
typedef enum RouteType {
|
||||
ROUTE_TYPE_TRANSPORT_FLOOD = 0x00,
|
||||
ROUTE_TYPE_FLOOD = 0x01,
|
||||
ROUTE_TYPE_DIRECT = 0x02,
|
||||
ROUTE_TYPE_TRANSPORT_DIRECT = 0x03,
|
||||
} RouteType;
|
||||
|
||||
|
||||
typedef enum PayloadType {
|
||||
PAYLOAD_TYPE_REQ = 0x00 << 2,
|
||||
PAYLOAD_TYPE_RESPONSE = 0x01 << 2,
|
||||
PAYLOAD_TYPE_TXT_MSG = 0x02 << 2,
|
||||
PAYLOAD_TYPE_ACK = 0x03 << 2,
|
||||
PAYLOAD_TYPE_ADVERT = 0x04 << 2,
|
||||
PAYLOAD_TYPE_GRP_TXT = 0x05 << 2,
|
||||
PAYLOAD_TYPE_GRP_DATA = 0x06 << 2,
|
||||
PAYLOAD_TYPE_ANON_REQ = 0x07 << 2,
|
||||
PAYLOAD_TYPE_PATH = 0x08 << 2,
|
||||
PAYLOAD_TYPE_TRACE = 0x09 << 2,
|
||||
PAYLOAD_TYPE_MULTIPART = 0x0A << 2,
|
||||
PAYLOAD_TYPE_RAW_CUSTOM = 0x0F << 2,
|
||||
} PayloadType;
|
||||
|
||||
|
||||
typedef enum PayloadVersion {
|
||||
PAYLOAD_VERSION_0 = 0 << 6,
|
||||
PAYLOAD_VERSION_1 = 1 << 6,
|
||||
PAYLOAD_VERSION_2 = 2 << 6,
|
||||
PAYLOAD_VERSION_3 = 3 << 6,
|
||||
} PayloadVersion;
|
||||
|
||||
|
||||
typedef struct FrameStruct {
|
||||
unsigned char header;
|
||||
unsigned char transportCodes[4];
|
||||
unsigned char pathLen;
|
||||
unsigned char path[64];
|
||||
unsigned char payloadLen;
|
||||
unsigned char payload[184];
|
||||
} FrameStruct;
|
||||
|
||||
typedef enum AdvertisementPayloadFlags {
|
||||
ADVERTISEMENT_FLAG_IS_CHAT_NODE = 0x01,
|
||||
ADVERTISEMENT_FLAG_IS_REAPEATER = 0x02,
|
||||
ADVERTISEMENT_FLAG_IS_ROOM_SERVER = 0x03,
|
||||
ADVERTISEMENT_FLAG_IS_SENSOR = 0x04,
|
||||
ADVERTISEMENT_FLAG_HAS_LOCATION = 0x10,
|
||||
ADVERTISEMENT_FLAG_RFU1 = 0x20,
|
||||
ADVERTISEMENT_FLAG_RFU2 = 0x40,
|
||||
ADVERTISEMENT_FLAG_HAS_NAME = 0x80,
|
||||
} AdvertisementPayloadFlags;
|
||||
|
||||
typedef struct AdvertisementPayload {
|
||||
unsigned char pubKey[32];
|
||||
int32_t timestamp;
|
||||
unsigned char signature[64];
|
||||
unsigned char dataFlags;
|
||||
int32_t latitude;
|
||||
int32_t longitude;
|
||||
int16_t rfu1;
|
||||
int16_t rfu2;
|
||||
char nodeName[128];
|
||||
|
||||
} AdvertisementPayload;
|
||||
|
||||
typedef struct ReturnedPathPayload {
|
||||
unsigned char destinationHash;
|
||||
unsigned char sourceHash;
|
||||
uint16_t cipherMAC;
|
||||
unsigned char pathLen;
|
||||
|
||||
} ReturnedPathPayload;
|
||||
|
||||
typedef struct RequestPayload {
|
||||
unsigned char destinationHash;
|
||||
unsigned char sourceHash;
|
||||
uint16_t cipherMAC;
|
||||
} RequestPayload;
|
||||
|
||||
typedef struct ResponsePayload {
|
||||
unsigned char destinationHash;
|
||||
unsigned char sourceHash;
|
||||
uint16_t cipherMAC;
|
||||
} ResponsePayload;
|
||||
|
||||
typedef struct PlainTextMessagePayload {
|
||||
unsigned char destinationHash;
|
||||
unsigned char sourceHash;
|
||||
uint16_t cipherMAC;
|
||||
} PlainTextMessagePayload;
|
||||
|
||||
typedef struct GroupTextMessage {
|
||||
unsigned char channelHash;
|
||||
int32_t timestamp;
|
||||
unsigned char flags;
|
||||
unsigned char text[190]
|
||||
} GroupTextMessage;
|
||||
|
||||
#endif
|
Reference in New Issue
Block a user