Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • cellframe/cellframe-sdk
  • MIKA83/cellframe-sdk
2 results
Show changes
Commits on Source (14)
Showing
with 298 additions and 32 deletions
......@@ -143,8 +143,12 @@
/* Define to 1 if you have the `vsyslog' function. */
#define HAVE_VSYSLOG 1
#ifdef DAP_OS_ANDROID
#define ENABLE_RDRAND
#else
/* Define if you have the `getrandom' function. */
#define HAVE_GETRANDOM
#endif
/* Define if you have the `getrusage' function. */
#define HAVE_GETRUSAGE
......
......@@ -38,3 +38,4 @@ HEADERS += $$PWD/arraylist.h\
$$PWD/strerror_override_private.h\
$$PWD/vasprintf_compat.h
INCLUDEPATH += $$PWD/../
......@@ -10,7 +10,7 @@
*/
#include "random_seed.h"
#include "config.h"
#include <json-c/config.h>
#include "strerror_override.h"
#include <stdio.h>
......
......@@ -35,4 +35,5 @@ HEADERS+= $$PWD/cdf.h\
$$PWD/tar.h\
$$PWD/config.h
INCLUDEPATH += $$PWD
DEFINES += HAVE_CONFIG_H
......@@ -2,7 +2,7 @@ project(cellframe-sdk C)
cmake_minimum_required(VERSION 2.8)
set(CMAKE_C_STANDARD 11)
set(CELLFRAME_SDK_NATIVE_VERSION "2.6-95")
set(CELLFRAME_SDK_NATIVE_VERSION "2.6-99")
add_definitions ("-DCELLFRAME_SDK_VERSION=\"${CELLFRAME_SDK_NATIVE_VERSION}\"")
set(DAPSDK_MODULES "")
......
......@@ -72,6 +72,8 @@ typedef uint8_t byte_t;
// Extracts a size_t from a pointer
#define DAP_POINTER_TO_SIZE(p) ((size_t) (p))
#define DAP_END_OF_DAYS 4102444799
#if defined(__GNUC__) ||defined (__clang__)
#define DAP_ALIGN_PACKED __attribute__((aligned(1),packed))
#else
......
/* Authors:
* Dmitriy A. Gearasimov <gerasimov.dmitriy@demlabs.net>
* Demlabs Ltd https://demlabs.net
* DAP SDK https://gitlab.demlabs.net/dap/dap-sdk
* Copyright (c) 2021
* All rights reserved.
This file is part of DAP SDK the open source project
DAP 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 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 DAP based project. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "dap_common.h"
typedef struct dap_meta{
uint32_t value_length;
byte_t name_n_value[]; // Name and value are splitted with terminated 0
} dap_meta_t;
dap_meta_t * dap_meta_create(const char * a_name, const void * a_data, size_t a_data_size);
dap_meta_t* dap_meta_find(byte_t * a_data, size_t a_data_size, const char * a_name);
int dap_meta_check(dap_meta_t * a_meta);
#define dap_meta_create_scalar(name,value) dap_meta_create (name, &value, sizeof(value) )
#define dap_meta_get_scalar(a,typeconv) *((typeconv*) a->name_n_value + strlen(a->name_n_value)+1)
// NULL-terminated string
#define dap_meta_create_string(name,str) dap_meta_create (name,str, dap_strlen(str)+1)
#define dap_meta_get_string(a) ( ((char*) a->name_n_value+ strlen((char*) a->name_n_value)+1)[a->value_length-1] == '\0'? (char*) a->name_n_value : "<CORRUPTED STRING>" )
#define dap_meta_get_string_const(a) ( ((const char*) a->name_n_value + strlen((char*) a->name_n_value)+1 )[a->value_length-1] == '\0'? (const char*) a->name_n_value : "<CORRUPTED STRING>" )
#define dap_meta_name(a) ( ((char*) a->name_n_value+ strlen((char*) a->name_n_value)+1)[a->value_length-1] == '\0'? (char*) a->name_n_value : "<CORRUPTED STRING>" )
#define dap_meta_size(a) (sizeof(*a)+a->value_length+ strlen((char*) a->name_n_value)+1)
/*
* Authors:
* Dmitriy A. Gearasimov <gerasimov.dmitriy@demlabs.net>
* DeM Labs Inc. https://demlabs.net
* Kelvin Project https://gitlab.demlabs.net/cellframe
* Copyright (c) 2017-2018
* Demlabs Ltd https://demlabs.net
* DAP SDK https://gitlab.demlabs.net/dap/dap-sdk
* Copyright (c) 2017
* All rights reserved.
This file is part of DAP (Deus Applications Prototypes) the open source project
This file is part of DAP SDK the open source project
DAP (Deus Applicaions Prototypes) is free software: you can redistribute it and/or modify
DAP 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,
DAP 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.
......
/* Authors:
* Dmitriy A. Gearasimov <gerasimov.dmitriy@demlabs.net>
* Demlabs Ltd https://demlabs.net
* DAP SDK https://gitlab.demlabs.net/dap/dap-sdk
* Copyright (c) 2021
* All rights reserved.
This file is part of DAP SDK the open source project
DAP 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 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 DAP based project. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "dap_common.h"
#include "dap_strfuncs.h"
typedef struct dap_tsd{
uint16_t type;
uint32_t size;
byte_t data[];
} dap_tsd_t;
dap_tsd_t * dap_tsd_create(uint16_t a_type, const void * a_data, size_t a_data_size);
dap_tsd_t* dap_tsd_find(byte_t * a_data, size_t a_data_size,uint16_t a_type);
#define dap_tsd_create_scalar(type,value) dap_tsd_create (type, &value, sizeof(value) )
#define dap_tsd_get_scalar(a,typeconv) *((typeconv*) a->data)
// NULL-terminated string
#define dap_tsd_create_string(type,str) dap_tsd_create (type,str, dap_strlen(str)+1)
#define dap_tsd_get_string(a) ( ((char*) a->data )[a->size-1] == '\0'? (char*) a->data : "<CORRUPTED STRING>" )
#define dap_tsd_get_string_const(a) ( ((const char*) a->data )[a->size-1] == '\0'? (const char*) a->data : "<CORRUPTED STRING>" )
#define dap_tsd_size(a) (sizeof(*a)+a->size)
QMAKE_CFLAGS_RELEASE += -std=gnu11
QMAKE_CFLAGS_DEBUG = -std=gnu11
-DDAP_DEBUG
#QMAKE_CFLAGS_RELEASE += -std=gnu11
#QMAKE_CFLAGS_DEBUG = -std=gnu11 -DDAP_DEBUG
#QMAKE_CFLAGS_RELEASE += -std=gnu1
QMAKE_CFLAGS_DEBUG += -DDAP_DEBUG
QMAKE_CXXFLAGS += -std=c++11
QMAKE_CFLAGS += -std=gnu11
unix {
include(src/unix/unix.pri)
DEFINES += DAP_OS_UNIX
......
......@@ -1068,11 +1068,14 @@ void dap_usleep(time_t a_microseconds)
char* dap_ctime_r(time_t *a_time, char* a_buf){
struct tm *l_time = localtime(a_time);
char *l_str_time = asctime_r(l_time, a_buf);
if (*a_time > DAP_END_OF_DAYS) {
return "(null)\r\n";
}
struct tm l_time;
localtime_r(a_time, &l_time);
char *l_str_time = asctime_r(&l_time, a_buf);
if (l_str_time)
return l_str_time;
else
return "(null)\n";
// localtime_r()
return "(null)\r\n";
}
......@@ -505,7 +505,7 @@ uint64_t dap_config_get_item_uint64_default(dap_config_t * a_config, const char
*/
static dap_config_item_t * dap_config_get_item(dap_config_t * a_config, const char * a_section_path, const char * a_item_name)
{
dap_config_item_t * l_item_section = DAP_CONFIG_INTERNAL(a_config)->item_root ;
dap_config_item_t * l_item_section = a_config? DAP_CONFIG_INTERNAL(a_config)->item_root: NULL ;
while(l_item_section){
if (strcmp(l_item_section->name,a_section_path)==0){
dap_config_item_t * l_item = l_item_section->childs;
......@@ -552,10 +552,11 @@ char** dap_config_get_array_str(dap_config_t * a_config, const char * a_section_
if(array_length != NULL)
*array_length = 0;
return NULL;
}else{
if (array_length != NULL)
*array_length = item->array_length;
return item->data_str_array;
}
if (array_length != NULL)
*array_length = item->array_length;
return item->data_str_array;
}
......@@ -569,7 +570,7 @@ char** dap_config_get_array_str(dap_config_t * a_config, const char * a_section_
*/
const char * dap_config_get_item_str_default(dap_config_t * a_config, const char * a_section_path, const char * a_item_name, const char * a_value_default)
{
dap_config_item_t * l_item_section = DAP_CONFIG_INTERNAL(a_config)->item_root ;
dap_config_item_t * l_item_section =a_config? DAP_CONFIG_INTERNAL(a_config)->item_root: NULL ;
while(l_item_section){
if (strcmp(l_item_section->name,a_section_path)==0){
dap_config_item_t * l_item = l_item_section->childs;
......
/* Authors:
* Dmitriy A. Gearasimov <gerasimov.dmitriy@demlabs.net>
* Demlabs Ltd https://demlabs.net
* DAP SDK https://gitlab.demlabs.net/dap/dap-sdk
* Copyright (c) 2021
* All rights reserved.
This file is part of DAP SDK the open source project
DAP 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 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 DAP based project. If not, see <http://www.gnu.org/licenses/>.
*/
#include "dap_meta.h"
#define LOG_TAG "dap_meta"
/**
* @brief dap_meta_create
* @param a_name
* @param a_data
* @param a_data_size
* @return
*/
dap_meta_t * dap_meta_create(const char * a_name, const void * a_data, size_t a_data_size)
{
if ( !a_name)
return NULL;
size_t a_name_len = strlen(a_name);
if( ! a_name_len )
return NULL;
dap_meta_t * l_ret = DAP_NEW_Z_SIZE(dap_meta_t, sizeof (dap_meta_t)+a_name_len+1+a_data_size );
if (l_ret){
memcpy(l_ret->name_n_value,a_name,a_name_len);
if(a_data_size)
memcpy(l_ret->name_n_value+a_name_len+1,a_data,a_data_size);
}
return l_ret;
}
/**
* @brief dap_meta_find
* @param a_data
* @param a_data_size
* @param a_name
* @return
*/
dap_meta_t* dap_meta_find(byte_t * a_data, size_t a_data_size, const char * a_name)
{
dap_meta_t * l_ret = NULL;
for(size_t l_offset=0; l_offset<a_data_size; ){
dap_meta_t * l_meta =(dap_meta_t*) (a_data + l_offset);
size_t l_meta_size = dap_meta_size(l_meta);
if( !l_meta_size || l_meta_size +l_offset > a_data_size){
break;
}
if (strcmp( dap_meta_name(l_meta), a_name) == 0 ){
l_ret = l_meta;
break;
}
l_offset+=l_meta_size;
}
return l_ret;
}
/**
* @brief dap_meta_check
* @param a_meta
* @return
*/
int dap_meta_check(dap_meta_t * a_meta)
{
return -1;
}
/* Authors:
* Dmitriy A. Gearasimov <gerasimov.dmitriy@demlabs.net>
* Demlabs Ltd https://demlabs.net
* DAP SDK https://gitlab.demlabs.net/dap/dap-sdk
* Copyright (c) 2021
* All rights reserved.
This file is part of DAP SDK the open source project
DAP 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 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 DAP based project. If not, see <http://www.gnu.org/licenses/>.
*/
#include "dap_tsd.h"
#define LOG_TAG "dap_tsd"
/**
* @brief dap_tsd_create
* @param a_type
* @param a_data
* @param a_data_size
* @return
*/
dap_tsd_t * dap_tsd_create(uint16_t a_type, const void * a_data, size_t a_data_size)
{
dap_tsd_t * l_tsd = DAP_NEW_Z_SIZE(dap_tsd_t, sizeof(dap_tsd_t) + a_data_size );
if ( l_tsd ){
if (a_data && a_data_size)
memcpy(l_tsd->data, a_data , a_data_size );
l_tsd->type = a_type;
l_tsd->size = a_data_size;
}
return l_tsd;
}
/**
* @brief dap_tsd_find
* @param a_data
* @param a_data_size
* @param a_typeid
* @return
*/
dap_tsd_t* dap_tsd_find(byte_t * a_data, size_t a_data_size,uint16_t a_type)
{
dap_tsd_t * l_ret = NULL;
for(size_t l_offset=0; l_offset<a_data_size; ){
dap_tsd_t * l_tsd =(dap_tsd_t*) (a_data + l_offset);
size_t l_tsd_size = dap_tsd_size(l_tsd);
if( !l_tsd_size || l_tsd_size +l_offset > a_data_size){
break;
}
if ( l_tsd->type == a_type ){
l_ret = l_tsd;
break;
}
l_offset+=l_tsd_size;
}
return l_ret;
}
......@@ -37,6 +37,8 @@
#define DAP_HASH_FAST_SIZE 32
#define DAP_CHAIN_HASH_FAST_SIZE 32
#define DAP_CHAIN_HASH_MAX_SIZE 63
typedef enum dap_hash_type {
DAP_HASH_TYPE_KECCAK = 0,
DAP_HASH_TYPE_SLOW_0 = 1,
......
......@@ -14,11 +14,12 @@ and related or neighboring rights to the source code in this file.
http://creativecommons.org/publicdomain/zero/1.0/
*/
#ifndef _SimpleFIPS202_h_
#define _SimpleFIPS202_h_
#pragma once
#include "../../lib/common/config.h"
#include "config.h"
#ifdef XKCP_has_KeccakP1600
#ifndef XKCP_has_KeccakP1600
#error This requires an implementation of Keccak-p[1600]
#endif
#include <string.h>
......@@ -76,12 +77,8 @@ int SHA3_384(unsigned char *output, const unsigned char *input, size_t inputByte
*/
int SHA3_512(unsigned char *output, const unsigned char *input, size_t inputByteLen);
#else
#error This requires an implementation of Keccak-p[1600]
#endif
#ifdef __cplusplus
}
#endif
#endif
\ No newline at end of file
......@@ -17,7 +17,7 @@ http://creativecommons.org/publicdomain/zero/1.0/
#ifndef _SP800_185_h_
#define _SP800_185_h_
#include "config.h"
#include "../../lib/common/config.h"
#ifdef XKCP_has_KeccakP1600
#include <stddef.h>
......
......@@ -119,13 +119,15 @@ static bool s_timer_timeout_check(void * a_arg)
dap_events_t * l_events = dap_events_get_default();
assert(l_events);
dap_worker_t * l_worker =(dap_worker_t*) pthread_getspecific(l_events->pth_key_worker);; // We're in own esocket context
dap_worker_t * l_worker = dap_events_get_current_worker(l_events); // We're in own esocket context
assert(l_worker);
if(dap_events_socket_check_unsafe(l_worker, l_es) ){
dap_client_http_pvt_t * l_http_pvt = PVT(l_es);
log_it(L_WARNING,"Connection timeout for request http://%s:%u/%s, possible network problems or host is down",
l_http_pvt->uplink_addr, l_http_pvt->uplink_port, l_http_pvt->path);
if(l_http_pvt->error_callback)
l_http_pvt->error_callback(ETIMEDOUT, l_http_pvt->obj);
l_http_pvt->is_closed_by_timeout = true;
l_es->flags |= DAP_SOCK_SIGNAL_CLOSE;
}
......@@ -469,7 +471,7 @@ void* dap_client_http_request_custom(dap_worker_t * a_worker,const char *a_uplin
l_ev_socket->remote_addr.sin_family = AF_INET;
l_ev_socket->remote_addr.sin_port = htons(a_uplink_port);
l_ev_socket->flags |= DAP_SOCK_CONNECTING;
l_ev_socket->type = DESCRIPTOR_TYPE_SOCKET;
l_ev_socket->type = DESCRIPTOR_TYPE_SOCKET_CLIENT;
l_ev_socket->flags |= DAP_SOCK_READY_TO_WRITE;
int l_err = connect(l_socket, (struct sockaddr *) &l_ev_socket->remote_addr, sizeof(struct sockaddr_in));
......
......@@ -58,6 +58,7 @@
#include "dap_strfuncs.h"
#include "dap_cert.h"
#include "dap_timerfd.h"
//#include "dap_http_client_simple.h"
#include "dap_client_http.h"
#include "dap_client.h"
......
android{
include (../../../3rdparty/json-c/json-c.pri)
}
HEADERS += $$PWD/include/dap_client.h \
$$PWD/include/dap_client_http.h \
$$PWD/include/dap_client_pool.h \
......