From 7068a20b18de87204924535c79190f1e702ea11c Mon Sep 17 00:00:00 2001 From: "Dmitriy A. Gerasimov" <dmitriy.gerasimov@demlabs.net> Date: Mon, 7 Jan 2019 16:36:25 +0700 Subject: [PATCH] [+] ChainNet packet structure --- CMakeLists.txt | 5 ++-- dap_stream_ch_chain_net_pkt.c | 1 + dap_stream_ch_chain_net_pkt.h | 48 +++++++++++++++++++++++++++++++++++ 3 files changed, 52 insertions(+), 2 deletions(-) create mode 100644 dap_stream_ch_chain_net_pkt.c create mode 100644 dap_stream_ch_chain_net_pkt.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 7e16423..58c5cbc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,10 +1,11 @@ cmake_minimum_required(VERSION 3.0) project (dap_stream_ch_chain_net) -set(DAP_STREAM_CH_CHAIN_NET_SRCS dap_stream_ch_chain_net.c) +set(DAP_STREAM_CH_CHAIN_NET_SRCS dap_stream_ch_chain_net.c dap_stream_ch_chain_net_pkt.c) add_library(${PROJECT_NAME} STATIC ${DAP_STREAM_CH_CHAIN_NET_SRCS}) -target_link_libraries(dap_stream_ch_chain_net dap_core dap_crypto dap_core_server dap_stream dap_stream_ch dap_stream_ch_chain) +target_link_libraries(dap_stream_ch_chain_net dap_core dap_crypto dap_core_server dap_stream dap_stream_ch dap_stream_ch_chain + dap_chain_net) target_include_directories(dap_stream_ch_chain_net INTERFACE .) diff --git a/dap_stream_ch_chain_net_pkt.c b/dap_stream_ch_chain_net_pkt.c new file mode 100644 index 0000000..e7cc184 --- /dev/null +++ b/dap_stream_ch_chain_net_pkt.c @@ -0,0 +1 @@ +#include "dap_stream_ch_chain_net.h" diff --git a/dap_stream_ch_chain_net_pkt.h b/dap_stream_ch_chain_net_pkt.h new file mode 100644 index 0000000..29784b5 --- /dev/null +++ b/dap_stream_ch_chain_net_pkt.h @@ -0,0 +1,48 @@ +/* + * Authors: + * Dmitriy A. Gearasimov <gerasimov.dmitriy@demlabs.net> + * DeM Labs Inc. https://demlabs.net + * Kelvin Project https://github.com/kelvinblockchain + * Copyright (c) 2017-2018 + * All rights reserved. + + This file is part of DAP (Deus Applications Prototypes) the open source project + + DAP (Deus Applicaions Prototypes) is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + DAP is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with any DAP based project. If not, see <http://www.gnu.org/licenses/>. +**/ +#pragma once + +#include <stdint.h> +#include <stddef.h> +#include "dap_chain_common.h" +#include "dap_chain_net.h" +#include "dap_chain_node.h" + +#define STREAM_CH_CHAIN_NET_PKT_TYPE_PING 0x0000 +#define STREAM_CH_CHAIN_NET_PKT_TYPE_PONG 0x0001 + +typedef struct stream_ch_chain_net_pkt_hdr{ + dap_chain_id_t chain_id; + uint16_t type; // Chain data type + uint8_t padding1[2]; // Some padding + union{ + uint64_t raw; + }; +} __attribute__((packed)) dap_stream_ch_chain_net_pkt_hdr_t; + +typedef struct dap_stream_ch_chain_net_pkt{ + dap_stream_ch_chain_net_pkt_hdr_t hdr; + uint8_t data[]; +} __attribute__((packed)) dap_stream_ch_chain_net_pkt_t; + -- GitLab