automotive-dlt
dlt_offline_logstorage.h File Reference
#include <search.h>
#include "dlt_common.h"
#include "dlt-daemon_cfg.h"
Include dependency graph for dlt_offline_logstorage.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  DltLogStorageCacheFooter
 
struct  DltLogStorageUserConfig
 
struct  DltLogStorageFileList
 
struct  DltLogStorageConfigData
 
struct  DltLogStorageConfig
 
struct  DltLogStorage
 

Macros

#define DLT_OFFLINE_LOGSTORAGE_MAXFILTERS   100 /* Maximum entries in hashmap */
 
#define DLT_OFFLINE_LOGSTORAGE_INIT_DONE   1 /* For device configuration status */
 
#define DLT_OFFLINE_LOGSTORAGE_DEVICE_CONNECTED   1
 
#define DLT_OFFLINE_LOGSTORAGE_FREE   0
 
#define DLT_OFFLINE_LOGSTORAGE_DEVICE_DISCONNECTED   0
 
#define DLT_OFFLINE_LOGSTORAGE_CONFIG_DONE   1
 
#define DLT_OFFLINE_LOGSTORAGE_SYNC_CACHES   2 /* sync logstorage caches */
 
#define DLT_OFFLINE_LOGSTORAGE_MAX_KEY_LEN   10 /* Maximum size for key */
 
#define DLT_OFFLINE_LOGSTORAGE_MAX_FILE_NAME_LEN   50 /* Maximum file name length of the log file */
 
#define DLT_OFFLINE_LOGSTORAGE_FILE_EXTENSION_LEN   4
 
#define DLT_OFFLINE_LOGSTORAGE_INDEX_LEN   3
 
#define DLT_OFFLINE_LOGSTORAGE_MAX_INDEX   999
 
#define DLT_OFFLINE_LOGSTORAGE_TIMESTAMP_LEN   16
 
#define DLT_OFFLINE_LOGSTORAGE_INDEX_OFFSET
 
#define DLT_OFFLINE_LOGSTORAGE_MAX_LOG_FILE_LEN
 
#define DLT_OFFLINE_LOGSTORAGE_FILTER_UNINIT   0
 
#define DLT_OFFLINE_LOGSTORAGE_ECUID   (1<<8)
 
#define DLT_OFFLINE_LOGSTORAGE_FILTER_PRESENT   (1<<7)
 
#define DLT_OFFLINE_LOGSTORAGE_APP_INIT   (1<<6)
 
#define DLT_OFFLINE_LOGSTORAGE_CTX_INIT   (1<<5)
 
#define DLT_OFFLINE_LOGSTORAGE_LOG_LVL_INIT   (1<<4)
 
#define DLT_OFFLINE_LOGSTORAGE_NAME_INIT   (1<<3)
 
#define DLT_OFFLINE_LOGSTORAGE_SIZE_INIT   (1<<2)
 
#define DLT_OFFLINE_LOGSTORAGE_SYNC_BEHAVIOR   (1<<1)
 
#define DLT_OFFLINE_LOGSTORAGE_NUM_INIT   1
 
#define DLT_OFFLINE_LOGSTORAGE_FILTER_INIT   0xFD
 
#define DLT_OFFLINE_LOGSTORAGE_FILTER_INITIALIZED(A)   ((A) >= DLT_OFFLINE_LOGSTORAGE_FILTER_INIT)
 
#define DLT_OFFLINE_LOGSTORAGE_IS_FILTER_PRESENT(A)   ((A) & DLT_OFFLINE_LOGSTORAGE_FILTER_PRESENT)
 
#define DLT_OFFLINE_LOGSTORAGE_CONFIG_DIR_PATH_LEN   50
 
#define DLT_OFFLINE_LOGSTORAGE_CONFIG_FILE_NAME   "dlt_logstorage.conf"
 
#define DLT_OFFLINE_LOGSTORAGE_MAX_PATH_LEN
 
#define DLT_OFFLINE_LOGSTORAGE_MAX(A, B)   ((A) > (B) ? (A) : (B))
 
#define DLT_OFFLINE_LOGSTORAGE_MIN(A, B)   ((A) < (B) ? (A) : (B))
 
#define DLT_OFFLINE_LOGSTORAGE_MAX_WRITE_ERRORS   5
 
#define DLT_OFFLINE_LOGSTORAGE_MAX_KEY_NUM   8
 
#define DLT_OFFLINE_LOGSTORAGE_CONFIG_SECTION   "FILTER"
 
#define DLT_OFFLINE_LOGSTORAGE_GENERAL_CONFIG_SECTION   "GENERAL"
 
#define DLT_LOGSTORAGE_SYNC_ON_ERROR   -1 /* error case */
 
#define DLT_LOGSTORAGE_SYNC_ON_MSG   1 /* default, on message sync */
 
#define DLT_LOGSTORAGE_SYNC_ON_DAEMON_EXIT   (1<<1) /* sync on daemon exit */
 
#define DLT_LOGSTORAGE_SYNC_ON_DEMAND   (1<<2) /* sync on demand */
 
#define DLT_LOGSTORAGE_SYNC_ON_DEVICE_DISCONNECT   (1<<3) /* sync on device disconnect*/
 
#define DLT_OFFLINE_LOGSTORAGE_IS_STRATEGY_SET(S, s)   ((S) & (s))
 

Typedefs

typedef struct DltLogStorageFileList DltLogStorageFileList
 
typedef struct DltLogStorageConfigData DltLogStorageConfigData
 

Functions

int dlt_logstorage_device_connected (DltLogStorage *handle, char *mount_point)
 
int dlt_logstorage_load_config (DltLogStorage *handle)
 
int dlt_logstorage_device_disconnected (DltLogStorage *handle, int reason)
 
DltLogStorageConfigData ** dlt_logstorage_get_config (DltLogStorage *handle, char *apid, char *ctid, int *num_config)
 
int dlt_logstorage_get_loglevel_by_key (DltLogStorage *handle, char *key)
 
int dlt_logstorage_write (DltLogStorage *handle, DltLogStorageUserConfig *uconfig, unsigned char *data1, int size1, unsigned char *data2, int size2, unsigned char *data3, int size3)
 
int dlt_logstorage_sync_caches (DltLogStorage *handle)
 

Variables

unsigned int g_logstorage_cache_max
 
unsigned int g_logstorage_cache_size
 

Detailed Description

app begin@ Copyright (C) 2013 - 2015 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 header file.

Author
Syed Hameed shame.nosp@m.ed@j.nosp@m.p.adi.nosp@m.t-jv.nosp@m..com ADIT 2013 - 2015
Christoph Lipka clipk.nosp@m.a@jp.nosp@m..adit.nosp@m.-jv..nosp@m.com ADIT 2015

For further information see http://www.genivi.org/. end@

Definition in file dlt_offline_logstorage.h.

Macro Definition Documentation

#define DLT_LOGSTORAGE_SYNC_ON_DAEMON_EXIT   (1<<1) /* sync on daemon exit */
#define DLT_LOGSTORAGE_SYNC_ON_DEMAND   (1<<2) /* sync on demand */
#define DLT_LOGSTORAGE_SYNC_ON_DEVICE_DISCONNECT   (1<<3) /* sync on device disconnect*/
#define DLT_LOGSTORAGE_SYNC_ON_ERROR   -1 /* error case */

Definition at line 119 of file dlt_offline_logstorage.h.

Referenced by dlt_logstorage_prepare_table().

#define DLT_LOGSTORAGE_SYNC_ON_MSG   1 /* default, on message sync */
#define DLT_OFFLINE_LOGSTORAGE_APP_INIT   (1<<6)

Definition at line 88 of file dlt_offline_logstorage.h.

Referenced by dlt_logstorage_validate_filter_value().

#define DLT_OFFLINE_LOGSTORAGE_CONFIG_DIR_PATH_LEN   50

Definition at line 102 of file dlt_offline_logstorage.h.

Referenced by dlt_logstorage_open_log_file().

#define DLT_OFFLINE_LOGSTORAGE_CONFIG_FILE_NAME   "dlt_logstorage.conf"

Definition at line 103 of file dlt_offline_logstorage.h.

Referenced by dlt_logstorage_load_config().

#define DLT_OFFLINE_LOGSTORAGE_CONFIG_SECTION   "FILTER"

Definition at line 115 of file dlt_offline_logstorage.h.

Referenced by dlt_logstorage_validate_filter_name().

#define DLT_OFFLINE_LOGSTORAGE_CTX_INIT   (1<<5)

Definition at line 89 of file dlt_offline_logstorage.h.

Referenced by dlt_logstorage_validate_filter_value().

#define DLT_OFFLINE_LOGSTORAGE_DEVICE_DISCONNECTED   0
#define DLT_OFFLINE_LOGSTORAGE_ECUID   (1<<8)

Definition at line 86 of file dlt_offline_logstorage.h.

Referenced by dlt_logstorage_validate_filter_value().

#define DLT_OFFLINE_LOGSTORAGE_FILE_EXTENSION_LEN   4

Definition at line 73 of file dlt_offline_logstorage.h.

Referenced by dlt_logstorage_get_idx_of_log_file().

#define DLT_OFFLINE_LOGSTORAGE_FILTER_INIT   0xFD

Definition at line 96 of file dlt_offline_logstorage.h.

#define DLT_OFFLINE_LOGSTORAGE_FILTER_INITIALIZED (   A)    ((A) >= DLT_OFFLINE_LOGSTORAGE_FILTER_INIT)

Definition at line 98 of file dlt_offline_logstorage.h.

Referenced by dlt_daemon_setup_filter_properties().

#define DLT_OFFLINE_LOGSTORAGE_FILTER_PRESENT   (1<<7)

Definition at line 87 of file dlt_offline_logstorage.h.

Referenced by dlt_daemon_setup_filter_properties().

#define DLT_OFFLINE_LOGSTORAGE_FILTER_UNINIT   0

Definition at line 85 of file dlt_offline_logstorage.h.

Referenced by dlt_daemon_setup_filter_properties().

#define DLT_OFFLINE_LOGSTORAGE_FREE   0

Definition at line 64 of file dlt_offline_logstorage.h.

#define DLT_OFFLINE_LOGSTORAGE_GENERAL_CONFIG_SECTION   "GENERAL"

Definition at line 116 of file dlt_offline_logstorage.h.

#define DLT_OFFLINE_LOGSTORAGE_INDEX_LEN   3

Definition at line 74 of file dlt_offline_logstorage.h.

#define DLT_OFFLINE_LOGSTORAGE_INDEX_OFFSET
#define DLT_OFFLINE_LOGSTORAGE_INIT_DONE   1 /* For device configuration status */

Definition at line 62 of file dlt_offline_logstorage.h.

#define DLT_OFFLINE_LOGSTORAGE_IS_FILTER_PRESENT (   A)    ((A) & DLT_OFFLINE_LOGSTORAGE_FILTER_PRESENT)

Definition at line 100 of file dlt_offline_logstorage.h.

Referenced by dlt_daemon_setup_filter_properties().

#define DLT_OFFLINE_LOGSTORAGE_IS_STRATEGY_SET (   S,
 
)    ((S) & (s))

Definition at line 125 of file dlt_offline_logstorage.h.

Referenced by dlt_logstorage_sync_msg_cache().

#define DLT_OFFLINE_LOGSTORAGE_LOG_LVL_INIT   (1<<4)

Definition at line 90 of file dlt_offline_logstorage.h.

Referenced by dlt_logstorage_validate_filter_value().

#define DLT_OFFLINE_LOGSTORAGE_MAX (   A,
 
)    ((A) > (B) ? (A) : (B))
#define DLT_OFFLINE_LOGSTORAGE_MAX_FILE_NAME_LEN   50 /* Maximum file name length of the log file */

Definition at line 71 of file dlt_offline_logstorage.h.

#define DLT_OFFLINE_LOGSTORAGE_MAX_INDEX   999

Definition at line 75 of file dlt_offline_logstorage.h.

#define DLT_OFFLINE_LOGSTORAGE_MAX_KEY_NUM   8

Definition at line 113 of file dlt_offline_logstorage.h.

Referenced by dlt_daemon_setup_filter_properties().

#define DLT_OFFLINE_LOGSTORAGE_MAX_LOG_FILE_LEN
#define DLT_OFFLINE_LOGSTORAGE_MAX_PATH_LEN
Value:

Definition at line 106 of file dlt_offline_logstorage.h.

#define DLT_OFFLINE_LOGSTORAGE_MAX_WRITE_ERRORS   5

Definition at line 112 of file dlt_offline_logstorage.h.

Referenced by dlt_logstorage_write().

#define DLT_OFFLINE_LOGSTORAGE_MAXFILTERS   100 /* Maximum entries in hashmap */
#define DLT_OFFLINE_LOGSTORAGE_MIN (   A,
 
)    ((A) < (B) ? (A) : (B))

Definition at line 110 of file dlt_offline_logstorage.h.

Referenced by dlt_logstorage_read_list_of_names().

#define DLT_OFFLINE_LOGSTORAGE_NAME_INIT   (1<<3)

Definition at line 91 of file dlt_offline_logstorage.h.

Referenced by dlt_logstorage_validate_filter_value().

#define DLT_OFFLINE_LOGSTORAGE_NUM_INIT   1

Definition at line 94 of file dlt_offline_logstorage.h.

Referenced by dlt_logstorage_validate_filter_value().

#define DLT_OFFLINE_LOGSTORAGE_SIZE_INIT   (1<<2)

Definition at line 92 of file dlt_offline_logstorage.h.

Referenced by dlt_logstorage_validate_filter_value().

#define DLT_OFFLINE_LOGSTORAGE_SYNC_BEHAVIOR   (1<<1)

Definition at line 93 of file dlt_offline_logstorage.h.

Referenced by dlt_logstorage_validate_filter_value().

#define DLT_OFFLINE_LOGSTORAGE_SYNC_CACHES   2 /* sync logstorage caches */

Definition at line 68 of file dlt_offline_logstorage.h.

Referenced by dlt_daemon_control_service_logstorage().

#define DLT_OFFLINE_LOGSTORAGE_TIMESTAMP_LEN   16

Typedef Documentation

Function Documentation

int dlt_logstorage_device_connected ( DltLogStorage handle,
char *  mount_point 
)
int dlt_logstorage_device_disconnected ( DltLogStorage handle,
int  reason 
)

dlt_logstorage_device_disconnected De-Initializes DLT Offline Logstorage with respect to device status

Parameters
handleDLT Logstorage handle
reasonReason for device disconnection
Returns
0 on success, -1 on error

dlt_logstorage_device_disconnected

De-Initializes DLT Offline Logstorage with respect to device status

Parameters
handleDLT Logstorage handle
reasonReason for disconnect
Returns
0 on success, -1 on error

Definition at line 659 of file dlt_offline_logstorage.c.

References DltLogStorage::config_status, DltLogStorage::connection_type, DltLogStorage::device_mount_point, dlt_logstorage_free(), DLT_MOUNT_PATH_MAX, DLT_OFFLINE_LOGSTORAGE_CONFIG_DONE, DLT_OFFLINE_LOGSTORAGE_DEVICE_DISCONNECTED, NULL, DltLogStorage::num_filter_keys, and DltLogStorage::write_errors.

Referenced by dlt_daemon_control_service_logstorage(), dlt_daemon_logstorage_cleanup(), dlt_daemon_logstorage_write(), and dlt_logstorage_device_connected().

DltLogStorageConfigData** dlt_logstorage_get_config ( DltLogStorage handle,
char *  apid,
char *  ctid,
int *  num_config 
)

dlt_logstorage_get_config

Obtain the configuration data of all filters for provided apid and ctid For a given apid and ctid, there can be 3 possiblities of configuration data available in the Hash map, this function will return the address of configuration data for all these 3 combinations

Parameters
handleDltLogStorage handle
appidapplication id
ctxidcontext id
num_config(o/p) contains the number of filter configration data obtained
Returns
on success: address of configuration data, NULL on failure or no configuration data found

Definition at line 1195 of file dlt_offline_logstorage.c.

References config, DltLogStorage::config_htab, DltLogStorage::config_status, DltLogStorage::connection_type, DLT_ID_SIZE, dlt_logstorage_hash_find(), DLT_OFFLINE_LOGSTORAGE_CONFIG_DONE, DLT_OFFLINE_LOGSTORAGE_DEVICE_CONNECTED, DLT_OFFLINE_LOGSTORAGE_MAX_KEY_LEN, and NULL.

Referenced by dlt_daemon_logstorage_get_loglevel(), and dlt_logstorage_filter().

int dlt_logstorage_get_loglevel_by_key ( DltLogStorage handle,
char *  key 
)

dlt_logstorage_get_loglevel_by_key

Obtain the log level for the provided key This function can be used to obtain log level when the actual key stored in the Hash map is availble with the caller

Parameters
handleDltLogstorage handle
keykey to search for in Hash MAP
Returns
log level on success:, -1 on error

Definition at line 1165 of file dlt_offline_logstorage.c.

References config, DltLogStorage::config_htab, DltLogStorage::config_status, DltLogStorage::connection_type, dlt_logstorage_hash_find(), DLT_OFFLINE_LOGSTORAGE_CONFIG_DONE, DLT_OFFLINE_LOGSTORAGE_DEVICE_CONNECTED, DltLogStorageConfigData::log_level, and NULL.

Referenced by dlt_daemon_logstorage_update_application_loglevel().

int dlt_logstorage_load_config ( DltLogStorage handle)

dlt_logstorage_load_config

Parse dlt_logstorage.conf file in the device and setup internal info table

Parameters
handleDltLogStorage handle
Returns
0 on success, -1 on error

dlt_logstorage_load_config

Read dlt_logstorage.conf file and setup filters in hash table Hash table key consists of "APPID:CTXID", e.g "APP1:CTX1". If wildcards used for application id or context id, the hash table key consists of none wildcard value, e.g. appid=.*, cxtid=CTX1 results in "CTX1".

Combination of two wildcards is not allowed.

Parameters
input_filepointer to configuration file stored on device
Returns
0 on success, -1 on error

Definition at line 1112 of file dlt_offline_logstorage.c.

References DltLogStorage::config_htab, DltLogStorage::config_status, DltLogStorage::connection_type, DltLogStorage::device_mount_point, dlt_log(), dlt_logstorage_hash_create(), dlt_logstorage_store_filters(), DLT_OFFLINE_LOGSTORAGE_CONFIG_DONE, DLT_OFFLINE_LOGSTORAGE_CONFIG_FILE_NAME, DLT_OFFLINE_LOGSTORAGE_DEVICE_CONNECTED, DLT_OFFLINE_LOGSTORAGE_MAXFILTERS, and NULL.

Referenced by dlt_daemon_control_service_logstorage(), and dlt_daemon_logstorage_setup_internal_storage().

int dlt_logstorage_sync_caches ( DltLogStorage handle)

dlt_logstorage_sync_caches

Sync all caches inside the specified logstorage device.

Parameters
handleDltLogStorage handle
Returns
0 on success, -1 otherwise

Definition at line 1453 of file dlt_offline_logstorage.c.

References DltLogStorage::config_data, DltLogStorageConfig::data, dlt_log(), DltLogStorageConfigData::dlt_logstorage_sync, DLT_LOGSTORAGE_SYNC_ON_DEMAND, NULL, and DltLogStorage::num_filter_keys.

Referenced by dlt_daemon_logstorage_sync_cache().

int dlt_logstorage_write ( DltLogStorage handle,
DltLogStorageUserConfig uconfig,
unsigned char *  data1,
int  size1,
unsigned char *  data2,
int  size2,
unsigned char *  data3,
int  size3 
)

dlt_logstorage_write

Write a message to one or more configured log files, based on filter configuration.

Parameters
handleDltLogStorage handle
uconfigUser configurations for log file
data1Data buffer of message header
size1Size of message header buffer
data2Data buffer of message body
size2Size of message body
Returns
0 on success or write errors < max write errors, -1 on error

dlt_logstorage_write

Write a message to one or more configured log files, based on filter configuration.

Parameters
handleDltLogStorage handle
configUser configurations for log file
data1Data buffer of message header
size1Size of message header buffer
data2Data buffer of message body
size2Size of message body
Returns
0 on success or write errors < max write errors, -1 on error

Definition at line 1330 of file dlt_offline_logstorage.c.

References config, DltLogStorage::config_status, DltLogStorage::connection_type, DltLogStorage::device_mount_point, DLT_GET_MSIN_MTIN, DLT_ID_SIZE, DLT_IS_HTYP_WEID, DLT_IS_HTYP_WSID, DLT_IS_HTYP_WTMS, dlt_log(), dlt_logstorage_filter(), DltLogStorageConfigData::dlt_logstorage_prepare, DltLogStorageConfigData::dlt_logstorage_sync, DLT_LOGSTORAGE_SYNC_ON_MSG, DltLogStorageConfigData::dlt_logstorage_write, DLT_OFFLINE_LOGSTORAGE_CONFIG_DONE, DLT_OFFLINE_LOGSTORAGE_DEVICE_CONNECTED, DLT_OFFLINE_LOGSTORAGE_MAX_WRITE_ERRORS, DLT_SIZE_WSID, DLT_SIZE_WTMS, NULL, and DltLogStorage::write_errors.

Referenced by dlt_daemon_logstorage_write().

Variable Documentation

unsigned int g_logstorage_cache_max
unsigned int g_logstorage_cache_size

Definition at line 130 of file dlt_offline_logstorage.h.

Referenced by dlt_logstorage_prepare_msg_cache().