Skip to content
Snippets Groups Projects
Commit a07f35f8 authored by Dmitriy A. Gerasimov's avatar Dmitriy A. Gerasimov
Browse files

[+] Request and response packets

parent c4aaeb6d
No related branches found
No related tags found
No related merge requests found
......@@ -2,8 +2,9 @@
* Authors:
* Dmitriy A. Gearasimov <gerasimov.dmitriy@demlabs.net>
* DeM Labs Inc. https://demlabs.net
* Kelvin Project https://github.com/kelvinblockchain
* Copyright (c) 2017-2018
* CellFrame https://cellframe.net
* Sources https://gitlab.demlabs.net/cellframe
* Copyright (c) 2017-2019
* All rights reserved.
This file is part of DAP (Deus Applications Prototypes) the open source project
......@@ -22,34 +23,17 @@
along with any DAP based project. If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#include <stdlib.h>
#include <stddef.h>
#include <stdint.h>
#ifdef WIN32
#undef _WIN32_WINNT
#define _WIN32_WINNT 0x0600
#include <winsock2.h>
#include <windows.h>
#include <mswsock.h>
#include <ws2tcpip.h>
#include <io.h>
//#include "wrappers.h"
#include <wepoll.h>
#include <pthread.h>
#endif
#include "dap_common.h"
#include "dap_stream.h"
#include "dap_stream_ch.h"
#include "dap_stream_ch_pkt.h"
#include "dap_stream_ch_chain_net_srv.h"
#include "dap_stream_ch_chain_net_srv_pkt.h"
#include "dap_stream_ch_proc.h"
#define LOG_TAG "dap_stream_ch_chain_net_srv"
typedef struct dap_stream_ch_chain_net_srv {
pthread_mutex_t mutex;
} dap_stream_ch_chain_net_srv_t;
......@@ -65,7 +49,7 @@ static void s_stream_ch_packet_out(dap_stream_ch_t* ch , void* arg);
* @brief dap_stream_ch_chain_net_init
* @return
*/
int dap_stream_ch_chain_net_srv_init()
int dap_stream_ch_chain_net_srv_init(void)
{
log_it(L_NOTICE,"Chain network services channel initialized");
dap_stream_ch_proc_add('S',s_stream_ch_new,s_stream_ch_delete,s_stream_ch_packet_in,s_stream_ch_packet_out);
......@@ -76,7 +60,7 @@ int dap_stream_ch_chain_net_srv_init()
/**
* @brief dap_stream_ch_chain_deinit
*/
void dap_stream_ch_chain_net_srv_deinit()
void dap_stream_ch_chain_net_srv_deinit(void)
{
}
......@@ -91,6 +75,8 @@ void s_stream_ch_new(dap_stream_ch_t* a_ch , void* arg)
a_ch->internal=DAP_NEW_Z(dap_stream_ch_chain_net_srv_t);
dap_stream_ch_chain_net_srv_t * l_ch_chain_net_srv = DAP_STREAM_CH_CHAIN_NET_SRV(a_ch);
pthread_mutex_init( &l_ch_chain_net_srv->mutex,NULL);
//a_ch->stream->session->_inheritor = DAP_NEW_Z()
}
......@@ -99,7 +85,7 @@ void s_stream_ch_new(dap_stream_ch_t* a_ch , void* arg)
* @param ch
* @param arg
*/
void s_stream_ch_delete(dap_stream_ch_t* ch , void* arg)
void s_stream_ch_delete(dap_stream_ch_t* a_ch , void* a_arg)
{
}
......@@ -109,8 +95,21 @@ void s_stream_ch_delete(dap_stream_ch_t* ch , void* arg)
* @param ch
* @param arg
*/
void s_stream_ch_packet_in(dap_stream_ch_t* ch , void* arg)
void s_stream_ch_packet_in(dap_stream_ch_t* a_ch , void* a_arg)
{
dap_stream_ch_chain_net_srv_t * l_ch_chain_net = DAP_STREAM_CH_CHAIN_NET_SRV(a_ch);
dap_stream_ch_pkt_t *l_ch_pkt = (dap_stream_ch_pkt_t *) a_arg; // chain packet
if(l_ch_pkt) {
switch (l_ch_pkt->hdr.type) {
case DAP_STREAM_CH_CHAIN_NET_SRV_PKT_TYPE_ERROR: {
}break;
case DAP_STREAM_CH_CHAIN_NET_SRV_PKT_TYPE_DBG: {
}break;
default: log_it( L_WARNING, "Unknown packet type 0x%02X", l_ch_pkt->hdr.type);
}
}
}
......
......@@ -2,8 +2,9 @@
* Authors:
* Dmitriy A. Gearasimov <gerasimov.dmitriy@demlabs.net>
* DeM Labs Inc. https://demlabs.net
* Kelvin Project https://github.com/kelvinblockchain
* Copyright (c) 2017-2010
* CellFrame https://cellframe.net
* Sources https://gitlab.demlabs.net/cellframe
* Copyright (c) 2017-2019
* All rights reserved.
This file is part of DAP (Deus Applications Prototypes) the open source project
......@@ -20,9 +21,9 @@
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
int dap_stream_ch_chain_net_srv_init();
void dap_stream_ch_chain_net_srv_deinit();
int dap_stream_ch_chain_net_srv_init(void);
void dap_stream_ch_chain_net_srv_deinit(void);
......@@ -22,46 +22,6 @@
along with any DAP based project. If not, see <http://www.gnu.org/licenses/>.
**/
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#include <stdlib.h>
#include <stddef.h>
#include <stdint.h>
#include "dap_stream_ch_chain_net_srv_pkt.h"
#ifdef WIN32
#undef _WIN32_WINNT
#define _WIN32_WINNT 0x0600
#include <winsock2.h>
#include <windows.h>
#include <mswsock.h>
#include <ws2tcpip.h>
#include <io.h>
//#include "wrappers.h"
#include <wepoll.h>
#include <pthread.h>
#endif
#include "dap_chain_net_srv_common.h"
typedef struct dap_stream_ch_chain_net_srv_pkt_hdr{
dap_chain_net_srv_uid_t srv_uid;
uint32_t type; // Chain data type
union{
struct{
}type_block;
struct{
}type_datum;
struct{
}type_global_db;
};
} __attribute__((packed)) dap_stream_ch_chain_net_srv_pkt_hdr_t;
typedef struct dap_stream_ch_chain_net_srv_pkt{
dap_stream_ch_chain_net_srv_pkt_hdr_t hdr;
uint8_t data[];
} __attribute__((packed)) dap_stream_ch_chain_net_srv_pkt_t;
#define LOG_TAG "dap_stream_ch_chain_net_srv_pkt"
/*
* 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 <stdlib.h>
#include <stdio.h>
#include <time.h>
#include <stdlib.h>
#include <stddef.h>
#include <stdint.h>
#include "dap_chain_net_srv_common.h"
#define DAP_STREAM_CH_CHAIN_NET_SRV_PKT_TYPE_REQUEST 0x01
#define DAP_STREAM_CH_CHAIN_NET_SRV_PKT_TYPE_RESPONSE 0x02
#define DAP_STREAM_CH_CHAIN_NET_SRV_PKT_TYPE_DBG 0x99
#define DAP_STREAM_CH_CHAIN_NET_SRV_PKT_TYPE_ERROR 0xff
typedef struct dap_stream_ch_chain_net_srv_pkt_request{
struct{
dap_chain_net_id_t net_id;// Network id wheither to request
dap_chain_hash_fast_t tx_cond; // Conditioned transaction with paymemt for
dap_chain_net_srv_uid_t srv_uid;
dap_chain_net_srv_class_t srv_class;
} hdr;
uint8_t data[];
} DAP_ALIGN_PACKED dap_stream_ch_chain_net_srv_pkt_request;
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment