From e3c2501313d98ff9f4519116e6d2f36314e0240e Mon Sep 17 00:00:00 2001 From: ManikandanC Date: Tue, 18 Oct 2016 15:43:44 +0530 Subject: UnitTest: Updates Gateway Logstorage Event Handler Signed-off-by: Christoph Lipka Signed-off-by: S. Hameed Signed-off-by: Aditya Paluri Signed-off-by: Saya Sugiura Signed-off-by: ManikandanC --- src/daemon/CMakeLists.txt | 10 ++ src/daemon/dlt-daemon.c | 6 +- src/daemon/dlt_daemon_client.c | 22 ++-- src/daemon/dlt_daemon_common.h | 1 + src/daemon/dlt_daemon_connection.c | 3 +- src/daemon/dlt_daemon_connection_types.h | 3 +- src/daemon/dlt_daemon_event_handler.c | 6 +- src/daemon/dlt_daemon_offline_logstorage.c | 1 + .../dlt_daemon_offline_logstorage_internal.h | 77 +++++++++++++ src/daemon/dlt_daemon_socket.c | 4 +- src/daemon/dlt_daemon_socket.h | 2 +- src/examples/dlt-example-user.c | 1 - src/gateway/dlt_gateway.c | 25 +---- src/gateway/dlt_gateway.h | 1 + src/gateway/dlt_gateway_internal.h | 99 +++++++++++++++++ src/gateway/dlt_gateway_types.h | 18 ++++ src/lib/dlt_client.c | 22 ++-- src/lib/dlt_env_ll.c | 2 +- src/lib/dlt_user.c | 76 +++++++------ src/offlinelogstorage/dlt_offline_logstorage.c | 31 +----- src/offlinelogstorage/dlt_offline_logstorage.h | 31 ++++++ .../dlt_offline_logstorage_behavior.c | 1 + .../dlt_offline_logstorage_behavior_internal.h | 95 ++++++++++++++++ .../dlt_offline_logstorage_internal.h | 119 +++++++++++++++++++++ src/tests/dlt-test-client.c | 29 +++-- 25 files changed, 556 insertions(+), 129 deletions(-) create mode 100644 src/daemon/dlt_daemon_offline_logstorage_internal.h create mode 100644 src/gateway/dlt_gateway_internal.h create mode 100644 src/offlinelogstorage/dlt_offline_logstorage_behavior_internal.h create mode 100644 src/offlinelogstorage/dlt_offline_logstorage_internal.h (limited to 'src') diff --git a/src/daemon/CMakeLists.txt b/src/daemon/CMakeLists.txt index e9fb2ba..a2f6e38 100644 --- a/src/daemon/CMakeLists.txt +++ b/src/daemon/CMakeLists.txt @@ -45,6 +45,15 @@ install(TARGETS dlt-daemon COMPONENT base) if (WITH_DLT_UNIT_TESTS) + if (WITH_DLT_FILTER_BACKEND_PROP) + add_library(dlt_daemon ${dlt_daemon_SRCS} ${dlt_prop_backend_SRCS} ${systemd_SRCS}) + target_link_libraries(dlt_daemon ald_plugin rt ${CMAKE_THREAD_LIBS_INIT}) + install(TARGETS dlt_daemon + RUNTIME DESTINATION bin + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}/static + COMPONENT base) + else() add_library(dlt_daemon ${dlt_daemon_SRCS}) target_link_libraries(dlt_daemon ${RT_LIBRARY} ${SOCKET_LIBRARY} ${CMAKE_THREAD_LIBS_INIT}) install(TARGETS dlt_daemon @@ -52,6 +61,7 @@ if (WITH_DLT_UNIT_TESTS) LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}/static COMPONENT base) + endif(WITH_DLT_FILTER_BACKEND_PROP) endif(WITH_DLT_UNIT_TESTS) INSTALL(FILES dlt.conf diff --git a/src/daemon/dlt-daemon.c b/src/daemon/dlt-daemon.c index 774573e..9e99c74 100644 --- a/src/daemon/dlt-daemon.c +++ b/src/daemon/dlt-daemon.c @@ -810,6 +810,8 @@ int main(int argc, char* argv[]) dlt_daemon_local_cleanup(&daemon, &daemon_local, daemon_local.flags.vflag); + dlt_gateway_deinit(&daemon_local.pGateway, daemon_local.flags.vflag); + dlt_daemon_free(&daemon, daemon_local.flags.vflag); dlt_log(LOG_NOTICE, "Leaving DLT daemon\n"); @@ -1488,9 +1490,9 @@ void dlt_daemon_daemonize(int verbose) This is a dlt-daemon only function. The libdlt has no equivalent function available. */ int dlt_daemon_log_internal(DltDaemon *daemon, DltDaemonLocal *daemon_local, char *str, int verbose) { - DltMessage msg; + DltMessage msg = {0}; static uint8_t uiMsgCount = 0; - DltStandardHeaderExtra *pStandardExtra; + DltStandardHeaderExtra *pStandardExtra = NULL; uint32_t uiType; uint16_t uiSize; uint32_t uiExtraSize; diff --git a/src/daemon/dlt_daemon_client.c b/src/daemon/dlt_daemon_client.c index 120d2af..55b775b 100644 --- a/src/daemon/dlt_daemon_client.c +++ b/src/daemon/dlt_daemon_client.c @@ -110,10 +110,9 @@ static int dlt_daemon_client_send_all_multiple(DltDaemon *daemon, int verbose) { int j, sent = 0; - DltConnection* temp = NULL; + DltConnection *temp = NULL; int type_mask = (DLT_CON_MASK_CLIENT_MSG_TCP | DLT_CON_MASK_CLIENT_MSG_SERIAL); - char local_str[DLT_DAEMON_TEXTBUFSIZE]; uint8_t *tmp_buffer = NULL; if ((daemon == NULL) || (daemon_local == NULL)) @@ -144,13 +143,19 @@ static int dlt_daemon_client_send_all_multiple(DltDaemon *daemon, DLT_DAEMON_SEM_FREE(); if ((ret != DLT_DAEMON_ERROR_OK) && - DLT_CONNECTION_CLIENT_MSG_TCP == temp->type) + (DLT_CONNECTION_CLIENT_MSG_TCP == temp->type)) { if (daemon->state != DLT_DAEMON_STATE_BUFFER_FULL) { if (temp->receiver->bytes_sent < (size1 + size2)) { tmp_buffer = (uint8_t*)calloc(size1 + size2, sizeof(uint8_t)); + + if (tmp_buffer == NULL) + { + dlt_vlog(LOG_ERR, "%s: Memory allocation failed.\n", __func__); + return 0; + } memcpy(tmp_buffer, data1, size1); memcpy(tmp_buffer + size1, data2, size2); DLT_DAEMON_SEM_LOCK(); @@ -158,10 +163,7 @@ static int dlt_daemon_client_send_all_multiple(DltDaemon *daemon, if (dlt_buffer_push3(&(daemon->client_ringbuffer), tmp_buffer + temp->receiver->bytes_sent, (size1 + size2 - temp->receiver->bytes_sent), - 0, - 0, - 0, - 0) < DLT_RETURN_OK) + 0, 0, 0, 0) < DLT_RETURN_OK) { dlt_vlog(LOG_DEBUG, "%s: Buffer is full! Message discarded.\n", __func__); dlt_daemon_change_state(daemon, DLT_DAEMON_STATE_BUFFER_FULL); @@ -178,11 +180,7 @@ static int dlt_daemon_client_send_all_multiple(DltDaemon *daemon, if (ret != DLT_DAEMON_ERROR_OK) { - snprintf(local_str, - DLT_DAEMON_TEXTBUFSIZE, - "%s: send dlt message failed\n", - __func__); - dlt_log(LOG_WARNING, local_str); + dlt_vlog(LOG_WARNING, "%s: send dlt message failed\n", __func__); } else { diff --git a/src/daemon/dlt_daemon_common.h b/src/daemon/dlt_daemon_common.h index bd81e0d..4110a72 100644 --- a/src/daemon/dlt_daemon_common.h +++ b/src/daemon/dlt_daemon_common.h @@ -233,6 +233,7 @@ DltDaemonRegisteredUsers *dlt_daemon_find_users_list(DltDaemon *daemon, int dlt_daemon_load_runtime_configuration(DltDaemon *daemon, const char *runtime_directory, int verbose); + /** * Add (new) application to internal application management * @param daemon pointer to dlt daemon structure diff --git a/src/daemon/dlt_daemon_connection.c b/src/daemon/dlt_daemon_connection.c index e0cb003..c9e7be7 100644 --- a/src/daemon/dlt_daemon_connection.c +++ b/src/daemon/dlt_daemon_connection.c @@ -62,7 +62,8 @@ extern char *app_recv_buffer; * @param msg The message buffer to be sent * @param msg_size The length of the message to be sent * - * @return The amount of bytes send on success, -1 otherwise. + * @return DLT_DAEMON_ERROR_OK on success, DLT_DAEMON_ERROR_SEND_FAILED + * on send failure, DLT_DAEMON_ERROR_UNKNOWN otherwise. * errno is appropriately set. */ DLT_STATIC int dlt_connection_send(DltConnection *conn, diff --git a/src/daemon/dlt_daemon_connection_types.h b/src/daemon/dlt_daemon_connection_types.h index 68a0400..560f7f9 100644 --- a/src/daemon/dlt_daemon_connection_types.h +++ b/src/daemon/dlt_daemon_connection_types.h @@ -40,7 +40,8 @@ typedef enum { } DltConnectionStatus; typedef enum { - DLT_CONNECTION_CLIENT_CONNECT = 0, + DLT_CONNECTION_NONE = 0, + DLT_CONNECTION_CLIENT_CONNECT, DLT_CONNECTION_CLIENT_MSG_TCP, DLT_CONNECTION_CLIENT_MSG_SERIAL, DLT_CONNECTION_APP_CONNECT, diff --git a/src/daemon/dlt_daemon_event_handler.c b/src/daemon/dlt_daemon_event_handler.c index 35b85c0..029e938 100644 --- a/src/daemon/dlt_daemon_event_handler.c +++ b/src/daemon/dlt_daemon_event_handler.c @@ -473,7 +473,11 @@ int dlt_connection_check_activate(DltEventHandler *evhdl, dlt_log(LOG_INFO, local_str); dlt_event_handler_disable_fd(evhdl, con->receiver->fd); - + + if (con->type == DLT_CONNECTION_CLIENT_CONNECT) + { + con->receiver->fd = -1; + } con->status = INACTIVE; } break; diff --git a/src/daemon/dlt_daemon_offline_logstorage.c b/src/daemon/dlt_daemon_offline_logstorage.c index b99944d..86d4b5e 100644 --- a/src/daemon/dlt_daemon_offline_logstorage.c +++ b/src/daemon/dlt_daemon_offline_logstorage.c @@ -26,6 +26,7 @@ #include #include "dlt_daemon_offline_logstorage.h" +#include "dlt_daemon_offline_logstorage_internal.h" #include "dlt_gateway_types.h" #include "dlt_gateway.h" diff --git a/src/daemon/dlt_daemon_offline_logstorage_internal.h b/src/daemon/dlt_daemon_offline_logstorage_internal.h new file mode 100644 index 0000000..4c1f828 --- /dev/null +++ b/src/daemon/dlt_daemon_offline_logstorage_internal.h @@ -0,0 +1,77 @@ +/** + * @licence app begin@ + * Copyright (C) 2017 Advanced Driver Information Technology. + * This code is developed by Advanced Driver Information Technology. + * Copyright of Advanced Driver Information Technology, Bosch and DENSO. + * + * DLT offline log storage functionality internal header file. + * + * \copyright + * This Source Code Form is subject to the terms of the + * Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with + * this file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * + * \author Aditya Paluri ADIT 2017 + * + * \file: dlt_daemon_offline_logstorage_internal.h + * For further information see http://www.genivi.org/. + * @licence end@ + */ + +/******************************************************************************* + * ** + * SRC-MODULE: dlt_daemon_offline_logstorage_internal.h ** + * ** + * TARGET : linux ** + * ** + * PROJECT : DLT ** + * ** + * AUTHOR : Aditya Paluri venkataaditya.paluri@in.bosch.com ** + * PURPOSE : ** + * ** + * REMARKS : ** + * ** + * PLATFORM DEPENDANT [yes/no]: yes ** + * ** + * TO BE CHANGED BY USER [yes/no]: no ** + * ** + ******************************************************************************/ + +/******************************************************************************* +* Author Identity ** +******************************************************************************* +* ** +* Initials Name Company ** +* -------- ------------------------- ---------------------------------- ** +* ap Aditya Paluri ADIT ** +*******************************************************************************/ + +#ifndef DLT_DAEMON_OFFLINE_LOGSTORAGE_INTERNAL_H +#define DLT_DAEMON_OFFLINE_LOGSTORAGE_INTERNAL_H + +DLT_STATIC DltReturnValue dlt_logstorage_split_key(char *key, char *appid, char *ctxid, char *ecuid); + +DltReturnValue dlt_logstorage_update_all_contexts(DltDaemon *daemon, + DltDaemonLocal *daemon_local, + char *id, + int curr_log_level, + int cmp_flag, + char *ecuid, + int verbose); + +DltReturnValue dlt_logstorage_update_context(DltDaemon *daemon, + DltDaemonLocal *daemon_local, + char *apid, + char *ctxid, + char *ecuid, + int curr_log_level, + int verbose); + +int dlt_logstorage_update_context_loglevel(DltDaemon *daemon, + DltDaemonLocal *daemon_local, + char *key, + int curr_log_level, + int verbose); + +#endif diff --git a/src/daemon/dlt_daemon_socket.c b/src/daemon/dlt_daemon_socket.c index c85798f..f51d803 100644 --- a/src/daemon/dlt_daemon_socket.c +++ b/src/daemon/dlt_daemon_socket.c @@ -161,7 +161,6 @@ int dlt_daemon_socket_send(int sock,void* data1,int size1,void* data2,int size2, } /* Send data */ - if ((data1 != NULL) && (size1 > 0)) { ret = dlt_daemon_socket_sendreliable(sock, data1, size1, &bytes_sent); @@ -183,7 +182,7 @@ int dlt_daemon_socket_get_send_qeue_max_size(int sock) { int n = 0; socklen_t m = sizeof(n); - getsockopt(sock,SOL_SOCKET,SO_SNDBUF,(void *)&n, &m); + getsockopt(sock, SOL_SOCKET, SO_SNDBUF, (void *)&n, &m); return n; } @@ -213,4 +212,3 @@ int dlt_daemon_socket_sendreliable(int sock, void* data_buffer, int message_size return DLT_DAEMON_ERROR_OK; } - diff --git a/src/daemon/dlt_daemon_socket.h b/src/daemon/dlt_daemon_socket.h index a94990f..3765c70 100644 --- a/src/daemon/dlt_daemon_socket.h +++ b/src/daemon/dlt_daemon_socket.h @@ -67,7 +67,7 @@ int dlt_daemon_socket_close(int sock); int dlt_daemon_socket_get_send_qeue_max_size(int sock); -int dlt_daemon_socket_send(int sock,void* data1,int size1,void* data2,int size2,char serialheader); +int dlt_daemon_socket_send(int sock, void* data1, int size1, void* data2, int size2, char serialheader); /** * @brief dlt_daemon_socket_sendreliable - sends data to socket with additional checks and resending functionality - trying to be reliable diff --git a/src/examples/dlt-example-user.c b/src/examples/dlt-example-user.c index 325f865..df5a163 100644 --- a/src/examples/dlt-example-user.c +++ b/src/examples/dlt-example-user.c @@ -136,7 +136,6 @@ int main(int argc, char* argv[]) int lvalue = DLT_LOG_WARN; char *tvalue = 0; int rvalue = -1; - int ret = 0; int index; int c; diff --git a/src/gateway/dlt_gateway.c b/src/gateway/dlt_gateway.c index 7edf6b7..7597b70 100644 --- a/src/gateway/dlt_gateway.c +++ b/src/gateway/dlt_gateway.c @@ -39,6 +39,7 @@ #include #include #include "dlt_gateway.h" +#include "dlt_gateway_internal.h" #include "dlt_config_file_parser.h" #include "dlt_common.h" #include "dlt-daemon_cfg.h" @@ -48,23 +49,6 @@ #include "dlt_daemon_client.h" #include "dlt_daemon_offline_logstorage.h" -typedef struct { - char *key; /* The configuration key*/ - int (*func)(DltGatewayConnection *con, char *value); /* Conf handler */ - int is_opt; /* If the configuration is optional or not */ -} DltGatewayConf; -typedef enum { - GW_CONF_IP_ADDRESS = 0, - GW_CONF_PORT, - GW_CONF_ECUID, - GW_CONF_CONNECT, - GW_CONF_TIMEOUT, - GW_CONF_SEND_CONTROL, - GW_CONF_SEND_PERIODIC_CONTROL, - GW_CONF_SEND_SERIAL_HEADER, - GW_CONF_COUNT -} DltGatewayConfType; - /** * Check if given string is a valid IP address * @@ -631,9 +615,7 @@ int dlt_gateway_store_connection(DltGateway *gateway, dlt_log(LOG_CRIT, "dlt_client_init_port() failed for gateway connection\n"); return DLT_RETURN_ERROR; } - dlt_receiver_init(&gateway->connections[i].client.receiver, - gateway->connections[i].client.sock, - DLT_DAEMON_RCVBUFSIZESOCK); + /* setup DltClient Structure */ if(dlt_client_set_server_ip(&gateway->connections[i].client, gateway->connections[i].ip_address) == -1) @@ -1280,7 +1262,7 @@ DltReturnValue dlt_gateway_process_passive_node_messages(DltDaemon *daemon, int i = 0; DltGateway *gateway = NULL; DltGatewayConnection *con = NULL; - DltMessage msg; + DltMessage msg = {0}; if ((daemon == NULL) || (daemon_local == NULL) || (receiver == NULL)) { @@ -1694,6 +1676,7 @@ int dlt_gateway_process_on_demand_request(DltGateway *gateway, { con->status = DLT_GATEWAY_DISCONNECTED; + con->trigger = DLT_GATEWAY_ON_DEMAND; if (dlt_event_handler_unregister_connection(&daemon_local->pEvent, daemon_local, con->client.sock) != 0) diff --git a/src/gateway/dlt_gateway.h b/src/gateway/dlt_gateway.h index c3c7324..7108253 100644 --- a/src/gateway/dlt_gateway.h +++ b/src/gateway/dlt_gateway.h @@ -190,4 +190,5 @@ DltGatewayConnection *dlt_gateway_get_connection(DltGateway *g, /* _ONLY_ for development purposes */ void print_gateway_connection_details(const DltGateway *g); + #endif diff --git a/src/gateway/dlt_gateway_internal.h b/src/gateway/dlt_gateway_internal.h new file mode 100644 index 0000000..3b665e1 --- /dev/null +++ b/src/gateway/dlt_gateway_internal.h @@ -0,0 +1,99 @@ +/* + * @licence app begin@ + * SPDX license identifier: MPL-2.0 + * + * Copyright (C) 2017 Advanced Driver Information Technology. + * This code is developed by Advanced Driver Information Technology. + * Copyright of Advanced Driver Information Technology, Bosch and DENSO. + * + * This file is part of GENIVI Project DLT - Diagnostic Log and Trace. + * + * This Source Code Form is subject to the terms of the + * Mozilla Public License (MPL), v. 2.0. + * If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. + * + * For further information see http://www.genivi.org/. + * @licence end@ + */ + +/*! + * \author + * Aditya Paluri + * + * \copyright Copyright © 2017 Advanced Driver Information Technology. \n + * License MPL-2.0: Mozilla Public License version 2.0 http://mozilla.org/MPL/2.0/. + * + * \file dlt_gateway_internal.h + */ + +/******************************************************************************* +** ** +** SRC-MODULE: dlt_gateway_internal.h ** +** ** +** TARGET : linux ** +** ** +** PROJECT : DLT ** +** ** +** AUTHOR : Aditya Paluri venkataaditya.paluri@in.bosch.com ** +** PURPOSE : ** +** ** +** REMARKS : ** +** ** +** PLATFORM DEPENDANT [yes/no]: yes ** +** ** +** TO BE CHANGED BY USER [yes/no]: no ** +** ** +*******************************************************************************/ + +/******************************************************************************* +** Author Identity ** +******************************************************************************** +** ** +** Initials Name Company ** +** -------- ------------------------- ---------------------------------- ** +** ap Aditya Paluri ADIT ** +*******************************************************************************/ + +#ifndef DLT_GATEWAY_INTERNAL_H_ +#define DLT_GATEWAY_INTERNAL_H_ + +DLT_STATIC int dlt_gateway_check_ip(DltGatewayConnection *con, char *value); + +DLT_STATIC int dlt_gateway_check_port(DltGatewayConnection *con, char *value); + +DLT_STATIC int dlt_gateway_check_ecu(DltGatewayConnection *con, char *value); + +DLT_STATIC int dlt_gateway_check_connect_trigger(DltGatewayConnection *con, + char *value); + +DLT_STATIC int dlt_gateway_check_timeout(DltGatewayConnection *con, char *value); + +DLT_STATIC int dlt_gateway_check_send_serial(DltGatewayConnection *con, char *value); + +DLT_STATIC int dlt_gateway_allocate_control_messages(DltGatewayConnection *con); + +DLT_STATIC int dlt_gateway_check_control_messages(DltGatewayConnection *con, + char *value); + +DLT_STATIC int dlt_gateway_check_periodic_control_messages(DltGatewayConnection *con, + char *value); + +DLT_STATIC int dlt_gateway_check_param(DltGateway *gateway, + DltGatewayConnection *con, + DltGatewayConfType ctype, + char *value); + +int dlt_gateway_configure(DltGateway *gateway, char *config_file, int verbose); + +int dlt_gateway_store_connection(DltGateway *gateway, + DltGatewayConnection *tmp, + int verbose); + +DLT_STATIC int dlt_gateway_parse_get_log_info(DltDaemon *daemon, + char *ecu, + DltMessage *msg, + int req, + int verbose); + +#endif diff --git a/src/gateway/dlt_gateway_types.h b/src/gateway/dlt_gateway_types.h index 4d0de0d..20d21f9 100644 --- a/src/gateway/dlt_gateway_types.h +++ b/src/gateway/dlt_gateway_types.h @@ -143,4 +143,22 @@ typedef struct int num_connections; /* number of connections */ } DltGateway; +typedef struct { + char *key; /* The configuration key*/ + int (*func)(DltGatewayConnection *con, char *value); /* Conf handler */ + int is_opt; /* If the configuration is optional or not */ +} DltGatewayConf; + +typedef enum { + GW_CONF_IP_ADDRESS = 0, + GW_CONF_PORT, + GW_CONF_ECUID, + GW_CONF_CONNECT, + GW_CONF_TIMEOUT, + GW_CONF_SEND_CONTROL, + GW_CONF_SEND_PERIODIC_CONTROL, + GW_CONF_SEND_SERIAL_HEADER, + GW_CONF_COUNT +} DltGatewayConfType; + #endif /* DLT_GATEWAY_TYPES_H_ */ diff --git a/src/lib/dlt_client.c b/src/lib/dlt_client.c index 0b22890..cfe38ea 100644 --- a/src/lib/dlt_client.c +++ b/src/lib/dlt_client.c @@ -300,14 +300,16 @@ DltReturnValue dlt_client_connect(DltClient *client, int verbose) DltReturnValue dlt_client_cleanup(DltClient *client, int verbose) { + int ret = DLT_RETURN_OK; + if (verbose) { printf("Cleanup dlt client\n"); } - if (client==0) + if (client == NULL) { - return DLT_RETURN_ERROR; + return DLT_RETURN_WRONG_PARAMETER; } if (client->sock!=-1) @@ -315,12 +317,20 @@ DltReturnValue dlt_client_cleanup(DltClient *client, int verbose) close(client->sock); } - if (dlt_receiver_free(&(client->receiver)) == DLT_RETURN_ERROR) + if (dlt_receiver_free(&(client->receiver)) != DLT_RETURN_OK) { - return DLT_RETURN_ERROR; + dlt_vlog(LOG_WARNING, "Failed to free receiver\n"); + ret = DLT_RETURN_ERROR; } - return DLT_RETURN_OK; + free(client->serialDevice); + client->serialDevice = NULL; + free(client->servIP); + client->servIP = NULL; + free(client->socketPath); + client->socketPath = NULL; + + return ret; } DltReturnValue dlt_client_main_loop(DltClient *client, void *data, int verbose) @@ -578,7 +588,7 @@ DltReturnValue dlt_client_send_log_level(DltClient *client, char *apid, char *ct DltServiceSetLogLevel *req; int ret = DLT_RETURN_ERROR; - if ((client == NULL) || (apid == NULL) || (ctid == NULL)) + if (client == NULL) { return ret; } diff --git a/src/lib/dlt_env_ll.c b/src/lib/dlt_env_ll.c index aeaa1d3..8972747 100644 --- a/src/lib/dlt_env_ll.c +++ b/src/lib/dlt_env_ll.c @@ -354,7 +354,7 @@ void dlt_env_free_ll_set(dlt_env_ll_set * const ll_set) return; } - if (!ll_set->item) + if (ll_set->item != NULL) { free(ll_set->item); ll_set->item = NULL; diff --git a/src/lib/dlt_user.c b/src/lib/dlt_user.c index 19bde1b..afef092 100644 --- a/src/lib/dlt_user.c +++ b/src/lib/dlt_user.c @@ -1091,7 +1091,9 @@ DltReturnValue dlt_register_context_ll_ts_llccb(DltContext *handle, //check nullpointer if (!handle) + { return DLT_RETURN_WRONG_PARAMETER; + } if ((contextid == NULL) || (contextid[0] == '\0')) { @@ -1154,7 +1156,6 @@ DltReturnValue dlt_register_context_ll_ts_llccb(DltContext *handle, dlt_user.dlt_ll_ts[i].context_description = 0; - dlt_user.dlt_ll_ts[i].injection_table = 0; dlt_user.dlt_ll_ts[i].nrcallbacks = 0; dlt_user.dlt_ll_ts[i].log_level_changed_callback = 0; @@ -1171,7 +1172,9 @@ DltReturnValue dlt_register_context_ll_ts_llccb(DltContext *handle, old_ll_ts = dlt_user.dlt_ll_ts; old_max_entries = dlt_user.dlt_ll_ts_max_num_entries; - dlt_user.dlt_ll_ts_max_num_entries = ((dlt_user.dlt_ll_ts_num_entries / DLT_USER_CONTEXT_ALLOC_SIZE) + 1) * DLT_USER_CONTEXT_ALLOC_SIZE; + dlt_user.dlt_ll_ts_max_num_entries = ((dlt_user.dlt_ll_ts_num_entries + / DLT_USER_CONTEXT_ALLOC_SIZE) + 1) + * DLT_USER_CONTEXT_ALLOC_SIZE; dlt_user.dlt_ll_ts = (dlt_ll_ts_type*) malloc(sizeof(dlt_ll_ts_type)* dlt_user.dlt_ll_ts_max_num_entries); if (dlt_user.dlt_ll_ts == 0) @@ -1268,7 +1271,6 @@ DltReturnValue dlt_register_context_ll_ts_llccb(DltContext *handle, } /* Prepare transfer struct */ - //dlt_set_id(log->appID, dlt_user.appID); dlt_set_id(handle->contextID, contextid); handle->log_level_pos = dlt_user.dlt_ll_ts_num_entries; @@ -1291,7 +1293,9 @@ DltReturnValue dlt_register_context_ll_ts_llccb(DltContext *handle, return dlt_user_log_send_register_context(&log); } -DltReturnValue dlt_register_context_ll_ts(DltContext *handle, const char *contextid, const char * description, int loglevel, int tracestatus) +DltReturnValue dlt_register_context_ll_ts(DltContext *handle, const char *contextid, + const char * description, int loglevel, + int tracestatus) { return dlt_register_context_ll_ts_llccb(handle, contextid, @@ -1309,9 +1313,10 @@ DltReturnValue dlt_register_context_llccb(DltContext *handle, uint8_t log_level, uint8_t trace_status)) { - // check nullpointer - if(handle == NULL) + if ((handle == NULL) || (contextid == NULL) || (contextid[0] == '\0')) + { return DLT_RETURN_WRONG_PARAMETER; + } if (!dlt_user_initialised) { @@ -1322,16 +1327,6 @@ DltReturnValue dlt_register_context_llccb(DltContext *handle, } } - DLT_SEM_LOCK(); - - if ((contextid == NULL) || (contextid[0] == '\0')) - { - DLT_SEM_FREE(); - return DLT_RETURN_WRONG_PARAMETER; - } - - DLT_SEM_FREE(); - return dlt_register_context_ll_ts_llccb(handle, contextid, description, @@ -1685,14 +1680,20 @@ inline DltReturnValue dlt_user_log_write_start(DltContext *handle, DltContextDat DltReturnValue dlt_user_log_write_start_id(DltContext *handle, DltContextData *log, DltLogLevelType loglevel, uint32_t messageid) { DLT_LOG_FATAL_RESET_TRAP(loglevel); + DltReturnValue ret = DLT_RETURN_OK; // check nullpointer if (handle == NULL || log == NULL) return DLT_RETURN_WRONG_PARAMETER; /* check log levels */ - if (dlt_user_is_logLevel_enabled(handle, loglevel) < DLT_RETURN_TRUE) + ret = dlt_user_is_logLevel_enabled(handle, loglevel); + if (ret == DLT_RETURN_WRONG_PARAMETER) + return DLT_RETURN_WRONG_PARAMETER; + else if (ret == DLT_RETURN_LOGGING_DISABLED) return DLT_RETURN_OK; + else + /* Do nothing */ /* initialize values */ if (dlt_user_log_init(handle, log) < DLT_RETURN_OK || dlt_user.dlt_ll_ts == NULL) @@ -2633,7 +2634,7 @@ DltReturnValue dlt_user_log_write_utf8_string(DltContextData *log, const char *t } DltReturnValue dlt_register_injection_callback_with_id(DltContext *handle, uint32_t service_id, - int (*dlt_injection_callback)(uint32_t service_id, void *data, uint32_t length, void *priv_data), void *priv) + dlt_injection_callback_id dlt_injection_cbk, void *priv) { DltContextData log; uint32_t i,j,k; @@ -2713,14 +2714,14 @@ DltReturnValue dlt_register_injection_callback_with_id(DltContext *handle, uint3 dlt_user.dlt_ll_ts[i].injection_table[j].service_id = service_id; if (priv == NULL) { - dlt_user.dlt_ll_ts[i].injection_table[j].injection_callback = dlt_injection_callback; + dlt_user.dlt_ll_ts[i].injection_table[j].injection_callback = (dlt_injection_callback)dlt_injection_cbk; dlt_user.dlt_ll_ts[i].injection_table[j].injection_callback_with_id = NULL; dlt_user.dlt_ll_ts[i].injection_table[j].data = NULL; } else { dlt_user.dlt_ll_ts[i].injection_table[j].injection_callback = NULL; - dlt_user.dlt_ll_ts[i].injection_table[j].injection_callback_with_id = dlt_injection_callback; + dlt_user.dlt_ll_ts[i].injection_table[j].injection_callback_with_id = dlt_injection_cbk; dlt_user.dlt_ll_ts[i].injection_table[j].data = priv; } @@ -2732,7 +2733,10 @@ DltReturnValue dlt_register_injection_callback_with_id(DltContext *handle, uint3 DltReturnValue dlt_register_injection_callback(DltContext *handle, uint32_t service_id, int (*dlt_injection_callback)(uint32_t service_id, void *data, uint32_t length)) { - return dlt_register_injection_callback_with_id(handle, service_id, dlt_injection_callback, NULL); + return dlt_register_injection_callback_with_id(handle, + service_id, + (dlt_injection_callback_id)dlt_injection_callback, + NULL); } DltReturnValue dlt_register_log_level_changed_callback(DltContext *handle, @@ -3346,6 +3350,7 @@ DltReturnValue dlt_user_trace_network_truncated(DltContext *handle, DltNetworkTr DltReturnValue dlt_log_string(DltContext *handle, DltLogLevelType loglevel, const char *text) { + DltReturnValue ret = DLT_RETURN_OK; DltContextData log; if (dlt_user.verbose_mode==0) @@ -3360,19 +3365,20 @@ DltReturnValue dlt_log_string(DltContext *handle, DltLogLevelType loglevel, cons if (dlt_user_log_write_start(handle, &log, loglevel) == DLT_RETURN_TRUE) { - dlt_user_log_write_string(&log, text); - + ret = dlt_user_log_write_string(&log, text); + if (dlt_user_log_write_finish(&log) < DLT_RETURN_OK) { return DLT_RETURN_ERROR; } } - return DLT_RETURN_OK; + return ret; } DltReturnValue dlt_log_string_int(DltContext *handle, DltLogLevelType loglevel, const char *text, int data) { + DltReturnValue ret = DLT_RETURN_OK; DltContextData log; if (dlt_user.verbose_mode==0) @@ -3387,7 +3393,7 @@ DltReturnValue dlt_log_string_int(DltContext *handle, DltLogLevelType loglevel, if (dlt_user_log_write_start(handle, &log, loglevel) == DLT_RETURN_TRUE) { - dlt_user_log_write_string(&log, text); + ret = dlt_user_log_write_string(&log, text); dlt_user_log_write_int(&log, data); if (dlt_user_log_write_finish(&log) < DLT_RETURN_OK) @@ -3396,11 +3402,12 @@ DltReturnValue dlt_log_string_int(DltContext *handle, DltLogLevelType loglevel, } } - return DLT_RETURN_OK; + return ret; } DltReturnValue dlt_log_string_uint(DltContext *handle, DltLogLevelType loglevel, const char *text, unsigned int data) { + DltReturnValue ret = DLT_RETURN_OK; DltContextData log; if (dlt_user.verbose_mode==0) @@ -3415,7 +3422,7 @@ DltReturnValue dlt_log_string_uint(DltContext *handle, DltLogLevelType loglevel, if (dlt_user_log_write_start(handle, &log, loglevel) == DLT_RETURN_TRUE) { - dlt_user_log_write_string(&log, text); + ret = dlt_user_log_write_string(&log, text); dlt_user_log_write_uint(&log, data); if (dlt_user_log_write_finish(&log) < DLT_RETURN_OK) @@ -3424,7 +3431,7 @@ DltReturnValue dlt_log_string_uint(DltContext *handle, DltLogLevelType loglevel, } } - return DLT_RETURN_OK; + return ret; } DltReturnValue dlt_log_int(DltContext *handle, DltLogLevelType loglevel, int data) @@ -4616,13 +4623,14 @@ DltReturnValue dlt_user_log_check_user_message(void) delayed_inject_data_length = usercontextinj->data_length_inject; delayed_inject_buffer = malloc(delayed_inject_data_length); - if(delayed_inject_buffer != NULL) + if (delayed_inject_buffer != NULL) { memcpy(delayed_inject_buffer, userbuffer, delayed_inject_data_length); } else { dlt_log(LOG_WARNING,"malloc failed!\n"); + DLT_SEM_FREE(); return DLT_RETURN_ERROR; } break; @@ -4633,16 +4641,16 @@ DltReturnValue dlt_user_log_check_user_message(void) DLT_SEM_FREE(); /* Delayed injection callback call */ - if(delayed_inject_buffer != NULL && - delayed_injection_callback.injection_callback != NULL) + if ((delayed_inject_buffer != NULL) && + (delayed_injection_callback.injection_callback != NULL)) { delayed_injection_callback.injection_callback(delayed_injection_callback.service_id, delayed_inject_buffer, delayed_inject_data_length); delayed_injection_callback.injection_callback = NULL; } - else if(delayed_inject_buffer != NULL && - delayed_injection_callback.injection_callback_with_id != NULL) + else if ((delayed_inject_buffer != NULL) && + (delayed_injection_callback.injection_callback_with_id != NULL)) { delayed_injection_callback.injection_callback_with_id(delayed_injection_callback.service_id, delayed_inject_buffer, @@ -4657,7 +4665,7 @@ DltReturnValue dlt_user_log_check_user_message(void) if (dlt_receiver_remove(receiver, (sizeof(DltUserHeader) + sizeof(DltUserControlMsgInjection) + - usercontextinj->data_length_inject)) == DLT_RETURN_ERROR) + usercontextinj->data_length_inject)) != DLT_RETURN_OK) { return DLT_RETURN_ERROR; } diff --git a/src/offlinelogstorage/dlt_offline_logstorage.c b/src/offlinelogstorage/dlt_offline_logstorage.c index 80dd3ec..c85af6e 100644 --- a/src/offlinelogstorage/dlt_offline_logstorage.c +++ b/src/offlinelogstorage/dlt_offline_logstorage.c @@ -32,6 +32,7 @@ #include #include "dlt_offline_logstorage.h" +#include "dlt_offline_logstorage_internal.h" #include "dlt_offline_logstorage_behavior.h" #include "dlt_config_file_parser.h" @@ -41,36 +42,6 @@ #define GENERAL_BASE_NAME "General" -typedef struct { - char *key; /* The configuration key */ - int (*func)(DltLogStorage *handle, char *value); /* conf handler */ - int is_opt; /* If configuration is optional or not */ -} DltLogstorageGeneralConf; - -typedef enum { - DLT_LOGSTORAGE_GENERAL_CONF_COUNT = 0 -} DltLogstorageGeneralConfType; - -typedef struct { - char *key; /* Configuration key */ - int (*func)(DltLogStorageFilterConfig *config, char *value); /* conf handler */ - int is_opt; /* If configuration is optional or not */ -} DltLogstorageFilterConf; - -typedef enum { - DLT_LOGSTORAGE_FILTER_CONF_LOGAPPNAME = 0, - DLT_LOGSTORAGE_FILTER_CONF_CONTEXTNAME, - DLT_LOGSTORAGE_FILTER_CONF_LOGLEVEL, - DLT_LOGSTORAGE_FILTER_CONF_RESET_LOGLEVEL, - DLT_LOGSTORAGE_FILTER_CONF_FILE, - DLT_LOGSTORAGE_FILTER_CONF_FILESIZE, - DLT_LOGSTORAGE_FILTER_CONF_NOFILES, - DLT_LOGSTORAGE_FILTER_CONF_SYNCBEHAVIOR, - DLT_LOGSTORAGE_FILTER_CONF_ECUID, - DLT_LOGSTORAGE_FILTER_CONF_SPECIFIC_SIZE, - DLT_LOGSTORAGE_FILTER_CONF_COUNT -} DltLogstorageFilterConfType; - DLT_STATIC void dlt_logstorage_filter_config_free(DltLogStorageFilterConfig *data) { DltLogStorageFileList *n = NULL; diff --git a/src/offlinelogstorage/dlt_offline_logstorage.h b/src/offlinelogstorage/dlt_offline_logstorage.h index b3f7dd3..5020042 100644 --- a/src/offlinelogstorage/dlt_offline_logstorage.h +++ b/src/offlinelogstorage/dlt_offline_logstorage.h @@ -208,6 +208,37 @@ typedef struct int write_errors; /* number of write errors */ }DltLogStorage; +typedef struct { + char *key; /* The configuration key */ + int (*func)(DltLogStorage *handle, char *value); /* conf handler */ + int is_opt; /* If configuration is optional or not */ +} DltLogstorageGeneralConf; + +typedef enum { + DLT_LOGSTORAGE_GENERAL_CONF_BLOCKMODE = 0, + DLT_LOGSTORAGE_GENERAL_CONF_COUNT +} DltLogstorageGeneralConfType; + +typedef struct { + char *key; /* Configuration key */ + int (*func)(DltLogStorageFilterConfig *config, char *value); /* conf handler */ + int is_opt; /* If configuration is optional or not */ +} DltLogstorageFilterConf; + +typedef enum { + DLT_LOGSTORAGE_FILTER_CONF_LOGAPPNAME = 0, + DLT_LOGSTORAGE_FILTER_CONF_CONTEXTNAME, + DLT_LOGSTORAGE_FILTER_CONF_LOGLEVEL, + DLT_LOGSTORAGE_FILTER_CONF_RESET_LOGLEVEL, + DLT_LOGSTORAGE_FILTER_CONF_FILE, + DLT_LOGSTORAGE_FILTER_CONF_FILESIZE, + DLT_LOGSTORAGE_FILTER_CONF_NOFILES, + DLT_LOGSTORAGE_FILTER_CONF_SYNCBEHAVIOR, + DLT_LOGSTORAGE_FILTER_CONF_ECUID, + DLT_LOGSTORAGE_FILTER_CONF_SPECIFIC_SIZE, + DLT_LOGSTORAGE_FILTER_CONF_COUNT +} DltLogstorageFilterConfType; + /** * dlt_logstorage_device_connected * diff --git a/src/offlinelogstorage/dlt_offline_logstorage_behavior.c b/src/offlinelogstorage/dlt_offline_logstorage_behavior.c index 4648159..cc31ff5 100644 --- a/src/offlinelogstorage/dlt_offline_logstorage_behavior.c +++ b/src/offlinelogstorage/dlt_offline_logstorage_behavior.c @@ -31,6 +31,7 @@ #include "dlt_offline_logstorage.h" #include "dlt_offline_logstorage_behavior.h" +#include "dlt_offline_logstorage_behavior_internal.h" /** * dlt_logstorage_log_file_name diff --git a/src/offlinelogstorage/dlt_offline_logstorage_behavior_internal.h b/src/offlinelogstorage/dlt_offline_logstorage_behavior_internal.h new file mode 100644 index 0000000..b8c80b2 --- /dev/null +++ b/src/offlinelogstorage/dlt_offline_logstorage_behavior_internal.h @@ -0,0 +1,95 @@ +/** + * @licence app begin@ + * Copyright (C) 2017 Advanced Driver Information Technology. + * This code is developed by Advanced Driver Information Technology. + * Copyright of Advanced Driver Information Technology, Bosch and DENSO. + * + * DLT offline log storage functionality internal header file. + * + * \copyright + * This Source Code Form is subject to the terms of the + * Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with + * this file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * + * \author Aditya Paluri ADIT 2017 + * + * \file: dlt_offline_logstorage_behavior_internal.h + * For further information see http://www.genivi.org/. + * @licence end@ + */ + +/******************************************************************************* +** ** +** SRC-MODULE: dlt_offline_logstorage_behavior_internal.h ** +** ** +** TARGET : linux ** +** ** +** PROJECT : DLT ** +** ** +** AUTHOR : Aditya Paluri venkataaditya.paluri@in.bosch.com ** +** ** +** PURPOSE : ** +** ** +** REMARKS : ** +** ** +** PLATFORM DEPENDANT [yes/no]: yes ** +** ** +** TO BE CHANGED BY USER [yes/no]: no ** +** ** +*******************************************************************************/ + +/******************************************************************************* +** Author Identity ** +******************************************************************************** +** ** +** Initials Name Company ** +** -------- ------------------------- ---------------------------------- ** +** ap Aditya Paluri ADIT ** +*******************************************************************************/ + +#ifndef DLT_OFFLINELOGSTORAGE_BEHAVIOR_INTERNAL_H_ +#define DLT_OFFLINELOGSTORAGE_BEHAVIOR_INTERNAL_H_ + +void dlt_logstorage_log_file_name(char *log_file_name, + DltLogStorageUserConfig *file_config, + char *name, + int idx); + +void dlt_logstorage_sort_file_name(DltLogStorageFileList **head); + +void dlt_logstorage_rearrange_file_name(DltLogStorageFileList **head); + +unsigned int dlt_logstorage_get_idx_of_log_file( + DltLogStorageUserConfig *file_config, + char *file); + +int dlt_logstorage_storage_dir_info(DltLogStorageUserConfig *file_config, + char *path, + DltLogStorageFilterConfig *config); + +int dlt_logstorage_open_log_file(DltLogStorageFilterConfig *config, + DltLogStorageUserConfig *file_config, + char *dev_path, + int msg_size); + +DLT_STATIC DltReturnValue dlt_logstorage_sync_create_new_file( + DltLogStorageFilterConfig *config, + DltLogStorageUserConfig *file_config, + char *dev_path, + unsigned int remain_file_size); + +DLT_STATIC DltReturnValue dlt_logstorage_sync_to_file( + DltLogStorageFilterConfig *config, + DltLogStorageUserConfig *file_config, + char *dev_path); + +DLT_STATIC DltReturnValue dlt_logstorage_sync_capable_data_to_file( + DltLogStorageFilterConfig *config, + int index_status); + +DLT_STATIC int dlt_logstorage_find_dlt_header(void *ptr, + unsigned int offset, + unsigned int cnt); + +#endif /* DLT_OFFLINELOGSTORAGE_BEHAVIOR_INTERNAL_H_ */ diff --git a/src/offlinelogstorage/dlt_offline_logstorage_internal.h b/src/offlinelogstorage/dlt_offline_logstorage_internal.h new file mode 100644 index 0000000..11da0dd --- /dev/null +++ b/src/offlinelogstorage/dlt_offline_logstorage_internal.h @@ -0,0 +1,119 @@ +/** + * @licence app begin@ + * Copyright (C) 2017 Advanced Driver Information Technology. + * This code is developed by Advanced Driver Information Technology. + * Copyright of Advanced Driver Information Technology, Bosch and DENSO. + * + * DLT offline log storage functionality internal header file. + * + * \copyright + * This Source Code Form is subject to the terms of the + * Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with + * this file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * + * \author Aditya Paluri ADIT 2017 + * + * \file: dlt_offline_logstorage_internal.h + * For further information see http://www.genivi.org/. + * @licence end@ + */ + +/******************************************************************************* +** ** +** SRC-MODULE: dlt_offline_logstorage_internal.h ** +** ** +** TARGET : linux ** +** ** +** PROJECT : DLT ** +** ** +** AUTHOR : Aditya Paluri venkataaditya.paluri@in.bosch.com ** +** PURPOSE : ** +** ** +** REMARKS : ** +** ** +** PLATFORM DEPENDANT [yes/no]: yes ** +** ** +** TO BE CHANGED BY USER [yes/no]: no ** +** ** +*******************************************************************************/ + +/******************************************************************************* +** Author Identity ** +******************************************************************************** +** ** +** Initials Name Company ** +** -------- ------------------------- ---------------------------------- ** +** ap Aditya Paluri ADIT ** +*******************************************************************************/ + +#ifndef DLT_OFFLINE_LOGSTORAGE_INTERNAL_H +#define DLT_OFFLINE_LOGSTORAGE_INTERNAL_H + +DLT_STATIC int dlt_logstorage_list_destroy(DltLogStorageFilterList **list, + int reason); + +DLT_STATIC int dlt_logstorage_list_add_config(DltLogStorageFilterConfig *data, + DltLogStorageFilterConfig **listdata); +DLT_STATIC int dlt_logstorage_list_add(char *key, + DltLogStorageFilterConfig *data, + DltLogStorageFilterList **list); + +DLT_STATIC void *dlt_logstorage_list_find(char *key, + DltLogStorageFilterList **list); + +DLT_STATIC int dlt_logstorage_count_ids(const char *str); + +DLT_STATIC int dlt_logstorage_read_number(unsigned int *number, char *value); + +DLT_STATIC int dlt_logstorage_read_list_of_names(char **names, char *value); + +DLT_STATIC int dlt_logstorage_check_apids(DltLogStorageFilterConfig *config, char *value); + +DLT_STATIC int dlt_logstorage_check_ctids(DltLogStorageFilterConfig *config, char *value); + +DLT_STATIC int dlt_logstorage_check_loglevel(DltLogStorageFilterConfig *config, char *value); + +DLT_STATIC int dlt_logstorage_check_filename(DltLogStorageFilterConfig *config, char *value); + +DLT_STATIC int dlt_logstorage_check_filesize(DltLogStorageFilterConfig *config, char *value); + +DLT_STATIC int dlt_logstorage_check_nofiles(DltLogStorageFilterConfig *config, char *value); + +DLT_STATIC int dlt_logstorage_check_sync_strategy(DltLogStorageFilterConfig *config, char *value); + +DLT_STATIC int dlt_logstorage_check_ecuid(DltLogStorageFilterConfig *config, char *value); + +DLT_STATIC int dlt_logstorage_check_param(DltLogStorageFilterConfig *config, + DltLogstorageFilterConfType ctype, + char *value); + +DLT_STATIC int dlt_logstorage_store_filters(DltLogStorage *handle, + char *config_file_name); + +void dlt_logstorage_free(DltLogStorage *handle, int reason); + +DLT_STATIC int dlt_logstorage_create_keys(char *appids, + char *ctxids, + char *ecuid, + char **keys, + int *num_keys); + +DLT_STATIC int dlt_logstorage_prepare_table(DltLogStorage *handle, + DltLogStorageFilterConfig *data); + +DLT_STATIC int dlt_logstorage_validate_filter_name(char *name); + +DLT_STATIC void dlt_logstorage_filter_set_strategy(DltLogStorageFilterConfig *config, + int strategy); + +DLT_STATIC int dlt_logstorage_load_config(DltLogStorage *handle); + +DLT_STATIC int dlt_logstorage_filter(DltLogStorage *handle, + DltLogStorageFilterConfig **config, + char *apid, + char *ctid, + char *ecuid, + int log_level); + +#endif /* DLT_OFFLINE_LOGSTORAGE_INTERNAL_H */ diff --git a/src/tests/dlt-test-client.c b/src/tests/dlt-test-client.c index d7b02fe..cab327f 100644 --- a/src/tests/dlt-test-client.c +++ b/src/tests/dlt-test-client.c @@ -85,7 +85,7 @@ #define DLT_TESTCLIENT_NUM_TESTS 9 static int g_testsFailed = 0; - +DltClient g_dltclient; /* Function prototypes */ int dlt_testclient_message_callback(DltMessage *message, void *data); @@ -151,7 +151,6 @@ void usage() */ int main(int argc, char* argv[]) { - DltClient dltclient; DltTestclientData dltdata; int c,i; int index; @@ -271,31 +270,31 @@ int main(int argc, char* argv[]) } /* Initialize DLT Client */ - dlt_client_init(&dltclient, dltdata.vflag); + dlt_client_init(&g_dltclient, dltdata.vflag); /* Register callback to be called when message was received */ dlt_client_register_message_callback(dlt_testclient_message_callback); /* Setup DLT Client structure */ - dltclient.mode = dltdata.yflag; + g_dltclient.mode = dltdata.yflag; - if (dltclient.mode==0) + if (g_dltclient.mode==0) { for (index = optind; index < argc; index++) { - if(dlt_client_set_server_ip(&dltclient, argv[index]) == -1) + if(dlt_client_set_server_ip(&g_dltclient, argv[index]) == -1) { fprintf(stderr,"set server ip didn't succeed\n"); return -1; } } - if (dltclient.servIP == 0) + if (g_dltclient.servIP == 0) { /* no hostname selected, show usage and terminate */ fprintf(stderr,"ERROR: No hostname selected\n"); usage(); - dlt_client_cleanup(&dltclient,dltdata.vflag); + dlt_client_cleanup(&g_dltclient,dltdata.vflag); return -1; } } @@ -303,14 +302,14 @@ int main(int argc, char* argv[]) { for (index = optind; index < argc; index++) { - if(dlt_client_set_serial_device(&dltclient, argv[index]) == -1) + if(dlt_client_set_serial_device(&g_dltclient, argv[index]) == -1) { fprintf(stderr,"set serial device didn't succeed\n"); return -1; } } - if (dltclient.serialDevice == 0) + if (g_dltclient.serialDevice == 0) { /* no serial device name selected, show usage and terminate */ fprintf(stderr,"ERROR: No serial device name specified\n"); @@ -318,7 +317,7 @@ int main(int argc, char* argv[]) return -1; } - dlt_client_setbaudrate(&dltclient,dltdata.bvalue); + dlt_client_setbaudrate(&g_dltclient,dltdata.bvalue); } /* initialise structure to use DLT file */ @@ -361,15 +360,15 @@ int main(int argc, char* argv[]) } /* Connect to TCP socket or open serial device */ - if (dlt_client_connect(&dltclient, dltdata.vflag) != DLT_RETURN_ERROR) + if (dlt_client_connect(&g_dltclient, dltdata.vflag) != DLT_RETURN_ERROR) { - dltdata.sock = dltclient.sock; + dltdata.sock = g_dltclient.sock; /* Dlt Client Main Loop */ - dlt_client_main_loop(&dltclient, &dltdata, dltdata.vflag); + dlt_client_main_loop(&g_dltclient, &dltdata, dltdata.vflag); /* Dlt Client Cleanup */ - dlt_client_cleanup(&dltclient,dltdata.vflag); + dlt_client_cleanup(&g_dltclient,dltdata.vflag); } /* dlt-receive cleanup */ -- cgit v1.2.1