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

[*] More activity for proto

parent 9f9d0cf5
No related branches found
No related tags found
No related merge requests found
cmake_minimum_required(VERSION 3.0)
project (dap_stream_ch_chain_net_srv)
set(DAP_STREAM_CH_CHAIN_NET_SRV_SRCS dap_stream_ch_chain_net_srv.c dap_stream_ch_chain_net_srv_pkt.c)
set(DAP_STREAM_CH_CHAIN_NET_SRV_SRCS dap_stream_ch_chain_net_srv.c dap_stream_ch_chain_net_srv_session.c dap_stream_ch_chain_net_srv_pkt.c)
if(WIN32)
include_directories(../libdap/src/win32/)
......
/*
* Authors:
* Dmitriy A. Gearasimov <gerasimov.dmitriy@demlabs.net>
* DeM Labs Inc. https://demlabs.net
* 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
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/>.
* Authors:
* Dmitriy Gerasimov <naeper@demlabs.net>
* Cellframe https://cellframe.net
* DeM Labs Inc. https://demlabs.net
* Copyright (c) 2017-2019
* All rights reserved.
This file is part of CellFrame SDK the open source project
CellFrame SDK 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.
CellFrame SDK 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 CellFrame SDK based project. If not, see <http://www.gnu.org/licenses/>.
*/
#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_chain_net_srv_session.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;
......@@ -75,8 +73,12 @@ 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()
if (a_ch->stream->session->_inheritor == NULL && a_ch->stream->session != NULL)
dap_stream_ch_chain_net_srv_session_create( a_ch->stream->session );
else if ( a_ch->stream->session == NULL)
log_it( L_ERROR, "No session at all!");
else
log_it(L_ERROR, "Session inheritor is already present!");
}
......
/*
* 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.
* Authors:
* Dmitriy Gerasimov <naeper@demlabs.net>
* Cellframe https://cellframe.net
* DeM Labs Inc. https://demlabs.net
* Copyright (c) 2017-2019
* All rights reserved.
This file is part of DAP (Deus Applications Prototypes) the open source project
This file is part of CellFrame SDK 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.
CellFrame SDK 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/>.
**/
CellFrame SDK 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 CellFrame SDK based project. If not, see <http://www.gnu.org/licenses/>.
*/
#include "dap_stream_ch_chain_net_srv_pkt.h"
#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/>.
**/
* Authors:
* Dmitriy Gerasimov <naeper@demlabs.net>
* Cellframe https://cellframe.net
* DeM Labs Inc. https://demlabs.net
* Copyright (c) 2017-2019
* All rights reserved.
This file is part of CellFrame SDK the open source project
CellFrame SDK 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.
CellFrame SDK 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 CellFrame SDK based project. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
......
/*
* Authors:
* Dmitriy Gerasimov <naeper@demlabs.net>
* Cellframe https://cellframe.net
* DeM Labs Inc. https://demlabs.net
* Copyright (c) 2017-2019
* All rights reserved.
This file is part of CellFrame SDK the open source project
CellFrame SDK 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.
CellFrame SDK 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 CellFrame SDK based project. If not, see <http://www.gnu.org/licenses/>.
*/
#include "dap_common.h"
#include "rand/dap_rand.h"
#include "dap_stream_ch_chain_net_srv_session.h"
#define LOG_TAG "dap_stream_ch_chain_net_srv_session"
/**
* @brief dap_stream_ch_chain_net_srv_session_create
* @param a_session
* @return
*/
dap_stream_ch_chain_net_srv_session_t * dap_stream_ch_chain_net_srv_session_create( dap_stream_session_t * a_session)
{
if (!a_session){
log_it (L_ERROR, "Session is NULL!");
return NULL;
}
dap_stream_ch_chain_net_srv_session_t * l_session_srv= DAP_NEW_Z(dap_stream_ch_chain_net_srv_session_t);
a_session->_inheritor = l_session_srv;
return l_session_srv;
}
/**
* @brief dap_stream_ch_chain_net_srv_usage_add
* @param a_srv_session
* @param a_net
* @param a_srv
* @return
*/
dap_stream_ch_chain_net_srv_usage_t* dap_stream_ch_chain_net_srv_usage_add (dap_stream_ch_chain_net_srv_session_t * a_srv_session,
dap_chain_net_t * a_net, dap_chain_net_srv_t * a_srv)
{
dap_stream_ch_chain_net_srv_usage_t * l_ret = DAP_NEW_Z(dap_stream_ch_chain_net_srv_usage_t);
randombytes(&l_ret->id, sizeof(l_ret->id));
l_ret->net = a_net;
l_ret->service = a_srv;
HASH_ADD_INT( a_srv_session->usages, id,l_ret );
return l_ret;
}
/**
* @brief dap_stream_ch_chain_net_srv_usage_delete
* @param a_srv_session
* @param a_usage
* @return
*/
void dap_stream_ch_chain_net_srv_usage_delete (dap_stream_ch_chain_net_srv_session_t * a_srv_session,
dap_stream_ch_chain_net_srv_usage_t* a_usage)
{
if ( a_usage->receipt_active )
DAP_DELETE( a_usage->receipt_active );
HASH_DEL(a_srv_session->usages, a_usage);
DAP_DELETE( a_usage );
}
/**
* @brief dap_stream_ch_chain_net_srv_usage_find
* @param a_srv_session
* @param a_usage_id
* @return
*/
dap_stream_ch_chain_net_srv_usage_t* dap_stream_ch_chain_net_srv_usage_find (dap_stream_ch_chain_net_srv_session_t * a_srv_session,
uint32_t a_usage_id)
{
dap_stream_ch_chain_net_srv_usage_t * l_ret = NULL;
HASH_FIND_INT(a_srv_session->usages, &a_usage_id, l_ret);
return l_ret;
}
/*
* Authors:
* Dmitriy Gerasimov <naeper@demlabs.net>
* Cellframe https://cellframe.net
* DeM Labs Inc. https://demlabs.net
* Copyright (c) 2017-2019
* All rights reserved.
This file is part of CellFrame SDK the open source project
CellFrame SDK 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.
CellFrame SDK 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 CellFrame SDK based project. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "uthash.h"
#include "dap_stream_session.h"
#include "dap_hash.h"
#include "dap_chain.h"
#include "dap_chain_sign.h"
#include "dap_chain_datum_tx.h"
#include "dap_chain_datum_tx_receipt.h"
#include "dap_chain_net_srv.h"
#include "dap_chain_net_srv_order.h"
typedef struct dap_stream_ch_chain_net_srv_usage{
uint32_t id; // Usage id
dap_chain_net_t * net; // Chain network where everything happens
dap_chain_net_srv_t * service; // Service that used
dap_chain_datum_tx_receipt_t* receipt_active;
UT_hash_handle hh; //
} dap_stream_ch_chain_net_srv_usage_t;
typedef struct dap_stream_ch_chain_net_srv_session {
dap_stream_session_t * parent;
dap_stream_ch_chain_net_srv_usage_t * usages;
dap_chain_sign_t* user_sign; // User's signature for auth if reconnect
} dap_stream_ch_chain_net_srv_session_t;
dap_stream_ch_chain_net_srv_session_t * dap_stream_ch_chain_net_srv_session_create( dap_stream_session_t * a_session);
dap_stream_ch_chain_net_srv_usage_t* dap_stream_ch_chain_net_srv_usage_add (dap_stream_ch_chain_net_srv_session_t * a_srv_session,
dap_chain_net_t * a_net, dap_chain_net_srv_t * a_srv);
void dap_stream_ch_chain_net_srv_usage_delete (dap_stream_ch_chain_net_srv_session_t * a_srv_session,
dap_stream_ch_chain_net_srv_usage_t* a_usage);
dap_stream_ch_chain_net_srv_usage_t* dap_stream_ch_chain_net_srv_usage_find (dap_stream_ch_chain_net_srv_session_t * a_srv_session,
uint32_t a_usage_id);
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