syntax = "proto3";
import "nanopb.proto";

enum MessageType {
    MESSAGE_TYPE_UNSPECIFIED = 0;
    MESSAGE_TYPE_DATA = 1;
    MESSAGE_TYPE_JOIN = 2;
    MESSAGE_TYPE_LEAVE = 3;
    MESSAGE_TYPE_KEEPALIVE = 4;
    MESSAGE_TYPE_FRAGMENT = 5;
    MESSAGE_TYPE_ACK = 6;
    MESSAGE_TYPE_CONNECT_REQUEST = 7;
    MESSAGE_TYPE_CONNECT_REPLY = 8;
}

message Fragment {
    uint32 id = 1;
    uint32 sequence = 2;
    uint32 total = 3;
}

message Ack {
    uint32 id = 1;
    uint32 history = 2;
}

message NetworkMessage {
    MessageType message_type = 1;
    uint32 client_id = 2;
    bytes mac = 3 [(nanopb).type = FT_POINTER];
    bytes frame = 4 [(nanopb).type = FT_POINTER];
    uint32 flags = 5;
    uint32 version = 6;
    Ack ack = 7;
    Fragment fragment = 8;
    int64 timestamp = 9;
    uint32 sequence = 10;
}